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 
12 
13 namespace DigitizerUtility {
14  class Amplitude {
15  public:
16  Amplitude() : _amp(0.0) {}
17  Amplitude(float amp, const PSimHit* hitp, float frac = 0, size_t hitIndex = 0, unsigned int tofBin = 0)
18  : _amp(amp) {
19  if (frac > 0) {
20  if (hitp != nullptr)
21  _simInfoList.push_back({frac, std::make_unique<SimHitInfoForLinks>(hitp, hitIndex, tofBin)});
22  else
23  _simInfoList.push_back({frac, nullptr});
24  }
25  }
26 
27  // can be used as a float by convers.
28  operator float() const { return _amp; }
29  float ampl() const { return _amp; }
30  const std::vector<std::pair<float, std::unique_ptr<SimHitInfoForLinks> > >& simInfoList() const {
31  return _simInfoList;
32  }
33 
34  void operator+=(const Amplitude& other) {
35  _amp += other._amp;
36  // in case of digi from the noise, the MC information need not be there
37  for (auto const& ic : other.simInfoList()) {
38  if (ic.first > -0.5)
39  _simInfoList.push_back({ic.first, std::make_unique<SimHitInfoForLinks>(*ic.second)});
40  }
41  }
42  void operator+=(const float& amp) { _amp += amp; }
43  void set(const float amplitude) { // Used to reset the amplitude
44  _amp = amplitude;
45  }
46  // void setind (const float indamplitude) { // Used to reset the amplitude
47  // _frac = idamplitude;
48  // }
49 
50  private:
51  float _amp;
52  std::vector<std::pair<float, std::unique_ptr<SimHitInfoForLinks> > > _simInfoList;
53  };
54 
55  //*********************************************************
56  // Define a class for 3D ionization points and energy
57  //*********************************************************
59  public:
60  EnergyDepositUnit() : _energy(0), _position(0, 0, 0) {}
61  EnergyDepositUnit(float energy, float x, float y, float z) : _energy(energy), _position(x, y, z) {}
62  EnergyDepositUnit(float energy, Local3DPoint position) : _energy(energy), _position(position) {}
63  float x() const { return _position.x(); }
64  float y() const { return _position.y(); }
65  float z() const { return _position.z(); }
66  float energy() const { return _energy; }
67 
68  private:
69  float _energy;
71  };
72 
73  //**********************************************************
74  // define class to store signals on the collection surface
75  //**********************************************************
76  class SignalPoint {
77  public:
78  SignalPoint() : _pos(0, 0), _time(0), _amplitude(0), _sigma_x(1.), _sigma_y(1.), _hitp(nullptr) {}
79 
80  SignalPoint(float x, float y, float sigma_x, float sigma_y, float t, float a = 1.0)
81  : _pos(x, y), _time(t), _amplitude(a), _sigma_x(sigma_x), _sigma_y(sigma_y), _hitp(nullptr) {}
82 
83  SignalPoint(float x, float y, float sigma_x, float sigma_y, float t, const PSimHit& hit, float a = 1.0)
84  : _pos(x, y), _time(t), _amplitude(a), _sigma_x(sigma_x), _sigma_y(sigma_y), _hitp(&hit) {}
85 
86  const LocalPoint& position() const { return _pos; }
87  float x() const { return _pos.x(); }
88  float y() const { return _pos.y(); }
89  float sigma_x() const { return _sigma_x; }
90  float sigma_y() const { return _sigma_y; }
91  float time() const { return _time; }
92  float amplitude() const { return _amplitude; }
93  const PSimHit& hit() { return *_hitp; }
94  SignalPoint& set_amplitude(float amp) {
95  _amplitude = amp;
96  return *this;
97  }
98 
99  private:
101  float _time;
102  float _amplitude;
103  float _sigma_x; // gaussian sigma in the x direction (cm)
104  float _sigma_y; // " " y direction (cm) */
105  const PSimHit* _hitp;
106  };
107  struct DigiSimInfo {
108  int sig_tot;
109  bool ot_bit;
110  std::vector<std::pair<float, SimHitInfoForLinks*> > simInfoList;
111  };
112 } // namespace DigitizerUtility
113 #endif
SignalPoint(float x, float y, float sigma_x, float sigma_y, float t, const PSimHit &hit, float a=1.0)
#define nullptr
SignalPoint(float x, float y, float sigma_x, float sigma_y, float t, float a=1.0)
Amplitude(float amp, const PSimHit *hitp, float frac=0, size_t hitIndex=0, unsigned int tofBin=0)
EnergyDepositUnit(float energy, Local3DPoint position)
std::vector< std::pair< float, std::unique_ptr< SimHitInfoForLinks > > > _simInfoList
SignalPoint & set_amplitude(float amp)
EnergyDepositUnit(float energy, float x, float y, float z)
const LocalPoint & position() const
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
std::vector< std::pair< float, SimHitInfoForLinks * > > simInfoList
const std::vector< std::pair< float, std::unique_ptr< SimHitInfoForLinks > > > & simInfoList() const