CMS 3D CMS Logo

DigitizerUtility.h
Go to the documentation of this file.
1 #ifndef __SimTracker_SiPhase2Digitizer_DigitizerUtility_h
2 #define __SimTracker_SiPhase2Digitizer_DigitizerUtility_h
3 
4 #include <map>
5 #include <memory>
6 #include <vector>
7 #include <iostream>
8 
11 
12 namespace DigitizerUtility {
13 
14  class SimHitInfo {
15  public:
16  SimHitInfo(const PSimHit* hitp, float corrTime, size_t hitIndex, uint32_t tofBin)
17  : eventId_(hitp->eventId()), trackId_(hitp->trackId()), hitIndex_(hitIndex), tofBin_(tofBin), time_(corrTime) {}
18 
19  uint32_t hitIndex() const { return hitIndex_; };
20  uint32_t tofBin() const { return tofBin_; };
21  EncodedEventId eventId() const { return eventId_; };
22  uint32_t trackId() const { return trackId_; };
23  float time() const { return time_; };
24 
25  private:
27  uint32_t trackId_;
28  uint32_t hitIndex_;
29  uint32_t tofBin_;
30  float time_;
31  };
32 
33  class Amplitude {
34  public:
35  Amplitude() : _amp(0.0) {}
36  Amplitude(float amp, const PSimHit* hitp, float frac = 0, float tcor = 0, size_t hitIndex = 0, uint32_t tofBin = 0)
37  : _amp(amp) {
38  if (frac > 0) {
39  if (hitp != nullptr)
40  _simInfoList.push_back({frac, std::make_unique<SimHitInfo>(hitp, tcor, hitIndex, tofBin)});
41  else
42  _simInfoList.push_back({frac, nullptr});
43  }
44  }
45 
46  // can be used as a float by convers.
47  operator float() const { return _amp; }
48  float ampl() const { return _amp; }
49  const std::vector<std::pair<float, std::unique_ptr<SimHitInfo> > >& simInfoList() const { return _simInfoList; }
50 
51  void operator+=(const Amplitude& other) {
52  _amp += other._amp;
53  // in case of digi from the noise, the MC information need not be there
54  for (auto const& ic : other.simInfoList()) {
55  if (ic.first > -0.5)
56  _simInfoList.push_back({ic.first, std::make_unique<SimHitInfo>(*ic.second)});
57  }
58  }
59  void operator+=(const float& amp) { _amp += amp; }
60  void set(const float amplitude) { // Used to reset the amplitude
61  _amp = amplitude;
62  }
63 
64  private:
65  float _amp;
66  std::vector<std::pair<float, std::unique_ptr<SimHitInfo> > > _simInfoList;
67  };
68 
69  //*********************************************************
70  // Define a class for 3D ionization points and energy
71  //*********************************************************
73  public:
74  EnergyDepositUnit() : _energy(0), _position(0, 0, 0) {}
75  EnergyDepositUnit(float energy, float x, float y, float z) : _energy(energy), _position(x, y, z) {}
77  float x() const { return _position.x(); }
78  float y() const { return _position.y(); }
79  float z() const { return _position.z(); }
80  float energy() const { return _energy; }
81 
82  // Allow migration between pixel cells
84 
85  private:
86  float _energy;
88  };
89 
90  //**********************************************************
91  // define class to store signals on the collection surface
92  //**********************************************************
93  class SignalPoint {
94  public:
95  SignalPoint() : _pos(0, 0), _time(0), _amplitude(0), _sigma_x(1.), _sigma_y(1.), _hitp(nullptr) {}
96 
97  SignalPoint(float x, float y, float sigma_x, float sigma_y, float t, float a = 1.0)
98  : _pos(x, y), _time(t), _amplitude(a), _sigma_x(sigma_x), _sigma_y(sigma_y), _hitp(nullptr) {}
99 
100  SignalPoint(float x, float y, float sigma_x, float sigma_y, float t, const PSimHit& hit, float a = 1.0)
102 
103  const LocalPoint& position() const { return _pos; }
104  float x() const { return _pos.x(); }
105  float y() const { return _pos.y(); }
106  float sigma_x() const { return _sigma_x; }
107  float sigma_y() const { return _sigma_y; }
108  float time() const { return _time; }
109  float amplitude() const { return _amplitude; }
110  const PSimHit& hit() { return *_hitp; }
112  _amplitude = amp;
113  return *this;
114  }
115 
116  private:
118  float _time;
119  float _amplitude;
120  float _sigma_x; // gaussian sigma in the x direction (cm)
121  float _sigma_y; // " " y direction (cm) */
122  const PSimHit* _hitp;
123  };
124  struct DigiSimInfo {
125  int sig_tot;
126  bool ot_bit;
127  std::vector<std::pair<float, SimHitInfo*> > simInfoList;
128  };
129 } // namespace DigitizerUtility
130 #endif
SimHitInfo(const PSimHit *hitp, float corrTime, size_t hitIndex, uint32_t tofBin)
SignalPoint(float x, float y, float sigma_x, float sigma_y, float t, const PSimHit &hit, float a=1.0)
T z() const
Definition: PV3DBase.h:61
const std::vector< std::pair< float, std::unique_ptr< SimHitInfo > > > & simInfoList() const
const LocalPoint & position() const
std::vector< std::pair< float, std::unique_ptr< SimHitInfo > > > _simInfoList
SignalPoint(float x, float y, float sigma_x, float sigma_y, float t, float a=1.0)
T x() const
Definition: PV3DBase.h:59
T y() const
Definition: PV3DBase.h:60
EnergyDepositUnit(float energy, Local3DPoint position)
EncodedEventId eventId() const
Amplitude(float amp, const PSimHit *hitp, float frac=0, float tcor=0, size_t hitIndex=0, uint32_t tofBin=0)
SignalPoint & set_amplitude(float amp)
std::vector< std::pair< float, SimHitInfo * > > simInfoList
EnergyDepositUnit(float energy, float x, float y, float z)
void migrate_position(const Local3DPoint &pos)
void operator+=(const Amplitude &other)
void operator+=(const float &amp)
double a
Definition: hdecay.h:119
static int position[264][3]
Definition: ReadPGInfo.cc:289