LArSoft  v06_85_00
Liquid Argon Software toolkit - http://larsoft.org/
OpDetPhotonTable.cxx
Go to the documentation of this file.
1 //
6 // Implementation of the OpDetPhotonTable class.
7 //
8 // See comments in the OpDetPhotonTable.h file.
9 //
10 // Ben Jones, MIT, 11/12/12
11 //
12 
13 
21 
23 
24 namespace larg4 {
26 
27  //--------------------------------------------------
29  {
30  fDetectedPhotons.clear();
31  }
33 
34 
35  //--------------------------------------------------
37  {
38  if(!TheOpDetPhotonTable){
39  TheOpDetPhotonTable = new OpDetPhotonTable;
40  }
41  return TheOpDetPhotonTable;
42  }
43 
44 
45  //--------------------------------------------------
46  void OpDetPhotonTable::AddPhoton(size_t opchannel, sim::OnePhoton&& photon)
47  {
48  if( opchannel >= fDetectedPhotons.size() ) {
49 
50  std::cerr << "<<" << __PRETTY_FUNCTION__ << ">>"
51  << "\033[93m"
52  << "Invalid channel: " << opchannel
53  << "\033[00m"
54  << std::endl;
55  throw std::exception();
56  }
57  fDetectedPhotons.at(opchannel).push_back(photon);
58  }
59 
60  void OpDetPhotonTable::AddPhoton(std::map<int, std::map<int, int>>* StepPhotonTable)
61  {
62  for(auto it = StepPhotonTable->begin(); it!=StepPhotonTable->end(); it++)
63  {
64  for(auto in_it = it->second.begin(); in_it!=it->second.end(); in_it++)
65  {
66  fLitePhotons[it->first][in_it->first]+= in_it->second;
67  }
68  }
69  }
70 
71  //--------------------------------------------------- cOpDetBacktrackerRecord population
72  //J Stock. 11 Oct 2016
74  int iChan = soc.OpDetNum();
75  //std::map<int,int> cOpChannelToSOCMap;
76  std::map<int, int>::iterator channelPosition = cOpChannelToSOCMap.find(iChan);
77  if (channelPosition == cOpChannelToSOCMap.end() ){
79  cOpDetBacktrackerRecordsCol.emplace_back(std::move(soc));
80  }else{
81  unsigned int idtest = channelPosition->second;
82  auto const& timePDclockSDPsMap = soc.timePDclockSDPsMap();
83  for(auto const& timePDclockSDP : timePDclockSDPsMap){
84  for(auto const& sdp : timePDclockSDP.second){
85  double xyz[3] = {sdp.x, sdp.y, sdp.z};
86  cOpDetBacktrackerRecordsCol.at(idtest).AddScintillationPhotons(
87  sdp.trackID,
88  timePDclockSDP.first,
89  sdp.numPhotons,
90  xyz,
91  sdp.energy);
92  }//end sdp : timesdp.second
93  }//end const timesdp : timeSDPMap
94  }// if chanPos == cOpChan else
95 
96 
97 
98  }//END void OpDetPhotonTable::AdOpDetBacktrackerRecords
99 
100  // cOpDetBacktrackerRecord return.
101  std::vector<sim::OpDetBacktrackerRecord> OpDetPhotonTable::YieldOpDetBacktrackerRecords() {
102  // we give the result to the caller, and don't retain it
103  std::vector<sim::OpDetBacktrackerRecord> result;
104  std::swap(result, cOpDetBacktrackerRecordsCol);
105  cOpChannelToSOCMap.clear();
106  return result;
107  } // OpDetPhotonTable::YieldOpDetBacktrackerRecords()
108 
109 
110 
111 
112  //--------------------------------------------------
113  void OpDetPhotonTable::ClearTable(const size_t nch)
114  {
115  if(fDetectedPhotons.size() != nch) fDetectedPhotons.resize(nch);
116  for(size_t i=0; i<fDetectedPhotons.size(); ++i) {
117  fDetectedPhotons.at(i).clear();
118  fDetectedPhotons.at(i).SetChannel(i);
119  //fDetectedPhotons.at(i).reserve(10000); // Just a guess on minimum # photons
120  }
121 
122  for(std::map<int,std::map<int, int>>::iterator it=fLitePhotons.begin(); it!=fLitePhotons.end(); ++it)
123  (it->second).clear();
124  fLitePhotons.clear();
125  }
126 
127  //--------------------------------------------------
128  std::map<int, std::map<int, int>> OpDetPhotonTable::GetLitePhotons()
129  {
130  return fLitePhotons;
131  }
132 
133  std::vector<sim::SimPhotons >& OpDetPhotonTable::GetPhotons()
134  { return fDetectedPhotons; }
135 
136  //--------------------------------------------------
138  {
139  if(opchannel >= fDetectedPhotons.size()) {
140  std::cerr << "<<" << __PRETTY_FUNCTION__ << ">>"
141  << "Invalid channel Number: " << opchannel
142  << std::endl;
143  }
144  return fDetectedPhotons.at(opchannel);
145  }
146 
147  std::map<int,int>& OpDetPhotonTable::GetLitePhotonsForOpChannel(int opchannel)
148  {
149  return fLitePhotons[opchannel];
150  }
151 
152 
153  //--------------------------------------------------
154  void OpDetPhotonTable::AddEnergyDeposit(int n_elec,int n_photon,
155  double energy,
156  float start_x,float start_y, float start_z,
157  float end_x,float end_y,float end_z,
158  double start_time,double end_time,
159  int trackid,int pdgcode,
160  std::string vol)
161  {
162  fSimEDepCol[vol].emplace_back(n_elec,n_photon,
163  energy,
164  sim::SimEnergyDeposit::Point_t{start_x,start_y,start_z},
165  sim::SimEnergyDeposit::Point_t{end_x,end_y,end_z},
166  start_time,end_time,
167  trackid,pdgcode);
168  }
169 
170  //--------------------------------------------------
172  { fSimEDepCol.clear(); }
173 
174 
175  //--------------------------------------------------
176  std::unordered_map< std::string,std::vector<sim::SimEnergyDeposit> >& OpDetPhotonTable::GetSimEnergyDeposits()
177  { return fSimEDepCol; }
178 
179 
180 }
void AddPhoton(size_t opchannel, sim::OnePhoton &&photon)
std::map< int, std::map< int, int > > fLitePhotons
Encapsulate the construction of a single cyostat.
intermediate_table::iterator iterator
std::vector< sim::SimPhotons > & GetPhotons()
Geant4 interface.
std::map< int, int > & GetLitePhotonsForOpChannel(int opchannel)
OpDetPhotonTable * TheOpDetPhotonTable
Energy deposited on a readout Optical Detector by simulated tracks.
sim::SimPhotons & GetPhotonsForOpChannel(size_t opchannel)
contains objects relating to OpDet hits
int OpDetNum() const
Returns the readout Optical Detector this object describes.
ROOT::Math::PositionVector3D< ROOT::Math::Cartesian3D< Length_t > > Point_t
std::unordered_map< std::string, std::vector< sim::SimEnergyDeposit > > & GetSimEnergyDeposits()
double energy
Definition: plottest35.C:25
void AddEnergyDeposit(int n_elec, int n_photon, double energy, float start_x, float start_y, float start_z, float end_x, float end_y, float end_z, double start_time, double end_time, int trackid, int pdgcode, std::string vol="EMPTY")
void AddOpDetBacktrackerRecord(sim::OpDetBacktrackerRecord soc)
std::map< int, std::map< int, int > > GetLitePhotons()
Encapsulate the geometry of an optical detector.
static OpDetPhotonTable * Instance(bool LitePhotons=false)
std::vector< sim::OpDetBacktrackerRecord > YieldOpDetBacktrackerRecords()
std::unordered_map< std::string, std::vector< sim::SimEnergyDeposit > > fSimEDepCol
contains information for a single step in the detector simulation
std::vector< sim::OpDetBacktrackerRecord > cOpDetBacktrackerRecordsCol
void ClearTable(size_t nch=0)
std::vector< sim::SimPhotons > fDetectedPhotons
timePDclockSDPs_t const & timePDclockSDPsMap() const
Returns all the deposited energy information as stored.
art framework interface to geometry description
cet::coded_exception< error, detail::translate > exception
Definition: exception.h:33
std::map< int, int > cOpChannelToSOCMap