MEvent/ScintillatorSimData.h
Go to the documentation of this file.
1 #ifndef _mevt_ScintillatorSimData_h_
2 #define _mevt_ScintillatorSimData_h_
3 
4 // For frienship declaration, just forward declare.
5 #include <utl/ShadowPtr_fwd.h>
6 #include <utl/Particle.h>
7 //
8 #include <utl/ShadowPtr.h>
9 #include <utl/Trace.h>
10 #include <utl/TimeStamp.h>
11 
12 #include <list>
13 
14 #include <boost/iterator/indirect_iterator.hpp>
15 #include <mdet/Pixel.h>
16 
17 namespace mevt {
18 
19  class Scintillator;
20 
21 
32 
33  public:
34  // structure holds information about single photo electron pulses before amplification - if PMT
35  struct SPEPulse {
36  double fMu; // time
37  double fSigma; // width in time, std (depends on setting of pulseParametrization in MModelConfig!!)
38  double fAmplitude; // charge (depends on setting of pulseParametrization in MModelConfig!!)
39  int fDestPixelId; // id of pixel where the spe goes after crosstalk, is not necessary the one that is retrieved by ScintillatorToPixelId() !
40  };
41 
42  // structure holds information about photo equivalent pulses before amplification - if SiPM
43  struct PEPulse {
44  double fT0;
45  double fAmplitude1; // Amplitude 1 (depends on setting of pulseParametrization in MModelConfig!!)
46  double fAmplitude2; // Amplitude 2 (depends on setting of pulseParametrization in MModelConfig!!)
47  double fAmplitude3; // Amplitude 3 (depends on setting of pulseParametrization in MModelConfig!!)
48  double fRiseTime; // Rise Time (depends on setting of pulseParametrization in MModelConfig!!)
49  double fFallTime1; // Fall Time fast (depends on setting of pulseParametrization in MModelConfig!!)
50  double fFallTime2; // Fall Time slow (depends on setting of pulseParametrization in MModelConfig!!)
51  double fFallTime3; // Fall Time slow (depends on setting of pulseParametrization in MModelConfig!!)
52  int fDestPixelId; // id of pixel where the spe goes after crosstalk, is not necessary the one that is retrieved by ScintillatorToPixelId() !
53  };
54 
55  // structure holds the arrival time of the G4 simulated photons
56  struct PhotonTime {
57  double fTime;
58  };
59 
60  private:
61  /*
62  * sevt::StationSimData
63  * uses std::vector as container. Even more, the name of the typedef
64  * talks about vector. The name I believe should be other, but that's
65  * a cosmetic issue.
66  * The usage context is the following:
67  * - No random access.
68  * - Insertion only at the end.
69  * - Front-to-back linear iteration.
70  * - No prior knowledge of total number of particles.
71  * - A O(1) (implicit) way of calculating the number of particles
72  * through the difference between begin and end iterators.
73  *
74  * Then a vector (continuous memory allocation) may not
75  * be the most proper structure: mainly due to the reallocation, copying
76  * of the contained objects when the current total continuous storage
77  * exhaust. With a naive implementation of vector (allocating +1 buckets
78  * storage) the insertion of n elements from scratch ends up begin n^2.
79  * Nevertheless, typical implementations of the standard library
80  * upon each reallocation they require times two the previous size.
81  * Given that, an amortized linear time is achieved (though plenty
82  * of copying and destructing underneath).
83  * I actually ran the example application
84  * /Documentation/ExampleApplications/SSimulation
85  * with list and vector, with 10000 and 100000 particles and no
86  * difference was found (the benchmark wasn't too conlusive, of course).
87  *
88  * The cons agains the usage of list are:
89  * - Memory overhead. List is double-linked (the single linked slist) is not
90  * standard. In this case each node is composed of a particle (wrapped in a shadow
91  * pointer) so the addition of, say, 8 bytes for the two pointers sees marginal.
92  * - Memory contiguity. The continuous storage may allow some fetching optimizations
93  * but given that at the end the actual objets are heap-allocated and then accessed
94  * through pointers it seems that no locality advantage will be found.
95  *
96  * Having said this, I prefer std::list; and keeping a counter in this class to
97  * keep track of the number of particles (recall that size in list is tipically
98  * linear). Having an explicit member to query the number of particles seems
99  * better than to have it calculated through the difference of pointers.
100  */
102  typedef std::list<ParticlePtr> InternalParticleContainer;
103  typedef InternalParticleContainer::iterator InternalParticleIterator;
104  typedef InternalParticleContainer::const_iterator InternalConstParticleIterator;
105 
106  typedef std::list<SPEPulse> SPEPulseContainer;
107  typedef std::list<PEPulse> PEPulseContainer;
108  typedef std::list<PhotonTime> PhotonTimeContainer;
109 
110  public:
111  typedef boost::indirect_iterator<InternalParticleIterator, utl::Particle&> ParticleIterator;
112  typedef boost::indirect_iterator<InternalConstParticleIterator, const utl::Particle&> ConstParticleIterator;
113  typedef SPEPulseContainer::iterator SPEPulseIterator;
114  typedef SPEPulseContainer::const_iterator ConstSPEPulseIterator;
115 
116  typedef PEPulseContainer::iterator PEPulseIterator;
117  typedef PEPulseContainer::const_iterator ConstPEPulseIterator;
118 
119  typedef PhotonTimeContainer::iterator PhotonTimeIterator;
120  typedef PhotonTimeContainer::const_iterator ConstPhotonTimeIterator;
121 
123  ConstParticleIterator ParticlesBegin() const { return fParticles.begin(); }
126 
127  void AddParticle(const utl::Particle& particle);
128 
130  ConstSPEPulseIterator SPEPulsesBegin() const { return fSPEPulses.begin(); }
133 
134  void AddSPEPulse(const double mu, const double sigma, const double amplitude, const int destPixelId);
135 
136  int GetNumberOfSPEPulses() const {return fSPEPulses.size();}
137 
139  ConstPEPulseIterator PEPulsesBegin() const { return fPEPulses.begin(); }
141  ConstPEPulseIterator PEPulsesEnd() const { return fPEPulses.end(); }
142 
143  void AddPEPulse(const double t0, const double a1, const double a2, const double a3, const double timeRise,
144  const double timeFall1, const double timeFall2, const double timeFall3, const int destPixelId);
145 
146  int GetNumberOfPEPulses() const {return fPEPulses.size();}
147 
152 
153  void AddPhotonTime(const double t0);
154  double GetPhotonTime(const PhotonTime& photon) const;
155 
156  int GetNumberOfPhotonTimes() const { return fPhotonTimes.size(); }
157 
159 
161 
163 
164  void AddEnergyDeposit(const double edep) { fEnergyDeposit += edep; }
165 
166  void AddEnergyDepositMuons(const double edep) { fEnergyDepositMuons += edep; }
167 
168  void SetNumberOfInjectedMuons(const unsigned int nmuons) { fNumberOfInjectedMuons = nmuons; }
169 
170  void SetNumberOfCornerClippingMuons(const unsigned int nmuons) { fNumberOfCornerClippingMuons = nmuons; }
171 
173 
174  void SetEnergyDeposit(const double edep) { fEnergyDeposit = edep; }
175 
176  void SetEnergyDepositMuons(const double edep) { fEnergyDepositMuons = edep; }
177 
178  unsigned int GetNumberOfInjectedMuons() const { return fNumberOfInjectedMuons; }
179 
181 
182  unsigned int GetNumberOfElectrons() const { return fNumberOfElectrons; }
183 
184  double GetEnergyDeposit() const { return fEnergyDeposit; }
185 
186  unsigned int GetEnergyDepositMuons() const { return fEnergyDepositMuons; }
187 
188  void ClearParticleList();
189 
190  unsigned int GetNumberOfParticles() const { return fNParticles; }
191 
220 
221  const utl::TraceD& GetAnalogicTrace() const;
222 
223  void MakeAnalogicTrace();
224 
225  bool HasAnalogicTrace() const;
226 
227  private:
228  ScintillatorSimData() = default;
229  ~ScintillatorSimData() = default;
230 
231  unsigned int fNParticles = 0;
232  unsigned int fNumberOfInjectedMuons = 0;
234  unsigned int fNumberOfElectrons = 0;
235  double fEnergyDeposit = 0;
238 
240 
241 
242 
244 
246 
248  /*
249  * Like sevt::StationRecData nothing said about
250  * operator= and copy-construction: let the compiler
251  * generate'em.
252  */
256  friend class Scintillator;
263  /*
264  * The usual case is just to have primitive types
265  * in here. So this class is like POD but a little
266  * spiced in the sense that its construction is
267  * privileged.
268  */
269  };
270 
271 }
272 
273 
274 #endif
ConstPhotonTimeIterator PhotonTimesEnd() const
pointer with built-in initialization, deletion, deep copying
Definition: ShadowPtr.h:163
void AddEnergyDepositMuons(const double edep)
unsigned int GetNumberOfCornerClippingMuons() const
InternalParticleContainer::const_iterator InternalConstParticleIterator
PEPulseContainer::const_iterator ConstPEPulseIterator
boost::indirect_iterator< InternalConstParticleIterator, const utl::Particle & > ConstParticleIterator
ConstParticleIterator ParticlesBegin() const
std::list< SPEPulse > SPEPulseContainer
void SetEnergyDeposit(const double edep)
Describes a particle for Simulation.
Definition: Particle.h:26
void SetNumberOfElectrons(const unsigned int electrons)
void AddSPEPulse(const double mu, const double sigma, const double amplitude, const int destPixelId)
ConstParticleIterator ParticlesEnd() const
ConstPEPulseIterator PEPulsesBegin() const
PhotonTimeContainer::const_iterator ConstPhotonTimeIterator
void AddParticle(const utl::Particle &particle)
void SetNumberOfInjectedMuons(const unsigned int nmuons)
void SetNumberOfCornerClippingMuons(const unsigned int nmuons)
ConstPhotonTimeIterator PhotonTimesBegin() const
unsigned int GetNumberOfElectrons() const
utl::TraceD & GetAnalogicTrace()
Return the trace of current pulse signal prior to the electronic amplification stage.
Scintillator level event data.
InternalParticleContainer fParticles
boost::indirect_iterator< InternalParticleIterator, utl::Particle & > ParticleIterator
std::list< PhotonTime > PhotonTimeContainer
PEPulseContainer::iterator PEPulseIterator
void SetEnergyDepositMuons(const double edep)
ConstSPEPulseIterator SPEPulsesEnd() const
void AddEnergyDeposit(const double edep)
Scintillator level simulation data.
InternalParticleContainer::iterator InternalParticleIterator
void AddPEPulse(const double t0, const double a1, const double a2, const double a3, const double timeRise, const double timeFall1, const double timeFall2, const double timeFall3, const int destPixelId)
double GetPhotonTime(const PhotonTime &photon) const
struct particle_info particle[80]
std::list< ParticlePtr > InternalParticleContainer
unsigned int GetEnergyDepositMuons() const
PhotonTimeContainer::iterator PhotonTimeIterator
SPEPulseContainer::iterator SPEPulseIterator
unsigned int GetNumberOfParticles() const
utl::ShadowPtr< utl::Particle > ParticlePtr
utl::ShadowPtr< utl::TraceD > fAnalogicTrace
ConstPEPulseIterator PEPulsesEnd() const
SPEPulseContainer::const_iterator ConstSPEPulseIterator
unsigned int GetNumberOfInjectedMuons() const
ConstSPEPulseIterator SPEPulsesBegin() const

, generated on Tue Sep 26 2023.