All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
SimPhotonCounterAlg.cxx
Go to the documentation of this file.
1 /*!
2  * Title: SimPhotonCounterALG Class
3  * Author: Wes Ketchum (wketchum@lanl.gov)
4  *
5  * Description: Alg class that counts up sim photons, leading towards
6  * comparisons with flashes and flash hypotheses.
7 */
8 
9 #include "SimPhotonCounterAlg.h"
10 #include "OpDetResponseInterface.h"
11 #include "OpDigiProperties.h"
12 
13 #include "fhiclcpp/ParameterSet.h"
14 
16 {
17  FillAllRanges( p.get< std::vector<fhicl::ParameterSet> >("SimPhotonCounterParams") );
18 }
19 
20 void opdet::SimPhotonCounterAlg::FillAllRanges(std::vector<fhicl::ParameterSet> const& pv)
21 {
22  fTimeRanges.clear();
23  fWavelengthRanges.clear();
24 
25  fTimeRanges.reserve(pv.size());
26  fWavelengthRanges.reserve(pv.size());
27 
28  for(auto const& p : pv)
29  FillRanges(p);
30 }
31 
32 void opdet::SimPhotonCounterAlg::FillRanges(fhicl::ParameterSet const& p)
33 {
34  std::vector<float> time_range(4);
35  time_range[0] = p.get<float>("MinPromptTime");
36  time_range[1] = p.get<float>("MaxPromptTime");
37  time_range[2] = p.get<float>("MinLateTime");
38  time_range[3] = p.get<float>("MaxLateTime");
39 
40  if( time_range[0]>time_range[1] || time_range[2]>time_range[3] || time_range[1]>time_range[2] )
41  throw std::runtime_error("ERROR in SimPhotonCounterAlg: Bad time range.");
42 
43  fTimeRanges.push_back(time_range);
44 
45  std::vector<float> wavelength_range(2);
46  wavelength_range[0] = p.get<float>("MinWavelength");
47  wavelength_range[1] = p.get<float>("MaxWavelength");
48 
49  if(wavelength_range[0] >= wavelength_range[1])
50  throw std::runtime_error("ERROR in SimPhotonCounterAlg: Bad wavelength range.");
51 
52  fWavelengthRanges.push_back(wavelength_range);
53 
54 }
55 
57  opdet::OpDigiProperties const& opdigip)
58 {
59  fCounters.resize(fTimeRanges.size());
60  art::ServiceHandle<opdet::OpDetResponseInterface const> odresponse;
61  for(size_t i=0; i<fCounters.size(); i++)
62  fCounters[i] = SimPhotonCounter(fTimeRanges[i][0],fTimeRanges[i][1],
63  fTimeRanges[i][2],fTimeRanges[i][3],
64  fWavelengthRanges[i][0],fWavelengthRanges[i][1],
65  std::vector<float>(odresponse->NOpChannels(),opdigip.QE()));
66 }
67 
69 {
70  if(ph_col.size() != fCounters.at(0).GetVectorSize())
71  throw std::runtime_error("ERROR in SimPhotonCounterAlg: Photon collection size and OpDet size not equal.");
72 
73  for(auto const& photons : ph_col)
74  for(auto & counter : fCounters)
75  counter.AddSimPhotons(photons.second);
76 }
77 
78 void opdet::SimPhotonCounterAlg::AddSimPhotonsVector(std::vector<sim::SimPhotons> const& spv)
79 {
80  for(auto const& photons : spv)
81  for(auto & counter : fCounters)
82  counter.AddSimPhotons(photons);
83 }
84 
86 {
87  for(auto & counter : fCounters)
88  counter.ClearVectors();
89 }
90 
91 std::vector<float> const& opdet::SimPhotonCounterAlg::PromptPhotonVector(size_t i)
92 {
93  return fCounters.at(i).PromptPhotonVector();
94 }
95 
96 std::vector<float> const& opdet::SimPhotonCounterAlg::LatePhotonVector(size_t i)
97 {
98  return fCounters.at(i).LatePhotonVector();
99 }
100 
102 {
103  return fCounters.at(i);
104 }
void InitializeCounters(geo::GeometryCore const &, opdet::OpDigiProperties const &)
std::vector< float > const & LatePhotonVector(size_t)
pdgs p
Definition: selectors.fcl:22
void FillRanges(fhicl::ParameterSet const &)
double QE() const noexcept
Returns quantum efficiency.
SimPhotonCounter const & GetSimPhotonCounter(size_t)
void FillAllRanges(std::vector< fhicl::ParameterSet > const &)
void AddSimPhotonsVector(std::vector< sim::SimPhotons > const &)
auto counter(T begin, T end)
Returns an object to iterate values from begin to end in a range-for loop.
Definition: counter.h:285
SimPhotonCounterAlg(fhicl::ParameterSet const &)
Description of geometry of one entire detector.
std::vector< float > const & PromptPhotonVector(size_t)
void AddSimPhotonCollection(sim::SimPhotonsCollection const &)
Collection of sim::SimPhotons, indexed by channel number.
Definition: SimPhotons.h:192