LArSoft  v07_13_02
Liquid Argon Software toolkit - http://larsoft.org/
OpDetBacktrackerRecord.h
Go to the documentation of this file.
1 /*
2  * @file OpDetBacktrackerRecord.h
3  * @brief object containing MC truth information necessary for backtracking Photons.
4  * Based on SimChannels by seligman@nevis.columbia.edu
5  * @author jason.stock@mines.sdsmt.edu
6  * @see OpDetBacktrackerRecord.cxx
7  *
8  * This class uses only LArSoft libraries that are header only.
9  */
10 
11 
12 #ifndef LARSIMOBJ_SIMULATION_OPDETBACKTRACKERRECORD_H
13 #define LARSIMOBJ_SIMULATION_OPDETBACKTRACKERRECORD_H
14 
15 // LArSoftObj libraries
17 
18 // C/C++ standard libraries
19 #include <string>
20 #include <vector>
21 #include <utility> // std::pair
22 
23 
24 namespace sim {
25 
27  struct TrackSDP{
28  int trackID;
29  float energyFrac;
30  float energy;
31 
32  TrackSDP() {}
33 
34 
35  TrackSDP(int id, float phF, float ph) : trackID(id), energyFrac(phF), energy (ph) {}
36 
37 
38  };
39 
40 
70  struct SDP{
71 
73  typedef int TrackID_t;
74 
76  SDP();
77 
78 
80  SDP(SDP const& sdp, int offset);
81 
83  SDP(TrackID_t tid,
84  float nPh,
85  float e,
86  float xpos,
87  float ypos,
88  float zpos)
89  : trackID (tid)
90  , numPhotons (nPh)
91  , energy (e)
92  , x (xpos)
93  , y (ypos)
94  , z (zpos)
95  {}
96 
97 
98  TrackID_t trackID;
99  float numPhotons;
100  float energy;
101  float x;
102  float y;
103  float z;
104  }; // struct SDP
105 
106 
108  typedef std::pair< double, std::vector<sim::SDP> > timePDclockSDP_t;
109 
128  {
129  public:
131  typedef timePDclockSDP_t::first_type storedTimePDclock_t;
132 
134  typedef std::vector<timePDclockSDP_t> timePDclockSDPs_t;
135 
136  private:
137  int iOpDetNum;
138  timePDclockSDPs_t timePDclockSDPs;
139 
140 
141  public:
142 
143  // Default constructor
145 
147  //typedef unsigned short timePDclock_t;
148  typedef double timePDclock_t;//This is the G4Time from OpFastScintillation. (ns)
149 
152 
153 
155  explicit OpDetBacktrackerRecord(int detNum);
156 
166  void AddScintillationPhotons(TrackID_t trackID,
167  timePDclock_t timePDclock,
168  double numberPhotons,
169  double const* xyz,
170  double energy);
171 
173  int OpDetNum() const;
174 
192  std::vector<sim::SDP> TrackIDsAndEnergies(timePDclock_t startTimePDclock,
193  timePDclock_t endTimePDclock) const;
194 
207  timePDclockSDPs_t const& timePDclockSDPsMap() const;
208 
209 
211  double Photons(timePDclock_t iTimePDclock) const;
212 
214  double Energy(timePDclock_t iTimePDclock) const;
215 
238  std::vector<sim::TrackSDP> TrackSDPs(timePDclock_t startTimePDclock,
239  timePDclock_t endTimePDclock) const;
240 
242  bool operator< (const OpDetBacktrackerRecord& other) const;
243 
245  bool operator== (const OpDetBacktrackerRecord& other) const;
246 
272  std::pair<TrackID_t,TrackID_t> MergeOpDetBacktrackerRecord
273  (const OpDetBacktrackerRecord& opDetNum, int offset);
274 
275 
283  template <typename Stream>
284  void Dump(Stream&& out, std::string indent, std::string first_indent) const;
285 
287  template <typename Stream>
288  void Dump(Stream&& out, std::string indent = "") const
289  { Dump(std::forward<Stream>(out), indent, indent); }
290 
291 
292  private:
294  struct CompareByTimePDclock;
295 
297  timePDclockSDPs_t::iterator findClosestTimePDclockSDP(storedTimePDclock_t timePDclock);
298 
300  timePDclockSDPs_t::const_iterator findClosestTimePDclockSDP
301  (storedTimePDclock_t timePDclock) const;
303 
304 
305  };
306 
307 } // namespace sim
308 
309 
310 inline bool sim::OpDetBacktrackerRecord::operator< (const sim::OpDetBacktrackerRecord& other) const { return iOpDetNum < other.OpDetNum(); }
311 inline bool sim::OpDetBacktrackerRecord::operator== (const sim::OpDetBacktrackerRecord& other) const { return iOpDetNum == other.OpDetNum(); }
313 inline int sim::OpDetBacktrackerRecord::OpDetNum() const { return iOpDetNum; }
314 
315 
316 // -----------------------------------------------------------------------------
317 // --- template implementation
318 // ---
319 template <class Stream>
321  (Stream&& out, std::string indent, std::string first_indent) const
322 {
323  out << first_indent << "OpDet #" << OpDetNum() << " read " << timePDclockSDPs.size()
324  << " timePDclocks:\n";
325  double opDet_energy = 0., opDet_photons = 0.;
326  for (const auto& timePDclockinfo: timePDclockSDPs) {
327  auto const iTimePDclock = timePDclockinfo.first;
328  out << indent << " timePDclock #" << iTimePDclock
329  << " with " << timePDclockinfo.second.size() << " SDPs\n";
330  double timePDclock_energy = 0., timePDclock_photons = 0.;
331  for (const sim::SDP& sdp: timePDclockinfo.second) {
332  out << indent
333  << " (" << sdp.x << ", " << sdp.y << ", " << sdp.z << ") "
334  << sdp.numPhotons << " photons, " << sdp.energy << "MeV (trkID="
335  << sdp.trackID << ")\n";
336  timePDclock_energy += sdp.energy;
337  timePDclock_photons += sdp.numPhotons;
338  } // for SDPs
339  out << indent << " => timePDclock #" << iTimePDclock << " CH #" << OpDetNum()
340  << " collected " << timePDclock_energy << " MeV and "
341  << timePDclock_photons <<" photons. \n";
342  opDet_energy += timePDclock_energy;
343  opDet_photons += timePDclock_photons;
344  } // for timePDclocks
345  out << indent << " => channel #" << OpDetNum() << " collected "
346  << opDet_photons << " photons and "<< opDet_energy << " MeV.\n" ;
347 } // sim::OpDetBacktrackerRecord::Dump<>()
348 
349 
350 #endif // LARSIMOBJ_SIMULATION_OPDETBACKTRACKERRECORD_H
351 
Float_t x
Definition: compare.C:6
int iOpDetNum
OpticalDetector where the photons were detected.
float x
x position of ionization [cm]
bool operator<(const OpDetBacktrackerRecord &other) const
Comparison: sorts by Optical Detector ID.
intermediate_table::iterator iterator
SDP(TrackID_t tid, float nPh, float e, float xpos, float ypos, float zpos)
Constructor: sets all data members.
Float_t y
Definition: compare.C:6
Double_t z
Definition: plot.C:279
std::vector< timePDclockSDP_t > timePDclockSDPs_t
Type of list of energy deposits for each timePDclock with signal.
void Dump(Stream &&out, std::string indent="") const
Documentation at Dump(Stream&&, std::string, std::string) const.
timePDclockSDP_t::first_type storedTimePDclock_t
Type for timePDclock tick used in the internal representation.
Energy deposited on a readout Optical Detector by simulated tracks.
timePDclockSDPs_t timePDclockSDPs
list of energy deposits for each timePDclock with signal
int OpDetNum() const
Returns the readout Optical Detector this object describes.
intermediate_table::const_iterator const_iterator
int trackID
Geant4 supplied trackID.
TrackID_t trackID
Geant4 supplied track ID.
SDP::TrackID_t TrackID_t
Type of track ID (the value comes from Geant4)
void Dump(Stream &&out, std::string indent, std::string first_indent) const
Dumps the full content of the OpDetBacktrackerRecord into a stream.
float energyFrac
fraction of OpHit energy from the particle with this trackID
double timePDclock_t
Type for iTimePDclock tick used in the interface.
std::string indent(std::size_t const i)
Monte Carlo Simulation.
Definition of data types for geometry description.
Ionization photons from a Geant4 track.
float y
y position of ionization [cm]
int TrackID_t
Type of track ID (the value comes from Geant4)
TrackSDP(int id, float phF, float ph)
std::pair< double, std::vector< sim::SDP > > timePDclockSDP_t
List of energy deposits at the same time (on this Optical Detector)
float numPhotons
number of photons at the optical detector for this track ID and time
float energy
energy deposited by ionization
bool operator==(const OpDetBacktrackerRecord &other) const
Comparison: true if OpDetBacktrackerRecords have the same Optical Detector ID.
float energy
energy from the particle with this trackID [MeV]
Float_t e
Definition: plot.C:34
float z
z position of ionization [cm]
bool operator==(geometry_element_iterator< GEOIDITER > const &iter, GEOIDITER const &id_iter)
Comparison operator: geometry ID and element point to the same ID.
timePDclockSDPs_t const & timePDclockSDPsMap() const
Returns all the deposited energy information as stored.
bool operator<(const BeamGateInfo &lhs, const BeamGateInfo &rhs)
Definition: BeamGateInfo.h:48