All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
SimPhotonCounter.cxx
Go to the documentation of this file.
1 #include "SimPhotonCounter.h"
2 
4 
5 #include <iostream>
6 #include <stdexcept>
7 #include <algorithm>
8 #include <functional>
9 
11  float t_p1, float t_p2,
12  float t_l1, float t_l2,
13  float min_w, float max_w,
14  float e)
15 {
16 
17  SetWavelengthRanges(min_w,max_w);
18  SetTimeRanges(t_p1,t_p2,t_l1,t_l2);
19 
20  _photonVector_prompt=std::vector<float>(s);
21  _photonVector_late=std::vector<float>(s);
22  _qeVector = std::vector<float>(s,e);
23 
24 }
25 
27  float t_l1, float t_l2,
28  float min_w, float max_w,
29  const std::vector<float>& eV)
30 {
31  SetWavelengthRanges(min_w,max_w);
32  SetTimeRanges(t_p1,t_p2,t_l1,t_l2);
33 
34  _photonVector_prompt=std::vector<float>(eV.size());
35  _photonVector_late=std::vector<float>(eV.size());
36  _qeVector = eV;
37 
38 }
39 
40 void opdet::SimPhotonCounter::SetWavelengthRanges(float min_w, float max_w)
41 {
42  if(min_w >= max_w)
43  throw std::runtime_error("ERROR in SimPhotonCounter: bad wavelength range");
44 
45  _min_wavelength = min_w;
46  _max_wavelength = max_w;
47 }
48 
50 {
51  if(ph.Energy < std::numeric_limits<float>::epsilon())
52  throw std::runtime_error("ERROR in SimPhotonCounter: photon energy is zero.");
53 
54  return 0.00124 / ph.Energy;
55 }
56 
57 void opdet::SimPhotonCounter::SetTimeRanges(float t_p1, float t_p2, float t_l1, float t_l2)
58 {
59  if(t_p2<t_p1 || t_l2<t_l1 || t_p2>t_l1 )
60  throw std::runtime_error("ERROR in SimPhotonCounter: bad time ranges");
61 
62  _min_prompt_time = t_p1; _max_prompt_time = t_p2;
63  _min_late_time = t_l1; _max_late_time = t_l2;
64 }
65 
67 {
68  if(i_opdet > GetVectorSize())
69  throw std::runtime_error("ERROR in SimPhotonCounter: Opdet requested out of range!");
70 
71  if(Wavelength(photon) < _min_wavelength || Wavelength(photon) > _max_wavelength) return;
72 
73  if(photon.Time > _min_prompt_time && photon.Time <= _max_prompt_time)
74  _photonVector_prompt[i_opdet] += _qeVector[i_opdet];
75  else if(photon.Time > _min_late_time && photon.Time < _max_late_time)
76  _photonVector_late[i_opdet] += _qeVector[i_opdet];
77 
78 }
79 
81 {
82  for(size_t i_ph=0; i_ph < photons.size(); i_ph++)
83  AddOnePhoton(photons.OpChannel(),photons[i_ph]);
84 }
85 
87 {
88  for(size_t i=0; i<GetVectorSize(); i++){
89  _photonVector_prompt[i]=0.0;
90  _photonVector_late[i]=0.0;
91  }
92 }
93 
94 std::vector<float> opdet::SimPhotonCounter::TotalPhotonVector() const{
95 
96  std::vector<float> totalPhotonVector(GetVectorSize());
97  std::transform(PromptPhotonVector().begin(),PromptPhotonVector().end(),
98  LatePhotonVector().begin(),
99  totalPhotonVector.begin(),
100  std::plus<float>());
101  return totalPhotonVector;
102 }
103 
105 {
106  std::cout << "Vector size: " << GetVectorSize() << std::endl;
107  std::cout << "Time cut ranges: ("
108  << MinPromptTime() << "," << MaxPromptTime() << ") , ("
109  << MinLateTime() << "," << MaxLateTime() << ")" << std::endl;
110  std::cout << "\t" << "i : QE / Prompt / Late / Total" << std::endl;
111  for(size_t i=0; i<GetVectorSize(); i++)
112  std::cout << "\t" << i << ": " << _qeVector[i] << " / " << _photonVector_prompt[i] << " / " << _photonVector_late[i] << " / " << TotalPhotonVector(i) << std::endl;
113 
114 }
process_name can override from command line with o or output photon
Definition: runPID.fcl:28
static constexpr Sample_t transform(Sample_t sample)
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)
All information of a photon entering the sensitive optical detector volume.
Definition: SimPhotons.h:64
std::vector< float > _photonVector_prompt
std::vector< float > TotalPhotonVector() const
Simulation objects for optical detectors.
auto end(FixedBins< T, C > const &) noexcept
Definition: FixedBins.h:585
float Wavelength(const sim::OnePhoton &ph)
auto begin(FixedBins< T, C > const &) noexcept
Definition: FixedBins.h:573
Collection of photons which recorded on one channel.
Definition: SimPhotons.h:136
then echo File list $list not found else cat $list while read file do echo $file sed s
Definition: file_to_url.sh:60
do i e
std::vector< float > _qeVector
std::vector< float > _photonVector_late
void AddOnePhoton(size_t i_opdet, const sim::OnePhoton &photon)
void SetWavelengthRanges(float min_w, float max_w)
float Energy
Scintillation photon energy [GeV].
Definition: SimPhotons.h:82
void AddSimPhotons(const sim::SimPhotons &photons)
BEGIN_PROLOG could also be cout