ScintTimeLAr_tool.cc
Go to the documentation of this file.
1 ////////////////////////////////////////////////////////////////////////
2 // Class: ScintTimeLAr
3 // Plugin Type: tool
4 // File: ScintTimeLAr_tool.cc ScintTimeLAr.h
5 // Description:
6 // Generate a random number for timing of LAr scintillation
7 // Oct. 8 by Mu Wei
8 ////////////////////////////////////////////////////////////////////////
10 
11 namespace phot
12 {
13  //......................................................................
15  : LogLevel{pset.get<int>("LogLevel")}
16  , SRTime{pset.get<double>("SlowRisingTime", 0.0)}
17  , SDTime{pset.get<double>("SlowDecayTime", 0.0)}
18  , FRTime{pset.get<double>("FastRisingTime", 0.0)}
19  , FDTime{pset.get<double>("FastDecayTime", 0.0)}
20  {
21  if ( LogLevel >= 1 )
22  {
23  std::cout << "ScintTimeLAr Tool configure:" << std::endl;
24  std::cout << "Fast rising time: " << FRTime
25  << ", Fast decay time: " << FDTime
26  << ", Slow rising time: " << SRTime
27  << ", Slow decay time: " << SDTime
28  << std::endl;
29  }
30  }
31 
32  //......................................................................
33  double ScintTimeLAr::single_exp(double t, double tau2)
34  {
35  return std::exp((-1.0 * t) / tau2) / tau2;
36  }
37 
38  //......................................................................
39  double ScintTimeLAr::bi_exp(double t, double tau1, double tau2)
40  {
41  return (((std::exp((-1.0 * t) / tau2) * (1.0 - std::exp((-1.0 * t) / tau1))) / tau2) / tau2) * (tau1 + tau2);
42  }
43 
44  //......................................................................
45  // Returns the time within the time distribution of the scintillation process, when the photon was created.
46  // Scintillation light has an exponential decay which is given by the decay time, tau2,
47  // and an exponential increase, which here is given by the rise time, tau1.
48  // randflatScintTimeLAr is passed to use the saved seed from the RandomNumberSaver in order to be able to reproduce the same results.
49  void ScintTimeLAr::GenScintTime(bool is_fast, CLHEP::HepRandomEngine& engine)
50  {
51  double tau1;
52  double tau2;
53 
54  if(is_fast == 1) // fast scinitllation
55  {
56  tau1 = FRTime;
57  tau2 = FDTime;
58  }
59  else
60  {
61  tau1 = SRTime;
62  tau2 = SDTime;
63  }
64 
65  CLHEP::RandFlat randflatscinttime{engine};
66 
67  if ((tau1 == 0.0) || (tau1 == -1.0))
68  {
69  timing = -tau2 * std::log(randflatscinttime());
70  return;
71  }
72 
73  //ran1, ran2 = random numbers for the algorithm
74  while (1)
75  {
76  auto ran1 = randflatscinttime();
77  auto ran2 = randflatscinttime();
78  auto d = (tau1 + tau2) / tau2;
79  auto t = -tau2 * std::log(1 - ran1);
80  auto g = d * single_exp(t, tau2);
81  if (ran2 <= bi_exp(t, tau1, tau2) / g)
82  {
83  timing = t;
84  return;
85  }
86  }
87  }
88 }
89 
#define DEFINE_ART_CLASS_TOOL(tool)
Definition: ToolMacros.h:42
static constexpr double g
Definition: Units.h:144
G4double tau1[100]
Definition: G4S2Light.cc:61
void GenScintTime(bool is_fast, CLHEP::HepRandomEngine &engine)
ScintTimeLAr(fhicl::ParameterSet const &pset)
double single_exp(double t, double tau2)
T get(std::string const &key) const
Definition: ParameterSet.h:271
General LArSoft Utilities.
double bi_exp(double t, double tau1, double tau2)
QTextStream & endl(QTextStream &s)
double timing
Definition: ScintTime.h:32