CMS 3D CMS Logo

List of all members | Public Types | Public Member Functions | Private Attributes
HGCFEElectronics< DFr > Class Template Reference

models the behavior of the front-end electronics More...

#include <HGCFEElectronics.h>

Public Types

enum  HGCFEElectronicsFirmwareVersion { TRIVIAL, SIMPLE, WITHTOT }
 
enum  HGCFEElectronicsTOTMode { WEIGHTEDBYE, SIMPLETHRESHOLD }
 

Public Member Functions

float getADClsb ()
 returns the LSB in MIP currently configured More...
 
float getADCThreshold ()
 
int getTargetMipValue ()
 
std::array< float, 3 > getTDCForToAOnset ()
 
float getTDClsb ()
 
float getTDCOnset ()
 
float getTimeJitter (float totalCharge, int thickness)
 
 HGCFEElectronics (const edm::ParameterSet &ps)
 CTOR. More...
 
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 More...
 
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 More...
 
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 More...
 
void runTrivialShaper (DFr &dataFrame, hgc::HGCSimHitData &chargeColl, uint32_t thrADC, float lsbADC, uint32_t gainIdx, float maxADC)
 converts charge to digis without pulse shape More...
 
void setADClsb (float newLSB)
 
void SetNoiseValues (const std::vector< float > &noise_fC)
 
uint32_t toaMode () const
 returns how ToT will be computed More...
 
 ~HGCFEElectronics ()
 DTOR. More...
 

Private Attributes

float adcLSB_fC_
 
std::array< float, 6 > adcPulse_
 
float adcSaturation_fC_
 
float adcThreshold_fC_
 
std::array< bool, hgc::nSamples > busyFlags
 
uint32_t fwVersion_
 
std::array< float, 3 > jitterConstant2_ns_
 
std::array< float, 3 > jitterNoise2_ns_
 
hgc::HGCSimHitData newCharge
 
std::vector< float > noise_fC_
 
std::array< float, 6 > pulseAvgT_
 
uint32_t targetMIPvalue_ADC_
 
std::vector< float > tdcChargeDrainParameterisation_
 
std::array< float, 3 > tdcForToAOnset_fC_
 
float tdcLSB_fC_
 
float tdcOnset_fC_
 
float tdcResolutionInNs_
 
float tdcSaturation_fC_
 
bool thresholdFollowsMIP_
 
std::array< bool, hgc::nSamples > toaFlags
 
hgc::HGCSimHitData toaFromToT
 
float toaLSB_ns_
 
uint32_t toaMode_
 
std::array< bool, hgc::nSamples > totFlags
 

Detailed Description

template<class DFr>
class HGCFEElectronics< DFr >

models the behavior of the front-end electronics

Definition at line 20 of file HGCFEElectronics.h.

Member Enumeration Documentation

◆ HGCFEElectronicsFirmwareVersion

Enumerator
TRIVIAL 
SIMPLE 
WITHTOT 

Definition at line 22 of file HGCFEElectronics.h.

22 { TRIVIAL, SIMPLE, WITHTOT };

◆ HGCFEElectronicsTOTMode

template<class DFr >
enum HGCFEElectronics::HGCFEElectronicsTOTMode
Enumerator
WEIGHTEDBYE 
SIMPLETHRESHOLD 

Definition at line 23 of file HGCFEElectronics.h.

Constructor & Destructor Documentation

◆ HGCFEElectronics()

template<class DFr >
HGCFEElectronics< DFr >::HGCFEElectronics ( const edm::ParameterSet ps)

CTOR.

Definition at line 11 of file HGCFEElectronics.cc.

12  : fwVersion_{ps.getParameter<uint32_t>("fwVersion")},
13  adcPulse_{},
14  pulseAvgT_{},
16  adcSaturation_fC_{-1.0},
17  adcLSB_fC_{},
18  tdcLSB_fC_{},
19  tdcSaturation_fC_{-1.0},
21  tdcOnset_fC_{},
22  toaLSB_ns_{},
23  tdcResolutionInNs_{1e-9}, // set time resolution very small by default
27  noise_fC_{},
29  edm::LogVerbatim("HGCFE") << "[HGCFEElectronics] running with version " << fwVersion_ << std::endl;
30  if (ps.exists("adcPulse")) {
31  auto temp = ps.getParameter<std::vector<double> >("adcPulse");
32  for (unsigned i = 0; i < temp.size(); ++i) {
33  adcPulse_[i] = (float)temp[i];
34  }
35  // normalize adc pulse
36  for (unsigned i = 0; i < adcPulse_.size(); ++i) {
37  adcPulse_[i] = adcPulse_[i] / adcPulse_[2];
38  }
39  temp = ps.getParameter<std::vector<double> >("pulseAvgT");
40  for (unsigned i = 0; i < temp.size(); ++i) {
41  pulseAvgT_[i] = (float)temp[i];
42  }
43  }
44  if (ps.exists("adcNbits")) {
45  uint32_t adcNbits = ps.getParameter<uint32_t>("adcNbits");
46  adcSaturation_fC_ = ps.getParameter<double>("adcSaturation_fC");
48  edm::LogVerbatim("HGCFE") << "[HGCFEElectronics] " << adcNbits << " bit ADC defined"
49  << " with LSB=" << adcLSB_fC_ << " saturation to occur @ " << adcSaturation_fC_
50  << std::endl;
51  }
52 
53  if (ps.exists("tdcNbits")) {
54  uint32_t tdcNbits = ps.getParameter<uint32_t>("tdcNbits");
55  tdcSaturation_fC_ = ps.getParameter<double>("tdcSaturation_fC");
57  // lower tdcSaturation_fC_ by one part in a million
58  // to ensure largest charge converted in bits is 0xfff and not 0x000
59  tdcSaturation_fC_ *= (1. - 1e-6);
60  edm::LogVerbatim("HGCFE") << "[HGCFEElectronics] " << tdcNbits << " bit TDC defined with LSB=" << tdcLSB_fC_
61  << " saturation to occur @ " << tdcSaturation_fC_
62  << " (NB lowered by 1 part in a million)" << std::endl;
63  }
64  if (ps.exists("targetMIPvalue_ADC"))
65  targetMIPvalue_ADC_ = ps.getParameter<uint32_t>("targetMIPvalue_ADC");
66  if (ps.exists("adcThreshold_fC"))
67  adcThreshold_fC_ = ps.getParameter<double>("adcThreshold_fC");
68  if (ps.exists("tdcOnset_fC"))
69  tdcOnset_fC_ = ps.getParameter<double>("tdcOnset_fC");
70  if (ps.exists("tdcForToAOnset_fC")) {
71  auto temp = ps.getParameter<std::vector<double> >("tdcForToAOnset_fC");
72  if (temp.size() == tdcForToAOnset_fC_.size()) {
73  std::copy_n(temp.begin(), temp.size(), tdcForToAOnset_fC_.begin());
74  } else {
75  throw cms::Exception("BadConfiguration") << " HGCFEElectronics wrong size for ToA thresholds ";
76  }
77  }
78  if (ps.exists("toaLSB_ns"))
79  toaLSB_ns_ = ps.getParameter<double>("toaLSB_ns");
80  if (ps.exists("tdcChargeDrainParameterisation")) {
81  for (auto val : ps.getParameter<std::vector<double> >("tdcChargeDrainParameterisation")) {
82  tdcChargeDrainParameterisation_.push_back((float)val);
83  }
84  }
85  if (ps.exists("tdcResolutionInPs"))
86  tdcResolutionInNs_ = ps.getParameter<double>("tdcResolutionInPs") * 1e-3; // convert to ns
87  if (ps.exists("toaMode"))
88  toaMode_ = ps.getParameter<uint32_t>("toaMode");
89 
90  if (ps.exists("jitterNoise_ns")) {
91  auto temp = ps.getParameter<std::vector<double> >("jitterNoise_ns");
92  if (temp.size() == jitterNoise2_ns_.size()) {
93  std::copy_n(temp.begin(), temp.size(), jitterNoise2_ns_.begin());
94  } else {
95  throw cms::Exception("BadConfiguration") << " HGCFEElectronics wrong size for ToA jitterNoise ";
96  }
97  }
98  if (ps.exists("jitterConstant_ns")) {
99  auto temp = ps.getParameter<std::vector<double> >("jitterConstant_ns");
100  if (temp.size() == jitterConstant2_ns_.size()) {
101  std::copy_n(temp.begin(), temp.size(), jitterConstant2_ns_.begin());
102  } else {
103  throw cms::Exception("BadConfiguration") << " HGCFEElectronics wrong size for ToA jitterConstant ";
104  }
105  }
106 }

References edm::ParameterSet::getParameter().

◆ ~HGCFEElectronics()

template<class DFr >
HGCFEElectronics< DFr >::~HGCFEElectronics ( )
inline

DTOR.

Definition at line 114 of file HGCFEElectronics.h.

114 {}

Member Function Documentation

◆ getADClsb()

template<class DFr >
float HGCFEElectronics< DFr >::getADClsb ( )
inline

returns the LSB in MIP currently configured

Definition at line 73 of file HGCFEElectronics.h.

73 { return adcLSB_fC_; }

References HGCFEElectronics< DFr >::adcLSB_fC_.

◆ getADCThreshold()

template<class DFr >
float HGCFEElectronics< DFr >::getADCThreshold ( )
inline

Definition at line 76 of file HGCFEElectronics.h.

76 { return adcThreshold_fC_; }

References HGCFEElectronics< DFr >::adcThreshold_fC_.

◆ getTargetMipValue()

template<class DFr >
int HGCFEElectronics< DFr >::getTargetMipValue ( )
inline

Definition at line 75 of file HGCFEElectronics.h.

75 { return targetMIPvalue_ADC_; }

References HGCFEElectronics< DFr >::targetMIPvalue_ADC_.

◆ getTDCForToAOnset()

template<class DFr >
std::array<float, 3> HGCFEElectronics< DFr >::getTDCForToAOnset ( )
inline

Definition at line 78 of file HGCFEElectronics.h.

78 { return tdcForToAOnset_fC_; }

References HGCFEElectronics< DFr >::tdcForToAOnset_fC_.

◆ getTDClsb()

template<class DFr >
float HGCFEElectronics< DFr >::getTDClsb ( )
inline

Definition at line 74 of file HGCFEElectronics.h.

74 { return tdcLSB_fC_; }

References HGCFEElectronics< DFr >::tdcLSB_fC_.

◆ getTDCOnset()

template<class DFr >
float HGCFEElectronics< DFr >::getTDCOnset ( )
inline

Definition at line 77 of file HGCFEElectronics.h.

77 { return tdcOnset_fC_; }

References HGCFEElectronics< DFr >::tdcOnset_fC_.

◆ getTimeJitter()

template<class DFr >
float HGCFEElectronics< DFr >::getTimeJitter ( float  totalCharge,
int  thickness 
)
inline

Definition at line 62 of file HGCFEElectronics.h.

62  {
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  };

References HGCFEElectronics< DFr >::jitterConstant2_ns_, HGCFEElectronics< DFr >::jitterNoise2_ns_, HGCFEElectronics< DFr >::noise_fC_, funct::pow(), mathSSE::sqrt(), and Calorimetry_cff::thickness.

◆ runShaper()

template<class DFr >
void HGCFEElectronics< DFr >::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 
)
inline

switches according to the firmware version

Definition at line 33 of file HGCFEElectronics.h.

41  {
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  }

References HGCFEElectronics< DFr >::fwVersion_, HGCFEElectronics< DFr >::runShaperWithToT(), HGCFEElectronics< DFr >::runSimpleShaper(), HGCFEElectronics< DFr >::runTrivialShaper(), HGCFEElectronics< DFr >::SIMPLE, Calorimetry_cff::thickness, and HGCFEElectronics< DFr >::WITHTOT.

◆ runShaperWithToT()

template<class DFr >
void HGCFEElectronics< DFr >::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

Definition at line 202 of file HGCFEElectronics.cc.

210  {
211  busyFlags.fill(false);
212  totFlags.fill(false);
213  toaFlags.fill(false);
214  newCharge.fill(0.f);
215  toaFromToT.fill(0.f);
216 
217 #ifdef EDM_ML_DEBUG
218  constexpr bool debug_state(true);
219 #else
220  constexpr bool debug_state(false);
221 #endif
222 
223  bool debug = debug_state;
224  float timeToA = 0.f;
225 
226  //first look at time
227  //for pileup look only at intime signals
228  //ToA is in central BX if fired -- std::floor(BX/25.)+9;
229  int fireBX = 9;
230  //noise fluctuation on charge is added after ToA computation
231  //do not recheck the ToA firing threshold tdcForToAOnset_fC_[thickness-1] not to bias the efficiency
232  //to be done properly with realistic ToA shaper and jitter for the moment accounted in the smearing
233  if (toaColl[fireBX] != 0.f) {
234  timeToA = toaColl[fireBX];
235  float jitter = getTimeJitter(chargeColl[fireBX], thickness);
236  if (jitter != 0)
237  timeToA = CLHEP::RandGaussQ::shoot(engine, timeToA, jitter);
238  else if (tdcResolutionInNs_ != 0)
239  timeToA = CLHEP::RandGaussQ::shoot(engine, timeToA, tdcResolutionInNs_);
240  if (timeToA >= 0.f && timeToA <= 25.f)
241  toaFlags[fireBX] = true;
242  }
243 
244  //now look at charge
245  //first identify bunches which will trigger ToT
246  //if(debug_state) edm::LogVerbatim("HGCFE") << "[runShaperWithToT]" << std::endl;
247  for (int it = 0; it < (int)(chargeColl.size()); ++it) {
248  debug = debug_state;
249  //if already flagged as busy it can't be re-used to trigger the ToT
250  if (busyFlags[it])
251  continue;
252 
253  //if below TDC onset will be handled by SARS ADC later
254  float charge = chargeColl[it];
255  if (charge < tdcOnset_fC_) {
256  debug = false;
257  continue;
258  }
259 
260  //raise TDC mode for charge computation
261  //ToA anyway fired independently will be sorted out with realistic ToA dedicated shaper
262  float toa = timeToA;
263  totFlags[it] = true;
264 
265  if (debug)
266  edm::LogVerbatim("HGCFE") << "\t q=" << charge << " fC with <toa>=" << toa << " ns, triggers ToT @ " << it
267  << std::endl;
268 
269  //compute total charge to be integrated and integration time
270  //needs a loop as ToT will last as long as there is charge to dissipate
271  int busyBxs(0);
272  float totalCharge(charge), finalToA(toa), integTime(0);
273  while (true) {
274  //compute integration time in ns and # bunches
275  //float newIntegTime(0);
276  int poffset = 0;
277  float charge_offset = 0.f;
278  const float charge_kfC(totalCharge * 1e-3);
279  if (charge_kfC < tdcChargeDrainParameterisation_[3]) {
280  //newIntegTime=tdcChargeDrainParameterisation_[0]*pow(charge_kfC,2)+tdcChargeDrainParameterisation_[1]*charge_kfC+tdcChargeDrainParameterisation_[2];
281  } else if (charge_kfC < tdcChargeDrainParameterisation_[7]) {
282  poffset = 4;
283  charge_offset = tdcChargeDrainParameterisation_[3];
284  //newIntegTime=tdcChargeDrainParameterisation_[4]*pow(charge_kfC-tdcChargeDrainParameterisation_[3],2)+tdcChargeDrainParameterisation_[5]*(charge_kfC-tdcChargeDrainParameterisation_[3])+tdcChargeDrainParameterisation_[6];
285  } else {
286  poffset = 8;
287  charge_offset = tdcChargeDrainParameterisation_[7];
288  //newIntegTime=tdcChargeDrainParameterisation_[8]*pow(charge_kfC-tdcChargeDrainParameterisation_[7],2)+tdcChargeDrainParameterisation_[9]*(charge_kfC-tdcChargeDrainParameterisation_[7])+tdcChargeDrainParameterisation_[10];
289  }
290  const float charge_mod = charge_kfC - charge_offset;
291  const float newIntegTime =
292  ((tdcChargeDrainParameterisation_[poffset] * charge_mod + tdcChargeDrainParameterisation_[poffset + 1]) *
293  charge_mod +
294  tdcChargeDrainParameterisation_[poffset + 2]);
295 
296  const int newBusyBxs = std::floor(newIntegTime / 25.f) + 1;
297 
298  //if no update is needed regarding the number of bunches,
299  //then the ToT integration time has converged
300  integTime = newIntegTime;
301  if (newBusyBxs == busyBxs)
302  break;
303 
304  //update charge integrated during ToT
305  if (debug) {
306  if (busyBxs == 0)
307  edm::LogVerbatim("HGCFE") << "\t Intial busy estimate=" << integTime << " ns = " << newBusyBxs << " bxs"
308  << std::endl;
309  else
310  edm::LogVerbatim("HGCFE") << "\t ...integrated charge overflows initial busy estimate, interating again"
311  << std::endl;
312  }
313 
314  //update number of busy bunches
315  busyBxs = newBusyBxs;
316 
317  //reset charge to be integrated
318  totalCharge = charge;
319  if (toaMode_ == WEIGHTEDBYE)
320  finalToA = toa * charge;
321 
322  //add leakage from previous bunches in SARS ADC mode
323  for (int jt = 0; jt < it; ++jt) {
324  const unsigned int deltaT = (it - jt);
325  if ((deltaT + 2) >= adcPulse_.size() || chargeColl[jt] == 0.f || totFlags[jt] || busyFlags[jt])
326  continue;
327 
328  const float leakCharge = chargeColl[jt] * adcPulse_[deltaT + 2];
329  totalCharge += leakCharge;
330  if (toaMode_ == WEIGHTEDBYE)
331  finalToA += leakCharge * pulseAvgT_[deltaT + 2];
332 
333  if (debug)
334  edm::LogVerbatim("HGCFE") << "\t\t leaking " << chargeColl[jt] << " fC @ deltaT=-" << deltaT << " -> +"
335  << leakCharge << " with avgT=" << pulseAvgT_[deltaT + 2] << std::endl;
336  }
337 
338  //add contamination from posterior bunches
339  for (int jt = it + 1; jt < it + busyBxs && jt < dataFrame.size(); ++jt) {
340  //this charge will be integrated in TDC mode
341  //disable for SARS ADC
342  busyFlags[jt] = true;
343 
344  const float extraCharge = chargeColl[jt];
345  if (extraCharge == 0.f)
346  continue;
347  if (debug)
348  edm::LogVerbatim("HGCFE") << "\t\t adding " << extraCharge << " fC @ deltaT=+" << (jt - it) << std::endl;
349 
350  totalCharge += extraCharge;
351  if (toaMode_ == WEIGHTEDBYE)
352  finalToA += extraCharge * toaColl[jt];
353  }
354 
355  //finalize ToA contamination
356  if (toaMode_ == WEIGHTEDBYE)
357  finalToA /= totalCharge;
358  }
359  newCharge[it] = (totalCharge - tdcOnset_fC_);
360 
361  if (debug)
362  edm::LogVerbatim("HGCFE") << "\t Final busy estimate=" << integTime << " ns = " << busyBxs << " bxs" << std::endl
363  << "\t Total integrated=" << totalCharge << " fC <toa>=" << toaFromToT[it]
364  << " (raw=" << finalToA << ") ns " << std::endl;
365 
366  //last fC (tdcOnset) are dissipated trough pulse
367  if (it + busyBxs < (int)(newCharge.size())) {
368  const float deltaT2nextBx((busyBxs * 25 - integTime));
369  const float tdcOnsetLeakage(tdcOnset_fC_ * vdt::fast_expf(-deltaT2nextBx / tdcChargeDrainParameterisation_[11]));
370  if (debug)
371  edm::LogVerbatim("HGCFE") << "\t Leaking remainder of TDC onset " << tdcOnset_fC_ << " fC, to be dissipated in "
372  << deltaT2nextBx << " DeltaT/tau=" << deltaT2nextBx << " / "
373  << tdcChargeDrainParameterisation_[11] << " ns, adds " << tdcOnsetLeakage << " fC @ "
374  << it + busyBxs << " bx (first free bx)" << std::endl;
375  newCharge[it + busyBxs] += tdcOnsetLeakage;
376  }
377  }
378 
379  //including the leakage from bunches in SARS ADC when not declared busy or in ToT
380  auto runChargeSharing = [&]() {
381  int ipulse = 0;
382  for (int it = 0; it < (int)(chargeColl.size()); ++it) {
383  //if busy, charge has been already integrated
384  //if(debug) edm::LogVerbatim("HGCFE") << "\t SARS ADC pulse activated @ " << it << " : ";
385  if (!totFlags[it] & !busyFlags[it]) {
386  const int start = std::max(0, 2 - it);
387  const int stop = std::min((int)adcPulse_.size(), (int)newCharge.size() - it + 2);
388  for (ipulse = start; ipulse < stop; ++ipulse) {
389  const int itoffset = it + ipulse - 2;
390  //notice that if the channel is already busy,
391  //it has already been affected by the leakage of the SARS ADC
392  //if(totFlags[itoffset] || busyFlags[itoffset]) continue;
393  if (!totFlags[itoffset] & !busyFlags[itoffset]) {
394  newCharge[itoffset] += chargeColl[it] * adcPulse_[ipulse];
395  }
396  //if(debug) edm::LogVerbatim("HGCFE") << " | " << itoffset << " " << chargeColl[it]*adcPulse_[ipulse] << "( " << chargeColl[it] << "->";
397  //if(debug) edm::LogVerbatim("HGCFE") << newCharge[itoffset] << ") ";
398  }
399  }
400 
401  if (debug)
402  edm::LogVerbatim("HGCFE") << std::endl;
403  }
404  };
405  runChargeSharing();
406 
407  //For the future need to understand how to deal with toa for out of time signals
408  //and for that should keep track of the BX firing the ToA somewhere (also to restore the use of finalToA)
409  /*
410  float finalToA(0.);
411  for(int it=0; it<(int)(newCharge.size()); it++){
412  if(toaFlags[it]){
413  finalToA = toaFromToT[it];
414  //to avoid +=25 for small negative time taken as 0
415  while(finalToA < -1.e-5) finalToA+=25.f;
416  while(finalToA > 25.f) finalToA-=25.f;
417  toaFromToT[it] = finalToA;
418  }
419  }
420  */
421  //timeToA is already in 0-25ns range by construction
422 
423  //set new ADCs and ToA
424  if (debug)
425  edm::LogVerbatim("HGCFE") << "\t final result : ";
426  if (lsbADC < 0)
427  lsbADC = adcLSB_fC_;
428  if (maxADC < 0)
429  maxADC = adcSaturation_fC_;
430  for (int it = 0; it < (int)(newCharge.size()); it++) {
431  if (debug)
432  edm::LogVerbatim("HGCFE") << chargeColl[it] << " -> " << newCharge[it] << " ";
433 
434  HGCSample newSample;
435  if (totFlags[it] || busyFlags[it]) {
436  if (totFlags[it]) {
437  //brute force saturation, maybe could to better with an exponential like saturation
438  const float saturatedCharge(std::min(newCharge[it], tdcSaturation_fC_));
439  //working version for in-time PU and signal
440  newSample.set(
441  true, true, gainIdx, (uint16_t)(timeToA / toaLSB_ns_), (uint16_t)(std::floor(saturatedCharge / tdcLSB_fC_)));
442  if (toaFlags[it])
443  newSample.setToAValid(true);
444  } else {
445  newSample.set(false, true, gainIdx, 0, 0);
446  }
447  } else {
448  //brute force saturation, maybe could to better with an exponential like saturation
449  const uint16_t adc = std::floor(std::min(newCharge[it], maxADC) / lsbADC);
450  //working version for in-time PU and signal
451  newSample.set(adc > thrADC, false, gainIdx, (uint16_t)(timeToA / toaLSB_ns_), adc);
452  if (toaFlags[it])
453  newSample.setToAValid(true);
454  }
455  dataFrame.setSample(it, newSample);
456  }
457 
458  if (debug) {
459  std::ostringstream msg;
460  dataFrame.print(msg);
461  edm::LogVerbatim("HGCFE") << msg.str() << std::endl;
462  }
463 }

References ecalMGPA::adc(), ALCARECOTkAlJpsiMuMu_cff::charge, debug, MillePedeFileConverter_cfg::e, f, myMath::fast_expf(), createfilelist::int, SiStripPI::max, min(), mps_check::msg, HGCSample::set(), HGCSample::setToAValid(), and Calorimetry_cff::thickness.

Referenced by HGCFEElectronics< DFr >::runShaper().

◆ runSimpleShaper()

template<class DFr >
void HGCFEElectronics< DFr >::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

Definition at line 149 of file HGCFEElectronics.cc.

150  {
151  //convolute with pulse shape to compute new ADCs
152  newCharge.fill(0.f);
153  bool debug(false);
154  for (int it = 0; it < (int)(chargeColl.size()); it++) {
155  const float charge(chargeColl[it]);
156  if (charge == 0.f)
157  continue;
158 
159 #ifdef EDM_ML_DEBUG
161 #endif
162 
163  if (debug)
164  edm::LogVerbatim("HGCFE") << "\t Redistributing SARS ADC" << charge << " @ " << it;
165 
166  for (int ipulse = -2; ipulse < (int)(adcPulse_.size()) - 2; ipulse++) {
167  if (it + ipulse < 0)
168  continue;
169  if (it + ipulse >= (int)(dataFrame.size()))
170  continue;
171  const float chargeLeak = charge * adcPulse_[(ipulse + 2)];
172  newCharge[it + ipulse] += chargeLeak;
173 
174  if (debug)
175  edm::LogVerbatim("HGCFE") << " | " << it + ipulse << " " << chargeLeak;
176  }
177 
178  if (debug)
179  edm::LogVerbatim("HGCFE") << std::endl;
180  }
181 
182  for (int it = 0; it < (int)(newCharge.size()); it++) {
183  //brute force saturation, maybe could to better with an exponential like saturation
184  const uint32_t adc = std::floor(std::min(newCharge[it], maxADC) / lsbADC);
185  HGCSample newSample;
186  newSample.set(adc > thrADC, false, gainIdx, 0, adc);
187  dataFrame.setSample(it, newSample);
188 
189  if (debug)
190  edm::LogVerbatim("HGCFE") << adc << " (" << std::min(newCharge[it], maxADC) << "/" << lsbADC << " ) ";
191  }
192 
193  if (debug) {
194  std::ostringstream msg;
195  dataFrame.print(msg);
196  edm::LogVerbatim("HGCFE") << msg.str() << std::endl;
197  }
198 }

References ecalMGPA::adc(), ALCARECOTkAlJpsiMuMu_cff::charge, debug, f, createfilelist::int, min(), mps_check::msg, and HGCSample::set().

Referenced by HGCFEElectronics< DFr >::runShaper().

◆ runTrivialShaper()

template<class DFr >
void HGCFEElectronics< DFr >::runTrivialShaper ( DFr &  dataFrame,
hgc::HGCSimHitData chargeColl,
uint32_t  thrADC,
float  lsbADC,
uint32_t  gainIdx,
float  maxADC 
)

converts charge to digis without pulse shape

Definition at line 110 of file HGCFEElectronics.cc.

111  {
112  bool debug(false);
113 
114 #ifdef EDM_ML_DEBUG
115  for (int it = 0; it < (int)(chargeColl.size()); it++)
116  debug |= (chargeColl[it] > adcThreshold_fC_);
117 #endif
118 
119  if (debug)
120  edm::LogVerbatim("HGCFE") << "[runTrivialShaper]" << std::endl;
121 
122  if (lsbADC < 0)
123  lsbADC = adcLSB_fC_;
124  if (maxADC < 0)
125  // lower adcSaturation_fC_ by one part in a million
126  // to ensure largest charge converted in bits is 0xfff==4095, not 0x1000
127  // no effect on charges loewer than; no impact on cpu time, only done once
128  maxADC = adcSaturation_fC_ * (1 - 1e-6);
129  for (int it = 0; it < (int)(chargeColl.size()); it++) {
130  //brute force saturation, maybe could to better with an exponential like saturation
131  const uint32_t adc = std::floor(std::min(chargeColl[it], maxADC) / lsbADC);
132  HGCSample newSample;
133  newSample.set(adc > thrADC, false, gainIdx, 0, adc);
134  dataFrame.setSample(it, newSample);
135 
136  if (debug)
137  edm::LogVerbatim("HGCFE") << adc << " (" << chargeColl[it] << "/" << adcLSB_fC_ << ") ";
138  }
139 
140  if (debug) {
141  std::ostringstream msg;
142  dataFrame.print(msg);
143  edm::LogVerbatim("HGCFE") << msg.str() << std::endl;
144  }
145 }

References ecalMGPA::adc(), debug, MillePedeFileConverter_cfg::e, createfilelist::int, min(), mps_check::msg, and HGCSample::set().

Referenced by HGCFEElectronics< DFr >::runShaper().

◆ setADClsb()

template<class DFr >
void HGCFEElectronics< DFr >::setADClsb ( float  newLSB)
inline

Definition at line 79 of file HGCFEElectronics.h.

79 { adcLSB_fC_ = newLSB; }

References HGCFEElectronics< DFr >::adcLSB_fC_.

◆ SetNoiseValues()

template<class DFr >
void HGCFEElectronics< DFr >::SetNoiseValues ( const std::vector< float > &  noise_fC)
inline

Definition at line 58 of file HGCFEElectronics.h.

58  {
59  noise_fC_.insert(noise_fC_.end(), noise_fC.begin(), noise_fC.end());
60  };

References hgcalDigitizer_cfi::noise_fC, and HGCFEElectronics< DFr >::noise_fC_.

◆ toaMode()

template<class DFr >
uint32_t HGCFEElectronics< DFr >::toaMode ( ) const
inline

returns how ToT will be computed

Definition at line 109 of file HGCFEElectronics.h.

109 { return toaMode_; }

References HGCFEElectronics< DFr >::toaMode_.

Member Data Documentation

◆ adcLSB_fC_

template<class DFr >
float HGCFEElectronics< DFr >::adcLSB_fC_
private

◆ adcPulse_

template<class DFr >
std::array<float, 6> HGCFEElectronics< DFr >::adcPulse_
private

Definition at line 119 of file HGCFEElectronics.h.

◆ adcSaturation_fC_

template<class DFr >
float HGCFEElectronics< DFr >::adcSaturation_fC_
private

Definition at line 122 of file HGCFEElectronics.h.

◆ adcThreshold_fC_

template<class DFr >
float HGCFEElectronics< DFr >::adcThreshold_fC_
private

Definition at line 122 of file HGCFEElectronics.h.

Referenced by HGCFEElectronics< DFr >::getADCThreshold().

◆ busyFlags

template<class DFr >
std::array<bool, hgc::nSamples> HGCFEElectronics< DFr >::busyFlags
private

Definition at line 130 of file HGCFEElectronics.h.

◆ fwVersion_

template<class DFr >
uint32_t HGCFEElectronics< DFr >::fwVersion_
private

Definition at line 118 of file HGCFEElectronics.h.

Referenced by HGCFEElectronics< DFr >::runShaper().

◆ jitterConstant2_ns_

template<class DFr >
std::array<float, 3> HGCFEElectronics< DFr >::jitterConstant2_ns_
private

Definition at line 125 of file HGCFEElectronics.h.

Referenced by HGCFEElectronics< DFr >::getTimeJitter().

◆ jitterNoise2_ns_

template<class DFr >
std::array<float, 3> HGCFEElectronics< DFr >::jitterNoise2_ns_
private

Definition at line 125 of file HGCFEElectronics.h.

Referenced by HGCFEElectronics< DFr >::getTimeJitter().

◆ newCharge

template<class DFr >
hgc::HGCSimHitData HGCFEElectronics< DFr >::newCharge
private

Definition at line 131 of file HGCFEElectronics.h.

◆ noise_fC_

template<class DFr >
std::vector<float> HGCFEElectronics< DFr >::noise_fC_
private

◆ pulseAvgT_

template<class DFr >
std::array<float, 6> HGCFEElectronics< DFr >::pulseAvgT_
private

Definition at line 119 of file HGCFEElectronics.h.

◆ targetMIPvalue_ADC_

template<class DFr >
uint32_t HGCFEElectronics< DFr >::targetMIPvalue_ADC_
private

Definition at line 124 of file HGCFEElectronics.h.

Referenced by HGCFEElectronics< DFr >::getTargetMipValue().

◆ tdcChargeDrainParameterisation_

template<class DFr >
std::vector<float> HGCFEElectronics< DFr >::tdcChargeDrainParameterisation_
private

Definition at line 121 of file HGCFEElectronics.h.

◆ tdcForToAOnset_fC_

template<class DFr >
std::array<float, 3> HGCFEElectronics< DFr >::tdcForToAOnset_fC_
private

Definition at line 120 of file HGCFEElectronics.h.

Referenced by HGCFEElectronics< DFr >::getTDCForToAOnset().

◆ tdcLSB_fC_

template<class DFr >
float HGCFEElectronics< DFr >::tdcLSB_fC_
private

Definition at line 122 of file HGCFEElectronics.h.

Referenced by HGCFEElectronics< DFr >::getTDClsb().

◆ tdcOnset_fC_

template<class DFr >
float HGCFEElectronics< DFr >::tdcOnset_fC_
private

Definition at line 122 of file HGCFEElectronics.h.

Referenced by HGCFEElectronics< DFr >::getTDCOnset().

◆ tdcResolutionInNs_

template<class DFr >
float HGCFEElectronics< DFr >::tdcResolutionInNs_
private

Definition at line 122 of file HGCFEElectronics.h.

◆ tdcSaturation_fC_

template<class DFr >
float HGCFEElectronics< DFr >::tdcSaturation_fC_
private

Definition at line 122 of file HGCFEElectronics.h.

◆ thresholdFollowsMIP_

template<class DFr >
bool HGCFEElectronics< DFr >::thresholdFollowsMIP_
private

Definition at line 128 of file HGCFEElectronics.h.

◆ toaFlags

template<class DFr >
std::array<bool, hgc::nSamples> HGCFEElectronics< DFr >::toaFlags
private

Definition at line 130 of file HGCFEElectronics.h.

◆ toaFromToT

template<class DFr >
hgc::HGCSimHitData HGCFEElectronics< DFr >::toaFromToT
private

Definition at line 131 of file HGCFEElectronics.h.

◆ toaLSB_ns_

template<class DFr >
float HGCFEElectronics< DFr >::toaLSB_ns_
private

Definition at line 122 of file HGCFEElectronics.h.

◆ toaMode_

template<class DFr >
uint32_t HGCFEElectronics< DFr >::toaMode_
private

Definition at line 127 of file HGCFEElectronics.h.

Referenced by HGCFEElectronics< DFr >::toaMode().

◆ totFlags

template<class DFr >
std::array<bool, hgc::nSamples> HGCFEElectronics< DFr >::totFlags
private

Definition at line 130 of file HGCFEElectronics.h.

ecalMGPA::adc
constexpr int adc(sample_type sample)
get the ADC sample (12 bits)
Definition: EcalMGPASample.h:11
mps_fire.i
i
Definition: mps_fire.py:355
HGCalUncalibRecHit_cfi.tdcNbits
tdcNbits
Definition: HGCalUncalibRecHit_cfi.py:27
start
Definition: start.py:1
dqmMemoryStats.float
float
Definition: dqmMemoryStats.py:127
HGCFEElectronics::adcSaturation_fC_
float adcSaturation_fC_
Definition: HGCFEElectronics.h:122
HGCFEElectronics::jitterNoise2_ns_
std::array< float, 3 > jitterNoise2_ns_
Definition: HGCFEElectronics.h:125
HGCalUncalibRecHit_cfi.adcNbits
adcNbits
Definition: HGCalUncalibRecHit_cfi.py:24
HGCFEElectronics::toaFromToT
hgc::HGCSimHitData toaFromToT
Definition: HGCFEElectronics.h:131
f
double f[11][100]
Definition: MuScleFitUtils.cc:78
HGCFEElectronics::tdcChargeDrainParameterisation_
std::vector< float > tdcChargeDrainParameterisation_
Definition: HGCFEElectronics.h:121
min
T min(T a, T b)
Definition: MathUtil.h:58
HGCFEElectronics::WITHTOT
Definition: HGCFEElectronics.h:22
HGCSample::set
void set(bool thr, bool mode, uint16_t gain, uint16_t toa, uint16_t data)
Definition: HGCSample.h:49
HGCFEElectronics::totFlags
std::array< bool, hgc::nSamples > totFlags
Definition: HGCFEElectronics.h:130
HGCFEElectronics::toaLSB_ns_
float toaLSB_ns_
Definition: HGCFEElectronics.h:122
HGCFEElectronics::tdcResolutionInNs_
float tdcResolutionInNs_
Definition: HGCFEElectronics.h:122
mps_check.msg
tuple msg
Definition: mps_check.py:285
HGCFEElectronics::TRIVIAL
Definition: HGCFEElectronics.h:22
HGCFEElectronics::toaFlags
std::array< bool, hgc::nSamples > toaFlags
Definition: HGCFEElectronics.h:130
groupFilesInBlocks.temp
list temp
Definition: groupFilesInBlocks.py:142
HGCFEElectronics::SIMPLE
Definition: HGCFEElectronics.h:22
HGCFEElectronics::tdcOnset_fC_
float tdcOnset_fC_
Definition: HGCFEElectronics.h:122
HGCFEElectronics::WEIGHTEDBYE
Definition: HGCFEElectronics.h:23
HGCFEElectronics::getTimeJitter
float getTimeJitter(float totalCharge, int thickness)
Definition: HGCFEElectronics.h:62
HGCSample::setToAValid
void setToAValid(bool toaFired)
Definition: HGCSample.h:47
debug
#define debug
Definition: HDRShower.cc:19
myMath::fast_expf
float fast_expf(float x)
Definition: EcalUncalibRecHitRatioMethodAlgo.h:27
Calorimetry_cff.thickness
thickness
Definition: Calorimetry_cff.py:114
HGCFEElectronics::toaMode_
uint32_t toaMode_
Definition: HGCFEElectronics.h:127
HGCFEElectronics::runTrivialShaper
void runTrivialShaper(DFr &dataFrame, hgc::HGCSimHitData &chargeColl, uint32_t thrADC, float lsbADC, uint32_t gainIdx, float maxADC)
converts charge to digis without pulse shape
Definition: HGCFEElectronics.cc:110
mathSSE::sqrt
T sqrt(T t)
Definition: SSEVec.h:19
HGCSample
wrapper for a data word
Definition: HGCSample.h:13
HGCFEElectronics::SIMPLETHRESHOLD
Definition: HGCFEElectronics.h:23
ALCARECOTkAlJpsiMuMu_cff.charge
charge
Definition: ALCARECOTkAlJpsiMuMu_cff.py:47
edm::ParameterSet::exists
bool exists(std::string const &parameterName) const
checks if a parameter exists
Definition: ParameterSet.cc:674
HGCFEElectronics::adcLSB_fC_
float adcLSB_fC_
Definition: HGCFEElectronics.h:122
hgcalDigitizer_cfi.noise_fC
noise_fC
Definition: hgcalDigitizer_cfi.py:91
SiStripPI::max
Definition: SiStripPayloadInspectorHelper.h:169
HGCFEElectronics::runSimpleShaper
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
Definition: HGCFEElectronics.cc:149
createfilelist.int
int
Definition: createfilelist.py:10
edm::LogVerbatim
Definition: MessageLogger.h:297
HGCFEElectronics::adcPulse_
std::array< float, 6 > adcPulse_
Definition: HGCFEElectronics.h:119
HGCFEElectronics::noise_fC_
std::vector< float > noise_fC_
Definition: HGCFEElectronics.h:126
HGCFEElectronics::newCharge
hgc::HGCSimHitData newCharge
Definition: HGCFEElectronics.h:131
HGCFEElectronics::jitterConstant2_ns_
std::array< float, 3 > jitterConstant2_ns_
Definition: HGCFEElectronics.h:125
edm::ParameterSet::getParameter
T getParameter(std::string const &) const
HGCFEElectronics::runShaperWithToT
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
Definition: HGCFEElectronics.cc:202
HGCFEElectronics::targetMIPvalue_ADC_
uint32_t targetMIPvalue_ADC_
Definition: HGCFEElectronics.h:124
HGCFEElectronics::tdcLSB_fC_
float tdcLSB_fC_
Definition: HGCFEElectronics.h:122
heppy_batch.val
val
Definition: heppy_batch.py:351
HGCFEElectronics::tdcForToAOnset_fC_
std::array< float, 3 > tdcForToAOnset_fC_
Definition: HGCFEElectronics.h:120
HGCFEElectronics::adcThreshold_fC_
float adcThreshold_fC_
Definition: HGCFEElectronics.h:122
Exception
Definition: hltDiff.cc:246
HGCFEElectronics::tdcSaturation_fC_
float tdcSaturation_fC_
Definition: HGCFEElectronics.h:122
funct::pow
Power< A, B >::type pow(const A &a, const B &b)
Definition: Power.h:30
HGCFEElectronics::fwVersion_
uint32_t fwVersion_
Definition: HGCFEElectronics.h:118
HGCFEElectronics::busyFlags
std::array< bool, hgc::nSamples > busyFlags
Definition: HGCFEElectronics.h:130
HGCFEElectronics::pulseAvgT_
std::array< float, 6 > pulseAvgT_
Definition: HGCFEElectronics.h:119
MillePedeFileConverter_cfg.e
e
Definition: MillePedeFileConverter_cfg.py:37