CMS 3D CMS Logo

DigitizerUtility.h
Go to the documentation of this file.
1 #ifndef SimTracker_Common_DigitizerUtility_h
2 #define SimTracker_Common_DigitizerUtility_h
3 
4 #include <map>
5 #include <memory>
6 #include <vector>
7 #include <iostream>
8 
12 
13 namespace digitizerUtility {
14 
15  class SimHitInfo {
16  public:
17  SimHitInfo(const PSimHit* hitp, float corrTime, size_t hitIndex, uint32_t tofBin)
18  : eventId_(hitp->eventId()), trackId_(hitp->trackId()), hitIndex_(hitIndex), tofBin_(tofBin), time_(corrTime) {}
19 
20  uint32_t hitIndex() const { return hitIndex_; };
21  uint32_t tofBin() const { return tofBin_; };
22  EncodedEventId eventId() const { return eventId_; };
23  uint32_t trackId() const { return trackId_; };
24  float time() const { return time_; };
25 
26  private:
28  uint32_t trackId_;
29  uint32_t hitIndex_;
30  uint32_t tofBin_;
31  float time_;
32  };
33 
34  //===================================================================================================
35  class Amplitude {
36  public:
37  Amplitude() : _amp(0.0) {}
38  Amplitude(float amp, float frac) : _amp(amp), _frac(1, frac) {
39  //in case of digi from noisypixels
40  //the MC information are removed
41  if (_frac[0] < -0.5) {
42  _frac.pop_back();
43  }
44  }
45 
46  Amplitude(float amp, const PSimHit* hitp, size_t hitIndex, size_t hitInd4CR, unsigned int tofBin, float frac)
47  : _amp(amp), _frac(1, frac) {
48  //in case of digi from noisypixels
49  //the MC information are removed
50  if (_frac[0] < -0.5) {
51  _frac.pop_back();
52  } else {
53  _hitInfos.emplace_back(hitp, hitIndex, tofBin, hitInd4CR, amp);
54  }
55  }
56 
57  // can be used as a float by convers.
58  operator float() const { return _amp; }
59  float ampl() const { return _amp; }
60  const std::vector<float>& individualampl() const { return _frac; }
61  const std::vector<SimHitInfoForLinks>& hitInfos() const { return _hitInfos; }
62 
63  void operator+=(const Amplitude& other) {
64  _amp += other._amp;
65  //in case of contribution of noise to the digi
66  //the MC information are removed
67  if (other._frac[0] > -0.5) {
68  if (!other._hitInfos.empty()) {
69  _hitInfos.insert(_hitInfos.end(), other._hitInfos.begin(), other._hitInfos.end());
70  }
71  _frac.insert(_frac.end(), other._frac.begin(), other._frac.end());
72  }
73  }
74  void operator+=(const float& amp) { _amp += amp; }
75 
76  void set(const float amplitude) { // Used to reset the amplitude
77  _amp = amplitude;
78  }
79  /* void setind (const float indamplitude) { // Used to reset the amplitude */
80  /* _frac = idamplitude; */
81  /* } */
82  private:
83  float _amp;
84  std::vector<float> _frac;
85  std::vector<SimHitInfoForLinks> _hitInfos;
86  }; // end class Amplitude
87 
88  //===================================================================================================
89  class Ph2Amplitude {
90  public:
91  Ph2Amplitude() : _amp(0.0) {}
93  float amp, const PSimHit* hitp, float frac = 0, float tcor = 0, size_t hitIndex = 0, uint32_t tofBin = 0)
94  : _amp(amp) {
95  if (frac > 0) {
96  if (hitp != nullptr)
97  _simInfoList.push_back({frac, std::make_unique<SimHitInfo>(hitp, tcor, hitIndex, tofBin)});
98  else
99  _simInfoList.push_back({frac, nullptr});
100  }
101  }
102 
103  // can be used as a float by convers.
104  operator float() const { return _amp; }
105  float ampl() const { return _amp; }
106  const std::vector<std::pair<float, std::unique_ptr<SimHitInfo> > >& simInfoList() const { return _simInfoList; }
107 
109  _amp += other._amp;
110  // in case of digi from the noise, the MC information need not be there
111  for (auto const& ic : other.simInfoList()) {
112  if (ic.first > -0.5)
113  _simInfoList.push_back({ic.first, std::make_unique<SimHitInfo>(*ic.second)});
114  }
115  }
116  void operator+=(const float& amp) { _amp += amp; }
117  void set(const float amplitude) { // Used to reset the amplitude
118  _amp = amplitude;
119  }
120 
121  private:
122  float _amp;
123  std::vector<std::pair<float, std::unique_ptr<SimHitInfo> > > _simInfoList;
124  }; // end class Ph2Amplitude
125 
126  //*********************************************************
127  // Define a class for 3D ionization points and energy
128  //*********************************************************
130  public:
131  EnergyDepositUnit() : _energy(0), _position(0, 0, 0) {}
132  EnergyDepositUnit(float energy, float x, float y, float z) : _energy(energy), _position(x, y, z) {}
134  float x() const { return _position.x(); }
135  float y() const { return _position.y(); }
136  float z() const { return _position.z(); }
137  float energy() const { return _energy; }
138 
139  // Allow migration between pixel cells
141 
142  private:
143  float _energy;
145  };
146 
147  //**********************************************************
148  // define class to store signals on the collection surface
149  //**********************************************************
150  class SignalPoint {
151  public:
152  SignalPoint() : _pos(0, 0), _time(0), _amplitude(0), _sigma_x(1.), _sigma_y(1.), _hitp(nullptr) {}
153 
154  SignalPoint(float x, float y, float sigma_x, float sigma_y, float t, float a = 1.0)
155  : _pos(x, y), _time(t), _amplitude(a), _sigma_x(sigma_x), _sigma_y(sigma_y), _hitp(nullptr) {}
156 
157  SignalPoint(float x, float y, float sigma_x, float sigma_y, float t, const PSimHit& hit, float a = 1.0)
159 
160  const LocalPoint& position() const { return _pos; }
161  float x() const { return _pos.x(); }
162  float y() const { return _pos.y(); }
163  float sigma_x() const { return _sigma_x; }
164  float sigma_y() const { return _sigma_y; }
165  float time() const { return _time; }
166  float amplitude() const { return _amplitude; }
167  const PSimHit& hit() { return *_hitp; }
169  _amplitude = amp;
170  return *this;
171  }
172 
173  private:
175  float _time;
176  float _amplitude;
177  float _sigma_x; // gaussian sigma in the x direction (cm)
178  float _sigma_y; // " " y direction (cm) */
179  const PSimHit* _hitp;
180  };
181  struct DigiSimInfo {
182  int sig_tot;
183  bool ot_bit;
184  std::vector<std::pair<float, SimHitInfo*> > simInfoList;
185  };
186 } // namespace digitizerUtility
187 #endif
SignalPoint(float x, float y, float sigma_x, float sigma_y, float t, float a=1.0)
Ph2Amplitude(float amp, const PSimHit *hitp, float frac=0, float tcor=0, size_t hitIndex=0, uint32_t tofBin=0)
T z() const
Definition: PV3DBase.h:61
void operator+=(const Ph2Amplitude &other)
void operator+=(const float &amp)
EnergyDepositUnit(float energy, float x, float y, float z)
SimHitInfo(const PSimHit *hitp, float corrTime, size_t hitIndex, uint32_t tofBin)
Amplitude(float amp, const PSimHit *hitp, size_t hitIndex, size_t hitInd4CR, unsigned int tofBin, float frac)
T x() const
Definition: PV3DBase.h:59
T y() const
Definition: PV3DBase.h:60
void operator+=(const float &amp)
std::vector< SimHitInfoForLinks > _hitInfos
const LocalPoint & position() const
SignalPoint(float x, float y, float sigma_x, float sigma_y, float t, const PSimHit &hit, float a=1.0)
EncodedEventId eventId() const
EnergyDepositUnit(float energy, Local3DPoint position)
void migrate_position(const Local3DPoint &pos)
std::vector< std::pair< float, std::unique_ptr< SimHitInfo > > > _simInfoList
const std::vector< float > & individualampl() const
std::vector< std::pair< float, SimHitInfo * > > simInfoList
double a
Definition: hdecay.h:121
static int position[264][3]
Definition: ReadPGInfo.cc:289
const std::vector< SimHitInfoForLinks > & hitInfos() const
SignalPoint & set_amplitude(float amp)
const std::vector< std::pair< float, std::unique_ptr< SimHitInfo > > > & simInfoList() const
std::vector< float > _frac
Amplitude(float amp, float frac)
void operator+=(const Amplitude &other)