LArSoft  v09_90_00
Liquid Argon Software toolkit - https://larsoft.org/
SimPhotonCounterAlg.cxx
Go to the documentation of this file.
1 
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 
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] ||
41  time_range[1] > time_range[2])
42  throw std::runtime_error("ERROR in SimPhotonCounterAlg: Bad time range.");
43 
44  fTimeRanges.push_back(time_range);
45 
46  std::vector<float> wavelength_range(2);
47  wavelength_range[0] = p.get<float>("MinWavelength");
48  wavelength_range[1] = p.get<float>("MaxWavelength");
49 
50  if (wavelength_range[0] >= wavelength_range[1])
51  throw std::runtime_error("ERROR in SimPhotonCounterAlg: Bad wavelength range.");
52 
53  fWavelengthRanges.push_back(wavelength_range);
54 }
55 
57  opdet::OpDigiProperties const& opdigip)
58 {
59  fCounters.resize(fTimeRanges.size());
61  for (size_t i = 0; i < fCounters.size(); i++)
63  fTimeRanges[i][1],
64  fTimeRanges[i][2],
65  fTimeRanges[i][3],
66  fWavelengthRanges[i][0],
67  fWavelengthRanges[i][1],
68  std::vector<float>(odresponse->NOpChannels(), opdigip.QE()));
69 }
70 
72 {
73  if (ph_col.size() != fCounters.at(0).GetVectorSize())
74  throw std::runtime_error(
75  "ERROR in SimPhotonCounterAlg: Photon collection size and OpDet size not equal.");
76 
77  for (auto const& photons : ph_col)
78  for (auto& counter : fCounters)
79  counter.AddSimPhotons(photons.second);
80 }
81 
82 void opdet::SimPhotonCounterAlg::AddSimPhotonsVector(std::vector<sim::SimPhotons> const& spv)
83 {
84  for (auto const& photons : spv)
85  for (auto& counter : fCounters)
86  counter.AddSimPhotons(photons);
87 }
88 
90 {
91  for (auto& counter : fCounters)
92  counter.ClearVectors();
93 }
94 
95 std::vector<float> const& opdet::SimPhotonCounterAlg::PromptPhotonVector(size_t i)
96 {
97  return fCounters.at(i).PromptPhotonVector();
98 }
99 
100 std::vector<float> const& opdet::SimPhotonCounterAlg::LatePhotonVector(size_t i)
101 {
102  return fCounters.at(i).LatePhotonVector();
103 }
104 
106 {
107  return fCounters.at(i);
108 }
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 &)
std::vector< std::vector< float > > fWavelengthRanges
void AddSimPhotonsVector(std::vector< sim::SimPhotons > const &)
std::vector< SimPhotonCounter > fCounters
double QE() const noexcept
Returns quantum efficiency.
auto counter(T begin, T end)
Returns an object to iterate values from begin to end in a range-for loop.
Definition: counter.h:295
T get(std::string const &key) const
Definition: ParameterSet.h:314
SimPhotonCounterAlg(fhicl::ParameterSet const &)
Description of geometry of one entire detector.
Definition: GeometryCore.h:119
std::vector< float > const & PromptPhotonVector(size_t)
void AddSimPhotonCollection(sim::SimPhotonsCollection const &)
Namespace collecting geometry-related classes utilities.
std::vector< std::vector< float > > fTimeRanges
Collection of sim::SimPhotons, indexed by channel number.
Definition: SimPhotons.h:178