LArSoft  v10_06_00
Liquid Argon Software toolkit - https://larsoft.org/
phot::ScintTimeLAr Class Reference

#include "ScintTimeLAr.h"

Inheritance diagram for phot::ScintTimeLAr:
phot::ScintTime

Public Member Functions

 ScintTimeLAr (fhicl::ParameterSet const &pset)
 
void initRand (CLHEP::HepRandomEngine &engine)
 
void GenScintTime (bool is_fast, CLHEP::HepRandomEngine &engine)
 
double fastScintTime ()
 
double slowScintTime ()
 
double GetScintTime () const
 

Protected Attributes

double timing {0.0}
 

Private Member Functions

double single_exp (double t, double tau2) const
 
double bi_exp (double t, double tau1, double tau2) const
 
double with_rising_time (double tau1, double tau2)
 

Private Attributes

int LogLevel
 
std::unique_ptr< CLHEP::RandFlat > fUniformGen
 
const double SRTime
 
const double SDTime
 
const double FRTime
 
const double FDTime
 
const bool fNoFastRisingTime
 
const bool fNoSlowRisingTime
 

Detailed Description

Definition at line 24 of file ScintTimeLAr.h.

Constructor & Destructor Documentation

phot::ScintTimeLAr::ScintTimeLAr ( fhicl::ParameterSet const &  pset)
explicit

Definition at line 15 of file ScintTimeLAr.cc.

References FDTime, fNoFastRisingTime, fNoSlowRisingTime, FRTime, fhicl::ParameterSet::get(), LogLevel, SDTime, and SRTime.

16  : LogLevel{pset.get<int>("LogLevel")}
17  , SRTime{pset.get<double>("SlowRisingTime", 0.)}
18  , SDTime{pset.get<double>("SlowDecayTime", 0.)}
19  , FRTime{pset.get<double>("FastRisingTime", 0.)}
20  , FDTime{pset.get<double>("FastDecayTime", 0.)}
21  , fNoFastRisingTime(pset.get<bool>("NoFastRisingTime", false))
22  , fNoSlowRisingTime(pset.get<bool>("NoSlowRisingTime", false))
23  {
24  if (LogLevel >= 1) {
25  std::cout << "ScintTimeLAr Tool configure:" << std::endl;
26  std::cout << "Fast rising time: " << FRTime << ", Fast decay time: " << FDTime
27  << ", Slow rising time: " << SRTime << ", Slow decay time: " << SDTime << std::endl;
28  }
29  }
const bool fNoSlowRisingTime
Definition: ScintTimeLAr.h:40
const double SRTime
Definition: ScintTimeLAr.h:36
const double FDTime
Definition: ScintTimeLAr.h:39
const double FRTime
Definition: ScintTimeLAr.h:38
const bool fNoFastRisingTime
Definition: ScintTimeLAr.h:40
const double SDTime
Definition: ScintTimeLAr.h:37

Member Function Documentation

double phot::ScintTimeLAr::bi_exp ( double  t,
double  tau1,
double  tau2 
) const
private

Definition at line 43 of file ScintTimeLAr.cc.

Referenced by GenScintTime(), and with_rising_time().

44  {
45  return (((std::exp((-1.0 * t) / tau2) * (1.0 - std::exp((-1.0 * t) / tau1))) / tau2) / tau2) *
46  (tau1 + tau2);
47  }
double phot::ScintTimeLAr::fastScintTime ( )
inlinevirtual

Implements phot::ScintTime.

Definition at line 108 of file ScintTimeLAr.cc.

References FDTime, fNoFastRisingTime, FRTime, fUniformGen, and with_rising_time().

109  {
110  if (fNoFastRisingTime) { return -FDTime * std::log(fUniformGen->fire()); }
111  return with_rising_time(FRTime, FDTime);
112  }
std::unique_ptr< CLHEP::RandFlat > fUniformGen
Definition: ScintTimeLAr.h:34
const double FDTime
Definition: ScintTimeLAr.h:39
const double FRTime
Definition: ScintTimeLAr.h:38
const bool fNoFastRisingTime
Definition: ScintTimeLAr.h:40
double with_rising_time(double tau1, double tau2)
Definition: ScintTimeLAr.cc:50
void phot::ScintTimeLAr::GenScintTime ( bool  is_fast,
CLHEP::HepRandomEngine &  engine 
)
virtual

Implements phot::ScintTime.

Definition at line 73 of file ScintTimeLAr.cc.

References bi_exp(), d, e, FDTime, FRTime, SDTime, single_exp(), SRTime, and phot::ScintTime::timing.

74  {
75  double tau1;
76  double tau2;
77 
78  if (is_fast) {
79  tau1 = FRTime;
80  tau2 = FDTime;
81  }
82  else {
83  tau1 = SRTime;
84  tau2 = SDTime;
85  }
86 
87  CLHEP::RandFlat randflatscinttime{engine};
88 
89  if ((tau1 < 1e-8) || (tau1 == -1.0)) {
90  timing = -tau2 * std::log(randflatscinttime());
91  return;
92  }
93 
94  //ran1, ran2 = random numbers for the algorithm
95  while (1) {
96  auto ran1 = randflatscinttime();
97  auto ran2 = randflatscinttime();
98  auto d = (tau1 + tau2) / tau2;
99  auto t = -tau2 * std::log(1 - ran1);
100  auto g = d * single_exp(t, tau2);
101  if (ran2 <= bi_exp(t, tau1, tau2) / g) {
102  timing = t;
103  return;
104  }
105  }
106  }
double bi_exp(double t, double tau1, double tau2) const
Definition: ScintTimeLAr.cc:43
Float_t d
Definition: plot.C:235
const double SRTime
Definition: ScintTimeLAr.h:36
const double FDTime
Definition: ScintTimeLAr.h:39
double single_exp(double t, double tau2) const
Definition: ScintTimeLAr.cc:37
const double FRTime
Definition: ScintTimeLAr.h:38
const double SDTime
Definition: ScintTimeLAr.h:37
Float_t e
Definition: plot.C:35
double timing
Definition: ScintTime.h:29
double phot::ScintTime::GetScintTime ( ) const
inlineinherited

Definition at line 22 of file ScintTime.h.

22 { return timing; }
double timing
Definition: ScintTime.h:29
void phot::ScintTimeLAr::initRand ( CLHEP::HepRandomEngine &  engine)
virtual

Implements phot::ScintTime.

Definition at line 31 of file ScintTimeLAr.cc.

References fUniformGen.

32  {
33  fUniformGen = std::make_unique<CLHEP::RandFlat>(engine);
34  }
std::unique_ptr< CLHEP::RandFlat > fUniformGen
Definition: ScintTimeLAr.h:34
double phot::ScintTimeLAr::single_exp ( double  t,
double  tau2 
) const
private

Definition at line 37 of file ScintTimeLAr.cc.

Referenced by GenScintTime(), and with_rising_time().

38  {
39  return std::exp((-1.0 * t) / tau2) / tau2;
40  }
double phot::ScintTimeLAr::slowScintTime ( )
inlinevirtual

Implements phot::ScintTime.

Definition at line 114 of file ScintTimeLAr.cc.

References fNoSlowRisingTime, fUniformGen, SDTime, SRTime, and with_rising_time().

115  {
116  if (fNoSlowRisingTime) { return -SDTime * std::log(fUniformGen->fire()); }
117  return with_rising_time(SRTime, SDTime);
118  }
const bool fNoSlowRisingTime
Definition: ScintTimeLAr.h:40
std::unique_ptr< CLHEP::RandFlat > fUniformGen
Definition: ScintTimeLAr.h:34
const double SRTime
Definition: ScintTimeLAr.h:36
const double SDTime
Definition: ScintTimeLAr.h:37
double with_rising_time(double tau1, double tau2)
Definition: ScintTimeLAr.cc:50
double phot::ScintTimeLAr::with_rising_time ( double  tau1,
double  tau2 
)
private

Definition at line 50 of file ScintTimeLAr.cc.

References bi_exp(), d, fUniformGen, and single_exp().

Referenced by fastScintTime(), and slowScintTime().

51  {
52  // TODO: This method is very inefficient.
53  // If we care about simulating the rising time, it would be better
54  // to simulate random numbers according a general distribution
55  double d = (tau1 + tau2) / tau2;
56  int ncalls = 0;
57  while (1) {
58  ++ncalls;
59  double ran1 = fUniformGen->fire();
60  double ran2 = fUniformGen->fire();
61  double t = -tau2 * std::log(1 - ran1);
62  double g = d * single_exp(t, tau2);
63  if (ran2 <= bi_exp(t, tau1, tau2) / g) { return t; }
64  }
65  }
double bi_exp(double t, double tau1, double tau2) const
Definition: ScintTimeLAr.cc:43
Float_t d
Definition: plot.C:235
std::unique_ptr< CLHEP::RandFlat > fUniformGen
Definition: ScintTimeLAr.h:34
double single_exp(double t, double tau2) const
Definition: ScintTimeLAr.cc:37

Member Data Documentation

const double phot::ScintTimeLAr::FDTime
private

Definition at line 39 of file ScintTimeLAr.h.

Referenced by fastScintTime(), GenScintTime(), and ScintTimeLAr().

const bool phot::ScintTimeLAr::fNoFastRisingTime
private

Definition at line 40 of file ScintTimeLAr.h.

Referenced by fastScintTime(), and ScintTimeLAr().

const bool phot::ScintTimeLAr::fNoSlowRisingTime
private

Definition at line 40 of file ScintTimeLAr.h.

Referenced by ScintTimeLAr(), and slowScintTime().

const double phot::ScintTimeLAr::FRTime
private

Definition at line 38 of file ScintTimeLAr.h.

Referenced by fastScintTime(), GenScintTime(), and ScintTimeLAr().

std::unique_ptr<CLHEP::RandFlat> phot::ScintTimeLAr::fUniformGen
private

Definition at line 34 of file ScintTimeLAr.h.

Referenced by fastScintTime(), initRand(), slowScintTime(), and with_rising_time().

int phot::ScintTimeLAr::LogLevel
private

Definition at line 33 of file ScintTimeLAr.h.

Referenced by ScintTimeLAr().

const double phot::ScintTimeLAr::SDTime
private

Definition at line 37 of file ScintTimeLAr.h.

Referenced by GenScintTime(), ScintTimeLAr(), and slowScintTime().

const double phot::ScintTimeLAr::SRTime
private

Definition at line 36 of file ScintTimeLAr.h.

Referenced by GenScintTime(), ScintTimeLAr(), and slowScintTime().

double phot::ScintTime::timing {0.0}
protectedinherited

Definition at line 29 of file ScintTime.h.

Referenced by GenScintTime().


The documentation for this class was generated from the following files: