All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
ScintTimeLAr.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 #include "fhiclcpp/ParameterSet.h"
12 
13 // Random number engine
14 #include "CLHEP/Random/RandFlat.h"
15 
16 namespace phot
17 {
18  //......................................................................
19  ScintTimeLAr::ScintTimeLAr(fhicl::ParameterSet const& pset)
20  : LogLevel{pset.get<int>("LogLevel")}
21  , SRTime{pset.get<double>("SlowRisingTime", 0.0)}
22  , SDTime{pset.get<double>("SlowDecayTime", 0.0)}
23  , FRTime{pset.get<double>("FastRisingTime", 0.0)}
24  , FDTime{pset.get<double>("FastDecayTime", 0.0)}
25  {
26  if ( LogLevel >= 1 ) {
27  std::cout << "ScintTimeLAr Tool configure:" << std::endl;
28  std::cout << "Fast rising time: " << FRTime
29  << ", Fast decay time: " << FDTime
30  << ", Slow rising time: " << SRTime
31  << ", Slow decay time: " << SDTime
32  << std::endl;
33  }
34  }
35 
36  //......................................................................
37  double ScintTimeLAr::single_exp(double t, double tau2) const
38  {
39  return std::exp((-1.0 * t) / tau2) / tau2;
40  }
41 
42  //......................................................................
43  double ScintTimeLAr::bi_exp(double t, double tau1, double tau2) const
44  {
45  return (((std::exp((-1.0 * t) / tau2) * (1.0 - std::exp((-1.0 * t) / tau1))) / tau2) / tau2) * (tau1 + tau2);
46  }
47 
48  //......................................................................
49  // Returns the time within the time distribution of the
50  // scintillation process, when the photon was created.
51  // Scintillation light has an exponential decay which is given by
52  // the decay time, tau2, and an exponential increase, which here is
53  // given by the rise time, tau1.
54  void ScintTimeLAr::GenScintTime(bool is_fast, CLHEP::HepRandomEngine& engine)
55  {
56  double tau1;
57  double tau2;
58 
59  if(is_fast) {
60  tau1 = FRTime;
61  tau2 = FDTime;
62  }
63  else {
64  tau1 = SRTime;
65  tau2 = SDTime;
66  }
67 
68  CLHEP::RandFlat randflatscinttime{engine};
69 
70  if ((tau1 < 1e-8) || (tau1 == -1.0)) {
71  timing = -tau2 * std::log(randflatscinttime());
72  return;
73  }
74 
75  //ran1, ran2 = random numbers for the algorithm
76  while (1) {
77  auto ran1 = randflatscinttime();
78  auto ran2 = randflatscinttime();
79  auto d = (tau1 + tau2) / tau2;
80  auto t = -tau2 * std::log(1 - ran1);
81  auto g = d * single_exp(t, tau2);
82  if (ran2 <= bi_exp(t, tau1, tau2) / g) {
83  timing = t;
84  return;
85  }
86  }
87  }
88 
89 }
double bi_exp(double t, double tau1, double tau2) const
Definition: ScintTimeLAr.cc:43
BEGIN_PROLOG g
void GenScintTime(bool is_fast, CLHEP::HepRandomEngine &engine)
Definition: ScintTimeLAr.cc:54
ScintTimeLAr(fhicl::ParameterSet const &pset)
Definition: ScintTimeLAr.cc:19
double single_exp(double t, double tau2) const
Definition: ScintTimeLAr.cc:37
do i e
BEGIN_PROLOG could also be cout
double timing
Definition: ScintTime.h:28