LArSoft  v06_85_00
Liquid Argon Software toolkit - http://larsoft.org/
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_ttimePDclockSDPs_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 127 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 131 of file OpDetBacktrackerRecord.h.

Type for iTimePDclock tick used in the interface.

Definition at line 148 of file OpDetBacktrackerRecord.h.

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

Definition at line 134 of file OpDetBacktrackerRecord.h.

Type of track ID (the value comes from Geant4)

Definition at line 151 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.

References energy, findClosestTimePDclockSDP(), LOG_ERROR, timePDclockSDPs, and weight.

Referenced by larg4::OpFastScintillation::RecordPhotonsProduced().

60  {
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  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  itr->first != iTimePDclock){
92  std::vector<sim::SDP> sdplist;
93  sdplist.emplace_back(trackID,
94  numberPhotons,
95  energy,
96  xyz[0],
97  xyz[1],
98  xyz[2]
99  );
100  timePDclockSDPs.emplace(itr, iTimePDclock, std::move(sdplist) );
101  }
102  else { // we have that iTimePDclock already; itr points to it
103 
104  // loop over the SDP vector for this iTimePDclock and add the electrons
105  // to the entry with the same track id
106  for(auto& sdp : itr->second){
107 
108  if (sdp.trackID != trackID ) continue;
109 
110  // make a weighted average for the location information
111  double weight = sdp.numPhotons + numberPhotons;
112  sdp.x = (sdp.x * sdp.numPhotons + xyz[0]*numberPhotons)/weight;
113  sdp.y = (sdp.y * sdp.numPhotons + xyz[1]*numberPhotons)/weight;
114  sdp.z = (sdp.z * sdp.numPhotons + xyz[2]*numberPhotons)/weight;
115  sdp.numPhotons = weight;
116  sdp.energy = sdp.energy + energy;
117 
118  // found the track id we wanted, so return;
119  return;
120  } // for
121 
122  // if we never found the track id, then this is the first instance of
123  // the track id for this TimePDclock, so add sdp to the vector
124  itr->second.emplace_back(trackID,
125  numberPhotons,
126  energy,
127  xyz[0],
128  xyz[1],
129  xyz[2]
130  );
131 
132  } // end of else "We have that iTimePDclock already"
133 
134  } // OpDetBacktrackerRecord::AddIonizationElectrons()
#define LOG_ERROR(category)
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.
double energy
Definition: plottest35.C:25
double weight
Definition: plottest35.C:25
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 321 of file OpDetBacktrackerRecord.h.

References sim::SDP::energy, sim::SDP::numPhotons, sim::SDP::trackID, sim::SDP::x, sim::SDP::y, and sim::SDP::z.

Referenced by sim::DumpOpDetBacktrackerRecords::DumpOpDetBacktrackerRecord(), and OpDetNum().

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<>()
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.
std::string indent(std::size_t const i)
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 288 of file OpDetBacktrackerRecord.h.

References art::detail::indent().

289  { 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.
std::string indent(std::size_t const i)
double sim::OpDetBacktrackerRecord::Energy ( timePDclock_t  iTimePDclock) const

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

Definition at line 161 of file OpDetBacktrackerRecord.cxx.

References energy, findClosestTimePDclockSDP(), and timePDclockSDPs.

162  {
163  double energy = 0.;
164 
165  auto itr = findClosestTimePDclockSDP(iTimePDclock);
166 
167  // check to see if this iTimePDclock value is in the map
168  if(itr != timePDclockSDPs.end() &&
169  itr->first == iTimePDclock){
170 
171  // loop over the list for this iTimePDclock value and add up
172  // the total number of photons
173  for(auto sdp : itr->second ){
174  energy += sdp.energy;
175  } // end loop over sim::SDP for this TimePDclock
176 
177  } // end if this iTimePDclock is represented in the map
178 
179  return energy;
180  }
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.
double energy
Definition: plottest35.C:25
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 341 of file OpDetBacktrackerRecord.cxx.

References timePDclockSDPs.

Referenced by AddScintillationPhotons(), Energy(), MergeOpDetBacktrackerRecord(), Photons(), and TrackIDsAndEnergies().

342  {
343  return std::lower_bound
344  (timePDclockSDPs.begin(), timePDclockSDPs.end(), iTimePDclock, CompareByTimePDclock());
345  }
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 348 of file OpDetBacktrackerRecord.cxx.

References timePDclockSDPs.

349  {
350  return std::lower_bound
351  ( timePDclockSDPs.begin(), timePDclockSDPs.end(), TimePDclock, CompareByTimePDclock() );
352  }
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 281 of file OpDetBacktrackerRecord.cxx.

References findClosestTimePDclockSDP(), max, min, OpDetNum(), timePDclockSDPs, and timePDclockSDPsMap().

283  {
284  if( this->OpDetNum() != channel.OpDetNum() )
285  throw std::runtime_error("ERROR OpDetBacktrackerRecord Merge: Trying to merge different channels!");
286 
287  std::pair<TrackID_t,TrackID_t> range_trackID(std::numeric_limits<int>::max(),
289 
290  for(auto const& itr : channel.timePDclockSDPsMap()){
291 
292  auto iTimePDclock = itr.first;
293  auto const& sdps = itr.second;
294 
295  // find the entry from this OpDetBacktrackerRecord corresponding to the iTimePDclock from the other
296  auto itrthis = findClosestTimePDclockSDP(iTimePDclock);
297 
298  // pick which SDP list we have to fill: new one or existing one
299  std::vector<sim::SDP>* curSDPVec;
300  if(itrthis == timePDclockSDPs.end() ||
301  itrthis->first != iTimePDclock){
302  timePDclockSDPs.emplace_back(iTimePDclock, std::vector<sim::SDP>());
303  curSDPVec = &(timePDclockSDPs.back().second);
304  }
305  else
306  curSDPVec = &(itrthis->second);
307 
308  for(auto const& sdp : sdps){
309  curSDPVec->emplace_back(sdp, offset);
310  if( sdp.trackID+offset < range_trackID.first )
311  range_trackID.first = sdp.trackID+offset;
312  if( sdp.trackID+offset > range_trackID.second )
313  range_trackID.second = sdp.trackID+offset;
314  }//end loop over SDPs
315 
316  }//end loop over TimePDclockSDPMap
317 
318 
319  return range_trackID;
320 
321  }
timePDclockSDPs_t timePDclockSDPs
list of energy deposits for each timePDclock with signal
Int_t max
Definition: plot.C:27
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_t min
Definition: plot.C:26
int sim::OpDetBacktrackerRecord::OpDetNum ( ) const
inline

Returns the readout Optical Detector this object describes.

Definition at line 313 of file OpDetBacktrackerRecord.h.

References Dump().

Referenced by larg4::OpDetPhotonTable::AddOpDetBacktrackerRecord(), MergeOpDetBacktrackerRecord(), operator<(), and operator==().

313 { 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 310 of file OpDetBacktrackerRecord.h.

References OpDetNum().

310 { 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 311 of file OpDetBacktrackerRecord.h.

References OpDetNum().

311 { 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 138 of file OpDetBacktrackerRecord.cxx.

References findClosestTimePDclockSDP(), and timePDclockSDPs.

139  {
140  double numPhotons = 0.;
141 
142  auto itr = findClosestTimePDclockSDP(iTimePDclock);
143 
144  // check to see if this iTimePDclock value is in the map
145  if(itr != timePDclockSDPs.end() &&
146  itr->first == iTimePDclock){
147 
148  // loop over the list for this iTimePDclock value and add up
149  // the total number of electrons
150  for(auto sdp : itr->second){
151  numPhotons += sdp.numPhotons;
152  } // end loop over sim::SDP for this TimePDclock
153 
154  } // end if this iTimePDclock is represented in the map
155 
156  return numPhotons;
157  }
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 312 of file OpDetBacktrackerRecord.h.

Referenced by larg4::OpDetPhotonTable::AddOpDetBacktrackerRecord(), and MergeOpDetBacktrackerRecord().

312 { 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 184 of file OpDetBacktrackerRecord.cxx.

References findClosestTimePDclockSDP(), sim::SDP::numPhotons, timePDclockSDPs, weight, sim::SDP::x, sim::SDP::y, and sim::SDP::z.

Referenced by cheat::PhotonBackTracker::ChannelToTrackSDPs(), cheat::PhotonBackTracker::OpDetToTrackSDPs(), cheat::PhotonBackTracker::OpHitToSDPs(), and TrackSDPs().

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

References e, sim::NoParticleId, and TrackIDsAndEnergies().

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

Member Data Documentation

int sim::OpDetBacktrackerRecord::iOpDetNum
private

OpticalDetector where the photons were detected.

Definition at line 137 of file OpDetBacktrackerRecord.h.

timePDclockSDPs_t sim::OpDetBacktrackerRecord::timePDclockSDPs
private

list of energy deposits for each timePDclock with signal

Definition at line 138 of file OpDetBacktrackerRecord.h.

Referenced by AddScintillationPhotons(), Energy(), findClosestTimePDclockSDP(), MergeOpDetBacktrackerRecord(), Photons(), and TrackIDsAndEnergies().


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