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 ()
 
float getTDClsb ()
 
float getTDCOnset ()
 
 HGCFEElectronics (const edm::ParameterSet &ps)
 CTOR. More...
 
void runShaper (DFr &dataFrame, hgc::HGCSimHitData &chargeColl, hgc::HGCSimHitData &toa, int thickness, CLHEP::HepRandomEngine *engine, float cce=1.0)
 switches according to the firmware version More...
 
void runShaperWithToT (DFr &dataFrame, hgc::HGCSimHitData &chargeColl, hgc::HGCSimHitData &toa, int thickness, CLHEP::HepRandomEngine *engine, float cce=1.0)
 implements pulse shape and switch to time over threshold including deadtime More...
 
void runSimpleShaper (DFr &dataFrame, hgc::HGCSimHitData &chargeColl, int thickness, float cce=1.0)
 applies a shape to each time sample and propagates the tails to the subsequent time samples More...
 
void runTrivialShaper (DFr &dataFrame, hgc::HGCSimHitData &chargeColl, int thickness, float cce=1.0)
 converts charge to digis without pulse shape More...
 
void setADClsb (float newLSB)
 
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_
 
hgc::HGCSimHitData newCharge
 
std::array< float, 6 > pulseAvgT_
 
std::vector< float > tdcChargeDrainParameterisation_
 
float tdcLSB_fC_
 
float tdcOnset_fC_
 
float tdcResolutionInNs_
 
float tdcSaturation_fC_
 
bool thresholdFollowsMIP_
 
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

Enumerator
TRIVIAL 
SIMPLE 
WITHTOT 

Definition at line 24 of file HGCFEElectronics.h.

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

Definition at line 25 of file HGCFEElectronics.h.

Constructor & Destructor Documentation

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

CTOR.

Definition at line 11 of file HGCFEElectronics.cc.

References HGCFEElectronics< DFr >::adcLSB_fC_, HGCalUncalibRecHit_cfi::adcNbits, HGCFEElectronics< DFr >::adcPulse_, HGCFEElectronics< DFr >::adcSaturation_fC_, HGCFEElectronics< DFr >::adcThreshold_fC_, MillePedeFileConverter_cfg::e, edm::ParameterSet::exists(), objects.autophobj::float, HGCFEElectronics< DFr >::fwVersion_, edm::ParameterSet::getParameter(), mps_fire::i, funct::pow(), HGCFEElectronics< DFr >::pulseAvgT_, HGCFEElectronics< DFr >::tdcChargeDrainParameterisation_, HGCFEElectronics< DFr >::tdcLSB_fC_, HGCalUncalibRecHit_cfi::tdcNbits, HGCFEElectronics< DFr >::tdcOnset_fC_, HGCFEElectronics< DFr >::tdcResolutionInNs_, HGCFEElectronics< DFr >::tdcSaturation_fC_, groupFilesInBlocks::temp, HGCFEElectronics< DFr >::thresholdFollowsMIP_, HGCFEElectronics< DFr >::toaLSB_ns_, HGCFEElectronics< DFr >::toaMode_, and heppy_batch::val.

11  :
13 {
14  tdcResolutionInNs_ = 1e-9; // set time resolution very small by default
15  thresholdFollowsMIP_ = ps.getParameter< bool >("thresholdFollowsMIP");
16  fwVersion_ = ps.getParameter< uint32_t >("fwVersion");
17  edm::LogVerbatim("HGCFE") << "[HGCFEElectronics] running with version " << fwVersion_ << std::endl;
18  if( ps.exists("adcPulse") )
19  {
20  auto temp = ps.getParameter< std::vector<double> >("adcPulse");
21  for( unsigned i = 0; i < temp.size(); ++i ) {
22  adcPulse_[i] = (float)temp[i];
23  }
24  // normalize adc pulse
25  for( unsigned i = 0; i < adcPulse_.size(); ++i ) {
27  }
28  temp = ps.getParameter< std::vector<double> >("pulseAvgT");
29  for( unsigned i = 0; i < temp.size(); ++i ) {
30  pulseAvgT_[i] = (float)temp[i];
31  }
32  }
33  adcSaturation_fC_=-1.0;
34  if( ps.exists("adcNbits") )
35  {
36  uint32_t adcNbits = ps.getParameter<uint32_t>("adcNbits");
37  adcSaturation_fC_ = ps.getParameter<double>("adcSaturation_fC");
38  adcLSB_fC_=adcSaturation_fC_/pow(2.,adcNbits);
39  edm::LogVerbatim("HGCFE")
40  << "[HGCFEElectronics] " << adcNbits << " bit ADC defined"
41  << " with LSB=" << adcLSB_fC_
42  << " saturation to occur @ " << adcSaturation_fC_ << std::endl;
43  }
44 
45  tdcSaturation_fC_=-1.0;
46  if( ps.exists("tdcNbits") )
47  {
48  uint32_t tdcNbits = ps.getParameter<uint32_t>("tdcNbits");
49  tdcSaturation_fC_ = ps.getParameter<double>("tdcSaturation_fC");
50  tdcLSB_fC_=tdcSaturation_fC_/pow(2.,tdcNbits);
51  edm::LogVerbatim("HGCFE")
52  << "[HGCFEElectronics] " << tdcNbits << " bit TDC defined with LSB="
53  << tdcLSB_fC_ << " saturation to occur @ " << tdcSaturation_fC_ << std::endl;
54  }
55  if( ps.exists("adcThreshold_fC") ) adcThreshold_fC_ = ps.getParameter<double>("adcThreshold_fC");
56  if( ps.exists("tdcOnset_fC") ) tdcOnset_fC_ = ps.getParameter<double>("tdcOnset_fC");
57  if( ps.exists("toaLSB_ns") ) toaLSB_ns_ = ps.getParameter<double>("toaLSB_ns");
58  if( ps.exists("tdcChargeDrainParameterisation") ) {
59  for( auto val : ps.getParameter< std::vector<double> >("tdcChargeDrainParameterisation") ) {
60  tdcChargeDrainParameterisation_.push_back((float)val);
61  }
62  }
63  if( ps.exists("tdcResolutionInPs") ) tdcResolutionInNs_ = ps.getParameter<double>("tdcResolutionInPs")*1e-3; // convert to ns
64  if( ps.exists("toaMode") ) toaMode_ = ps.getParameter<uint32_t>("toaMode");
65 }
T getParameter(std::string const &) const
bool exists(std::string const &parameterName) const
checks if a parameter exists
std::array< float, 6 > adcPulse_
std::vector< float > tdcChargeDrainParameterisation_
std::array< float, 6 > pulseAvgT_
Power< A, B >::type pow(const A &a, const B &b)
Definition: Power.h:40
template<class DFr >
HGCFEElectronics< DFr >::~HGCFEElectronics ( )
inline

DTOR.

Definition at line 79 of file HGCFEElectronics.h.

79 {}

Member Function Documentation

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

returns the LSB in MIP currently configured

Definition at line 49 of file HGCFEElectronics.h.

References HGCFEElectronics< DFr >::adcLSB_fC_.

49 { return adcLSB_fC_; }
template<class DFr >
float HGCFEElectronics< DFr >::getADCThreshold ( )
inline

Definition at line 51 of file HGCFEElectronics.h.

References HGCFEElectronics< DFr >::adcThreshold_fC_.

51 { return adcThreshold_fC_; }
template<class DFr >
float HGCFEElectronics< DFr >::getTDClsb ( )
inline

Definition at line 50 of file HGCFEElectronics.h.

References HGCFEElectronics< DFr >::tdcLSB_fC_.

50 { return tdcLSB_fC_; }
template<class DFr >
float HGCFEElectronics< DFr >::getTDCOnset ( )
inline

Definition at line 52 of file HGCFEElectronics.h.

References HGCFEElectronics< DFr >::tdcOnset_fC_.

52 { return tdcOnset_fC_; }
template<class DFr >
void HGCFEElectronics< DFr >::runShaper ( DFr &  dataFrame,
hgc::HGCSimHitData chargeColl,
hgc::HGCSimHitData toa,
int  thickness,
CLHEP::HepRandomEngine *  engine,
float  cce = 1.0 
)
inline

switches according to the firmware version

Definition at line 35 of file HGCFEElectronics.h.

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

37  {
38  switch(fwVersion_)
39  {
40  case SIMPLE : { runSimpleShaper(dataFrame,chargeColl, thickness, cce); break; }
41  case WITHTOT : { runShaperWithToT(dataFrame,chargeColl,toa, thickness, engine, cce); break; }
42  default : { runTrivialShaper(dataFrame,chargeColl, thickness, cce); break; }
43  }
44  }
void runShaperWithToT(DFr &dataFrame, hgc::HGCSimHitData &chargeColl, hgc::HGCSimHitData &toa, int thickness, CLHEP::HepRandomEngine *engine, float cce=1.0)
implements pulse shape and switch to time over threshold including deadtime
void runSimpleShaper(DFr &dataFrame, hgc::HGCSimHitData &chargeColl, int thickness, float cce=1.0)
applies a shape to each time sample and propagates the tails to the subsequent time samples ...
void runTrivialShaper(DFr &dataFrame, hgc::HGCSimHitData &chargeColl, int thickness, float cce=1.0)
converts charge to digis without pulse shape
template<class DFr >
void HGCFEElectronics< DFr >::runShaperWithToT ( DFr &  dataFrame,
hgc::HGCSimHitData chargeColl,
hgc::HGCSimHitData toa,
int  thickness,
CLHEP::HepRandomEngine *  engine,
float  cce = 1.0 
)

implements pulse shape and switch to time over threshold including deadtime

Definition at line 155 of file HGCFEElectronics.cc.

References HGCFEElectronics< DFr >::adcLSB_fC_, HGCFEElectronics< DFr >::adcPulse_, HGCFEElectronics< DFr >::adcSaturation_fC_, HGCFEElectronics< DFr >::adcThreshold_fC_, HGCFEElectronics< DFr >::busyFlags, ALCARECOTkAlJpsiMuMu_cff::charge, constexpr, debug, MillePedeFileConverter_cfg::e, f, myMath::fast_expf(), createfilelist::int, hpstanc_transforms::max, min(), mps_alisetup::msg, HGCFEElectronics< DFr >::newCharge, HGCFEElectronics< DFr >::pulseAvgT_, HGCSample::set(), HGCFEElectronics< DFr >::tdcChargeDrainParameterisation_, HGCFEElectronics< DFr >::tdcLSB_fC_, HGCFEElectronics< DFr >::tdcOnset_fC_, HGCFEElectronics< DFr >::tdcResolutionInNs_, HGCFEElectronics< DFr >::tdcSaturation_fC_, HGCFEElectronics< DFr >::thresholdFollowsMIP_, HGCFEElectronics< DFr >::toaFromToT, HGCFEElectronics< DFr >::toaLSB_ns_, HGCFEElectronics< DFr >::toaMode_, HGCFEElectronics< DFr >::totFlags, and HGCFEElectronics< DFr >::WEIGHTEDBYE.

Referenced by HGCFEElectronics< DFr >::runShaper(), and HGCFEElectronics< DFr >::setADClsb().

156 {
157  busyFlags.fill(false);
158  totFlags.fill(false);
159  newCharge.fill( 0.f );
160  toaFromToT.fill( 0.f );
161 
162 #ifdef EDM_ML_DEBUG
163  constexpr bool debug_state(true);
164 #else
165  constexpr bool debug_state(false);
166 #endif
167 
168  bool debug = debug_state;
169 
170  //first identify bunches which will trigger ToT
171  //if(debug_state) edm::LogVerbatim("HGCFE") << "[runShaperWithToT]" << std::endl;
172  for(int it=0; it<(int)(chargeColl.size()); ++it)
173  {
174  debug = debug_state;
175  //if already flagged as busy it can't be re-used to trigger the ToT
176  if(busyFlags[it]) continue;
177 
178  //if below TDC onset will be handled by SARS ADC later
179  float charge = chargeColl[it];
180  if(charge < tdcOnset_fC_) {
181  debug = false;
182  continue;
183  }
184 
185  //raise TDC mode
186  float toa = toaColl[it];
187  totFlags[it]=true;
188 
189  if(debug) edm::LogVerbatim("HGCFE") << "\t q=" << charge << " fC with <toa>=" << toa << " ns, triggers ToT @ " << it << std::endl;
190 
191  //compute total charge to be integrated and integration time
192  //needs a loop as ToT will last as long as there is charge to dissipate
193  int busyBxs(0);
194  float totalCharge(charge), finalToA(toa), integTime(0);
195  while(true) {
196  //compute integration time in ns and # bunches
197  //float newIntegTime(0);
198  int poffset = 0;
199  float charge_offset = 0.f;
200  const float charge_kfC(totalCharge*1e-3);
201  if(charge_kfC<tdcChargeDrainParameterisation_[3]) {
202  //newIntegTime=tdcChargeDrainParameterisation_[0]*pow(charge_kfC,2)+tdcChargeDrainParameterisation_[1]*charge_kfC+tdcChargeDrainParameterisation_[2];
203  } else if(charge_kfC<tdcChargeDrainParameterisation_[7]) {
204  poffset = 4;
205  charge_offset = tdcChargeDrainParameterisation_[3];
206  //newIntegTime=tdcChargeDrainParameterisation_[4]*pow(charge_kfC-tdcChargeDrainParameterisation_[3],2)+tdcChargeDrainParameterisation_[5]*(charge_kfC-tdcChargeDrainParameterisation_[3])+tdcChargeDrainParameterisation_[6];
207  } else {
208  poffset = 8;
209  charge_offset = tdcChargeDrainParameterisation_[7];
210  //newIntegTime=tdcChargeDrainParameterisation_[8]*pow(charge_kfC-tdcChargeDrainParameterisation_[7],2)+tdcChargeDrainParameterisation_[9]*(charge_kfC-tdcChargeDrainParameterisation_[7])+tdcChargeDrainParameterisation_[10];
211  }
212  const float charge_mod = charge_kfC - charge_offset;
213  const float newIntegTime = ( ( tdcChargeDrainParameterisation_[poffset]*charge_mod +
214  tdcChargeDrainParameterisation_[poffset+1] )*charge_mod +
215  tdcChargeDrainParameterisation_[poffset+2] );
216 
217  const int newBusyBxs=std::floor(newIntegTime/25.f)+1;
218 
219  //if no update is needed regarding the number of bunches,
220  //then the ToT integration time has converged
221  integTime=newIntegTime;
222  if(newBusyBxs==busyBxs) break;
223 
224  //update charge integrated during ToT
225  if(debug)
226  {
227  if(busyBxs==0) edm::LogVerbatim("HGCFE") << "\t Intial busy estimate="<< integTime << " ns = " << newBusyBxs << " bxs" << std::endl;
228  else edm::LogVerbatim("HGCFE") << "\t ...integrated charge overflows initial busy estimate, interating again" << std::endl;
229  }
230 
231  //update number of busy bunches
232  busyBxs=newBusyBxs;
233 
234  //reset charge to be integrated
235  totalCharge=charge;
236  if(toaMode_==WEIGHTEDBYE) finalToA=toa*charge;
237 
238  //add leakage from previous bunches in SARS ADC mode
239  for(int jt=0; jt<it; ++jt)
240  {
241  const unsigned int deltaT=(it-jt);
242  if((deltaT+2) >= adcPulse_.size() || chargeColl[jt]==0.f || totFlags[jt] || busyFlags[jt]) continue;
243 
244  const float leakCharge = chargeColl[jt]*adcPulse_[deltaT+2];
245  totalCharge += leakCharge;
246  if(toaMode_==WEIGHTEDBYE) finalToA += leakCharge*pulseAvgT_[deltaT+2];
247 
248  if(debug) edm::LogVerbatim("HGCFE") << "\t\t leaking " << chargeColl[jt] << " fC @ deltaT=-" << deltaT << " -> +" << leakCharge << " with avgT=" << pulseAvgT_[deltaT+2] << std::endl;
249  }
250 
251  //add contamination from posterior bunches
252  for(int jt=it+1; jt<it+busyBxs && jt<dataFrame.size() ; ++jt)
253  {
254  //this charge will be integrated in TDC mode
255  //disable for SARS ADC
256  busyFlags[jt]=true;
257 
258  const float extraCharge=chargeColl[jt];
259  if(extraCharge==0.f) continue;
260  if(debug) edm::LogVerbatim("HGCFE") << "\t\t adding " << extraCharge << " fC @ deltaT=+" << (jt-it) << std::endl;
261 
262  totalCharge += extraCharge;
263  if(toaMode_==WEIGHTEDBYE) finalToA += extraCharge*toaColl[jt];
264  }
265 
266  //finalize ToA contamination
267  if(toaMode_==WEIGHTEDBYE) finalToA /= totalCharge;
268  }
269 
270  toaFromToT[it] = CLHEP::RandGaussQ::shoot(engine,finalToA,tdcResolutionInNs_);
271  newCharge[it] = (totalCharge-tdcOnset_fC_);
272 
273  if(debug) edm::LogVerbatim("HGCFE") << "\t Final busy estimate="<< integTime << " ns = " << busyBxs << " bxs" << std::endl
274  << "\t Total integrated=" << totalCharge << " fC <toa>=" << toaFromToT[it] << " (raw=" << finalToA << ") ns " << std::endl;
275 
276  //last fC (tdcOnset) are dissipated trough pulse
277  if(it+busyBxs<(int)(newCharge.size()))
278  {
279  const float deltaT2nextBx((busyBxs*25-integTime));
280  const float tdcOnsetLeakage(tdcOnset_fC_*vdt::fast_expf(-deltaT2nextBx/tdcChargeDrainParameterisation_[11]));
281  if(debug) edm::LogVerbatim("HGCFE") << "\t Leaking remainder of TDC onset " << tdcOnset_fC_
282  << " fC, to be dissipated in " << deltaT2nextBx
283  << " DeltaT/tau=" << deltaT2nextBx << " / " << tdcChargeDrainParameterisation_[11]
284  << " ns, adds " << tdcOnsetLeakage << " fC @ " << it+busyBxs << " bx (first free bx)" << std::endl;
285  newCharge[it+busyBxs] += tdcOnsetLeakage;
286  }
287  }
288 
289  //including the leakage from bunches in SARS ADC when not declared busy or in ToT
290  auto runChargeSharing = [&]() {
291  int ipulse = 0;
292  for(int it=0; it<(int)(chargeColl.size()); ++it)
293  {
294  //if busy, charge has been already integrated
295  //if(debug) edm::LogVerbatim("HGCFE") << "\t SARS ADC pulse activated @ " << it << " : ";
296  if( !totFlags[it] & !busyFlags[it] ) {
297  const int start = std::max(0,2-it);
298  const int stop = std::min((int)adcPulse_.size(),(int)newCharge.size()-it+2);
299  for(ipulse = start; ipulse < stop; ++ipulse) {
300  const int itoffset = it + ipulse - 2;
301  //notice that if the channel is already busy,
302  //it has already been affected by the leakage of the SARS ADC
303  //if(totFlags[itoffset] || busyFlags[itoffset]) continue;
304  if( !totFlags[itoffset] & !busyFlags[itoffset] ) {
305  newCharge[itoffset] += chargeColl[it]*adcPulse_[ipulse];
306  }
307  //if(debug) edm::LogVerbatim("HGCFE") << " | " << itoffset << " " << chargeColl[it]*adcPulse_[ipulse] << "( " << chargeColl[it] << "->";
308  //if(debug) edm::LogVerbatim("HGCFE") << newCharge[itoffset] << ") ";
309  }
310  }
311 
312  if(debug) edm::LogVerbatim("HGCFE") << std::endl;
313  }
314  };
315  runChargeSharing();
316 
317  //set new ADCs and ToA
318  if(debug) edm::LogVerbatim("HGCFE") << "\t final result : ";
319  const float adj_thresh = thresholdFollowsMIP_ ? thickness*adcThreshold_fC_*cce : thickness*adcThreshold_fC_;
320  for(int it=0; it<(int)(newCharge.size()); it++)
321  {
322  if(debug) edm::LogVerbatim("HGCFE") << chargeColl[it] << " -> " << newCharge[it] << " ";
323 
324  HGCSample newSample;
325  if(totFlags[it] || busyFlags[it])
326  {
327  if(totFlags[it])
328  {
329  float finalToA(toaFromToT[it]);
330  while(finalToA < 0.f) finalToA+=25.f;
331  while(finalToA > 25.f) finalToA-=25.f;
332 
333  //brute force saturation, maybe could to better with an exponential like saturation
334  const float saturatedCharge(std::min(newCharge[it],tdcSaturation_fC_));
335  newSample.set(true,true,(uint16_t)(finalToA/toaLSB_ns_),(uint16_t)(std::floor(saturatedCharge/tdcLSB_fC_)));
336  }
337  else
338  {
339  newSample.set(false,true,0,0);
340  }
341  }
342  else
343  {
344  //brute force saturation, maybe could to better with an exponential like saturation
345  const float saturatedCharge(std::min(newCharge[it],adcSaturation_fC_));
346  newSample.set(newCharge[it]>adj_thresh,false,(uint16_t)0,(uint16_t)(std::floor(saturatedCharge/adcLSB_fC_)));
347  }
348  dataFrame.setSample(it,newSample);
349  }
350 
351  if(debug) {
352  std::ostringstream msg;
353  dataFrame.print(msg);
354  edm::LogVerbatim("HGCFE") << msg.str() << std::endl;
355  }
356 }
Definition: start.py:1
hgc::HGCSimHitData toaFromToT
std::array< bool, hgc::nSamples > totFlags
wrapper for a data word
Definition: HGCSample.h:13
#define constexpr
std::array< bool, hgc::nSamples > busyFlags
double f[11][100]
T min(T a, T b)
Definition: MathUtil.h:58
#define debug
Definition: HDRShower.cc:19
std::array< float, 6 > adcPulse_
float fast_expf(float x)
std::vector< float > tdcChargeDrainParameterisation_
std::array< float, 6 > pulseAvgT_
void set(bool thr, bool mode, uint16_t toa, uint16_t data)
Definition: HGCSample.h:34
hgc::HGCSimHitData newCharge
template<class DFr >
void HGCFEElectronics< DFr >::runSimpleShaper ( DFr &  dataFrame,
hgc::HGCSimHitData chargeColl,
int  thickness,
float  cce = 1.0 
)

applies a shape to each time sample and propagates the tails to the subsequent time samples

Definition at line 103 of file HGCFEElectronics.cc.

References HGCFEElectronics< DFr >::adcLSB_fC_, HGCFEElectronics< DFr >::adcPulse_, HGCFEElectronics< DFr >::adcSaturation_fC_, HGCFEElectronics< DFr >::adcThreshold_fC_, ALCARECOTkAlJpsiMuMu_cff::charge, debug, f, createfilelist::int, min(), mps_alisetup::msg, HGCFEElectronics< DFr >::newCharge, HGCSample::set(), and HGCFEElectronics< DFr >::thresholdFollowsMIP_.

Referenced by HGCFEElectronics< DFr >::runShaper(), and HGCFEElectronics< DFr >::setADClsb().

104 {
105  //convolute with pulse shape to compute new ADCs
106  newCharge.fill(0.f);
107  bool debug(false);
108  for(int it=0; it<(int)(chargeColl.size()); it++)
109  {
110  const float charge(chargeColl[it]);
111  if(charge==0.f) continue;
112 
113 #ifdef EDM_ML_DEBUG
115 #endif
116 
117  if(debug) edm::LogVerbatim("HGCFE") << "\t Redistributing SARS ADC" << charge << " @ " << it;
118 
119  for(int ipulse=-2; ipulse<(int)(adcPulse_.size())-2; ipulse++)
120  {
121  if(it+ipulse<0) continue;
122  if(it+ipulse>=(int)(dataFrame.size())) continue;
123  const float chargeLeak=charge*adcPulse_[(ipulse+2)];
124  newCharge[it+ipulse]+= chargeLeak;
125 
126  if(debug) edm::LogVerbatim("HGCFE") << " | " << it+ipulse << " " << chargeLeak;
127  }
128 
129  if(debug) edm::LogVerbatim("HGCFE") << std::endl;
130  }
131 
132  //set new ADCs
133  const float adj_thresh = thresholdFollowsMIP_ ? thickness*adcThreshold_fC_*cce : thickness*adcThreshold_fC_;
134 
135  for(int it=0; it<(int)(newCharge.size()); it++)
136  {
137  //brute force saturation, maybe could to better with an exponential like saturation
138  const float saturatedCharge(std::min(newCharge[it],adcSaturation_fC_));
139  HGCSample newSample;
140  newSample.set(newCharge[it]>adj_thresh,false,0,std::floor(saturatedCharge/adcLSB_fC_));
141  dataFrame.setSample(it,newSample);
142 
143  if(debug) edm::LogVerbatim("HGCFE") << std::floor(saturatedCharge/adcLSB_fC_) << " (" << saturatedCharge << "/" << adcLSB_fC_ <<" ) " ;
144  }
145 
146  if(debug) {
147  std::ostringstream msg;
148  dataFrame.print(msg);
149  edm::LogVerbatim("HGCFE") << msg.str() << std::endl;
150  }
151 }
wrapper for a data word
Definition: HGCSample.h:13
double f[11][100]
T min(T a, T b)
Definition: MathUtil.h:58
#define debug
Definition: HDRShower.cc:19
std::array< float, 6 > adcPulse_
void set(bool thr, bool mode, uint16_t toa, uint16_t data)
Definition: HGCSample.h:34
hgc::HGCSimHitData newCharge
template<class DFr >
void HGCFEElectronics< DFr >::runTrivialShaper ( DFr &  dataFrame,
hgc::HGCSimHitData chargeColl,
int  thickness,
float  cce = 1.0 
)

converts charge to digis without pulse shape

Definition at line 70 of file HGCFEElectronics.cc.

References ecalMGPA::adc(), HGCFEElectronics< DFr >::adcLSB_fC_, HGCFEElectronics< DFr >::adcSaturation_fC_, HGCFEElectronics< DFr >::adcThreshold_fC_, debug, createfilelist::int, min(), mps_alisetup::msg, HGCSample::set(), and HGCFEElectronics< DFr >::thresholdFollowsMIP_.

Referenced by HGCFEElectronics< DFr >::runShaper(), and HGCFEElectronics< DFr >::setADClsb().

71 {
72  bool debug(false);
73 
74 #ifdef EDM_ML_DEBUG
75  for(int it=0; it<(int)(chargeColl.size()); it++) debug |= (chargeColl[it]>adcThreshold_fC_);
76 #endif
77 
78  if(debug) edm::LogVerbatim("HGCFE") << "[runTrivialShaper]" << std::endl;
79 
80  //set new ADCs
81  const float adj_thresh = thresholdFollowsMIP_ ? thickness*adcThreshold_fC_*cce : thickness*adcThreshold_fC_;
82 
83  for(int it=0; it<(int)(chargeColl.size()); it++)
84  {
85  //brute force saturation, maybe could to better with an exponential like saturation
86  const uint32_t adc=std::floor( std::min(chargeColl[it],adcSaturation_fC_) / adcLSB_fC_ );
87  HGCSample newSample;
88  newSample.set(chargeColl[it]>adj_thresh,false,0,adc);
89  dataFrame.setSample(it,newSample);
90 
91  if(debug) edm::LogVerbatim("HGCFE") << adc << " (" << chargeColl[it] << "/" << adcLSB_fC_ << ") ";
92  }
93 
94  if(debug) {
95  std::ostringstream msg;
96  dataFrame.print(msg);
97  edm::LogVerbatim("HGCFE") << msg.str() << std::endl;
98  }
99 }
int adc(sample_type sample)
get the ADC sample (12 bits)
wrapper for a data word
Definition: HGCSample.h:13
T min(T a, T b)
Definition: MathUtil.h:58
#define debug
Definition: HDRShower.cc:19
void set(bool thr, bool mode, uint16_t toa, uint16_t data)
Definition: HGCSample.h:34
template<class DFr >
void HGCFEElectronics< DFr >::setADClsb ( float  newLSB)
inline
template<class DFr >
uint32_t HGCFEElectronics< DFr >::toaMode ( ) const
inline

returns how ToT will be computed

Definition at line 74 of file HGCFEElectronics.h.

References HGCFEElectronics< DFr >::toaMode_.

74 { return toaMode_; }

Member Data Documentation

template<class DFr >
float HGCFEElectronics< DFr >::adcLSB_fC_
private
template<class DFr >
std::array<float,6> HGCFEElectronics< DFr >::adcPulse_
private
template<class DFr >
float HGCFEElectronics< DFr >::adcSaturation_fC_
private
template<class DFr >
float HGCFEElectronics< DFr >::adcThreshold_fC_
private
template<class DFr >
std::array<bool,hgc::nSamples> HGCFEElectronics< DFr >::busyFlags
private

Definition at line 92 of file HGCFEElectronics.h.

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

template<class DFr >
uint32_t HGCFEElectronics< DFr >::fwVersion_
private
template<class DFr >
hgc::HGCSimHitData HGCFEElectronics< DFr >::newCharge
private
template<class DFr >
std::array<float,6> HGCFEElectronics< DFr >::pulseAvgT_
private
template<class DFr >
std::vector<float> HGCFEElectronics< DFr >::tdcChargeDrainParameterisation_
private
template<class DFr >
float HGCFEElectronics< DFr >::tdcLSB_fC_
private
template<class DFr >
float HGCFEElectronics< DFr >::tdcOnset_fC_
private
template<class DFr >
float HGCFEElectronics< DFr >::tdcResolutionInNs_
private
template<class DFr >
float HGCFEElectronics< DFr >::tdcSaturation_fC_
private
template<class DFr >
bool HGCFEElectronics< DFr >::thresholdFollowsMIP_
private
template<class DFr >
hgc::HGCSimHitData HGCFEElectronics< DFr >::toaFromToT
private

Definition at line 93 of file HGCFEElectronics.h.

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

template<class DFr >
float HGCFEElectronics< DFr >::toaLSB_ns_
private
template<class DFr >
uint32_t HGCFEElectronics< DFr >::toaMode_
private
template<class DFr >
std::array<bool,hgc::nSamples> HGCFEElectronics< DFr >::totFlags
private

Definition at line 92 of file HGCFEElectronics.h.

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