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 
12 #include "fhiclcpp/ParameterSet.h"
13 
15 {
16  FillAllRanges( p.get< std::vector<fhicl::ParameterSet> >("SimPhotonCounterParams") );
17 }
18 
19 void opdet::SimPhotonCounterAlg::FillAllRanges(std::vector<fhicl::ParameterSet> const& pv)
20 {
21  fTimeRanges.clear();
22  fWavelengthRanges.clear();
23 
24  fTimeRanges.reserve(pv.size());
25  fWavelengthRanges.reserve(pv.size());
26 
27  for(auto const& p : pv)
28  FillRanges(p);
29 }
30 
32 {
33  std::vector<float> time_range(4);
34  time_range[0] = p.get<float>("MinPromptTime");
35  time_range[1] = p.get<float>("MaxPromptTime");
36  time_range[2] = p.get<float>("MinLateTime");
37  time_range[3] = p.get<float>("MaxLateTime");
38 
39  if( time_range[0]>time_range[1] || time_range[2]>time_range[3] || time_range[1]>time_range[2] )
40  throw std::runtime_error("ERROR in SimPhotonCounterAlg: Bad time range.");
41 
42  fTimeRanges.push_back(time_range);
43 
44  std::vector<float> wavelength_range(2);
45  wavelength_range[0] = p.get<float>("MinWavelength");
46  wavelength_range[1] = p.get<float>("MaxWavelength");
47 
48  if(wavelength_range[0] >= wavelength_range[1])
49  throw std::runtime_error("ERROR in SimPhotonCounterAlg: Bad wavelength range.");
50 
51  fWavelengthRanges.push_back(wavelength_range);
52 
53 }
54 
56  opdet::OpDigiProperties const& opdigip)
57 {
58  fCounters.resize(fTimeRanges.size());
60  for(size_t i=0; i<fCounters.size(); i++)
62  fTimeRanges[i][2],fTimeRanges[i][3],
64  std::vector<float>(odresponse->NOpChannels(),opdigip.QE()));
65 }
66 
68 {
69  if(ph_col.size() != fCounters.at(0).GetVectorSize())
70  throw std::runtime_error("ERROR in SimPhotonCounterAlg: Photon collection size and OpDet size not equal.");
71 
72  for(auto const& photons : ph_col)
73  for(auto & counter : fCounters)
74  counter.AddSimPhotons(photons.second);
75 }
76 
77 void opdet::SimPhotonCounterAlg::AddSimPhotonsVector(std::vector<sim::SimPhotons> const& spv)
78 {
79  for(auto const& photons : spv)
80  for(auto & counter : fCounters)
81  counter.AddSimPhotons(photons);
82 }
83 
85 {
86  for(auto & counter : fCounters)
87  counter.ClearVectors();
88 }
89 
90 std::vector<float> const& opdet::SimPhotonCounterAlg::PromptPhotonVector(size_t i)
91 {
92  return fCounters.at(i).PromptPhotonVector();
93 }
94 
95 std::vector<float> const& opdet::SimPhotonCounterAlg::LatePhotonVector(size_t i)
96 {
97  return fCounters.at(i).LatePhotonVector();
98 }
99 
101 {
102  return fCounters.at(i);
103 }
void InitializeCounters(geo::GeometryCore const &, opdet::OpDigiProperties const &)
std::vector< float > const & LatePhotonVector(size_t)
void FillRanges(fhicl::ParameterSet const &)
SimPhotonCounter const & GetSimPhotonCounter(size_t)
void FillAllRanges(std::vector< fhicl::ParameterSet > const &)
void AddSimPhotonsVector(std::vector< sim::SimPhotons > const &)
std::vector< SimPhotonCounter > fCounters
double QE() const noexcept
Returns quantum efficiency.
std::vector< std::vector< float > > fTimeRanges
T get(std::string const &key) const
Definition: ParameterSet.h:271
SimPhotonCounterAlg(fhicl::ParameterSet const &)
p
Definition: test.py:223
Description of geometry of one entire detector.
std::vector< float > const & PromptPhotonVector(size_t)
std::vector< std::vector< float > > fWavelengthRanges
void AddSimPhotonCollection(sim::SimPhotonsCollection const &)
LArSoft geometry interface.
Definition: ChannelGeo.h:16
Collection of sim::SimPhotons, indexed by channel number.
Definition: SimPhotons.h:192