LArSoft  v09_90_00
Liquid Argon Software toolkit - https://larsoft.org/
SimChannel.h
Go to the documentation of this file.
1 
11 #ifndef LARDATAOBJ_SIMULATION_SIMCHANNEL_H
12 #define LARDATAOBJ_SIMULATION_SIMCHANNEL_H
13 
14 // LArSoftObj libraries
16 #include "larcoreobj/SimpleTypesAndConstants/RawTypes.h" // raw::ChannelID_t
17 
18 // C/C++ standard libraries
19 #include <string>
20 #include <utility> // std::pair
21 #include <vector>
22 
23 namespace sim {
24 
26  struct TrackIDE {
27  int trackID;
28  float energyFrac;
29  float energy;
30  float numElectrons;
31  int
33 
34  TrackIDE() {}
35 
36  TrackIDE(int id, float ef, float e, float ne, int gid = util::kBogusI)
37  : trackID(id), energyFrac(ef), energy(e), numElectrons(ne), origTrackID(gid)
38  {}
39  };
40 
85  struct IDE {
86 
88  typedef int TrackID_t;
89 
91  IDE();
92 
94  IDE(IDE const& ide, int offset);
95 
97  IDE(TrackID_t tid,
98  float nel,
99  float e,
100  float xpos,
101  float ypos,
102  float zpos,
103  TrackID_t gid = util::kBogusI)
104  : trackID(tid), numElectrons(nel), energy(e), x(xpos), y(ypos), z(zpos), origTrackID(gid)
105  {}
106 
107  TrackID_t trackID;
108  float numElectrons;
109  float energy;
110  float x;
111  float y;
112  float z;
113  TrackID_t
115  }; // struct IDE
116 
118  typedef std::pair<unsigned short, std::vector<sim::IDE>> TDCIDE;
119 
136  class SimChannel {
137  public:
139  typedef TDCIDE::first_type StoredTDC_t;
140 
142  typedef std::vector<TDCIDE> TDCIDEs_t;
143 
144  private:
146  TDCIDEs_t fTDCIDEs;
147 
148  public:
149  // Default constructor
150  SimChannel();
151 
155  typedef unsigned int TDC_t;
156 
159 
161  explicit SimChannel(raw::ChannelID_t channel);
162 
174  void AddIonizationElectrons(TrackID_t trackID,
175  TDC_t tdc,
176  double numberElectrons,
177  double const* xyz,
178  double energy,
179  TrackID_t origTrackID = util::kBogusI);
180 
182  raw::ChannelID_t Channel() const;
183 
201  std::vector<sim::IDE> TrackIDsAndEnergies(TDC_t startTDC, TDC_t endTDC) const;
202 
215  TDCIDEs_t const& TDCIDEMap() const;
216 
218  double Charge(TDC_t tdc) const;
219 
221  double Energy(TDC_t tdc) const;
222 
245  std::vector<sim::TrackIDE> TrackIDEs(TDC_t startTDC, TDC_t endTDC) const;
246 
248  bool operator<(const SimChannel& other) const;
249 
251  bool operator==(const SimChannel& other) const;
252 
278  std::pair<TrackID_t, TrackID_t> MergeSimChannel(const SimChannel& channel, int offset);
279 
287  template <typename Stream>
288  void Dump(Stream&& out, std::string indent, std::string first_indent) const;
289 
291  template <typename Stream>
292  void Dump(Stream&& out, std::string indent = "") const
293  {
294  Dump(std::forward<Stream>(out), indent, indent);
295  }
296 
297  private:
299  struct CompareByTDC;
300 
302  TDCIDEs_t::iterator findClosestTDCIDE(StoredTDC_t tdc);
303 
305  TDCIDEs_t::const_iterator findClosestTDCIDE(StoredTDC_t tdc) const;
307  };
308 
309 } // namespace sim
310 
312 {
313  return fChannel < other.Channel();
314 }
316 {
317  return fChannel == other.Channel();
318 }
320 {
321  return fTDCIDEs;
322 }
324 {
325  return fChannel;
326 }
327 
328 // -----------------------------------------------------------------------------
329 // --- template implementation
330 // ---
331 template <class Stream>
332 void sim::SimChannel::Dump(Stream&& out, std::string indent, std::string first_indent) const
333 {
334  out << first_indent << "channel #" << Channel() << " read " << fTDCIDEs.size() << " TDCs:\n";
335  double channel_energy = 0., channel_charge = 0.;
336  for (const auto& TDCinfo : fTDCIDEs) {
337  auto const tdc = TDCinfo.first;
338  out << indent << " TDC #" << tdc << " with " << TDCinfo.second.size() << " IDEs\n";
339  double tdc_energy = 0., tdc_charge = 0.;
340  for (const sim::IDE& ide : TDCinfo.second) {
341  out << indent << " (" << ide.x << ", " << ide.y << ", " << ide.z << ") "
342  << ide.numElectrons << " electrons, " << ide.energy << " MeV (trkID=" << ide.trackID
343  << ")\n";
344  tdc_energy += ide.energy;
345  tdc_charge += ide.numElectrons;
346  } // for IDEs
347  out << indent << " => TDC #" << tdc << " CH #" << Channel() << " collected " << tdc_charge
348  << " electrons and " << tdc_energy << " MeV\n";
349  channel_energy += tdc_energy;
350  channel_charge += tdc_charge;
351  } // for TDCs
352  out << indent << " => channel #" << Channel() << " collected " << channel_charge
353  << " electrons and " << channel_energy << " MeV\n";
354 } // sim::SimChannel::Dump<>()
355 
356 #endif // LARDATAOBJ_SIMULATION_SIMCHANNEL_H
357 
Float_t x
Definition: compare.C:6
TrackID_t trackID
Geant4 supplied track ID.
Definition: SimChannel.h:107
intermediate_table::iterator iterator
raw::ChannelID_t fChannel
readout channel where electrons are collected
Definition: SimChannel.h:145
float z
z position of ionization [cm]
Definition: SimChannel.h:112
Energy deposited on a readout channel by simulated tracks.
Definition: SimChannel.h:136
std::pair< unsigned short, std::vector< sim::IDE > > TDCIDE
List of energy deposits at the same time (on this channel)
Definition: SimChannel.h:118
Float_t y
Definition: compare.C:6
void Dump(Stream &&out, std::string indent, std::string first_indent) const
Dumps the full content of the SimChannel into a stream.
Definition: SimChannel.h:332
Double_t z
Definition: plot.C:276
float numElectrons
number of electrons from the particle detected on the wires
Definition: SimChannel.h:30
void Dump(Stream &&out, std::string indent="") const
Documentation at Dump(Stream&&, std::string, std::string) const.
Definition: SimChannel.h:292
TrackID_t origTrackID
Geant4 supplied track ID (remains true trackID even for shower secondaries/tertiaries etc) ...
Definition: SimChannel.h:114
constexpr int kBogusI
obviously bogus integer value
intermediate_table::const_iterator const_iterator
unsigned int TDC_t
Definition: SimChannel.h:155
float energy
energy from the particle with this trackID [MeV]
Definition: SimChannel.h:29
std::vector< TDCIDE > TDCIDEs_t
Type of list of energy deposits for each TDC with signal.
Definition: SimChannel.h:142
float x
x position of ionization [cm]
Definition: SimChannel.h:110
IDE(TrackID_t tid, float nel, float e, float xpos, float ypos, float zpos, TrackID_t gid=util::kBogusI)
Constructor: sets all data members.
Definition: SimChannel.h:97
TDCIDEs_t fTDCIDEs
list of energy deposits for each TDC with signal
Definition: SimChannel.h:146
Ionization at a point of the TPC sensitive volume.
Definition: SimChannel.h:85
int origTrackID
Geant4 supplied trackID, including no modification for shower secondaries/tertiaries.
Definition: SimChannel.h:32
float energy
energy deposited by ionization by this track ID and time [MeV]
Definition: SimChannel.h:109
std::string indent(std::size_t const i)
float energyFrac
fraction of hit energy from the particle with this trackID
Definition: SimChannel.h:28
TrackIDE(int id, float ef, float e, float ne, int gid=util::kBogusI)
Definition: SimChannel.h:36
Monte Carlo Simulation.
float y
y position of ionization [cm]
Definition: SimChannel.h:111
bool operator==(const SimChannel &other) const
Comparison: true if SimChannels have the same channel ID.
Definition: SimChannel.h:315
raw::ChannelID_t Channel() const
Returns the readout channel this object describes.
Definition: SimChannel.h:323
int trackID
Geant4 supplied trackID.
Definition: SimChannel.h:27
bool operator<(const SimChannel &other) const
Comparison: sorts by channel ID.
Definition: SimChannel.h:311
IDE::TrackID_t TrackID_t
Type of track ID (the value comes from Geant4)
Definition: SimChannel.h:158
TDCIDEs_t const & TDCIDEMap() const
Returns all the deposited energy information as stored.
Definition: SimChannel.h:319
unsigned int ChannelID_t
Type representing the ID of a readout channel.
Definition: RawTypes.h:28
Collection of Physical constants used in LArSoft.
int TrackID_t
Type of track ID (the value comes from Geant4)
Definition: SimChannel.h:88
Float_t e
Definition: plot.C:35
Ionization energy from a Geant4 track.
Definition: SimChannel.h:26
bool operator==(infinite_endcount_iterator< T > const &, count_iterator< T > const &)
Definition: counter.h:278
bool operator<(const BeamGateInfo &lhs, const BeamGateInfo &rhs)
Definition: BeamGateInfo.h:40
float numElectrons
number of electrons at the readout for this track ID and time
Definition: SimChannel.h:108
TDCIDE::first_type StoredTDC_t
Type for TDC tick used in the internal representation.
Definition: SimChannel.h:139