ScintTimeXeDoping_tool.cc
Go to the documentation of this file.
1 ////////////////////////////////////////////////////////////////////////
2 // Class: ScintTimeXeDoping
3 // Plugin Type: tool
4 // File: ScintTimeXeDoping_tool.cc ScintTimeXeDoping.h
5 // Description:
6 // Generate a random number for timing of LAr scintillation
7 // Oct. 8 by Mu Wei
8 ////////////////////////////////////////////////////////////////////////
11 
12 namespace phot
13 {
14 
15  //......................................................................
17  : ScintTime()
18  , fXeConcentration{pset.get<double>("XeConcentration")}
19  , fArSingletTime {pset.get<double>("ArSingletTime")}
20  , fArTripletTime {pset.get<double>("ArTripletTime")}
21  , fXe150nmTime {pset.get<double>("Xe150nmTime")}
22  , fTauAX {pset.get<double>("TauAX")}
23  , fTauXX {pset.get<double>("TauXX")}
24  , fTauN2 {pset.get<double>("TauN2", 0)}
25  {
26  double invTauN2 = 0;
27  if (fTauN2 > 0) invTauN2 = 1./fTauN2;
28 
29  // Calculations from D. Totani, Feb. 2021
31  fTauTAt = 1./(1./fArTripletTime + fXeConcentration/fTauAX + invTauN2);
32  fTauTX = 1./(1./fXe150nmTime + fXeConcentration/fTauXX + invTauN2);
33 
34  double step = 0.1; //ns
35 
36  fMaxProbs = 0;
37  fMaxTs = 0;
38  double integral = 0;
39  while (integral < 0.999) {
40  double val = singlet_distro(fMaxTs);
41  if (val > fMaxProbs) fMaxProbs = val;
42  integral += val*step;
43  fMaxTs += step;
44  }
45 
46  fMaxProbt = 0;
47  fMaxTt = 0;
48  integral = 0;
49  while (integral < 0.999) {
50  double val = triplet_distro(fMaxTt);
51  if (val > fMaxProbt) fMaxProbt = val;
52  integral += val*step;
53  fMaxTt += step;
54  }
55 
56  mf::LogInfo("ScintTimeXeDoping")
57  << "Configured:" << "\n"
58  << " XeConcentration: " << fXeConcentration << " ppm\n"
59  << " ArTripletTime: " << fArTripletTime << " ns\n"
60  << " Xe150nmTime: " << fXe150nmTime << " ns\n"
61  << " TauAX: " << fTauAX << " ns\n"
62  << " TauXX: " << fTauXX << " ns\n"
63  << "Calculated:" << "\n"
64  << " TauTA singlet: " << fTauTAs << " ns\n"
65  << " TauTA triplet: " << fTauTAt << " ns\n"
66  << " TauTX: " << fTauTX << " ns\n"
67  << " MaxTime Singlet: " << fMaxTs << " ns\n"
68  << " MaxTime Triplet: " << fMaxTt << " ns\n";
69  }
70 
71  //......................................................................
72  double ScintTimeXeDoping::exp_diff(double t, double tau1, double tau2) const
73  {
74  using std::exp;
75  return ( exp(-t/tau1) - exp(-t/tau2) ) / (tau1 - tau2);
76  }
77 
78  //......................................................................
79  // Returns the time within the time distribution of the scintillation process, when the photon was created.
80  // Rejection sampling is used to get a random time from the difference-of-exponentials distribution
81  void ScintTimeXeDoping::GenScintTime(bool is_fast, CLHEP::HepRandomEngine& engine)
82  {
83  CLHEP::RandFlat randflatscinttime{engine};
84 
85  //ran1, ran2 = random numbers for the algorithm
86  while (1)
87  {
88  double ran1 = randflatscinttime();
89  double ran2 = randflatscinttime();
90 
91  // Use ran1 to pick a proposal time
92  // uniformly within the allowed range
93  double t = ran1 * (is_fast ? fMaxTs
94  : fMaxTt);
95 
96  // Rejection prob for this point
97  auto p = (is_fast ? singlet_distro(t) / fMaxProbs
98  : triplet_distro(t) / fMaxProbt);
99 
100  // Keep the point if ran2 below p
101  // (larger value of scint_distro -> more likely to sample)
102  if (ran2 < p) {
103  timing = t;
104  return;
105  }
106  }
107  }
108 }
109 
ScintTimeXeDoping(fhicl::ParameterSet const &pset)
#define DEFINE_ART_CLASS_TOOL(tool)
Definition: ToolMacros.h:42
double singlet_distro(double t) const
MaybeLogger_< ELseverityLevel::ELsev_info, false > LogInfo
G4double tau1[100]
Definition: G4S2Light.cc:61
double triplet_distro(double t) const
T get(std::string const &key) const
Definition: ParameterSet.h:271
p
Definition: test.py:223
General LArSoft Utilities.
void GenScintTime(bool is_fast, CLHEP::HepRandomEngine &engine)
double exp_diff(double t, double tau1, double tau2) const
double timing
Definition: ScintTime.h:32