LArSoft  v07_13_02
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  //--------------------------------------------------
47  void OpDetPhotonTable::AddPhoton(size_t opchannel, sim::OnePhoton&& photon, bool Reflected)
48  {
49  if( opchannel >= fDetectedPhotons.size() ) {
50 
51  std::cerr << "<<" << __PRETTY_FUNCTION__ << ">>"
52  << "\033[93m"
53  << "Invalid channel: " << opchannel
54  << "\033[00m"
55  << std::endl;
56  throw std::exception();
57  }
58  if (!Reflected)
59  fDetectedPhotons.at(opchannel).push_back(photon);
60  else
61  fReflectedDetectedPhotons.at(opchannel).push_back(photon);
62  }
63 
64  //--------------------------------------------------
65  void OpDetPhotonTable::AddLitePhoton( int opchannel, int time, int nphotons, bool Reflected)
66  {
67  if (!Reflected)
68  fLitePhotons[opchannel][time] += nphotons;
69  else
70  fReflectedLitePhotons[opchannel][time] += nphotons;
71  }
72 
73  //--------------------------------------------------
74  void OpDetPhotonTable::AddPhoton(std::map<int, std::map<int, int>>* StepPhotonTable, bool Reflected)
75  {
76  for(auto it = StepPhotonTable->begin(); it!=StepPhotonTable->end(); it++)
77  {
78  for(auto in_it = it->second.begin(); in_it!=it->second.end(); in_it++)
79  {
80  if (!Reflected)
81  fLitePhotons[it->first][in_it->first]+= in_it->second;
82  else
83  fReflectedLitePhotons[it->first][in_it->first]+= in_it->second;
84  }
85  }
86  }
87 
88  //--------------------------------------------------- cOpDetBacktrackerRecord population
89  //J Stock. 11 Oct 2016
91 // std::cout << "DEBUG: Adding to " << (Reflected?"Reflected":"Direct") << " cOpDetBTR" << std::endl;
92  if (!Reflected)
94  else
96  }
97 
98  //--------------------------------------------------- cOpDetBacktrackerRecord population
99  void OpDetPhotonTable::AddOpDetBacktrackerRecord(std::vector< sim::OpDetBacktrackerRecord > & RecordsCol,
100  std::map<int, int> & ChannelMap,
102  int iChan = soc.OpDetNum();
103  std::map<int, int>::iterator channelPosition = ChannelMap.find(iChan);
104  if (channelPosition == ChannelMap.end() ){
105  ChannelMap[iChan] = RecordsCol.size();
106  RecordsCol.emplace_back(std::move(soc));
107  }else{
108  unsigned int idtest = channelPosition->second;
109  auto const& timePDclockSDPsMap = soc.timePDclockSDPsMap();
110  for(auto const& timePDclockSDP : timePDclockSDPsMap){
111  for(auto const& sdp : timePDclockSDP.second){
112  double xyz[3] = {sdp.x, sdp.y, sdp.z};
113  RecordsCol.at(idtest).AddScintillationPhotons(
114  sdp.trackID,
115  timePDclockSDP.first,
116  sdp.numPhotons,
117  xyz,
118  sdp.energy);
119  }//end sdp : timesdp.second
120  }//end const timesdp : timeSDPMap
121  }// if chanPos == cOpChan else
122 
123 
124 // std::cout << "DEBUG: Add to " << iChan << " to cOpDetBTR. Now " << RecordsCol.size() << " in size " << std::endl;
125  }//END void OpDetPhotonTable::AdOpDetBacktrackerRecords
126 
127 
128  //--------------------------------------------------
129  // cOpDetBacktrackerRecord return.
130  std::vector<sim::OpDetBacktrackerRecord> OpDetPhotonTable::YieldOpDetBacktrackerRecords() {
131  // we give the result to the caller, and don't retain it
132  std::vector<sim::OpDetBacktrackerRecord> result;
133 // std::cout << "DEBUG: result.size() = " << result.size() << std::endl;
134 // std::cout << "DEBUG: cOpDetBTRCol.size() = " << cOpDetBacktrackerRecordsCol.size() << std::endl;
135  std::swap(result, cOpDetBacktrackerRecordsCol);
136 // std::cout << "DEBUG: std::swap(result, cOpDetBacktrackerRecordsCol);" << std::endl;
137 // std::cout << "DEBUG: result.size() = " << result.size() << std::endl;
138 // std::cout << "DEBUG: cOpDetBTRCol.size() = " << cOpDetBacktrackerRecordsCol.size() << std::endl;
139  cOpChannelToSOCMap.clear();
140  return result;
141  } // OpDetPhotonTable::YieldOpDetBacktrackerRecords()
142 
143  //--------------------------------------------------
144  // cReflectedOpDetBacktrackerRecord return.
145  std::vector<sim::OpDetBacktrackerRecord> OpDetPhotonTable::YieldReflectedOpDetBacktrackerRecords() {
146  // we give the result to the caller, and don't retain it
147  std::vector<sim::OpDetBacktrackerRecord> result;
148 // std::cout << "DEBUG: result.size() = " << result.size() << std::endl;
149 // std::cout << "DEBUG: cReflOpDetBTRCol.size() = " << cReflectedOpDetBacktrackerRecordsCol.size() << std::endl;
150  std::swap(result, cReflectedOpDetBacktrackerRecordsCol);
151 // std::cout << "DEBUG: result.size() = " << result.size() << std::endl;
152 // std::cout << "DEBUG: cReflOpDetBTRCol.size() = " << cReflectedOpDetBacktrackerRecordsCol.size() << std::endl;
154  return result;
155  } // OpDetPhotonTable::YieldOpDetBacktrackerRecords()
156 
157 
158  //--------------------------------------------------
159  void OpDetPhotonTable::ClearTable(const size_t nch)
160  {
161  if(fDetectedPhotons.size() != nch) fDetectedPhotons.resize(nch);
162  for(size_t i=0; i<fDetectedPhotons.size(); ++i) {
163  fDetectedPhotons.at(i).clear();
164  fDetectedPhotons.at(i).SetChannel(i);
165  //fDetectedPhotons.at(i).reserve(10000); // Just a guess on minimum # photons
166  }
167  for(size_t i=0; i<fReflectedDetectedPhotons.size(); ++i) {
168  fReflectedDetectedPhotons.at(i).clear();
169  fReflectedDetectedPhotons.at(i).SetChannel(i);
170  //fDetectedPhotons.at(i).reserve(10000); // Just a guess on minimum # photons
171  }
172 
173  for(auto it=fLitePhotons.begin(); it!=fLitePhotons.end(); ++it)
174  (it->second).clear();
175  for(auto it=fReflectedLitePhotons.begin(); it!=fReflectedLitePhotons.end(); ++it)
176  (it->second).clear();
177  fLitePhotons.clear();
178  fReflectedLitePhotons.clear();
179  }
180 
181  //--------------------------------------------------
183  {
184  if(opchannel >= fDetectedPhotons.size()) {
185  std::cerr << "<<" << __PRETTY_FUNCTION__ << ">>"
186  << "Invalid channel Number: " << opchannel
187  << std::endl;
188  }
189  return fDetectedPhotons.at(opchannel);
190  }
191 
192  //--------------------------------------------------
194  {
195  if(opchannel >= fReflectedDetectedPhotons.size()) {
196  std::cerr << "<<" << __PRETTY_FUNCTION__ << ">>"
197  << "Invalid channel Number: " << opchannel
198  << std::endl;
199  }
200  return fReflectedDetectedPhotons.at(opchannel);
201  }
202 
203 
204  //--------------------------------------------------
205  void OpDetPhotonTable::AddEnergyDeposit(int n_elec,int n_photon,
206  double energy,
207  float start_x,float start_y, float start_z,
208  float end_x,float end_y,float end_z,
209  double start_time,double end_time,
210  int trackid,int pdgcode,
211  std::string const& vol)
212  {
213  fSimEDepCol[vol].emplace_back(n_elec,n_photon,
214  energy,
215  geo::Point_t{start_x,start_y,start_z},
216  geo::Point_t{end_x,end_y,end_z},
217  start_time,end_time,
218  trackid,pdgcode);
219  }
220 
221  //--------------------------------------------------
223  { fSimEDepCol.clear(); }
224 
225 
226  //--------------------------------------------------
227  std::unordered_map< std::string,std::vector<sim::SimEnergyDeposit> > const& OpDetPhotonTable::GetSimEnergyDeposits() const
228  { return fSimEDepCol; }
229 
230 
231 }
std::vector< sim::OpDetBacktrackerRecord > YieldReflectedOpDetBacktrackerRecords()
std::map< int, std::map< int, int > > fLitePhotons
Encapsulate the construction of a single cyostat.
intermediate_table::iterator iterator
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 const &vol="EMPTY")
Geant4 interface.
OpDetPhotonTable * TheOpDetPhotonTable
std::map< int, std::map< int, int > > fReflectedLitePhotons
sim::SimPhotons & GetReflectedPhotonsForOpChannel(size_t opchannel)
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.
std::unordered_map< std::string, std::vector< sim::SimEnergyDeposit > > const & GetSimEnergyDeposits() const
void AddPhoton(size_t opchannel, sim::OnePhoton &&photon, bool Reflected=false)
std::vector< sim::SimPhotons > fReflectedDetectedPhotons
double energy
Definition: plottest35.C:25
void AddOpDetBacktrackerRecord(sim::OpDetBacktrackerRecord soc, bool Reflected=false)
void AddLitePhoton(int opchannel, int time, int nphotons, bool Reflected=false)
Encapsulate the geometry of an optical detector.
static OpDetPhotonTable * Instance(bool LitePhotons=false)
std::vector< sim::OpDetBacktrackerRecord > cReflectedOpDetBacktrackerRecordsCol
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
ROOT::Math::PositionVector3D< ROOT::Math::Cartesian3D< double >, ROOT::Math::GlobalCoordinateSystemTag > Point_t
Type for representation of position in physical 3D space.
Definition: geo_vectors.h:187
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
std::map< int, int > cReflectedOpChannelToSOCMap