All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Classes | Public Types | Public Member Functions | Private Member Functions | Private Attributes | List of all members
sim::OpDetBacktrackerRecord Class Reference

Energy deposited on a readout Optical Detector by simulated tracks. More...

#include <OpDetBacktrackerRecord.h>

Classes

struct  CompareByTimePDclock
 

Public Types

typedef
timePDclockSDP_t::first_type 
storedTimePDclock_t
 Type for timePDclock tick used in the internal representation. More...
 
typedef std::vector
< timePDclockSDP_t
timePDclockSDPs_t
 Type of list of energy deposits for each timePDclock with signal. More...
 
typedef double timePDclock_t
 Type for iTimePDclock tick used in the interface. More...
 
typedef SDP::TrackID_t TrackID_t
 Type of track ID (the value comes from Geant4) More...
 

Public Member Functions

 OpDetBacktrackerRecord ()
 
 OpDetBacktrackerRecord (int detNum)
 Constructor: immediately sets the Optical Detector number. More...
 
void AddScintillationPhotons (TrackID_t trackID, timePDclock_t timePDclock, double numberPhotons, double const *xyz, double energy)
 Add scintillation photons and energy to this OpticalDetector. More...
 
int OpDetNum () const
 Returns the readout Optical Detector this object describes. More...
 
std::vector< sim::SDPTrackIDsAndEnergies (timePDclock_t startTimePDclock, timePDclock_t endTimePDclock) const
 Return all the recorded energy deposition within a time interval. More...
 
timePDclockSDPs_t const & timePDclockSDPsMap () const
 Returns all the deposited energy information as stored. More...
 
double Photons (timePDclock_t iTimePDclock) const
 Returns the total number of scintillation photons on this Optical Detector in the specified timePDclock. More...
 
double Energy (timePDclock_t iTimePDclock) const
 Returns the total energy on this Optical Detector in the specified iTimePDclock [MeV]. More...
 
std::vector< sim::TrackSDPTrackSDPs (timePDclock_t startTimePDclock, timePDclock_t endTimePDclock) const
 Returns energies collected for each track within a time interval. More...
 
bool operator< (const OpDetBacktrackerRecord &other) const
 Comparison: sorts by Optical Detector ID. More...
 
bool operator== (const OpDetBacktrackerRecord &other) const
 Comparison: true if OpDetBacktrackerRecords have the same Optical Detector ID. More...
 
std::pair< TrackID_t, TrackID_tMergeOpDetBacktrackerRecord (const OpDetBacktrackerRecord &opDetNum, int offset)
 Merges the deposits from another Optical Detector into this one. More...
 
template<typename Stream >
void Dump (Stream &&out, std::string indent, std::string first_indent) const
 Dumps the full content of the OpDetBacktrackerRecord into a stream. More...
 
template<typename Stream >
void Dump (Stream &&out, std::string indent="") const
 Documentation at Dump(Stream&&, std::string, std::string) const. More...
 

Private Member Functions

timePDclockSDPs_t::iterator findClosestTimePDclockSDP (storedTimePDclock_t timePDclock)
 Return the iterator to the first timePDclockSDP not earlier than timePDclock. More...
 
timePDclockSDPs_t::const_iterator findClosestTimePDclockSDP (storedTimePDclock_t timePDclock) const
 Return the (constant) iterator to the first timePDclockSDP not earlier than timePDclock. More...
 

Private Attributes

int iOpDetNum
 OpticalDetector where the photons were detected. More...
 
timePDclockSDPs_t timePDclockSDPs
 list of energy deposits for each timePDclock with signal More...
 

Detailed Description

Energy deposited on a readout Optical Detector by simulated tracks.

This class stores a time organized list of scintillation photons detected connected to the G4 tracks they originated from. This class also tracks the energy deposited by those tracks, and what fraction of the energy deposited is realted to the photons detected by this OpDet.

The information is organized by time: it is divided by timePDclock ticks (units of ns), and each timePDclock tick where some energy was deposited appears in a separate entry, while the quiet timePDclock ticks are omitted. For each timePDclock, the information is stored as a list of energy deposits; each deposit comes from a single Geant4 track and stores the location where the ionization happened according to the simulation (see sim::SDP class).

Note that there can be multiple energy deposit records (that is sim::SDP) for a single track in a single timePDclock tick.

Definition at line 123 of file OpDetBacktrackerRecord.h.

Member Typedef Documentation

typedef timePDclockSDP_t::first_type sim::OpDetBacktrackerRecord::storedTimePDclock_t

Type for timePDclock tick used in the internal representation.

Definition at line 127 of file OpDetBacktrackerRecord.h.

Type for iTimePDclock tick used in the interface.

Definition at line 144 of file OpDetBacktrackerRecord.h.

Type of list of energy deposits for each timePDclock with signal.

Definition at line 130 of file OpDetBacktrackerRecord.h.

Type of track ID (the value comes from Geant4)

Definition at line 147 of file OpDetBacktrackerRecord.h.

Constructor & Destructor Documentation

sim::OpDetBacktrackerRecord::OpDetBacktrackerRecord ( )

Definition at line 44 of file OpDetBacktrackerRecord.cxx.

45  : iOpDetNum(-1) //set an impossible channel number in the case where this is called without an opticalchannel.
46  //The reason for doing this is to follow the structure of SimChannel, which uses kBogusChannel
47  {}
int iOpDetNum
OpticalDetector where the photons were detected.
sim::OpDetBacktrackerRecord::OpDetBacktrackerRecord ( int  detNum)
explicit

Constructor: immediately sets the Optical Detector number.

Definition at line 50 of file OpDetBacktrackerRecord.cxx.

51  : iOpDetNum(detNum)
52  {}
int iOpDetNum
OpticalDetector where the photons were detected.

Member Function Documentation

void sim::OpDetBacktrackerRecord::AddScintillationPhotons ( TrackID_t  trackID,
timePDclock_t  timePDclock,
double  numberPhotons,
double const *  xyz,
double  energy 
)

Add scintillation photons and energy to this OpticalDetector.

Parameters
trackIDID of simulated track depositing this energy (from Geant4)
timePDclocktick when this deposit was collected (ns)
numberPhotonsdetected at the OpticalDetector at this time from this track
xyzcoordinates of original location of ionization/scintillation (3D array) [cm]
energyenergy deposited at this point by this track [MeV]

The iTimePDclock from OpFastScintillation (where OpDetBacktrackerRecords originate) is done with CLHEP::ns (units of nanoseconds).

Definition at line 55 of file OpDetBacktrackerRecord.cxx.

60  {
61  /**
62  * The iTimePDclock from OpFastScintillation (where OpDetBacktrackerRecords originate) is done with CLHEP::ns (units of nanoseconds).
63  */
64  // look at the collection to see if the current iTimePDclock already
65  // exists, if not, add it, if so, just add a new track id to the
66  // vector, or update the information if track is already present
67 
68  // no photons? no good!
69  if (( numberPhotons < std::numeric_limits<double>::epsilon() )
70  || ( energy<=std::numeric_limits<double>::epsilon() ))
71  {
72  // will throw
73  MF_LOG_ERROR("OpDetBacktrackerRecord")
74  << "AddTrackPhotons() trying to add to iTimePDclock #"
75  << iTimePDclock
76  << " "
77  << numberPhotons
78  << " photons with "
79  << energy
80  << " MeV of energy from track ID="
81  << trackID;
82  return;
83  } // if no photons
84 
85  auto itr = findClosestTimePDclockSDP(iTimePDclock);
86 
87  // check if this iTimePDclock value is in the vector, it is possible that
88  // the lower bound is different from the given TimePDclock, in which case
89  // we need to add something for that TimePDclock
90  if(itr == timePDclockSDPs.end() ||
91  (abs(itr->first - iTimePDclock) > .50 )){
92  //itr->first != iTimePDclock){
93  std::vector<sim::SDP> sdplist;
94  sdplist.emplace_back(trackID,
95  numberPhotons,
96  energy,
97  xyz[0],
98  xyz[1],
99  xyz[2]
100  );
101  timePDclockSDPs.emplace(itr, std::round(iTimePDclock), std::move(sdplist) );
102  }
103  else { // we have that iTimePDclock already; itr points to it
104 
105  // loop over the SDP vector for this iTimePDclock and add the electrons
106  // to the entry with the same track id
107  for(auto& sdp : itr->second){
108 
109  if (sdp.trackID != trackID ) continue;
110 
111  // make a weighted average for the location information
112  double weight = sdp.numPhotons + numberPhotons;
113  sdp.x = (sdp.x * sdp.numPhotons + xyz[0]*numberPhotons)/weight;
114  sdp.y = (sdp.y * sdp.numPhotons + xyz[1]*numberPhotons)/weight;
115  sdp.z = (sdp.z * sdp.numPhotons + xyz[2]*numberPhotons)/weight;
116  sdp.numPhotons = weight;
117  sdp.energy = sdp.energy + energy;
118 
119  // found the track id we wanted, so return;
120  return;
121  } // for
122 
123  // if we never found the track id, then this is the first instance of
124  // the track id for this TimePDclock, so add sdp to the vector
125  itr->second.emplace_back(trackID,
126  numberPhotons,
127  energy,
128  xyz[0],
129  xyz[1],
130  xyz[2]
131  );
132 
133  } // end of else "We have that iTimePDclock already"
134 
135  } // OpDetBacktrackerRecord::AddIonizationElectrons()
timePDclockSDPs_t timePDclockSDPs
list of energy deposits for each timePDclock with signal
T abs(T value)
timePDclockSDPs_t::iterator findClosestTimePDclockSDP(storedTimePDclock_t timePDclock)
Return the iterator to the first timePDclockSDP not earlier than timePDclock.
template<class Stream >
void sim::OpDetBacktrackerRecord::Dump ( Stream &&  out,
std::string  indent,
std::string  first_indent 
) const

Dumps the full content of the OpDetBacktrackerRecord into a stream.

Template Parameters
Streaman ostream-like stream object
Parameters
outthe stream to send the information into
indentindentation of the lines (default: none)
first_indentindentation for the first line (default: as indent)

Definition at line 316 of file OpDetBacktrackerRecord.h.

317 {
318  out << first_indent << "OpDet #" << OpDetNum() << " read " << timePDclockSDPs.size()
319  << " timePDclocks:\n";
320  double opDet_energy = 0., opDet_photons = 0.;
321  for (const auto& timePDclockinfo: timePDclockSDPs) {
322  auto const iTimePDclock = timePDclockinfo.first;
323  out << indent << " timePDclock #" << iTimePDclock
324  << " with " << timePDclockinfo.second.size() << " SDPs\n";
325  double timePDclock_energy = 0., timePDclock_photons = 0.;
326  for (const sim::SDP& sdp: timePDclockinfo.second) {
327  out << indent
328  << " (" << sdp.x << ", " << sdp.y << ", " << sdp.z << ") "
329  << sdp.numPhotons << " photons, " << sdp.energy << "MeV (trkID="
330  << sdp.trackID << ")\n";
331  timePDclock_energy += sdp.energy;
332  timePDclock_photons += sdp.numPhotons;
333  } // for SDPs
334  out << indent << " => timePDclock #" << iTimePDclock << " CH #" << OpDetNum()
335  << " collected " << timePDclock_energy << " MeV and "
336  << timePDclock_photons <<" photons. \n";
337  opDet_energy += timePDclock_energy;
338  opDet_photons += timePDclock_photons;
339  } // for timePDclocks
340  out << indent << " => channel #" << OpDetNum() << " collected "
341  << opDet_photons << " photons and "<< opDet_energy << " MeV.\n" ;
342 } // sim::OpDetBacktrackerRecord::Dump<>()
float x
x position of ionization [cm]
timePDclockSDPs_t timePDclockSDPs
list of energy deposits for each timePDclock with signal
int OpDetNum() const
Returns the readout Optical Detector this object describes.
TrackID_t trackID
Geant4 supplied track ID.
float y
y position of ionization [cm]
float numPhotons
number of photons at the optical detector for this track ID and time
float energy
energy deposited by ionization
float z
z position of ionization [cm]
template<typename Stream >
void sim::OpDetBacktrackerRecord::Dump ( Stream &&  out,
std::string  indent = "" 
) const
inline

Documentation at Dump(Stream&&, std::string, std::string) const.

Definition at line 284 of file OpDetBacktrackerRecord.h.

285  { Dump(std::forward<Stream>(out), indent, indent); }
void Dump(Stream &&out, std::string indent, std::string first_indent) const
Dumps the full content of the OpDetBacktrackerRecord into a stream.
double sim::OpDetBacktrackerRecord::Energy ( timePDclock_t  iTimePDclock) const

Returns the total energy on this Optical Detector in the specified iTimePDclock [MeV].

Definition at line 162 of file OpDetBacktrackerRecord.cxx.

163  {
164  double energy = 0.;
165 
166  auto itr = findClosestTimePDclockSDP(iTimePDclock);
167 
168  // check to see if this iTimePDclock value is in the map
169  if(itr != timePDclockSDPs.end() &&
170  itr->first == iTimePDclock){
171 
172  // loop over the list for this iTimePDclock value and add up
173  // the total number of photons
174  for(auto sdp : itr->second ){
175  energy += sdp.energy;
176  } // end loop over sim::SDP for this TimePDclock
177 
178  } // end if this iTimePDclock is represented in the map
179 
180  return energy;
181  }
timePDclockSDPs_t timePDclockSDPs
list of energy deposits for each timePDclock with signal
timePDclockSDPs_t::iterator findClosestTimePDclockSDP(storedTimePDclock_t timePDclock)
Return the iterator to the first timePDclockSDP not earlier than timePDclock.
OpDetBacktrackerRecord::timePDclockSDPs_t::iterator sim::OpDetBacktrackerRecord::findClosestTimePDclockSDP ( storedTimePDclock_t  timePDclock)
private

Return the iterator to the first timePDclockSDP not earlier than timePDclock.

Definition at line 342 of file OpDetBacktrackerRecord.cxx.

343  {
344  return std::lower_bound
345  (timePDclockSDPs.begin(), timePDclockSDPs.end(), iTimePDclock, CompareByTimePDclock());
346  }
timePDclockSDPs_t timePDclockSDPs
list of energy deposits for each timePDclock with signal
OpDetBacktrackerRecord::timePDclockSDPs_t::const_iterator sim::OpDetBacktrackerRecord::findClosestTimePDclockSDP ( storedTimePDclock_t  timePDclock) const
private

Return the (constant) iterator to the first timePDclockSDP not earlier than timePDclock.

Definition at line 349 of file OpDetBacktrackerRecord.cxx.

350  {
351  return std::lower_bound
352  ( timePDclockSDPs.begin(), timePDclockSDPs.end(), TimePDclock, CompareByTimePDclock() );
353  }
timePDclockSDPs_t timePDclockSDPs
list of energy deposits for each timePDclock with signal
std::pair< OpDetBacktrackerRecord::TrackID_t, OpDetBacktrackerRecord::TrackID_t > sim::OpDetBacktrackerRecord::MergeOpDetBacktrackerRecord ( const OpDetBacktrackerRecord opDetNum,
int  offset 
)

Merges the deposits from another Optical Detector into this one.

Parameters
opDetNumthe sim::OpDetBacktrackerRecord holding information to be merged
offsettrack ID offset for the merge
Returns
range of the IDs of the added tracks

The information from the specified simulated opDetRecord is added to the current one. This is achieved by appending the energy deposit information (sim::SDP) at each iTimePDclock tick from the merged opDetRecord to the list of existing energy deposits for that iTimePDclock tick.

In addition, the track IDs of the merged opDetRecord are added an offset, so that they can be distinguished from the existing ones. This is useful when simulating tracks with multiple Geant4 runs. Geant4 will reuse track IDs on each run, and using the highest number of track ID from one run as the offset for the next avoids track ID collisions. Note however that this function does not perform any collision check, and it is caller's duty to ensure that the offset is properly large. The return value is a pair including the lowest and the largest track IDs added to this opDetRecord, equivalent to the lowest and the highest track IDs present in the merged opDetRecord, both augmented by the applied offset.

The opDetNum number of the merged opDetRecord is ignored.

Definition at line 282 of file OpDetBacktrackerRecord.cxx.

284  {
285  if( this->OpDetNum() != channel.OpDetNum() )
286  throw std::runtime_error("ERROR OpDetBacktrackerRecord Merge: Trying to merge different channels!");
287 
288  std::pair<TrackID_t,TrackID_t> range_trackID(std::numeric_limits<int>::max(),
289  std::numeric_limits<int>::min());
290 
291  for(auto const& itr : channel.timePDclockSDPsMap()){
292 
293  auto iTimePDclock = itr.first;
294  auto const& sdps = itr.second;
295 
296  // find the entry from this OpDetBacktrackerRecord corresponding to the iTimePDclock from the other
297  auto itrthis = findClosestTimePDclockSDP(iTimePDclock);
298 
299  // pick which SDP list we have to fill: new one or existing one
300  std::vector<sim::SDP>* curSDPVec;
301  if(itrthis == timePDclockSDPs.end() ||
302  itrthis->first != iTimePDclock){
303  timePDclockSDPs.emplace_back(iTimePDclock, std::vector<sim::SDP>());
304  curSDPVec = &(timePDclockSDPs.back().second);
305  }
306  else
307  curSDPVec = &(itrthis->second);
308 
309  for(auto const& sdp : sdps){
310  curSDPVec->emplace_back(sdp, offset);
311  if( sdp.trackID+offset < range_trackID.first )
312  range_trackID.first = sdp.trackID+offset;
313  if( sdp.trackID+offset > range_trackID.second )
314  range_trackID.second = sdp.trackID+offset;
315  }//end loop over SDPs
316 
317  }//end loop over TimePDclockSDPMap
318 
319 
320  return range_trackID;
321 
322  }
BEGIN_PROLOG TPC Trig offset(g4 rise time) ProjectToHeight
Definition: CORSIKAGen.fcl:7
timePDclockSDPs_t timePDclockSDPs
list of energy deposits for each timePDclock with signal
int OpDetNum() const
Returns the readout Optical Detector this object describes.
timePDclockSDPs_t::iterator findClosestTimePDclockSDP(storedTimePDclock_t timePDclock)
Return the iterator to the first timePDclockSDP not earlier than timePDclock.
int sim::OpDetBacktrackerRecord::OpDetNum ( ) const
inline

Returns the readout Optical Detector this object describes.

Definition at line 308 of file OpDetBacktrackerRecord.h.

308 { return iOpDetNum; }
int iOpDetNum
OpticalDetector where the photons were detected.
bool sim::OpDetBacktrackerRecord::operator< ( const OpDetBacktrackerRecord other) const
inline

Comparison: sorts by Optical Detector ID.

Definition at line 305 of file OpDetBacktrackerRecord.h.

305 { return iOpDetNum < other.OpDetNum(); }
int iOpDetNum
OpticalDetector where the photons were detected.
bool sim::OpDetBacktrackerRecord::operator== ( const OpDetBacktrackerRecord other) const
inline

Comparison: true if OpDetBacktrackerRecords have the same Optical Detector ID.

Definition at line 306 of file OpDetBacktrackerRecord.h.

306 { return iOpDetNum == other.OpDetNum(); }
int iOpDetNum
OpticalDetector where the photons were detected.
double sim::OpDetBacktrackerRecord::Photons ( timePDclock_t  iTimePDclock) const

Returns the total number of scintillation photons on this Optical Detector in the specified timePDclock.

Definition at line 139 of file OpDetBacktrackerRecord.cxx.

140  {
141  double numPhotons = 0.;
142 
143  auto itr = findClosestTimePDclockSDP(iTimePDclock);
144 
145  // check to see if this iTimePDclock value is in the map
146  if(itr != timePDclockSDPs.end() &&
147  itr->first == iTimePDclock){
148 
149  // loop over the list for this iTimePDclock value and add up
150  // the total number of electrons
151  for(auto sdp : itr->second){
152  numPhotons += sdp.numPhotons;
153  } // end loop over sim::SDP for this TimePDclock
154 
155  } // end if this iTimePDclock is represented in the map
156 
157  return numPhotons;
158  }
timePDclockSDPs_t timePDclockSDPs
list of energy deposits for each timePDclock with signal
timePDclockSDPs_t::iterator findClosestTimePDclockSDP(storedTimePDclock_t timePDclock)
Return the iterator to the first timePDclockSDP not earlier than timePDclock.
sim::OpDetBacktrackerRecord::timePDclockSDPs_t const & sim::OpDetBacktrackerRecord::timePDclockSDPsMap ( ) const
inline

Returns all the deposited energy information as stored.

Returns
all the deposited energy information as stored in the object

The returned list is organized in pairs. Each pair contains all ionization information in a single iTimePDclock tick (collection of sim::SDP), and the number of that tick. The information is sorted by increasing timePDclock tick.

See the class description for the details of the ionization information content.

Definition at line 307 of file OpDetBacktrackerRecord.h.

307 { return timePDclockSDPs; }
timePDclockSDPs_t timePDclockSDPs
list of energy deposits for each timePDclock with signal
std::vector< sim::SDP > sim::OpDetBacktrackerRecord::TrackIDsAndEnergies ( timePDclock_t  startTimePDclock,
timePDclock_t  endTimePDclock 
) const

Return all the recorded energy deposition within a time interval.

Parameters
startTimePDclockiTimePDclock tick opening the time window
endTimePDclockiTimePDclock tick closing the time window (included in the interval)
Returns
a collection of energy deposit information from all tracks

This method returns the energy deposited on this Optical Detector by each track ID active in the specified iTimePDclock time interval.

Each entry pertains a single track ID. For each entry, all energy deposit information is merged into a single record. It includes:

  • energy and number of photons, as the integral in the time interval
  • position, as average weighted by the number of photons
  • the ID of the track depositing this energy

Entries are sorted by track ID number.

Definition at line 185 of file OpDetBacktrackerRecord.cxx.

187  {
188  // make a map of track ID values to sim::SDP objects
189 
190  if(startTimePDclock > endTimePDclock ){
191  mf::LogWarning("OpDetBacktrackerRecord") << "requested TimePDclock range is bogus: "
192  << startTimePDclock << " " << endTimePDclock
193  << " return empty vector";
194  return {}; // returns an empty vector
195  }
196 
197  std::map<TrackID_t, sim::SDP> idToSDP;
198 
199  //find the lower bound for this iTimePDclock and then iterate from there
200  auto itr = findClosestTimePDclockSDP(startTimePDclock);
201 
202  while(itr != timePDclockSDPs.end()){
203 
204  // check the iTimePDclock value for the iterator, break the loop if we
205  // are outside the range
206  if(itr->first > endTimePDclock) break;
207 
208  // grab the vector of SDPs for this TimePDclock
209  auto const& sdplist = itr->second;
210  // now loop over them and add their content to the map
211  for(auto const& sdp : sdplist){
212  auto itTrkSDP = idToSDP.find(sdp.trackID);
213  if( itTrkSDP != idToSDP.end() ){
214  // the SDP we are going to update:
215  sim::SDP& trackSDP = itTrkSDP->second;
216 
217  double const nPh1 = trackSDP.numPhotons;
218  double const nPh2 = sdp.numPhotons;
219  double const weight = nPh1 + nPh2;
220 
221  // make a weighted average for the location information
222  trackSDP.x = (sdp.x*nPh2 + trackSDP.x*nPh1)/weight;
223  trackSDP.y = (sdp.y*nPh2 + trackSDP.y*nPh1)/weight;
224  trackSDP.z = (sdp.z*nPh2 + trackSDP.z*nPh1)/weight;
225  trackSDP.numPhotons = weight;
226  } // end if the track id for this one is found
227  else{
228  idToSDP[sdp.trackID] = sim::SDP(sdp);
229  }
230  } // end loop over vector
231 
232  ++itr;
233  } // end loop over iTimePDclock values
234 
235  // now fill the vector with the sdps from the map
236  std::vector<sim::SDP> sdps;
237  sdps.reserve(idToSDP.size());
238  for(auto const& itr : idToSDP){
239  sdps.push_back(itr.second);
240  }
241 
242  return sdps;
243  }
float x
x position of ionization [cm]
timePDclockSDPs_t timePDclockSDPs
list of energy deposits for each timePDclock with signal
timePDclockSDPs_t::iterator findClosestTimePDclockSDP(storedTimePDclock_t timePDclock)
Return the iterator to the first timePDclockSDP not earlier than timePDclock.
float y
y position of ionization [cm]
float numPhotons
number of photons at the optical detector for this track ID and time
float z
z position of ionization [cm]
std::vector< sim::TrackSDP > sim::OpDetBacktrackerRecord::TrackSDPs ( timePDclock_t  startTimePDclock,
timePDclock_t  endTimePDclock 
) const

Returns energies collected for each track within a time interval.

Parameters
startTimePDclockiTimePDclock tick opening the time window
endTimePDclockiTimePDclock tick closing the time window (included in the interval)
Returns
a collection of energy and fraction from each track in interval
See Also
TrackIDsAndEnergies()

This method returns the energy deposited on this Optical Detector by each track ID active in the specified iTimePDclock time interval.

Each entry pertains a single track ID. For each entry, all energy deposit information is merged into a single record. It includes:

  • energy of the track, as the integral in the time interval [MeV]
  • energy fraction respect to the total (see below)
  • the ID of the track depositing this energy

The energy fraction is the energy deposited by the track on this Optical Detector in the specified time interval, divided by the total of the energy deposited by all tracks on this Optical Detector in that same time interval.

Entries are sorted by track ID number.

Definition at line 247 of file OpDetBacktrackerRecord.cxx.

249  {
250 
251  std::vector<sim::TrackSDP> trackSDPs;
252 
253  if(startTimePDclock > endTimePDclock ){
254  mf::LogWarning("OpDetBacktrackerRecord::TrackSDPs") << "requested iTimePDclock range is bogus: "
255  << startTimePDclock << " " << endTimePDclock
256  << " return empty vector";
257  return trackSDPs;
258  }
259 
260  double totalPhotons = 0.;
261  std::vector<sim::SDP> const sdps = TrackIDsAndEnergies(startTimePDclock, endTimePDclock);
262  for (auto const& sdp : sdps)
263  totalPhotons += sdp.numPhotons;
264 
265  // protect against a divide by zero below
266  if(totalPhotons < 1.e-5) totalPhotons = 1.;
267 
268  // loop over the entries in the map and fill the input vectors
269  for (auto const& sdp : sdps){
270  if(sdp.trackID == sim::NoParticleId) continue;
271  trackSDPs.emplace_back(sdp.trackID, sdp.numPhotons/totalPhotons, sdp.numPhotons);
272  }
273 
274  return trackSDPs;
275  }
static const int NoParticleId
Definition: sim.h:21
do i e
std::vector< sim::SDP > TrackIDsAndEnergies(timePDclock_t startTimePDclock, timePDclock_t endTimePDclock) const
Return all the recorded energy deposition within a time interval.

Member Data Documentation

int sim::OpDetBacktrackerRecord::iOpDetNum
private

OpticalDetector where the photons were detected.

Definition at line 133 of file OpDetBacktrackerRecord.h.

timePDclockSDPs_t sim::OpDetBacktrackerRecord::timePDclockSDPs
private

list of energy deposits for each timePDclock with signal

Definition at line 134 of file OpDetBacktrackerRecord.h.


The documentation for this class was generated from the following files: