CMS 3D CMS Logo

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,
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  float noiseWidth = -1) {
49  switch (fwVersion_) {
50  case SIMPLE: {
51  runSimpleShaper(dataFrame, chargeColl, thrADC, lsbADC, gainIdx, maxADC, adcPulse);
52  break;
53  }
54  case WITHTOT: {
55  runShaperWithToT(dataFrame,
56  chargeColl,
57  toa,
58  engine,
59  thrADC,
60  lsbADC,
61  gainIdx,
62  maxADC,
63  thickness,
64  tdcOnsetAuto,
65  noiseWidth,
66  adcPulse);
67  break;
68  }
69  default: {
70  runTrivialShaper(dataFrame, chargeColl, thrADC, lsbADC, gainIdx, maxADC);
71  break;
72  }
73  }
74  }
75  inline void runShaper(DFr& dataFrame,
76  hgc::HGCSimHitData& chargeColl,
77  hgc::HGCSimHitData& toa,
78  CLHEP::HepRandomEngine* engine,
79  uint32_t thrADC = 0,
80  float lsbADC = -1,
81  uint32_t gainIdx = 0,
82  float maxADC = -1,
83  int thickness = 1) {
84  runShaper(dataFrame, chargeColl, toa, adcPulse_, engine, thrADC, lsbADC, gainIdx, maxADC, thickness);
85  }
86 
87  void SetNoiseValues(const std::vector<float>& noise_fC) {
88  noise_fC_.insert(noise_fC_.end(), noise_fC.begin(), noise_fC.end());
89  };
90 
91  void generateTimeOffset(CLHEP::HepRandomEngine* engine) {
92  for (int i = 0; i < 3; i++)
93  eventTimeOffset_ns_[i] = CLHEP::RandGaussQ::shoot(engine, 0, jitterConstant_ns_[i]);
94  };
95 
99  float getADClsb() { return adcLSB_fC_; }
100  float getTDClsb() { return tdcLSB_fC_; }
102  float getADCThreshold() { return adcThreshold_fC_; }
103  float getMaxADC() { return adcSaturation_fC_; }
104  float getMaxTDC() { return tdcSaturation_fC_; }
105  float getTDCOnset() { return tdcOnset_fC_; }
106  std::array<float, 3> getTDCForToAOnset() { return tdcForToAOnset_fC_; }
107  void setADClsb(float newLSB) { adcLSB_fC_ = newLSB; }
108  void setTDCfsc(float newTDCfsc) {
109  tdcSaturation_fC_ = newTDCfsc;
111  // lower tdcSaturation_fC_ by one part in a million
112  // to ensure largest charge converted in bits is 0xfff and not 0x000
113  tdcSaturation_fC_ *= (1. - 1e-6);
114  }
115 
119  void runTrivialShaper(
120  DFr& dataFrame, hgc::HGCSimHitData& chargeColl, uint32_t thrADC, float lsbADC, uint32_t gainIdx, float maxADC);
121 
125  void runSimpleShaper(DFr& dataFrame,
126  hgc::HGCSimHitData& chargeColl,
127  uint32_t thrADC,
128  float lsbADC,
129  uint32_t gainIdx,
130  float maxADC,
133  DFr& dataFrame, hgc::HGCSimHitData& chargeColl, uint32_t thrADC, float lsbADC, uint32_t gainIdx, float maxADC) {
134  runSimpleShaper(dataFrame, chargeColl, thrADC, lsbADC, gainIdx, maxADC, adcPulse_);
135  }
136 
140  void runShaperWithToT(DFr& dataFrame,
141  hgc::HGCSimHitData& chargeColl,
142  hgc::HGCSimHitData& toa,
143  CLHEP::HepRandomEngine* engine,
144  uint32_t thrADC,
145  float lsbADC,
146  uint32_t gainIdx,
147  float maxADC,
148  int thickness,
149  float tdcOnsetAuto,
150  float noiseWidth,
152  void runShaperWithToT(DFr& dataFrame,
153  hgc::HGCSimHitData& chargeColl,
154  hgc::HGCSimHitData& toa,
155  CLHEP::HepRandomEngine* engine,
156  uint32_t thrADC,
157  float lsbADC,
158  uint32_t gainIdx,
159  float maxADC,
160  int thickness,
161  float tdcOnsetAuto,
162  float noiseWidth) {
163  runShaperWithToT(dataFrame,
164  chargeColl,
165  toa,
166  engine,
167  thrADC,
168  lsbADC,
169  gainIdx,
170  maxADC,
171  thickness,
172  tdcOnsetAuto,
173  noiseWidth,
174  adcPulse_);
175  }
176 
180  uint32_t toaMode() const { return toaMode_; }
181 
186 
191 
192 private:
193  //private members
194  uint32_t fwVersion_;
196  std::array<float, 3> tdcForToAOnset_fC_;
202  std::vector<float> noise_fC_;
203  uint32_t toaMode_;
204  uint32_t tdcNbits_;
206  //caches
207  std::array<bool, hgc::nSamples> busyFlags, totFlags, toaFlags;
209 };
210 
211 #endif
std::array< bool, hgc::nSamples > busyFlags
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 generateTimeOffset(CLHEP::HepRandomEngine *engine)
hgc::HGCSimHitData toaFromToT
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, float noiseWidth, const hgc_digi::FEADCPulseShape &adcPulse)
implements pulse shape and switch to time over threshold including deadtime
uint32_t toaMode() const
returns how ToT will be computed
std::array< HGCSimData_t, nSamples > HGCSimHitData
HGCFEElectronics(const edm::ParameterSet &ps)
CTOR.
std::array< float, 3 > jitterNoise_ns_
std::array< float, 3 > getTDCForToAOnset()
uint32_t targetMIPvalue_ADC_
hgc_digi::FEADCPulseShape adcPulse_
std::vector< float > noise_fC_
std::array< float, 3 > eventTimeOffset_ns_
hgc_digi::FEADCPulseShape & getDefaultADCPulse()
getter for the default ADC pulse configured by python
float getADClsb()
returns the LSB currently configured
void setADClsb(float newLSB)
void SetNoiseValues(const std::vector< float > &noise_fC)
std::array< bool, hgc::nSamples > totFlags
hgc_digi::FEADCPulseShape pulseAvgT_
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, float noiseWidth)
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 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, float noiseWidth=-1)
switches according to the firmware version
std::array< float, 3 > jitterConstant_ns_
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