LArSoft  v09_90_00
Liquid Argon Software toolkit - https://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 #ifndef LARSIMOBJ_SIMULATION_OPDETBACKTRACKERRECORD_H
12 #define LARSIMOBJ_SIMULATION_OPDETBACKTRACKERRECORD_H
13 
14 // C/C++ standard libraries
15 #include <string>
16 #include <utility> // std::pair
17 #include <vector>
18 
19 namespace sim {
20 
22  struct TrackSDP {
23  int trackID;
24  float energyFrac;
25  float energy;
26 
27  TrackSDP() {}
28 
29  TrackSDP(int id, float phF, float ph) : trackID(id), energyFrac(phF), energy(ph) {}
30  };
31 
61  struct SDP {
62 
64  typedef int TrackID_t;
65 
67  SDP();
68 
70  SDP(SDP const& sdp, int offset);
71 
73  SDP(TrackID_t tid, float nPh, float e, float xpos, float ypos, float zpos)
74  : trackID(tid), numPhotons(nPh), energy(e), x(xpos), y(ypos), z(zpos)
75  {}
76 
77  TrackID_t trackID;
78  float numPhotons;
79  float energy;
80  float x;
81  float y;
82  float z;
83  }; // struct SDP
84 
86  typedef std::pair<double, std::vector<sim::SDP>> timePDclockSDP_t;
87 
106  public:
108  typedef timePDclockSDP_t::first_type storedTimePDclock_t;
109 
111  typedef std::vector<timePDclockSDP_t> timePDclockSDPs_t;
112 
113  private:
114  int iOpDetNum;
115  timePDclockSDPs_t timePDclockSDPs;
116 
117  public:
118  // Default constructor
120 
122  //typedef unsigned short timePDclock_t;
123  typedef double timePDclock_t; //This is the G4Time from OpFastScintillation. (ns)
124 
127 
129  explicit OpDetBacktrackerRecord(int detNum);
130 
140  void AddScintillationPhotons(TrackID_t trackID,
141  timePDclock_t timePDclock,
142  double numberPhotons,
143  double const* xyz,
144  double energy);
145 
147  int OpDetNum() const;
148 
166  std::vector<sim::SDP> TrackIDsAndEnergies(timePDclock_t startTimePDclock,
167  timePDclock_t endTimePDclock) const;
168 
181  timePDclockSDPs_t const& timePDclockSDPsMap() const;
182 
184  double Photons(timePDclock_t iTimePDclock) const;
185 
187  double Energy(timePDclock_t iTimePDclock) const;
188 
211  std::vector<sim::TrackSDP> TrackSDPs(timePDclock_t startTimePDclock,
212  timePDclock_t endTimePDclock) const;
213 
215  bool operator<(const OpDetBacktrackerRecord& other) const;
216 
218  bool operator==(const OpDetBacktrackerRecord& other) const;
219 
245  std::pair<TrackID_t, TrackID_t> MergeOpDetBacktrackerRecord(
246  const OpDetBacktrackerRecord& opDetNum,
247  int offset);
248 
256  template <typename Stream>
257  void Dump(Stream&& out, std::string indent, std::string first_indent) const;
258 
260  template <typename Stream>
261  void Dump(Stream&& out, std::string indent = "") const
262  {
263  Dump(std::forward<Stream>(out), indent, indent);
264  }
265 
266  private:
268  struct CompareByTimePDclock;
269 
271  timePDclockSDPs_t::iterator findClosestTimePDclockSDP(storedTimePDclock_t timePDclock);
272 
274  timePDclockSDPs_t::const_iterator findClosestTimePDclockSDP(
275  storedTimePDclock_t timePDclock) const;
276  };
277 
278 } // namespace sim
279 
281 {
282  return iOpDetNum < other.OpDetNum();
283 }
285 {
286  return iOpDetNum == other.OpDetNum();
287 }
290 {
291  return timePDclockSDPs;
292 }
294 {
295  return iOpDetNum;
296 }
297 
298 // -----------------------------------------------------------------------------
299 // --- template implementation
300 // ---
301 template <class Stream>
303  std::string indent,
304  std::string first_indent) const
305 {
306  out << first_indent << "OpDet #" << OpDetNum() << " read " << timePDclockSDPs.size()
307  << " timePDclocks:\n";
308  double opDet_energy = 0., opDet_photons = 0.;
309  for (const auto& timePDclockinfo : timePDclockSDPs) {
310  auto const iTimePDclock = timePDclockinfo.first;
311  out << indent << " timePDclock #" << iTimePDclock << " with " << timePDclockinfo.second.size()
312  << " SDPs\n";
313  double timePDclock_energy = 0., timePDclock_photons = 0.;
314  for (const sim::SDP& sdp : timePDclockinfo.second) {
315  out << indent << " (" << sdp.x << ", " << sdp.y << ", " << sdp.z << ") " << sdp.numPhotons
316  << " photons, " << sdp.energy << "MeV (trkID=" << sdp.trackID << ")\n";
317  timePDclock_energy += sdp.energy;
318  timePDclock_photons += sdp.numPhotons;
319  } // for SDPs
320  out << indent << " => timePDclock #" << iTimePDclock << " CH #" << OpDetNum()
321  << " collected " << timePDclock_energy << " MeV and " << timePDclock_photons
322  << " photons. \n";
323  opDet_energy += timePDclock_energy;
324  opDet_photons += timePDclock_photons;
325  } // for timePDclocks
326  out << indent << " => channel #" << OpDetNum() << " collected " << opDet_photons
327  << " photons and " << opDet_energy << " MeV.\n";
328 } // sim::OpDetBacktrackerRecord::Dump<>()
329 
330 #endif // LARSIMOBJ_SIMULATION_OPDETBACKTRACKERRECORD_H
331 
Float_t x
Definition: compare.C:6
intermediate_table::iterator iterator
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.
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:276
std::vector< timePDclockSDP_t > timePDclockSDPs_t
Type of list of energy deposits for each timePDclock with signal.
std::pair< double, std::vector< sim::SDP > > timePDclockSDP_t
List of energy deposits at the same time (on this Optical Detector)
intermediate_table::const_iterator const_iterator
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.
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.
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)
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:35
float z
z position of ionization [cm]
bool operator==(infinite_endcount_iterator< T > const &, count_iterator< T > const &)
Definition: counter.h:278
timePDclockSDPs_t const & timePDclockSDPsMap() const
Returns all the deposited energy information as stored.
bool operator<(const BeamGateInfo &lhs, const BeamGateInfo &rhs)
Definition: BeamGateInfo.h:40