All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Classes | Public Member Functions | Private Member Functions | Private Attributes | List of all members
opdet::DigiPMTSBNDAlg Class Reference

#include <DigiPMTSBNDAlg.hh>

Classes

struct  ConfigurationParameters_t
 

Public Member Functions

 DigiPMTSBNDAlg (ConfigurationParameters_t const &config)
 
 ~DigiPMTSBNDAlg ()
 
void ConstructWaveform (int ch, sim::SimPhotons const &simphotons, std::vector< short unsigned int > &waveform, std::string pdtype, double start_time, unsigned n_sample)
 
void ConstructWaveformCoatedPMT (int ch, std::vector< short unsigned int > &waveform, std::unordered_map< int, sim::SimPhotons > &DirectPhotonsMap, std::unordered_map< int, sim::SimPhotons > &ReflectedPhotonsMap, double start_time, unsigned n_sample)
 
void ConstructWaveformLite (int ch, sim::SimPhotonsLite const &litesimphotons, std::vector< short unsigned int > &waveform, std::string pdtype, double start_time, unsigned n_sample)
 
void ConstructWaveformLiteCoatedPMT (int ch, std::vector< short unsigned int > &waveform, std::unordered_map< int, sim::SimPhotonsLite > &DirectPhotonsMap, std::unordered_map< int, sim::SimPhotonsLite > &ReflectedPhotonsMap, double start_time, unsigned n_sample)
 
double Baseline ()
 

Private Member Functions

void AddSPE (size_t time_bin, std::vector< double > &wave)
 
void Pulse1PE (std::vector< double > &wave)
 
double Transittimespread (double fwhm)
 
void CreatePDWaveform (sim::SimPhotons const &SimPhotons, double t_min, std::vector< double > &wave, int ch, std::string pdtype)
 
void CreatePDWaveformCoatedPMT (int ch, double t_min, std::vector< double > &wave, std::unordered_map< int, sim::SimPhotons > &DirectPhotonsMap, std::unordered_map< int, sim::SimPhotons > &ReflectedPhotonsMap)
 
void CreatePDWaveformLite (sim::SimPhotonsLite const &litesimphotons, double t_min, std::vector< double > &wave, int ch, std::string pdtype)
 
void CreatePDWaveformLiteCoatedPMT (int ch, double t_min, std::vector< double > &wave, std::unordered_map< int, sim::SimPhotonsLite > &DirectPhotonsMap, std::unordered_map< int, sim::SimPhotonsLite > &ReflectedPhotonsMap)
 
void CreateSaturation (std::vector< double > &wave)
 
void AddLineNoise (std::vector< double > &wave)
 
void AddDarkNoise (std::vector< double > &wave)
 
double FindMinimumTime (sim::SimPhotons const &, int ch, std::string pdtype, std::unordered_map< int, sim::SimPhotons > &directPhotonsOnPMTS)
 
double FindMinimumTimeLite (sim::SimPhotonsLite const &litesimphotons, int ch, std::string pdtype, std::unordered_map< int, sim::SimPhotonsLite > &directPhotonsOnPMTS)
 

Private Attributes

ConfigurationParameters_t fParams
 
double fSampling
 
double fQEDirect
 
double fQERefl
 
double sigma1
 
double sigma2
 
const double transitTimeSpread_frac = 2.0 * std::sqrt(2.0 * std::log(2.0))
 
double saturation
 
CLHEP::HepRandomEngine * fEngine
 Reference to art-managed random-number engine. More...
 
CLHEP::RandFlat fFlatGen
 
CLHEP::RandPoissonQ fPoissonQGen
 
CLHEP::RandGaussQ fGaussQGen
 
CLHEP::RandExponential fExponentialGen
 
std::unique_ptr
< CLHEP::RandGeneral > 
fTimeTPB
 
std::unique_ptr
< opdet::PMTGainFluctuations
fPMTGainFluctuationsPtr
 
std::vector< double > fSinglePEWave
 
int pulsesize
 
std::unordered_map
< raw::Channel_t, std::vector
< double > > 
fFullWaveforms
 

Detailed Description

Definition at line 46 of file DigiPMTSBNDAlg.hh.

Constructor & Destructor Documentation

opdet::DigiPMTSBNDAlg::DigiPMTSBNDAlg ( ConfigurationParameters_t const &  config)

Definition at line 10 of file DigiPMTSBNDAlg.cc.

11  : fParams(config)
15  // , fSinglePEmodel(fParams.SinglePEmodel)
17  , fFlatGen(*fEngine)
21  {
22 
23  mf::LogInfo("DigiPMTSBNDAlg") << "PMT corrected efficiencies = "
24  << fQEDirect << " " << fQERefl;
25 
26  if(fQERefl > 1.0001 || fQEDirect > 1.0001)
27  mf::LogWarning("DigiPMTSBNDAlg")
28  << "Quantum efficiency set in fhicl file " << fParams.QERefl
29  << " or " << fParams.QEDirect << " seems to be too large!\n"
30  << "Final QE must be equal or smaller than the scintillation "
31  << "pre scale applied at simulation time.\n"
32  << "Please check this number (ScintPreScale): "
34 
35  fSampling = fSampling / 1000.0; //in GHz, to cancel with ns
36 
37  std::string fname;
38  cet::search_path sp("FW_SEARCH_PATH");
39  sp.find_file(fParams.PMTDataFile, fname);
40  TFile* file = TFile::Open(fname.c_str(), "READ");
41 
42  // TPB emission time histogram for pmt_coated histogram
43  std::vector<double>* timeTPB_p;
44  file->GetObject("timeTPB", timeTPB_p);
45  fTimeTPB = std::make_unique<CLHEP::RandGeneral>
46  (*fEngine, timeTPB_p->data(), timeTPB_p->size());
47 
48  //shape of single pulse
50  mf::LogDebug("DigiPMTSBNDAlg") << " using testbench pe response";
51  std::vector<double>* SinglePEVec_p;
52  file->GetObject("SinglePEVec", SinglePEVec_p);
53  fSinglePEWave = *SinglePEVec_p;
54  pulsesize = fSinglePEWave.size();
55  }
56  else {
57  mf::LogDebug("DigiPMTSBNDAlg") << " using ideal pe response";
58  //shape of single pulse
59  sigma1 = fParams.PMTRiseTime / (std::sqrt(2.0) * (std::sqrt(-std::log(0.1)) - std::sqrt(-std::log(0.9))));
60  sigma2 = fParams.PMTFallTime / (std::sqrt(2.0) * (std::sqrt(-std::log(0.1)) - std::sqrt(-std::log(0.9))));
61 
62  pulsesize = (int)((6 * sigma2 + fParams.TransitTime) * fSampling);
63  fSinglePEWave.resize(pulsesize);
65  }
66 
68  fPMTGainFluctuationsPtr = art::make_tool<opdet::PMTGainFluctuations>(fParams.GainFluctuationsParams);
69  }
70 
72  file->Close();
73  } // end constructor
std::unique_ptr< CLHEP::RandGeneral > fTimeTPB
ConfigurationParameters_t fParams
CLHEP::RandExponential fExponentialGen
string fname
Definition: demo.py:5
CLHEP::RandFlat fFlatGen
* file
Definition: file_to_url.sh:69
std::vector< double > fSinglePEWave
CLHEP::RandPoissonQ fPoissonQGen
CLHEP::HepRandomEngine * fEngine
Reference to art-managed random-number engine.
std::unique_ptr< opdet::PMTGainFluctuations > fPMTGainFluctuationsPtr
virtual double ScintPreScale(bool prescale=true) const =0
void Pulse1PE(std::vector< double > &wave)
CLHEP::RandGaussQ fGaussQGen
opdet::DigiPMTSBNDAlg::~DigiPMTSBNDAlg ( )

Definition at line 76 of file DigiPMTSBNDAlg.cc.

76 {}

Member Function Documentation

void opdet::DigiPMTSBNDAlg::AddDarkNoise ( std::vector< double > &  wave)
private

Definition at line 374 of file DigiPMTSBNDAlg.cc.

375  {
376  size_t timeBin;
377  // Multiply by 10^9 since fParams.DarkNoiseRate is in Hz (conversion from s to ns)
378  double mean = 1000000000.0 / fParams.PMTDarkNoiseRate;
379  double darkNoiseTime = fExponentialGen.fire(mean);
380  while(darkNoiseTime < wave.size()) {
381  timeBin = std::round(darkNoiseTime);
382  if(timeBin < wave.size()) {AddSPE(timeBin, wave);}
383  // Find next time to add dark noise
384  darkNoiseTime += fExponentialGen.fire(mean);
385  }
386  }
ConfigurationParameters_t fParams
CLHEP::RandExponential fExponentialGen
double mean(const std::vector< short > &wf, size_t start, size_t nsample)
Definition: UtilFunc.cxx:13
void AddSPE(size_t time_bin, std::vector< double > &wave)
void opdet::DigiPMTSBNDAlg::AddLineNoise ( std::vector< double > &  wave)
private

Definition at line 353 of file DigiPMTSBNDAlg.cc.

354  {
355  // TODO: after running the profiler I can see that this is where
356  // most cycles are being used. Potentially some improvement could
357  // be achieved with the below code but the array dynamic allocation
358  // is not helping. The function would need to have it passed.
359  // ~icaza
360  //
361  // double *array = new double[wave.size()]();
362  // CLHEP::RandGaussQ::shootArray(fEngine, wave.size(), array, 0, fParams.PMTBaselineRMS);
363  // for(size_t i = 0; i<wave.size(); i++) {
364  // wave[i] += array[i];
365  // }
366  // delete array;
367  //
368  std::transform(wave.begin(), wave.end(), wave.begin(),
369  [this](double w) -> double {
370  return w + fGaussQGen.fire(0., fParams.PMTBaselineRMS) ; });
371  }
ConfigurationParameters_t fParams
static constexpr Sample_t transform(Sample_t sample)
CLHEP::RandGaussQ fGaussQGen
void opdet::DigiPMTSBNDAlg::AddSPE ( size_t  time_bin,
std::vector< double > &  wave 
)
private

Definition at line 327 of file DigiPMTSBNDAlg.cc.

328  {
329  size_t max = time_bin + pulsesize < wave.size() ? time_bin + pulsesize : wave.size();
330  auto min_it = std::next(wave.begin(), time_bin);
331  auto max_it = std::next(wave.begin(), max);
333  double npe=fPMTGainFluctuationsPtr->GainFluctuation(1,fEngine);
334  std::transform(min_it, max_it,
335  fSinglePEWave.begin(), min_it,
336  [npe](auto a, auto b) { return a+npe*b; });
337  }
338  else{
339  std::transform(min_it, max_it,
340  fSinglePEWave.begin(), min_it,
341  std::plus<double>( ));
342  }
343  }
ConfigurationParameters_t fParams
static constexpr Sample_t transform(Sample_t sample)
std::vector< double > fSinglePEWave
process_name gaushit a
CLHEP::HepRandomEngine * fEngine
Reference to art-managed random-number engine.
std::unique_ptr< opdet::PMTGainFluctuations > fPMTGainFluctuationsPtr
double opdet::DigiPMTSBNDAlg::Baseline ( )
inline

Definition at line 111 of file DigiPMTSBNDAlg.hh.

112  {
113  return fParams.PMTBaseline;
114  }
ConfigurationParameters_t fParams
void opdet::DigiPMTSBNDAlg::ConstructWaveform ( int  ch,
sim::SimPhotons const &  simphotons,
std::vector< short unsigned int > &  waveform,
std::string  pdtype,
double  start_time,
unsigned  n_sample 
)

Definition at line 79 of file DigiPMTSBNDAlg.cc.

86  {
87  std::vector<double> waves(n_sample, fParams.PMTBaseline);
88  CreatePDWaveform(simphotons, start_time, waves, ch, pdtype);
89  waveform = std::vector<short unsigned int> (waves.begin(), waves.end());
90  }
ConfigurationParameters_t fParams
void CreatePDWaveform(sim::SimPhotons const &SimPhotons, double t_min, std::vector< double > &wave, int ch, std::string pdtype)
then echo fcl sbnd_project sbnd_project sbnd_project sbnd_project production production start_time
void opdet::DigiPMTSBNDAlg::ConstructWaveformCoatedPMT ( int  ch,
std::vector< short unsigned int > &  waveform,
std::unordered_map< int, sim::SimPhotons > &  DirectPhotonsMap,
std::unordered_map< int, sim::SimPhotons > &  ReflectedPhotonsMap,
double  start_time,
unsigned  n_sample 
)

Definition at line 92 of file DigiPMTSBNDAlg.cc.

99  {
100  std::vector<double> waves(n_sample, fParams.PMTBaseline);
101  CreatePDWaveformCoatedPMT(ch, start_time, waves, DirectPhotonsMap, ReflectedPhotonsMap);
102  waveform = std::vector<short unsigned int> (waves.begin(), waves.end());
103  }
ConfigurationParameters_t fParams
void CreatePDWaveformCoatedPMT(int ch, double t_min, std::vector< double > &wave, std::unordered_map< int, sim::SimPhotons > &DirectPhotonsMap, std::unordered_map< int, sim::SimPhotons > &ReflectedPhotonsMap)
then echo fcl sbnd_project sbnd_project sbnd_project sbnd_project production production start_time
void opdet::DigiPMTSBNDAlg::ConstructWaveformLite ( int  ch,
sim::SimPhotonsLite const &  litesimphotons,
std::vector< short unsigned int > &  waveform,
std::string  pdtype,
double  start_time,
unsigned  n_sample 
)

Definition at line 106 of file DigiPMTSBNDAlg.cc.

113  {
114  std::vector<double> waves(n_sample, fParams.PMTBaseline);
115  CreatePDWaveformLite(litesimphotons, start_time, waves, ch, pdtype);
116  waveform = std::vector<short unsigned int> (waves.begin(), waves.end());
117  }
void CreatePDWaveformLite(sim::SimPhotonsLite const &litesimphotons, double t_min, std::vector< double > &wave, int ch, std::string pdtype)
ConfigurationParameters_t fParams
then echo fcl sbnd_project sbnd_project sbnd_project sbnd_project production production start_time
void opdet::DigiPMTSBNDAlg::ConstructWaveformLiteCoatedPMT ( int  ch,
std::vector< short unsigned int > &  waveform,
std::unordered_map< int, sim::SimPhotonsLite > &  DirectPhotonsMap,
std::unordered_map< int, sim::SimPhotonsLite > &  ReflectedPhotonsMap,
double  start_time,
unsigned  n_sample 
)

Definition at line 120 of file DigiPMTSBNDAlg.cc.

127  {
128  std::vector<double> waves(n_sample, fParams.PMTBaseline);
129  CreatePDWaveformLiteCoatedPMT(ch, start_time, waves, DirectPhotonsMap, ReflectedPhotonsMap);
130  waveform = std::vector<short unsigned int> (waves.begin(), waves.end());
131  }
void CreatePDWaveformLiteCoatedPMT(int ch, double t_min, std::vector< double > &wave, std::unordered_map< int, sim::SimPhotonsLite > &DirectPhotonsMap, std::unordered_map< int, sim::SimPhotonsLite > &ReflectedPhotonsMap)
ConfigurationParameters_t fParams
then echo fcl sbnd_project sbnd_project sbnd_project sbnd_project production production start_time
void opdet::DigiPMTSBNDAlg::CreatePDWaveform ( sim::SimPhotons const &  SimPhotons,
double  t_min,
std::vector< double > &  wave,
int  ch,
std::string  pdtype 
)
private

Definition at line 134 of file DigiPMTSBNDAlg.cc.

140  {
141  double ttsTime = 0;
142  double tphoton;
143  size_t timeBin;
144  double ttpb=0;
145  for(size_t i = 0; i < simphotons.size(); i++) { //simphotons is here reflected light. To be added for all PMTs
146  if(fFlatGen.fire(1.0) < fQERefl) {
147  if(fParams.TTS > 0.0) ttsTime = Transittimespread(fParams.TTS);
148  ttpb = fTimeTPB->fire(); //for including TPB emission time
149  tphoton = ttsTime + simphotons[i].Time - t_min + ttpb + fParams.CableTime;
150  if(tphoton < 0.) continue; // discard if it didn't made it to the acquisition
151  timeBin = std::floor(tphoton*fSampling);
152  if(timeBin < wave.size()) {AddSPE(timeBin, wave);}
153  }
154  }
155 
156  if(fParams.PMTBaselineRMS > 0.0) AddLineNoise(wave);
157  if(fParams.PMTDarkNoiseRate > 0.0) AddDarkNoise(wave);
158  CreateSaturation(wave);
159  }
std::unique_ptr< CLHEP::RandGeneral > fTimeTPB
ConfigurationParameters_t fParams
CLHEP::RandFlat fFlatGen
void CreateSaturation(std::vector< double > &wave)
void AddDarkNoise(std::vector< double > &wave)
double Transittimespread(double fwhm)
void AddLineNoise(std::vector< double > &wave)
void AddSPE(size_t time_bin, std::vector< double > &wave)
void opdet::DigiPMTSBNDAlg::CreatePDWaveformCoatedPMT ( int  ch,
double  t_min,
std::vector< double > &  wave,
std::unordered_map< int, sim::SimPhotons > &  DirectPhotonsMap,
std::unordered_map< int, sim::SimPhotons > &  ReflectedPhotonsMap 
)
private

Definition at line 162 of file DigiPMTSBNDAlg.cc.

168  {
169 
170  double ttsTime = 0;
171  double tphoton;
172  size_t timeBin;
173  double ttpb=0;
174  sim::SimPhotons auxphotons;
175 
176  //direct light
177  if(auto it{ DirectPhotonsMap.find(ch) }; it != std::end(DirectPhotonsMap) )
178  {auxphotons = it->second;}
179  for(size_t j = 0; j < auxphotons.size(); j++) { //auxphotons is direct light
180  if(fFlatGen.fire(1.0) < fQEDirect) {
181  if(fParams.TTS > 0.0) ttsTime = Transittimespread(fParams.TTS); //implementing transit time spread
182  ttpb = fTimeTPB->fire(); //for including TPB emission time
183  tphoton = ttsTime + auxphotons[j].Time - t_min + ttpb + fParams.CableTime;
184  if(tphoton < 0.) continue; // discard if it didn't made it to the acquisition
185  timeBin = std::floor(tphoton*fSampling);
186  if(timeBin < wave.size()) {AddSPE(timeBin, wave);}
187  }
188  }
189  // reflected light
190  if(auto it{ ReflectedPhotonsMap.find(ch) }; it != std::end(ReflectedPhotonsMap) )
191  {auxphotons = it->second;}
192  for(size_t j = 0; j < auxphotons.size(); j++) { //auxphotons is now reflected light
193  if(fFlatGen.fire(1.0) < fQERefl) {
194  if(fParams.TTS > 0.0) ttsTime = Transittimespread(fParams.TTS); //implementing transit time spread
195  ttpb = fTimeTPB->fire(); //for including TPB emission time
196  tphoton = ttsTime + auxphotons[j].Time - t_min + ttpb + fParams.CableTime;
197  if(tphoton < 0.) continue; // discard if it didn't made it to the acquisition
198  timeBin = std::floor(tphoton*fSampling);
199  if(timeBin < wave.size()) {AddSPE(timeBin, wave);}
200  }
201  }
202 
203  //Adding noise and saturation
204  if(fParams.PMTBaselineRMS > 0.0) AddLineNoise(wave);
205  if(fParams.PMTDarkNoiseRate > 0.0) AddDarkNoise(wave);
206  CreateSaturation(wave);
207  }
std::unique_ptr< CLHEP::RandGeneral > fTimeTPB
ConfigurationParameters_t fParams
CLHEP::RandFlat fFlatGen
void CreateSaturation(std::vector< double > &wave)
void AddDarkNoise(std::vector< double > &wave)
double Transittimespread(double fwhm)
void AddLineNoise(std::vector< double > &wave)
auto end(FixedBins< T, C > const &) noexcept
Definition: FixedBins.h:585
Collection of photons which recorded on one channel.
Definition: SimPhotons.h:136
void AddSPE(size_t time_bin, std::vector< double > &wave)
void opdet::DigiPMTSBNDAlg::CreatePDWaveformLite ( sim::SimPhotonsLite const &  litesimphotons,
double  t_min,
std::vector< double > &  wave,
int  ch,
std::string  pdtype 
)
private

Definition at line 210 of file DigiPMTSBNDAlg.cc.

216  {
217  double mean_photons;
218  size_t accepted_photons;
219  double ttsTime = 0;
220  double tphoton;
221  size_t timeBin;
222  double ttpb=0;
223  // reflected light to be added to all PMTs
224  std::map<int, int> const& photonMap = litesimphotons.DetectedPhotons;
225  for (auto const& reflectedPhotons : photonMap) {
226  // TODO: check that this new approach of not using the last
227  // (1-accepted_photons) doesn't introduce some bias. ~icaza
228  mean_photons = reflectedPhotons.second*fQERefl;
229  accepted_photons = fPoissonQGen.fire(mean_photons);
230  for(size_t i = 0; i < accepted_photons; i++) {
231  if(fParams.TTS > 0.0) ttsTime = Transittimespread(fParams.TTS);
232  ttpb = fTimeTPB->fire(); //for including TPB emission time
233  tphoton = ttsTime + reflectedPhotons.first - t_min + ttpb + fParams.CableTime;
234  if(tphoton < 0.) continue; // discard if it didn't made it to the acquisition
235  timeBin = std::floor(tphoton*fSampling);
236  if(timeBin < wave.size()) {AddSPE(timeBin, wave);}
237  }
238  }
239 
240  if(fParams.PMTBaselineRMS > 0.0) AddLineNoise(wave);
241  if(fParams.PMTDarkNoiseRate > 0.0) AddDarkNoise(wave);
242  CreateSaturation(wave);
243  }
std::unique_ptr< CLHEP::RandGeneral > fTimeTPB
ConfigurationParameters_t fParams
void CreateSaturation(std::vector< double > &wave)
void AddDarkNoise(std::vector< double > &wave)
double Transittimespread(double fwhm)
void AddLineNoise(std::vector< double > &wave)
CLHEP::RandPoissonQ fPoissonQGen
void AddSPE(size_t time_bin, std::vector< double > &wave)
void opdet::DigiPMTSBNDAlg::CreatePDWaveformLiteCoatedPMT ( int  ch,
double  t_min,
std::vector< double > &  wave,
std::unordered_map< int, sim::SimPhotonsLite > &  DirectPhotonsMap,
std::unordered_map< int, sim::SimPhotonsLite > &  ReflectedPhotonsMap 
)
private

Definition at line 246 of file DigiPMTSBNDAlg.cc.

252  {
253  double mean_photons;
254  size_t accepted_photons;
255  double ttsTime = 0;
256  double tphoton;
257  size_t timeBin;
258  double ttpb;
259  // direct light
260  if ( auto it{ DirectPhotonsMap.find(ch) }; it != std::end(DirectPhotonsMap) ){
261  for (auto& directPhotons : (it->second).DetectedPhotons) {
262  // TODO: check that this new approach of not using the last
263  // (1-accepted_photons) doesn't introduce some bias. ~icaza
264  mean_photons = directPhotons.second*fQEDirect;
265  accepted_photons = fPoissonQGen.fire(mean_photons);
266  for(size_t i = 0; i < accepted_photons; i++) {
267  if(fParams.TTS > 0.0) ttsTime = Transittimespread(fParams.TTS); //implementing transit time spread
268  ttpb = fTimeTPB->fire(); //for including TPB emission time
269  tphoton = ttsTime + directPhotons.first - t_min + ttpb + fParams.CableTime;
270  if(tphoton < 0.) continue; // discard if it didn't made it to the acquisition
271  timeBin = std::floor(tphoton*fSampling);
272  if(timeBin < wave.size()) {AddSPE(timeBin, wave);}
273  }
274  }
275  }
276 
277  // reflected light
278  if ( auto it{ ReflectedPhotonsMap.find(ch) }; it != std::end(ReflectedPhotonsMap) ){
279  for (auto& reflectedPhotons : (it->second).DetectedPhotons) {
280  // TODO: check that this new approach of not using the last
281  // (1-accepted_photons) doesn't introduce some bias. ~icaza
282  mean_photons = reflectedPhotons.second*fQERefl;
283  accepted_photons = fPoissonQGen.fire(mean_photons);
284  for(size_t i = 0; i < accepted_photons; i++) {
285  if(fParams.TTS > 0.0) ttsTime = Transittimespread(fParams.TTS); //implementing transit time spread
286  ttpb = fTimeTPB->fire(); //for including TPB emission time
287  tphoton = ttsTime + reflectedPhotons.first - t_min + ttpb + fParams.CableTime;
288  if(tphoton < 0.) continue; // discard if it didn't made it to the acquisition
289  timeBin = std::floor(tphoton*fSampling);
290  if(timeBin < wave.size()) {AddSPE(timeBin, wave);}
291  }
292  }
293  }
294 
295  //Adding noise and saturation
296  if(fParams.PMTBaselineRMS > 0.0) AddLineNoise(wave);
297  if(fParams.PMTDarkNoiseRate > 0.0) AddDarkNoise(wave);
298  CreateSaturation(wave);
299  }
std::unique_ptr< CLHEP::RandGeneral > fTimeTPB
ConfigurationParameters_t fParams
void CreateSaturation(std::vector< double > &wave)
void AddDarkNoise(std::vector< double > &wave)
double Transittimespread(double fwhm)
void AddLineNoise(std::vector< double > &wave)
auto end(FixedBins< T, C > const &) noexcept
Definition: FixedBins.h:585
CLHEP::RandPoissonQ fPoissonQGen
void AddSPE(size_t time_bin, std::vector< double > &wave)
void opdet::DigiPMTSBNDAlg::CreateSaturation ( std::vector< double > &  wave)
private

Definition at line 346 of file DigiPMTSBNDAlg.cc.

347  {
348  std::replace_if(wave.begin(), wave.end(),
349  [&](auto w){return w < saturation;}, saturation);
350  }
double opdet::DigiPMTSBNDAlg::FindMinimumTime ( sim::SimPhotons const &  simphotons,
int  ch,
std::string  pdtype,
std::unordered_map< int, sim::SimPhotons > &  directPhotonsOnPMTS 
)
private

Definition at line 390 of file DigiPMTSBNDAlg.cc.

395  {
396  double t_min = 1e15;
397 
398  if(pdtype == "pmt_uncoated") {
399  // TODO: use std::algorithm. ~icaza
400  for(size_t i = 0; i < simphotons.size(); i++) {
401  if(simphotons[i].Time < t_min) t_min = simphotons[i].Time;
402  }
403  }
404  else if(pdtype == "pmt_coated") {
405  sim::SimPhotons auxphotons;
406  if ( auto it{ directPhotonsOnPMTS.find(ch) }; it != std::end(directPhotonsOnPMTS) )
407  {auxphotons = it->second;}
408  auxphotons += (simphotons);
409  // TODO: use std::algorithm. ~icaza
410  for(size_t i = 0; i < auxphotons.size(); i++) {
411  if(auxphotons[i].Time < t_min) t_min = auxphotons[i].Time;
412  }
413  }
414  else {
415  throw cet::exception("DigiPMTSBNDAlg") << "Wrong pdtype: " << pdtype << std::endl;
416  }
417  return t_min;
418  }
auto end(FixedBins< T, C > const &) noexcept
Definition: FixedBins.h:585
Collection of photons which recorded on one channel.
Definition: SimPhotons.h:136
double opdet::DigiPMTSBNDAlg::FindMinimumTimeLite ( sim::SimPhotonsLite const &  litesimphotons,
int  ch,
std::string  pdtype,
std::unordered_map< int, sim::SimPhotonsLite > &  directPhotonsOnPMTS 
)
private

Definition at line 422 of file DigiPMTSBNDAlg.cc.

427  {
428 
429  if(pdtype == "pmt_uncoated") {
430  std::map<int, int> const& photonMap = litesimphotons.DetectedPhotons;
431  auto min = std::find_if(
432  photonMap.begin(),
433  photonMap.end(),
434  [](const auto& pm) {return pm.second != 0; });
435  if(min != photonMap.end()) return double(min->first);
436  }
437  else if(pdtype == "pmt_coated") {
438  sim::SimPhotonsLite auxphotons;
439  if ( auto it{ directPhotonsOnPMTS.find(ch) }; it != std::end(directPhotonsOnPMTS) )
440  {auxphotons = it->second;}
441  // TODO: this might be buggy:
442  // potentially adding to a uninitialized object. ~icaza
443  auxphotons += (litesimphotons);
444  std::map<int, int> const& auxphotonMap = auxphotons.DetectedPhotons;
445  auto min = std::find_if(
446  auxphotonMap.begin(),
447  auxphotonMap.end(),
448  [](const auto& pm) {return pm.second != 0; });
449  if(min != auxphotonMap.end()) return double(min->first);
450  }
451  else {
452  throw cet::exception("DigiPMTSBNDAlg") << "Wrong pdtype: " << pdtype << std::endl;
453  }
454  return 1e5;
455  }
std::map< int, int > DetectedPhotons
Number of photons detected at each given time: time tick -&gt; photons.
Definition: SimPhotons.h:117
auto end(FixedBins< T, C > const &) noexcept
Definition: FixedBins.h:585
Compact representation of photons on a channel.
Definition: SimPhotons.h:103
void opdet::DigiPMTSBNDAlg::Pulse1PE ( std::vector< double > &  wave)
private

Definition at line 302 of file DigiPMTSBNDAlg.cc.

303  {
304  double time;
305  double constT1 = fParams.PMTChargeToADC * fParams.PMTMeanAmplitude;
306  double constT21 = 2.0 * sigma1 * sigma1;
307  double constT22 = 2.0 * sigma2 * sigma2;
308  for(size_t i = 0; i<fSinglePEWave.size(); i++) {
309  time = static_cast<double>(i) / fSampling;
310  if (time < fParams.TransitTime)
311  fSinglePEWave[i] = constT1 * std::exp(-1.0 * std::pow(time - fParams.TransitTime, 2) / constT21);
312  else
313  fSinglePEWave[i] = constT1 * std::exp(-1.0 * std::pow(time - fParams.TransitTime, 2) / constT22);
314  }
315  }
ConfigurationParameters_t fParams
std::vector< double > fSinglePEWave
double opdet::DigiPMTSBNDAlg::Transittimespread ( double  fwhm)
private

Definition at line 318 of file DigiPMTSBNDAlg.cc.

319  {
320  double tts, sigma;
321  sigma = fwhm / transitTimeSpread_frac;
322  tts = fGaussQGen.fire(0., sigma);
323  return tts;
324  }
const double transitTimeSpread_frac
CLHEP::RandGaussQ fGaussQGen

Member Data Documentation

CLHEP::HepRandomEngine* opdet::DigiPMTSBNDAlg::fEngine
private

Reference to art-managed random-number engine.

Definition at line 130 of file DigiPMTSBNDAlg.hh.

CLHEP::RandExponential opdet::DigiPMTSBNDAlg::fExponentialGen
private

Definition at line 134 of file DigiPMTSBNDAlg.hh.

CLHEP::RandFlat opdet::DigiPMTSBNDAlg::fFlatGen
private

Definition at line 131 of file DigiPMTSBNDAlg.hh.

std::unordered_map< raw::Channel_t, std::vector<double> > opdet::DigiPMTSBNDAlg::fFullWaveforms
private

Definition at line 147 of file DigiPMTSBNDAlg.hh.

CLHEP::RandGaussQ opdet::DigiPMTSBNDAlg::fGaussQGen
private

Definition at line 133 of file DigiPMTSBNDAlg.hh.

ConfigurationParameters_t opdet::DigiPMTSBNDAlg::fParams
private

Definition at line 118 of file DigiPMTSBNDAlg.hh.

std::unique_ptr<opdet::PMTGainFluctuations> opdet::DigiPMTSBNDAlg::fPMTGainFluctuationsPtr
private

Definition at line 139 of file DigiPMTSBNDAlg.hh.

CLHEP::RandPoissonQ opdet::DigiPMTSBNDAlg::fPoissonQGen
private

Definition at line 132 of file DigiPMTSBNDAlg.hh.

double opdet::DigiPMTSBNDAlg::fQEDirect
private

Definition at line 121 of file DigiPMTSBNDAlg.hh.

double opdet::DigiPMTSBNDAlg::fQERefl
private

Definition at line 122 of file DigiPMTSBNDAlg.hh.

double opdet::DigiPMTSBNDAlg::fSampling
private

Definition at line 120 of file DigiPMTSBNDAlg.hh.

std::vector<double> opdet::DigiPMTSBNDAlg::fSinglePEWave
private

Definition at line 145 of file DigiPMTSBNDAlg.hh.

std::unique_ptr<CLHEP::RandGeneral> opdet::DigiPMTSBNDAlg::fTimeTPB
private

Definition at line 135 of file DigiPMTSBNDAlg.hh.

int opdet::DigiPMTSBNDAlg::pulsesize
private

Definition at line 146 of file DigiPMTSBNDAlg.hh.

double opdet::DigiPMTSBNDAlg::saturation
private

Definition at line 128 of file DigiPMTSBNDAlg.hh.

double opdet::DigiPMTSBNDAlg::sigma1
private

Definition at line 124 of file DigiPMTSBNDAlg.hh.

double opdet::DigiPMTSBNDAlg::sigma2
private

Definition at line 125 of file DigiPMTSBNDAlg.hh.

const double opdet::DigiPMTSBNDAlg::transitTimeSpread_frac = 2.0 * std::sqrt(2.0 * std::log(2.0))
private

Definition at line 127 of file DigiPMTSBNDAlg.hh.


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