CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
HGCFEElectronics.h
Go to the documentation of this file.
1 #ifndef _hgcfeelectronics_h_
2 #define _hgcfeelectronics_h_
3 
6 
7 #include "CLHEP/Random/RandGauss.h"
8 #include "CLHEP/Random/RandGaussQ.h"
9 #include "CLHEP/Random/RandFlat.h"
11 
17 namespace hgc = hgc_digi;
18 
19 namespace hgc_digi {
20  typedef std::array<float, 6> FEADCPulseShape;
21 }
22 
23 template <class DFr>
25 public:
28 
33 
37  inline void runShaper(DFr& dataFrame,
38  hgc::HGCSimHitData& chargeColl,
39  hgc::HGCSimHitData& toa,
40  const hgc_digi::FEADCPulseShape& adcPulse,
41  CLHEP::HepRandomEngine* engine,
42  uint32_t thrADC = 0,
43  float lsbADC = -1,
44  uint32_t gainIdx = 0,
45  float maxADC = -1,
46  int thickness = 1,
47  float tdcOnsetAuto = -1) {
48  switch (fwVersion_) {
49  case SIMPLE: {
50  runSimpleShaper(dataFrame, chargeColl, thrADC, lsbADC, gainIdx, maxADC, adcPulse);
51  break;
52  }
53  case WITHTOT: {
55  dataFrame, chargeColl, toa, engine, thrADC, lsbADC, gainIdx, maxADC, thickness, tdcOnsetAuto, adcPulse);
56  break;
57  }
58  default: {
59  runTrivialShaper(dataFrame, chargeColl, thrADC, lsbADC, gainIdx, maxADC);
60  break;
61  }
62  }
63  }
64  inline void runShaper(DFr& dataFrame,
65  hgc::HGCSimHitData& chargeColl,
66  hgc::HGCSimHitData& toa,
67  CLHEP::HepRandomEngine* engine,
68  uint32_t thrADC = 0,
69  float lsbADC = -1,
70  uint32_t gainIdx = 0,
71  float maxADC = -1,
72  int thickness = 1) {
73  runShaper(dataFrame, chargeColl, toa, adcPulse_, engine, thrADC, lsbADC, gainIdx, maxADC, thickness);
74  }
75 
76  void SetNoiseValues(const std::vector<float>& noise_fC) {
77  noise_fC_.insert(noise_fC_.end(), noise_fC.begin(), noise_fC.end());
78  };
79 
80  float getTimeJitter(float totalCharge, int thickness) {
81  float A2 = jitterNoise2_ns_.at(thickness - 1);
82  float C2 = jitterConstant2_ns_.at(thickness - 1);
83  float X2 = pow((totalCharge / noise_fC_.at(thickness - 1)), 2.);
84  float jitter2 = A2 / X2 + C2;
85  return sqrt(jitter2);
86  };
87 
91  float getADClsb() { return adcLSB_fC_; }
92  float getTDClsb() { return tdcLSB_fC_; }
94  float getADCThreshold() { return adcThreshold_fC_; }
95  float getMaxADC() { return adcSaturation_fC_; }
96  float getMaxTDC() { return tdcSaturation_fC_; }
97  float getTDCOnset() { return tdcOnset_fC_; }
98  std::array<float, 3> getTDCForToAOnset() { return tdcForToAOnset_fC_; }
99  void setADClsb(float newLSB) { adcLSB_fC_ = newLSB; }
100  void setTDCfsc(float newTDCfsc) {
101  tdcSaturation_fC_ = newTDCfsc;
103  // lower tdcSaturation_fC_ by one part in a million
104  // to ensure largest charge converted in bits is 0xfff and not 0x000
105  tdcSaturation_fC_ *= (1. - 1e-6);
106  }
107 
111  void runTrivialShaper(
112  DFr& dataFrame, hgc::HGCSimHitData& chargeColl, uint32_t thrADC, float lsbADC, uint32_t gainIdx, float maxADC);
113 
117  void runSimpleShaper(DFr& dataFrame,
118  hgc::HGCSimHitData& chargeColl,
119  uint32_t thrADC,
120  float lsbADC,
121  uint32_t gainIdx,
122  float maxADC,
123  const hgc_digi::FEADCPulseShape& adcPulse);
125  DFr& dataFrame, hgc::HGCSimHitData& chargeColl, uint32_t thrADC, float lsbADC, uint32_t gainIdx, float maxADC) {
126  runSimpleShaper(dataFrame, chargeColl, thrADC, lsbADC, gainIdx, maxADC, adcPulse_);
127  }
128 
132  void runShaperWithToT(DFr& dataFrame,
133  hgc::HGCSimHitData& chargeColl,
134  hgc::HGCSimHitData& toa,
135  CLHEP::HepRandomEngine* engine,
136  uint32_t thrADC,
137  float lsbADC,
138  uint32_t gainIdx,
139  float maxADC,
140  int thickness,
141  float tdcOnsetAuto,
142  const hgc_digi::FEADCPulseShape& adcPulse);
143  void runShaperWithToT(DFr& dataFrame,
144  hgc::HGCSimHitData& chargeColl,
145  hgc::HGCSimHitData& toa,
146  CLHEP::HepRandomEngine* engine,
147  uint32_t thrADC,
148  float lsbADC,
149  uint32_t gainIdx,
150  float maxADC,
151  int thickness,
152  float tdcOnsetAuto) {
154  dataFrame, chargeColl, toa, engine, thrADC, lsbADC, gainIdx, maxADC, thickness, tdcOnsetAuto, adcPulse_);
155  }
156 
160  uint32_t toaMode() const { return toaMode_; }
161 
166 
171 
172 private:
173  //private members
174  uint32_t fwVersion_;
176  std::array<float, 3> tdcForToAOnset_fC_;
181  std::array<float, 3> jitterNoise2_ns_, jitterConstant2_ns_;
182  std::vector<float> noise_fC_;
183  uint32_t toaMode_;
184  uint32_t tdcNbits_;
186  //caches
187  std::array<bool, hgc::nSamples> busyFlags, totFlags, toaFlags;
189 };
190 
191 #endif
std::array< bool, hgc::nSamples > busyFlags
std::array< float, 3 > jitterConstant2_ns_
void runShaperWithToT(DFr &dataFrame, hgc::HGCSimHitData &chargeColl, hgc::HGCSimHitData &toa, CLHEP::HepRandomEngine *engine, uint32_t thrADC, float lsbADC, uint32_t gainIdx, float maxADC, int thickness, float tdcOnsetAuto, const hgc_digi::FEADCPulseShape &adcPulse)
implements pulse shape and switch to time over threshold including deadtime
void runShaper(DFr &dataFrame, hgc::HGCSimHitData &chargeColl, hgc::HGCSimHitData &toa, CLHEP::HepRandomEngine *engine, uint32_t thrADC=0, float lsbADC=-1, uint32_t gainIdx=0, float maxADC=-1, int thickness=1)
void runShaper(DFr &dataFrame, hgc::HGCSimHitData &chargeColl, hgc::HGCSimHitData &toa, const hgc_digi::FEADCPulseShape &adcPulse, CLHEP::HepRandomEngine *engine, uint32_t thrADC=0, float lsbADC=-1, uint32_t gainIdx=0, float maxADC=-1, int thickness=1, float tdcOnsetAuto=-1)
switches according to the firmware version
std::array< float, 3 > jitterNoise2_ns_
hgc::HGCSimHitData toaFromToT
std::array< HGCSimData_t, nSamples > HGCSimHitData
float getTimeJitter(float totalCharge, int thickness)
HGCFEElectronics(const edm::ParameterSet &ps)
CTOR.
void runShaperWithToT(DFr &dataFrame, hgc::HGCSimHitData &chargeColl, hgc::HGCSimHitData &toa, CLHEP::HepRandomEngine *engine, uint32_t thrADC, float lsbADC, uint32_t gainIdx, float maxADC, int thickness, float tdcOnsetAuto)
T sqrt(T t)
Definition: SSEVec.h:19
std::array< float, 3 > getTDCForToAOnset()
uint32_t targetMIPvalue_ADC_
hgc_digi::FEADCPulseShape adcPulse_
std::vector< float > noise_fC_
hgc_digi::FEADCPulseShape & getDefaultADCPulse()
getter for the default ADC pulse configured by python
float getADClsb()
returns the LSB currently configured
uint32_t toaMode() const
returns how ToT will be computed
void setADClsb(float newLSB)
void SetNoiseValues(const std::vector< float > &noise_fC)
std::array< bool, hgc::nSamples > totFlags
hgc_digi::FEADCPulseShape pulseAvgT_
void setTDCfsc(float newTDCfsc)
void runSimpleShaper(DFr &dataFrame, hgc::HGCSimHitData &chargeColl, uint32_t thrADC, float lsbADC, uint32_t gainIdx, float maxADC, const hgc_digi::FEADCPulseShape &adcPulse)
applies a shape to each time sample and propagates the tails to the subsequent time samples ...
void runTrivialShaper(DFr &dataFrame, hgc::HGCSimHitData &chargeColl, uint32_t thrADC, float lsbADC, uint32_t gainIdx, float maxADC)
converts charge to digis without pulse shape
std::vector< float > tdcChargeDrainParameterisation_
models the behavior of the front-end electronics
void runSimpleShaper(DFr &dataFrame, hgc::HGCSimHitData &chargeColl, uint32_t thrADC, float lsbADC, uint32_t gainIdx, float maxADC)
hgc::HGCSimHitData newCharge
Power< A, B >::type pow(const A &a, const B &b)
Definition: Power.h:29
std::array< float, 6 > FEADCPulseShape
std::array< float, 3 > tdcForToAOnset_fC_
std::array< bool, hgc::nSamples > toaFlags