SimPhotonCounter.cxx
Go to the documentation of this file.
1 #include "SimPhotonCounter.h"
2 #include <iostream>
3 #include <stdexcept>
4 #include <algorithm>
5 #include <functional>
6 
8  float t_p1, float t_p2,
9  float t_l1, float t_l2,
10  float min_w, float max_w,
11  float e)
12 {
13 
14  SetWavelengthRanges(min_w,max_w);
15  SetTimeRanges(t_p1,t_p2,t_l1,t_l2);
16 
17  _photonVector_prompt=std::vector<float>(s);
18  _photonVector_late=std::vector<float>(s);
19  _qeVector = std::vector<float>(s,e);
20 
21 }
22 
24  float t_l1, float t_l2,
25  float min_w, float max_w,
26  const std::vector<float>& eV)
27 {
28  SetWavelengthRanges(min_w,max_w);
29  SetTimeRanges(t_p1,t_p2,t_l1,t_l2);
30 
31  _photonVector_prompt=std::vector<float>(eV.size());
32  _photonVector_late=std::vector<float>(eV.size());
33  _qeVector = eV;
34 
35 }
36 
37 void opdet::SimPhotonCounter::SetWavelengthRanges(float min_w, float max_w)
38 {
39  if(min_w >= max_w)
40  throw std::runtime_error("ERROR in SimPhotonCounter: bad wavelength range");
41 
42  _min_wavelength = min_w;
43  _max_wavelength = max_w;
44 }
45 
47 {
48  if(ph.Energy < std::numeric_limits<float>::epsilon())
49  throw std::runtime_error("ERROR in SimPhotonCounter: photon energy is zero.");
50 
51  return 0.00124 / ph.Energy;
52 }
53 
54 void opdet::SimPhotonCounter::SetTimeRanges(float t_p1, float t_p2, float t_l1, float t_l2)
55 {
56  if(t_p2<t_p1 || t_l2<t_l1 || t_p2>t_l1 )
57  throw std::runtime_error("ERROR in SimPhotonCounter: bad time ranges");
58 
59  _min_prompt_time = t_p1; _max_prompt_time = t_p2;
60  _min_late_time = t_l1; _max_late_time = t_l2;
61 }
62 
63 void opdet::SimPhotonCounter::AddOnePhoton(size_t i_opdet, const sim::OnePhoton& photon)
64 {
65  if(i_opdet > GetVectorSize())
66  throw std::runtime_error("ERROR in SimPhotonCounter: Opdet requested out of range!");
67 
68  if(Wavelength(photon) < _min_wavelength || Wavelength(photon) > _max_wavelength) return;
69 
70  if(photon.Time > _min_prompt_time && photon.Time <= _max_prompt_time)
71  _photonVector_prompt[i_opdet] += _qeVector[i_opdet];
72  else if(photon.Time > _min_late_time && photon.Time < _max_late_time)
73  _photonVector_late[i_opdet] += _qeVector[i_opdet];
74 
75 }
76 
78 {
79  for(size_t i_ph=0; i_ph < photons.size(); i_ph++)
80  AddOnePhoton(photons.OpChannel(),photons[i_ph]);
81 }
82 
84 {
85  for(size_t i=0; i<GetVectorSize(); i++){
86  _photonVector_prompt[i]=0.0;
87  _photonVector_late[i]=0.0;
88  }
89 }
90 
91 std::vector<float> opdet::SimPhotonCounter::TotalPhotonVector() const{
92 
93  std::vector<float> totalPhotonVector(GetVectorSize());
94  std::transform(PromptPhotonVector().begin(),PromptPhotonVector().end(),
96  totalPhotonVector.begin(),
97  std::plus<float>());
98  return totalPhotonVector;
99 }
100 
102 {
103  std::cout << "Vector size: " << GetVectorSize() << std::endl;
104  std::cout << "Time cut ranges: ("
105  << MinPromptTime() << "," << MaxPromptTime() << ") , ("
106  << MinLateTime() << "," << MaxLateTime() << ")" << std::endl;
107  std::cout << "\t" << "i : QE / Prompt / Late / Total" << std::endl;
108  for(size_t i=0; i<GetVectorSize(); i++)
109  std::cout << "\t" << i << ": " << _qeVector[i] << " / " << _photonVector_prompt[i] << " / " << _photonVector_late[i] << " / " << TotalPhotonVector(i) << std::endl;
110 
111 }
end
while True: pbar.update(maxval-len(onlies[E][S])) #print iS, "/", len(onlies[E][S]) found = False for...
float MinPromptTime() const
int OpChannel() const
Returns the optical channel number this object is associated to.
Definition: SimPhotons.h:254
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:64
std::vector< float > _photonVector_prompt
const std::vector< float > & PromptPhotonVector() const
std::vector< float > TotalPhotonVector() const
const double e
static constexpr double eV
Definition: Units.h:127
float MaxPromptTime() const
float Wavelength(const sim::OnePhoton &ph)
float MaxLateTime() const
Collection of photons which recorded on one channel.
Definition: SimPhotons.h:136
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:72
void SetWavelengthRanges(float min_w, float max_w)
float Energy
Scintillation photon energy [GeV].
Definition: SimPhotons.h:82
void AddSimPhotons(const sim::SimPhotons &photons)
size_t GetVectorSize() const
static QCString * s
Definition: config.cpp:1042
QTextStream & endl(QTextStream &s)