LArSoft  v06_85_00
Liquid Argon Software toolkit - http://larsoft.org/
SimChannel.h
Go to the documentation of this file.
1 
12 #ifndef LARDATAOBJ_SIMULATION_SIMCHANNEL_H
13 #define LARDATAOBJ_SIMULATION_SIMCHANNEL_H
14 
15 // LArSoftObj libraries
17 #include "larcoreobj/SimpleTypesAndConstants/RawTypes.h" // raw::ChannelID_t
18 
19 // C/C++ standard libraries
20 #include <string>
21 #include <vector>
22 #include <utility> // std::pair
23 
24 
25 namespace sim {
26 
28  struct TrackIDE{
29  int trackID;
30  float energyFrac;
31  float energy;
32  float numElectrons;
33 
34  TrackIDE() {}
35 
36 
37  TrackIDE(int id, float ef, float e, float ne ) : trackID(id), energyFrac(ef), energy (e), numElectrons (ne) {}
38 
39 
40  };
41 
42 
87  struct IDE{
88 
90  typedef int TrackID_t;
91 
93  IDE();
94 
95 
97  IDE(IDE const& ide, int offset);
98 
100  IDE(TrackID_t tid,
101  float nel,
102  float e,
103  float xpos,
104  float ypos,
105  float zpos)
106  : trackID (tid)
107  , numElectrons(nel)
108  , energy (e)
109  , x (xpos)
110  , y (ypos)
111  , z (zpos)
112  {}
113 
114 
115  TrackID_t trackID;
116  float numElectrons;
117  float energy;
118  float x;
119  float y;
120  float z;
121  }; // struct IDE
122 
123 
125  typedef std::pair<unsigned short, std::vector<sim::IDE> > TDCIDE;
126 
144  {
145  public:
147  typedef TDCIDE::first_type StoredTDC_t;
148 
150  typedef std::vector<TDCIDE> TDCIDEs_t;
151 
152  private:
154  TDCIDEs_t fTDCIDEs;
155 
156 
157  public:
158 
159  // Default constructor
160  SimChannel();
161 
165  typedef unsigned int TDC_t;
166 
169 
170 
172  explicit SimChannel(raw::ChannelID_t channel);
173 
185  void AddIonizationElectrons(TrackID_t trackID,
186  TDC_t tdc,
187  double numberElectrons,
188  double const* xyz,
189  double energy);
190 
192  raw::ChannelID_t Channel() const;
193 
211  std::vector<sim::IDE> TrackIDsAndEnergies(TDC_t startTDC,
212  TDC_t endTDC) const;
213 
226  TDCIDEs_t const& TDCIDEMap() const;
227 
228 
230  double Charge(TDC_t tdc) const;
231 
233  double Energy(TDC_t tdc) const;
234 
257  std::vector<sim::TrackIDE> TrackIDEs(TDC_t startTDC,
258  TDC_t endTDC) const;
259 
261  bool operator< (const SimChannel& other) const;
262 
264  bool operator== (const SimChannel& other) const;
265 
291  std::pair<TrackID_t,TrackID_t> MergeSimChannel
292  (const SimChannel& channel, int offset);
293 
294 
302  template <typename Stream>
303  void Dump(Stream&& out, std::string indent, std::string first_indent) const;
304 
306  template <typename Stream>
307  void Dump(Stream&& out, std::string indent = "") const
308  { Dump(std::forward<Stream>(out), indent, indent); }
309 
310 
311  private:
313  struct CompareByTDC;
314 
316  TDCIDEs_t::iterator findClosestTDCIDE(StoredTDC_t tdc);
317 
319  TDCIDEs_t::const_iterator findClosestTDCIDE
320  (StoredTDC_t tdc) const;
322 
323 
324  };
325 
326 } // namespace sim
327 
328 
329 inline bool sim::SimChannel::operator< (const sim::SimChannel& other) const { return fChannel < other.Channel(); }
330 inline bool sim::SimChannel::operator== (const sim::SimChannel& other) const { return fChannel == other.Channel(); }
331 inline sim::SimChannel::TDCIDEs_t const& sim::SimChannel::TDCIDEMap() const { return fTDCIDEs; }
332 inline raw::ChannelID_t sim::SimChannel::Channel() const { return fChannel; }
333 
334 
335 // -----------------------------------------------------------------------------
336 // --- template implementation
337 // ---
338 template <class Stream>
340  (Stream&& out, std::string indent, std::string first_indent) const
341 {
342  out << first_indent << "channel #" << Channel() << " read " << fTDCIDEs.size()
343  << " TDCs:\n";
344  double channel_energy = 0., channel_charge = 0.;
345  for (const auto& TDCinfo: fTDCIDEs) {
346  auto const tdc = TDCinfo.first;
347  out << indent << " TDC #" << tdc
348  << " with " << TDCinfo.second.size() << " IDEs\n";
349  double tdc_energy = 0., tdc_charge = 0.;
350  for (const sim::IDE& ide: TDCinfo.second) {
351  out << indent
352  << " (" << ide.x << ", " << ide.y << ", " << ide.z << ") "
353  << ide.numElectrons << " electrons, " << ide.energy << " MeV (trkID="
354  << ide.trackID << ")\n";
355  tdc_energy += ide.energy;
356  tdc_charge += ide.numElectrons;
357  } // for IDEs
358  out << indent << " => TDC #" << tdc << " CH #" << Channel()
359  << " collected " << tdc_charge << " electrons and " << tdc_energy
360  << " MeV\n";
361  channel_energy += tdc_energy;
362  channel_charge += tdc_charge;
363  } // for TDCs
364  out << indent << " => channel #" << Channel() << " collected "
365  << channel_charge << " electrons and " << channel_energy << " MeV\n";
366 } // sim::SimChannel::Dump<>()
367 
368 
369 #endif // LARDATAOBJ_SIMULATION_SIMCHANNEL_H
370 
Float_t x
Definition: compare.C:6
TrackID_t trackID
Geant4 supplied track ID.
Definition: SimChannel.h:115
raw::ChannelID_t fChannel
readout channel where electrons are collected
Definition: SimChannel.h:153
float z
z position of ionization [cm]
Definition: SimChannel.h:120
Energy deposited on a readout channel by simulated tracks.
Definition: SimChannel.h:143
IDE(TrackID_t tid, float nel, float e, float xpos, float ypos, float zpos)
Constructor: sets all data members.
Definition: SimChannel.h:100
std::pair< unsigned short, std::vector< sim::IDE > > TDCIDE
List of energy deposits at the same time (on this channel)
Definition: SimChannel.h:125
intermediate_table::iterator iterator
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:340
Double_t z
Definition: plot.C:279
float numElectrons
number of electrons from the particle detected on the wires
Definition: SimChannel.h:32
void Dump(Stream &&out, std::string indent="") const
Documentation at Dump(Stream&&, std::string, std::string) const.
Definition: SimChannel.h:307
unsigned int TDC_t
Definition: SimChannel.h:165
float energy
energy from the particle with this trackID [MeV]
Definition: SimChannel.h:31
std::vector< TDCIDE > TDCIDEs_t
Type of list of energy deposits for each TDC with signal.
Definition: SimChannel.h:150
float x
x position of ionization [cm]
Definition: SimChannel.h:118
TDCIDEs_t fTDCIDEs
list of energy deposits for each TDC with signal
Definition: SimChannel.h:154
TrackIDE(int id, float ef, float e, float ne)
Definition: SimChannel.h:37
intermediate_table::const_iterator const_iterator
Ionization at a point of the TPC sensitive volume.
Definition: SimChannel.h:87
float energy
energy deposited by ionization by this track ID and time [MeV]
Definition: SimChannel.h:117
std::string indent(std::size_t const i)
float energyFrac
fraction of hit energy from the particle with this trackID
Definition: SimChannel.h:30
Monte Carlo Simulation.
Definition of data types for geometry description.
float y
y position of ionization [cm]
Definition: SimChannel.h:119
bool operator==(const SimChannel &other) const
Comparison: true if SimChannels have the same channel ID.
Definition: SimChannel.h:330
raw::ChannelID_t Channel() const
Returns the readout channel this object describes.
Definition: SimChannel.h:332
int trackID
Geant4 supplied trackID.
Definition: SimChannel.h:29
bool operator<(const SimChannel &other) const
Comparison: sorts by channel ID.
Definition: SimChannel.h:329
IDE::TrackID_t TrackID_t
Type of track ID (the value comes from Geant4)
Definition: SimChannel.h:168
TDCIDEs_t const & TDCIDEMap() const
Returns all the deposited energy information as stored.
Definition: SimChannel.h:331
unsigned int ChannelID_t
Type representing the ID of a readout channel.
Definition: RawTypes.h:27
int TrackID_t
Type of track ID (the value comes from Geant4)
Definition: SimChannel.h:90
Float_t e
Definition: plot.C:34
Ionization energy from a Geant4 track.
Definition: SimChannel.h:28
bool operator==(geometry_element_iterator< GEOIDITER > const &iter, GEOIDITER const &id_iter)
Comparison operator: geometry ID and element point to the same ID.
bool operator<(const BeamGateInfo &lhs, const BeamGateInfo &rhs)
Definition: BeamGateInfo.h:48
float numElectrons
number of electrons at the readout for this track ID and time
Definition: SimChannel.h:116
TDCIDE::first_type StoredTDC_t
Type for TDC tick used in the internal representation.
Definition: SimChannel.h:147