LArSoft  v09_90_00
Liquid Argon Software toolkit - https://larsoft.org/
SimPhotonCounter.cxx
Go to the documentation of this file.
1 #include "SimPhotonCounter.h"
2 
4 
5 #include <algorithm>
6 #include <functional>
7 #include <iostream>
8 #include <stdexcept>
9 
11  float t_p1,
12  float t_p2,
13  float t_l1,
14  float t_l2,
15  float min_w,
16  float max_w,
17  float e)
18 {
19 
20  SetWavelengthRanges(min_w, max_w);
21  SetTimeRanges(t_p1, t_p2, t_l1, t_l2);
22 
23  _photonVector_prompt = std::vector<float>(s);
24  _photonVector_late = std::vector<float>(s);
25  _qeVector = std::vector<float>(s, e);
26 }
27 
29  float t_p2,
30  float t_l1,
31  float t_l2,
32  float min_w,
33  float max_w,
34  const std::vector<float>& eV)
35 {
36  SetWavelengthRanges(min_w, max_w);
37  SetTimeRanges(t_p1, t_p2, t_l1, t_l2);
38 
39  _photonVector_prompt = std::vector<float>(eV.size());
40  _photonVector_late = std::vector<float>(eV.size());
41  _qeVector = eV;
42 }
43 
44 void opdet::SimPhotonCounter::SetWavelengthRanges(float min_w, float max_w)
45 {
46  if (min_w >= max_w) throw std::runtime_error("ERROR in SimPhotonCounter: bad wavelength range");
47 
48  _min_wavelength = min_w;
49  _max_wavelength = max_w;
50 }
51 
53 {
54  if (ph.Energy < std::numeric_limits<float>::epsilon())
55  throw std::runtime_error("ERROR in SimPhotonCounter: photon energy is zero.");
56 
57  return 0.00124 / ph.Energy;
58 }
59 
60 void opdet::SimPhotonCounter::SetTimeRanges(float t_p1, float t_p2, float t_l1, float t_l2)
61 {
62  if (t_p2 < t_p1 || t_l2 < t_l1 || t_p2 > t_l1)
63  throw std::runtime_error("ERROR in SimPhotonCounter: bad time ranges");
64 
65  _min_prompt_time = t_p1;
66  _max_prompt_time = t_p2;
67  _min_late_time = t_l1;
68  _max_late_time = t_l2;
69 }
70 
71 void opdet::SimPhotonCounter::AddOnePhoton(size_t i_opdet, const sim::OnePhoton& photon)
72 {
73  if (i_opdet > GetVectorSize())
74  throw std::runtime_error("ERROR in SimPhotonCounter: Opdet requested out of range!");
75 
76  if (Wavelength(photon) < _min_wavelength || Wavelength(photon) > _max_wavelength) return;
77 
78  if (photon.Time > _min_prompt_time && photon.Time <= _max_prompt_time)
79  _photonVector_prompt[i_opdet] += _qeVector[i_opdet];
80  else if (photon.Time > _min_late_time && photon.Time < _max_late_time)
81  _photonVector_late[i_opdet] += _qeVector[i_opdet];
82 }
83 
85 {
86  for (size_t i_ph = 0; i_ph < photons.size(); i_ph++)
87  AddOnePhoton(photons.OpChannel(), photons[i_ph]);
88 }
89 
91 {
92  for (size_t i = 0; i < GetVectorSize(); i++) {
93  _photonVector_prompt[i] = 0.0;
94  _photonVector_late[i] = 0.0;
95  }
96 }
97 
99 {
100 
101  std::vector<float> totalPhotonVector(GetVectorSize());
102  std::transform(PromptPhotonVector().begin(),
105  totalPhotonVector.begin(),
106  std::plus<float>());
107  return totalPhotonVector;
108 }
109 
111 {
112  std::cout << "Vector size: " << GetVectorSize() << std::endl;
113  std::cout << "Time cut ranges: (" << MinPromptTime() << "," << MaxPromptTime() << ") , ("
114  << MinLateTime() << "," << MaxLateTime() << ")" << std::endl;
115  std::cout << "\t"
116  << "i : QE / Prompt / Late / Total" << std::endl;
117  for (size_t i = 0; i < GetVectorSize(); i++)
118  std::cout << "\t" << i << ": " << _qeVector[i] << " / " << _photonVector_prompt[i] << " / "
119  << _photonVector_late[i] << " / " << TotalPhotonVector(i) << std::endl;
120 }
float MinPromptTime() const
int OpChannel() const
Returns the optical channel number this object is associated to.
Definition: SimPhotons.h:239
void SetTimeRanges(float t_p1, float t_p2, float t_l1, float t_l2)
float MinLateTime() const
All information of a photon entering the sensitive optical detector volume.
Definition: SimPhotons.h:60
std::vector< float > _photonVector_prompt
const std::vector< float > & PromptPhotonVector() const
decltype(auto) constexpr end(T &&obj)
ADL-aware version of std::end.
Definition: StdUtils.h:77
std::vector< float > TotalPhotonVector() const
Simulation objects for optical detectors.
float MaxPromptTime() const
float Wavelength(const sim::OnePhoton &ph)
float MaxLateTime() const
Collection of photons which recorded on one channel.
Definition: SimPhotons.h:127
const std::vector< float > & LatePhotonVector() const
std::vector< float > _qeVector
std::vector< float > _photonVector_late
void AddOnePhoton(size_t i_opdet, const sim::OnePhoton &photon)
decltype(auto) constexpr begin(T &&obj)
ADL-aware version of std::begin.
Definition: StdUtils.h:69
void SetWavelengthRanges(float min_w, float max_w)
float Energy
Scintillation photon energy [GeV].
Definition: SimPhotons.h:78
Float_t e
Definition: plot.C:35
void AddSimPhotons(const sim::SimPhotons &photons)
size_t GetVectorSize() const