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  // void setind (const float indamplitude) { // Used to reset the amplitude
64  // _frac = idamplitude;
65  // }
66 
67  private:
68  float _amp;
69  std::vector<std::pair<float, std::unique_ptr<SimHitInfo> > > _simInfoList;
70  };
71 
72  //*********************************************************
73  // Define a class for 3D ionization points and energy
74  //*********************************************************
76  public:
77  EnergyDepositUnit() : _energy(0), _position(0, 0, 0) {}
78  EnergyDepositUnit(float energy, float x, float y, float z) : _energy(energy), _position(x, y, z) {}
80  float x() const { return _position.x(); }
81  float y() const { return _position.y(); }
82  float z() const { return _position.z(); }
83  float energy() const { return _energy; }
84 
85  // Allow migration between pixel cells
87 
88  private:
89  float _energy;
91  };
92 
93  //**********************************************************
94  // define class to store signals on the collection surface
95  //**********************************************************
96  class SignalPoint {
97  public:
98  SignalPoint() : _pos(0, 0), _time(0), _amplitude(0), _sigma_x(1.), _sigma_y(1.), _hitp(nullptr) {}
99 
100  SignalPoint(float x, float y, float sigma_x, float sigma_y, float t, float a = 1.0)
101  : _pos(x, y), _time(t), _amplitude(a), _sigma_x(sigma_x), _sigma_y(sigma_y), _hitp(nullptr) {}
102 
103  SignalPoint(float x, float y, float sigma_x, float sigma_y, float t, const PSimHit& hit, float a = 1.0)
105 
106  const LocalPoint& position() const { return _pos; }
107  float x() const { return _pos.x(); }
108  float y() const { return _pos.y(); }
109  float sigma_x() const { return _sigma_x; }
110  float sigma_y() const { return _sigma_y; }
111  float time() const { return _time; }
112  float amplitude() const { return _amplitude; }
113  const PSimHit& hit() { return *_hitp; }
115  _amplitude = amp;
116  return *this;
117  }
118 
119  private:
121  float _time;
122  float _amplitude;
123  float _sigma_x; // gaussian sigma in the x direction (cm)
124  float _sigma_y; // " " y direction (cm) */
125  const PSimHit* _hitp;
126  };
127  struct DigiSimInfo {
128  int sig_tot;
129  bool ot_bit;
130  std::vector<std::pair<float, SimHitInfo*> > simInfoList;
131  };
132 } // namespace DigitizerUtility
133 #endif
CustomPhysics_cfi.amplitude
amplitude
Definition: CustomPhysics_cfi.py:12
dqmMemoryStats.float
float
Definition: dqmMemoryStats.py:127
DigitizerUtility::SimHitInfo::time_
float time_
Definition: DigitizerUtility.h:30
PV3DBase::x
T x() const
Definition: PV3DBase.h:59
DigitizerUtility
Definition: DigitizerUtility.h:12
DigitizerUtility::EnergyDepositUnit::y
float y() const
Definition: DigitizerUtility.h:81
cropTnPTrees.frac
frac
Definition: cropTnPTrees.py:18
pos
Definition: PixelAliasList.h:18
DigitizerUtility::SignalPoint::position
const LocalPoint & position() const
Definition: DigitizerUtility.h:106
DigitizerUtility::Amplitude::_simInfoList
std::vector< std::pair< float, std::unique_ptr< SimHitInfo > > > _simInfoList
Definition: DigitizerUtility.h:69
DigitizerUtility::SignalPoint::x
float x() const
Definition: DigitizerUtility.h:107
DigitizerUtility::SimHitInfo::eventId
EncodedEventId eventId() const
Definition: DigitizerUtility.h:21
DigitizerUtility::SimHitInfo::hitIndex
uint32_t hitIndex() const
Definition: DigitizerUtility.h:19
DigitizerUtility::Amplitude::simInfoList
const std::vector< std::pair< float, std::unique_ptr< SimHitInfo > > > & simInfoList() const
Definition: DigitizerUtility.h:49
DigitizerUtility::Amplitude::set
void set(const float amplitude)
Definition: DigitizerUtility.h:60
DigitizerUtility::DigiSimInfo::simInfoList
std::vector< std::pair< float, SimHitInfo * > > simInfoList
Definition: DigitizerUtility.h:130
DigitizerUtility::SignalPoint::_pos
LocalPoint _pos
Definition: DigitizerUtility.h:120
DigitizerUtility::SignalPoint::set_amplitude
SignalPoint & set_amplitude(float amp)
Definition: DigitizerUtility.h:114
PV3DBase::z
T z() const
Definition: PV3DBase.h:61
EncodedEventId
Definition: EncodedEventId.h:11
DigitizerUtility::EnergyDepositUnit
Definition: DigitizerUtility.h:75
DigitizerUtility::SimHitInfo::time
float time() const
Definition: DigitizerUtility.h:23
DigitizerUtility::EnergyDepositUnit::_energy
float _energy
Definition: DigitizerUtility.h:89
DigitizerUtility::SignalPoint::sigma_x
float sigma_x() const
Definition: DigitizerUtility.h:109
PSimHit.h
DigitizerUtility::SimHitInfo::trackId
uint32_t trackId() const
Definition: DigitizerUtility.h:22
DigitizerUtility::DigiSimInfo::sig_tot
int sig_tot
Definition: DigitizerUtility.h:128
DigitizerUtility::SimHitInfo::tofBin
uint32_t tofBin() const
Definition: DigitizerUtility.h:20
DigitizerUtility::Amplitude::Amplitude
Amplitude(float amp, const PSimHit *hitp, float frac=0, float tcor=0, size_t hitIndex=0, uint32_t tofBin=0)
Definition: DigitizerUtility.h:36
DigitizerUtility::SignalPoint::_time
float _time
Definition: DigitizerUtility.h:121
DigitizerUtility::Amplitude
Definition: DigitizerUtility.h:33
DigitizerUtility::SignalPoint::amplitude
float amplitude() const
Definition: DigitizerUtility.h:112
trackingPlots.other
other
Definition: trackingPlots.py:1465
Point3DBase< float, LocalTag >
OrderedSet.t
t
Definition: OrderedSet.py:90
DigitizerUtility::SignalPoint::_sigma_x
float _sigma_x
Definition: DigitizerUtility.h:123
DigitizerUtility::SimHitInfo::hitIndex_
uint32_t hitIndex_
Definition: DigitizerUtility.h:28
DigitizerUtility::EnergyDepositUnit::x
float x() const
Definition: DigitizerUtility.h:80
a
double a
Definition: hdecay.h:119
DigitizerUtility::SignalPoint::_sigma_y
float _sigma_y
Definition: DigitizerUtility.h:124
DigitizerUtility::SimHitInfo::trackId_
uint32_t trackId_
Definition: DigitizerUtility.h:27
DigitizerUtility::SimHitInfo::SimHitInfo
SimHitInfo(const PSimHit *hitp, float corrTime, size_t hitIndex, uint32_t tofBin)
Definition: DigitizerUtility.h:16
DigitizerUtility::SignalPoint::time
float time() const
Definition: DigitizerUtility.h:111
DigitizerUtility::EnergyDepositUnit::EnergyDepositUnit
EnergyDepositUnit(float energy, float x, float y, float z)
Definition: DigitizerUtility.h:78
DigitizerUtility::EnergyDepositUnit::z
float z() const
Definition: DigitizerUtility.h:82
position
static int position[264][3]
Definition: ReadPGInfo.cc:289
PV3DBase::y
T y() const
Definition: PV3DBase.h:60
DigitizerUtility::Amplitude::_amp
float _amp
Definition: DigitizerUtility.h:68
DigitizerUtility::SignalPoint::SignalPoint
SignalPoint(float x, float y, float sigma_x, float sigma_y, float t, float a=1.0)
Definition: DigitizerUtility.h:100
DigitizerUtility::EnergyDepositUnit::EnergyDepositUnit
EnergyDepositUnit(float energy, Local3DPoint position)
Definition: DigitizerUtility.h:79
DigitizerUtility::SignalPoint::_hitp
const PSimHit * _hitp
Definition: DigitizerUtility.h:125
DigitizerUtility::DigiSimInfo::ot_bit
bool ot_bit
Definition: DigitizerUtility.h:129
DigitizerUtility::EnergyDepositUnit::migrate_position
void migrate_position(const Local3DPoint &pos)
Definition: DigitizerUtility.h:86
DigitizerUtility::SimHitInfo::eventId_
EncodedEventId eventId_
Definition: DigitizerUtility.h:23
DigitizerUtility::Amplitude::operator+=
void operator+=(const Amplitude &other)
Definition: DigitizerUtility.h:51
DigitizerUtility::SimHitInfo
Definition: DigitizerUtility.h:14
DigitizerUtility::EnergyDepositUnit::EnergyDepositUnit
EnergyDepositUnit()
Definition: DigitizerUtility.h:77
DigitizerUtility::SignalPoint::SignalPoint
SignalPoint(float x, float y, float sigma_x, float sigma_y, float t, const PSimHit &hit, float a=1.0)
Definition: DigitizerUtility.h:103
DigitizerUtility::Amplitude::operator+=
void operator+=(const float &amp)
Definition: DigitizerUtility.h:59
DigitizerUtility::SignalPoint::hit
const PSimHit & hit()
Definition: DigitizerUtility.h:113
DigitizerUtility::SignalPoint
Definition: DigitizerUtility.h:96
DigitizerUtility::DigiSimInfo
Definition: DigitizerUtility.h:127
DigitizerUtility::SignalPoint::SignalPoint
SignalPoint()
Definition: DigitizerUtility.h:98
DigitizerUtility::Amplitude::ampl
float ampl() const
Definition: DigitizerUtility.h:48
PSimHit
Definition: PSimHit.h:15
DigitizerUtility::SignalPoint::_amplitude
float _amplitude
Definition: DigitizerUtility.h:122
DigitizerUtility::SignalPoint::y
float y() const
Definition: DigitizerUtility.h:108
DigitizerUtility::EnergyDepositUnit::_position
Local3DPoint _position
Definition: DigitizerUtility.h:90
DigitizerUtility::SignalPoint::sigma_y
float sigma_y() const
Definition: DigitizerUtility.h:110
DigitizerUtility::Amplitude::Amplitude
Amplitude()
Definition: DigitizerUtility.h:35
DigitizerUtility::SimHitInfo::tofBin_
uint32_t tofBin_
Definition: DigitizerUtility.h:29
hit
Definition: SiStripHitEffFromCalibTree.cc:88
DigitizerUtility::EnergyDepositUnit::energy
float energy() const
Definition: DigitizerUtility.h:83
EncodedEventId.h