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 template <class DFr>
21 public:
24 
29 
33  inline void runShaper(DFr& dataFrame,
34  hgc::HGCSimHitData& chargeColl,
35  hgc::HGCSimHitData& toa,
36  CLHEP::HepRandomEngine* engine,
37  uint32_t thrADC = 0,
38  float lsbADC = -1,
39  uint32_t gainIdx = 0,
40  float maxADC = -1,
41  int thickness = 1) {
42  switch (fwVersion_) {
43  case SIMPLE: {
44  runSimpleShaper(dataFrame, chargeColl, thrADC, lsbADC, gainIdx, maxADC);
45  break;
46  }
47  case WITHTOT: {
48  runShaperWithToT(dataFrame, chargeColl, toa, engine, thrADC, lsbADC, gainIdx, maxADC, thickness);
49  break;
50  }
51  default: {
52  runTrivialShaper(dataFrame, chargeColl, thrADC, lsbADC, gainIdx, maxADC);
53  break;
54  }
55  }
56  }
57 
58  void SetNoiseValues(const std::vector<float>& noise_fC) {
59  noise_fC_.insert(noise_fC_.end(), noise_fC.begin(), noise_fC.end());
60  };
61 
62  float getTimeJitter(float totalCharge, int thickness) {
63  float A2 = jitterNoise2_ns_.at(thickness - 1);
64  float C2 = jitterConstant2_ns_.at(thickness - 1);
65  float X2 = pow((totalCharge / noise_fC_.at(thickness - 1)), 2.);
66  float jitter2 = A2 / X2 + C2;
67  return sqrt(jitter2);
68  };
69 
73  float getADClsb() { return adcLSB_fC_; }
74  float getTDClsb() { return tdcLSB_fC_; }
76  float getADCThreshold() { return adcThreshold_fC_; }
77  float getTDCOnset() { return tdcOnset_fC_; }
78  std::array<float, 3> getTDCForToAOnset() { return tdcForToAOnset_fC_; }
79  void setADClsb(float newLSB) { adcLSB_fC_ = newLSB; }
80 
84  void runTrivialShaper(
85  DFr& dataFrame, hgc::HGCSimHitData& chargeColl, uint32_t thrADC, float lsbADC, uint32_t gainIdx, float maxADC);
86 
90  void runSimpleShaper(
91  DFr& dataFrame, hgc::HGCSimHitData& chargeColl, uint32_t thrADC, float lsbADC, uint32_t gainIdx, float maxADC);
92 
96  void runShaperWithToT(DFr& dataFrame,
97  hgc::HGCSimHitData& chargeColl,
98  hgc::HGCSimHitData& toa,
99  CLHEP::HepRandomEngine* engine,
100  uint32_t thrADC,
101  float lsbADC,
102  uint32_t gainIdx,
103  float maxADC,
104  int thickness);
105 
109  uint32_t toaMode() const { return toaMode_; }
110 
115 
116 private:
117  //private members
118  uint32_t fwVersion_;
119  std::array<float, 6> adcPulse_, pulseAvgT_;
120  std::array<float, 3> tdcForToAOnset_fC_;
125  std::array<float, 3> jitterNoise2_ns_, jitterConstant2_ns_;
126  std::vector<float> noise_fC_;
127  uint32_t toaMode_;
129  //caches
130  std::array<bool, hgc::nSamples> busyFlags, totFlags, toaFlags;
132 };
133 
134 #endif
std::array< bool, hgc::nSamples > busyFlags
std::array< float, 3 > jitterConstant2_ns_
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)
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.
T sqrt(T t)
Definition: SSEVec.h:19
std::array< float, 3 > getTDCForToAOnset()
uint32_t targetMIPvalue_ADC_
std::vector< float > noise_fC_
float getADClsb()
returns the LSB in MIP 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
std::array< float, 6 > adcPulse_
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)
implements pulse shape and switch to time over threshold including deadtime
std::array< float, 6 > pulseAvgT_
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)
applies a shape to each time sample and propagates the tails to the subsequent time samples ...
hgc::HGCSimHitData newCharge
Power< A, B >::type pow(const A &a, const B &b)
Definition: Power.h:30
std::array< float, 3 > tdcForToAOnset_fC_
std::array< bool, hgc::nSamples > toaFlags