LArSoft  v09_90_00
Liquid Argon Software toolkit - https://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 105 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 108 of file OpDetBacktrackerRecord.h.

Type for iTimePDclock tick used in the interface.

Definition at line 123 of file OpDetBacktrackerRecord.h.

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

Definition at line 111 of file OpDetBacktrackerRecord.h.

Type of track ID (the value comes from Geant4)

Definition at line 126 of file OpDetBacktrackerRecord.h.

Constructor & Destructor Documentation

sim::OpDetBacktrackerRecord::OpDetBacktrackerRecord ( )

Definition at line 43 of file OpDetBacktrackerRecord.cxx.

44  : iOpDetNum(
45  -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.

50 : iOpDetNum(detNum) {}
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 53 of file OpDetBacktrackerRecord.cxx.

References util::abs(), energy, findClosestTimePDclockSDP(), MF_LOG_ERROR, timePDclockSDPs, and weight.

Referenced by phot::PDFastSimPVS::produce(), phot::PDFastSimANN::produce(), phot::PDFastSimPAR::produce(), and larg4::OpFastScintillation::RecordPhotonsProduced().

58  {
62  // look at the collection to see if the current iTimePDclock already
63  // exists, if not, add it, if so, just add a new track id to the
64  // vector, or update the information if track is already present
65 
66  // no photons? no good!
67  if ((numberPhotons < std::numeric_limits<double>::epsilon()) ||
68  (energy <= std::numeric_limits<double>::epsilon())) {
69  // will throw
70  MF_LOG_ERROR("OpDetBacktrackerRecord")
71  << "AddTrackPhotons() trying to add to iTimePDclock #" << iTimePDclock << " "
72  << numberPhotons << " photons with " << energy
73  << " MeV of energy from track ID=" << trackID;
74  return;
75  } // if no photons
76 
77  auto itr = findClosestTimePDclockSDP(iTimePDclock);
78 
79  // check if this iTimePDclock value is in the vector, it is possible that
80  // the lower bound is different from the given TimePDclock, in which case
81  // we need to add something for that TimePDclock
82  if (itr == timePDclockSDPs.end() || (abs(itr->first - iTimePDclock) > .50)) {
83  //itr->first != iTimePDclock){
84  std::vector<sim::SDP> sdplist;
85  sdplist.emplace_back(trackID, numberPhotons, energy, xyz[0], xyz[1], xyz[2]);
86  timePDclockSDPs.emplace(itr, std::round(iTimePDclock), std::move(sdplist));
87  }
88  else { // we have that iTimePDclock already; itr points to it
89 
90  // loop over the SDP vector for this iTimePDclock and add the electrons
91  // to the entry with the same track id
92  for (auto& sdp : itr->second) {
93 
94  if (sdp.trackID != trackID) continue;
95 
96  // make a weighted average for the location information
97  double weight = sdp.numPhotons + numberPhotons;
98  sdp.x = (sdp.x * sdp.numPhotons + xyz[0] * numberPhotons) / weight;
99  sdp.y = (sdp.y * sdp.numPhotons + xyz[1] * numberPhotons) / weight;
100  sdp.z = (sdp.z * sdp.numPhotons + xyz[2] * numberPhotons) / weight;
101  sdp.numPhotons = weight;
102  sdp.energy = sdp.energy + energy;
103 
104  // found the track id we wanted, so return;
105  return;
106  } // for
107 
108  // if we never found the track id, then this is the first instance of
109  // the track id for this TimePDclock, so add sdp to the vector
110  itr->second.emplace_back(trackID, numberPhotons, energy, xyz[0], xyz[1], xyz[2]);
111 
112  } // end of else "We have that iTimePDclock already"
113 
114  } // OpDetBacktrackerRecord::AddIonizationElectrons()
constexpr auto abs(T v)
Returns the absolute value of the argument.
#define MF_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 302 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().

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<>()
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 261 of file OpDetBacktrackerRecord.h.

References art::detail::indent().

262  {
263  Dump(std::forward<Stream>(out), indent, indent);
264  }
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 139 of file OpDetBacktrackerRecord.cxx.

References energy, findClosestTimePDclockSDP(), and timePDclockSDPs.

140  {
141  double energy = 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() && itr->first == iTimePDclock) {
147 
148  // loop over the list for this iTimePDclock value and add up
149  // the total number of photons
150  for (auto sdp : itr->second) {
151  energy += sdp.energy;
152  } // end loop over sim::SDP for this TimePDclock
153 
154  } // end if this iTimePDclock is represented in the map
155 
156  return energy;
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.
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 318 of file OpDetBacktrackerRecord.cxx.

References timePDclockSDPs.

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

319  {
320  return std::lower_bound(
321  timePDclockSDPs.begin(), timePDclockSDPs.end(), iTimePDclock, CompareByTimePDclock());
322  }
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 325 of file OpDetBacktrackerRecord.cxx.

References timePDclockSDPs.

326  {
327  return std::lower_bound(
328  timePDclockSDPs.begin(), timePDclockSDPs.end(), TimePDclock, CompareByTimePDclock());
329  }
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 258 of file OpDetBacktrackerRecord.cxx.

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

260  {
261  if (this->OpDetNum() != channel.OpDetNum())
262  throw std::runtime_error(
263  "ERROR OpDetBacktrackerRecord Merge: Trying to merge different channels!");
264 
265  std::pair<TrackID_t, TrackID_t> range_trackID(std::numeric_limits<int>::max(),
266  std::numeric_limits<int>::min());
267 
268  for (auto const& itr : channel.timePDclockSDPsMap()) {
269 
270  auto iTimePDclock = itr.first;
271  auto const& sdps = itr.second;
272 
273  // find the entry from this OpDetBacktrackerRecord corresponding to the iTimePDclock from the other
274  auto itrthis = findClosestTimePDclockSDP(iTimePDclock);
275 
276  // pick which SDP list we have to fill: new one or existing one
277  std::vector<sim::SDP>* curSDPVec;
278  if (itrthis == timePDclockSDPs.end() || itrthis->first != iTimePDclock) {
279  timePDclockSDPs.emplace_back(iTimePDclock, std::vector<sim::SDP>());
280  curSDPVec = &(timePDclockSDPs.back().second);
281  }
282  else
283  curSDPVec = &(itrthis->second);
284 
285  for (auto const& sdp : sdps) {
286  curSDPVec->emplace_back(sdp, offset);
287  if (sdp.trackID + offset < range_trackID.first) range_trackID.first = sdp.trackID + offset;
288  if (sdp.trackID + offset > range_trackID.second)
289  range_trackID.second = sdp.trackID + offset;
290  } //end loop over SDPs
291 
292  } //end loop over TimePDclockSDPMap
293 
294  return range_trackID;
295  }
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 293 of file OpDetBacktrackerRecord.h.

Referenced by larg4::OpDetPhotonTable::AddOpDetBacktrackerRecord(), phot::PDFastSimPVS::AddOpDetBTR(), phot::PDFastSimANN::AddOpDetBTR(), phot::PDFastSimPAR::AddOpDetBTR(), MergeOpDetBacktrackerRecord(), operator<(), and operator==().

294 {
295  return iOpDetNum;
296 }
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 280 of file OpDetBacktrackerRecord.h.

References OpDetNum().

281 {
282  return iOpDetNum < other.OpDetNum();
283 }
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 284 of file OpDetBacktrackerRecord.h.

References OpDetNum().

285 {
286  return iOpDetNum == other.OpDetNum();
287 }
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 117 of file OpDetBacktrackerRecord.cxx.

References findClosestTimePDclockSDP(), and timePDclockSDPs.

118  {
119  double numPhotons = 0.;
120 
121  auto itr = findClosestTimePDclockSDP(iTimePDclock);
122 
123  // check to see if this iTimePDclock value is in the map
124  if (itr != timePDclockSDPs.end() && itr->first == iTimePDclock) {
125 
126  // loop over the list for this iTimePDclock value and add up
127  // the total number of electrons
128  for (auto sdp : itr->second) {
129  numPhotons += sdp.numPhotons;
130  } // end loop over sim::SDP for this TimePDclock
131 
132  } // end if this iTimePDclock is represented in the map
133 
134  return numPhotons;
135  }
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 289 of file OpDetBacktrackerRecord.h.

Referenced by larg4::OpDetPhotonTable::AddOpDetBacktrackerRecord(), phot::PDFastSimPVS::AddOpDetBTR(), phot::PDFastSimANN::AddOpDetBTR(), phot::PDFastSimPAR::AddOpDetBTR(), and MergeOpDetBacktrackerRecord().

290 {
291  return timePDclockSDPs;
292 }
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 161 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().

164  {
165  // make a map of track ID values to sim::SDP objects
166 
167  if (startTimePDclock > endTimePDclock) {
168  mf::LogWarning("OpDetBacktrackerRecord")
169  << "requested TimePDclock range is bogus: " << startTimePDclock << " " << endTimePDclock
170  << " return empty vector";
171  return {}; // returns an empty vector
172  }
173 
174  std::map<TrackID_t, sim::SDP> idToSDP;
175 
176  //find the lower bound for this iTimePDclock and then iterate from there
177  auto itr = findClosestTimePDclockSDP(startTimePDclock);
178 
179  while (itr != timePDclockSDPs.end()) {
180 
181  // check the iTimePDclock value for the iterator, break the loop if we
182  // are outside the range
183  if (itr->first > endTimePDclock) break;
184 
185  // grab the vector of SDPs for this TimePDclock
186  auto const& sdplist = itr->second;
187  // now loop over them and add their content to the map
188  for (auto const& sdp : sdplist) {
189  auto itTrkSDP = idToSDP.find(sdp.trackID);
190  if (itTrkSDP != idToSDP.end()) {
191  // the SDP we are going to update:
192  sim::SDP& trackSDP = itTrkSDP->second;
193 
194  double const nPh1 = trackSDP.numPhotons;
195  double const nPh2 = sdp.numPhotons;
196  double const weight = nPh1 + nPh2;
197 
198  // make a weighted average for the location information
199  trackSDP.x = (sdp.x * nPh2 + trackSDP.x * nPh1) / weight;
200  trackSDP.y = (sdp.y * nPh2 + trackSDP.y * nPh1) / weight;
201  trackSDP.z = (sdp.z * nPh2 + trackSDP.z * nPh1) / weight;
202  trackSDP.numPhotons = weight;
203  } // end if the track id for this one is found
204  else {
205  idToSDP[sdp.trackID] = sim::SDP(sdp);
206  }
207  } // end loop over vector
208 
209  ++itr;
210  } // end loop over iTimePDclock values
211 
212  // now fill the vector with the sdps from the map
213  std::vector<sim::SDP> sdps;
214  sdps.reserve(idToSDP.size());
215  for (auto const& itr : idToSDP) {
216  sdps.push_back(itr.second);
217  }
218 
219  return sdps;
220  }
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 224 of file OpDetBacktrackerRecord.cxx.

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

226  {
227 
228  std::vector<sim::TrackSDP> trackSDPs;
229 
230  if (startTimePDclock > endTimePDclock) {
231  mf::LogWarning("OpDetBacktrackerRecord::TrackSDPs")
232  << "requested iTimePDclock range is bogus: " << startTimePDclock << " " << endTimePDclock
233  << " return empty vector";
234  return trackSDPs;
235  }
236 
237  double totalPhotons = 0.;
238  std::vector<sim::SDP> const sdps = TrackIDsAndEnergies(startTimePDclock, endTimePDclock);
239  for (auto const& sdp : sdps)
240  totalPhotons += sdp.numPhotons;
241 
242  // protect against a divide by zero below
243  if (totalPhotons < 1.e-5) totalPhotons = 1.;
244 
245  // loop over the entries in the map and fill the input vectors
246  for (auto const& sdp : sdps) {
247  if (sdp.trackID == sim::NoParticleId) continue;
248  trackSDPs.emplace_back(sdp.trackID, sdp.numPhotons / totalPhotons, sdp.numPhotons);
249  }
250 
251  return trackSDPs;
252  }
static const int NoParticleId
Definition: sim.h:21
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:35

Member Data Documentation

int sim::OpDetBacktrackerRecord::iOpDetNum
private

OpticalDetector where the photons were detected.

Definition at line 114 of file OpDetBacktrackerRecord.h.

timePDclockSDPs_t sim::OpDetBacktrackerRecord::timePDclockSDPs
private

list of energy deposits for each timePDclock with signal

Definition at line 115 of file OpDetBacktrackerRecord.h.

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


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