CMS 3D CMS Logo

List of all members | Public Member Functions | Static Public Attributes | Private Member Functions | Private Attributes
BTLElectronicsSim Class Reference

#include <BTLElectronicsSim.h>

Public Member Functions

 BTLElectronicsSim (const edm::ParameterSet &pset)
 
void getEvent (const edm::Event &evt)
 
void getEventSetup (const edm::EventSetup &evt)
 
void run (const mtd::MTDSimHitDataAccumulator &input, BTLDigiCollection &output, CLHEP::HepRandomEngine *hre) const
 
void runTrivialShaper (BTLDataFrame &dataFrame, const mtd::MTDSimHitData &chargeColl, const mtd::MTDSimHitData &toa1, const mtd::MTDSimHitData &toa2, const uint8_t row, const uint8_t col) const
 
void updateOutput (BTLDigiCollection &coll, const BTLDataFrame &rawDataFrame) const
 

Static Public Attributes

static int dfSIZE = 2
 

Private Member Functions

float sigma2_pe (const float &Q, const float &R) const
 

Private Attributes

const uint32_t adcBitSaturation_
 
const float adcLSB_MIP_
 
const uint32_t adcNbits_
 
const float adcSaturation_MIP_
 
const float adcThreshold_MIP_
 
const BTLPulseShape btlPulseShape_
 
const float bxTime_
 
const float ChannelTimeOffset_
 
const float CorrCoeff_
 
const float cosPhi_
 
const float DarkCountRate_
 
const float DCRxRiseTime_
 
const bool debug_
 
const float EnergyThreshold_
 
const float Npe_to_pC_
 
const float Npe_to_V_
 
const float ReferencePulseNpe_
 
const float ScintillatorDecayTime2_
 
const float ScintillatorDecayTime_
 
const float ScintillatorRiseTime_
 
const float SigmaClock2_
 
const float SigmaClock_
 
const float SigmaElectronicNoise2_
 
const float SigmaElectronicNoise_
 
const float SinglePhotonTimeResolution_
 
const float sinPhi_
 
const float smearChannelTimeOffset_
 
const float SPTR2_
 
const uint32_t tdcBitSaturation_
 
const uint32_t tdcNbits_
 
const float testBeamMIPTimeRes_
 
const float TimeThreshold1_
 
const float TimeThreshold2_
 
const float toaLSB_ns_
 

Detailed Description

Definition at line 21 of file BTLElectronicsSim.h.

Constructor & Destructor Documentation

BTLElectronicsSim::BTLElectronicsSim ( const edm::ParameterSet pset)

Definition at line 11 of file BTLElectronicsSim.cc.

11  :
12  debug_( pset.getUntrackedParameter<bool>("debug",false) ),
13  bxTime_( pset.getParameter<double>("bxTime") ),
14  testBeamMIPTimeRes_( pset.getParameter<double>("TestBeamMIPTimeRes") ),
15  ScintillatorRiseTime_( pset.getParameter<double>("ScintillatorRiseTime") ),
16  ScintillatorDecayTime_( pset.getParameter<double>("ScintillatorDecayTime") ),
17  ChannelTimeOffset_( pset.getParameter<double>("ChannelTimeOffset") ),
18  smearChannelTimeOffset_( pset.getParameter<double>("smearChannelTimeOffset") ),
19  EnergyThreshold_( pset.getParameter<double>("EnergyThreshold") ),
20  TimeThreshold1_( pset.getParameter<double>("TimeThreshold1") ),
21  TimeThreshold2_( pset.getParameter<double>("TimeThreshold2") ),
22  ReferencePulseNpe_( pset.getParameter<double>("ReferencePulseNpe") ),
23  SinglePhotonTimeResolution_( pset.getParameter<double>("SinglePhotonTimeResolution") ),
24  DarkCountRate_( pset.getParameter<double>("DarkCountRate") ),
25  SigmaElectronicNoise_( pset.getParameter<double>("SigmaElectronicNoise") ),
26  SigmaClock_( pset.getParameter<double>("SigmaClock")),
27  Npe_to_pC_( pset.getParameter<double>("Npe_to_pC") ),
28  Npe_to_V_( pset.getParameter<double>("Npe_to_V") ),
29  adcNbits_( pset.getParameter<uint32_t>("adcNbits") ),
30  tdcNbits_( pset.getParameter<uint32_t>("tdcNbits") ),
31  adcSaturation_MIP_( pset.getParameter<double>("adcSaturation_MIP") ),
34  adcThreshold_MIP_( pset.getParameter<double>("adcThreshold_MIP") ),
35  toaLSB_ns_( pset.getParameter<double>("toaLSB_ns") ),
37  CorrCoeff_( pset.getParameter<double>("CorrelationCoefficient") ),
38  cosPhi_( 0.5*(sqrt(1.+CorrCoeff_)+sqrt(1.-CorrCoeff_)) ),
39  sinPhi_( 0.5*CorrCoeff_/cosPhi_ ),
45 }
T getParameter(std::string const &) const
T getUntrackedParameter(std::string const &, T const &) const
const float Npe_to_pC_
const float DCRxRiseTime_
const float adcThreshold_MIP_
const float adcSaturation_MIP_
const float SigmaClock_
const float DarkCountRate_
const float TimeThreshold2_
const float adcLSB_MIP_
const float ScintillatorDecayTime2_
const float toaLSB_ns_
T sqrt(T t)
Definition: SSEVec.h:18
const float CorrCoeff_
const uint32_t adcBitSaturation_
const uint32_t tdcNbits_
const float SigmaElectronicNoise2_
const float SigmaElectronicNoise_
const float EnergyThreshold_
const float SinglePhotonTimeResolution_
const uint32_t tdcBitSaturation_
const float ScintillatorDecayTime_
const float TimeThreshold1_
const float ChannelTimeOffset_
const float ScintillatorRiseTime_
const float testBeamMIPTimeRes_
const float smearChannelTimeOffset_
const float SigmaClock2_
Power< A, B >::type pow(const A &a, const B &b)
Definition: Power.h:40
const uint32_t adcNbits_
const float ReferencePulseNpe_

Member Function Documentation

void BTLElectronicsSim::getEvent ( const edm::Event evt)
inline

Definition at line 25 of file BTLElectronicsSim.h.

25 { }
void BTLElectronicsSim::getEventSetup ( const edm::EventSetup evt)
inline

Definition at line 27 of file BTLElectronicsSim.h.

References cuy::col, coll, input, convertSQLitetoXML_cfg::output, and writedatasetfile::run.

27 { }
void BTLElectronicsSim::run ( const mtd::MTDSimHitDataAccumulator input,
BTLDigiCollection output,
CLHEP::HepRandomEngine *  hre 
) const

Definition at line 48 of file BTLElectronicsSim.cc.

References btlPulseShape_, ChannelTimeOffset_, cosPhi_, DCRxRiseTime_, EnergyThreshold_, f, mps_fire::i, Npe_to_pC_, Npe_to_V_, ReferencePulseNpe_, runTrivialShaper(), ScintillatorDecayTime2_, ScintillatorDecayTime_, sigma2_pe(), SigmaClock2_, SigmaElectronicNoise2_, sinPhi_, smearChannelTimeOffset_, SPTR2_, mathSSE::sqrt(), testBeamMIPTimeRes_, MTDShapeBase::timeAtThr(), create_public_lumi_plots::times, hcalSimParameters_cfi::timeSmearing, TimeThreshold1_, TimeThreshold2_, and updateOutput().

50  {
51 
52  MTDSimHitData chargeColl, toa1, toa2;
53 
54  for(MTDSimHitDataAccumulator::const_iterator it=input.begin();
55  it!=input.end();
56  it++) {
57 
58  chargeColl.fill(0.f);
59  toa1.fill(0.f);
60  toa2.fill(0.f);
61  for(size_t i=0; i<it->second.hit_info[0].size(); i++) {
62 
63  // --- Fluctuate the total number of photo-electrons
64  float Npe = CLHEP::RandPoissonQ::shoot(hre, (it->second).hit_info[0][i]);
65  if ( Npe < EnergyThreshold_ ) continue;
66 
67 
68  // --- Get the time of arrival and add a channel time offset
69  float finalToA1 = (it->second).hit_info[1][i] + ChannelTimeOffset_;
70 
71  if ( smearChannelTimeOffset_ > 0. ){
72  float timeSmearing = CLHEP::RandGaussQ::shoot(hre, 0., smearChannelTimeOffset_);
73  finalToA1 += timeSmearing;
74  }
75 
76 
77  // --- Calculate and add the time walk: the time of arrival is read in correspondence
78  // with two thresholds on the signal pulse
79  std::array<float, 3> times = btlPulseShape_.timeAtThr(Npe/ReferencePulseNpe_,
81  TimeThreshold2_*Npe_to_V_);
82 
83 
84  // --- If the pulse amplitude is smaller than TimeThreshold2, the trigger does not fire
85  if (times[1] == 0.) continue;
86 
87  float finalToA2 = finalToA1 + times[1];
88  finalToA1 += times[0];
89 
90 
91  // --- Uncertainty due to the fluctuations of the n-th photon arrival time:
92  if ( testBeamMIPTimeRes_ > 0. ) {
93  // In this case the time resolution is parametrized from the testbeam.
94  // The same parameterization is used for both thresholds.
95  float sigma = testBeamMIPTimeRes_/sqrt(Npe);
96  float smearing_stat_thr1 = CLHEP::RandGaussQ::shoot(hre, 0., sigma);
97  float smearing_stat_thr2 = CLHEP::RandGaussQ::shoot(hre, 0., sigma);
98 
99  finalToA1 += smearing_stat_thr1;
100  finalToA2 += smearing_stat_thr2;
101 
102  }
103  else {
104  // In this case the time resolution is taken from the literature.
105  // The fluctuations due to the first TimeThreshold1_ p.e. are common to both times
106  float smearing_stat_thr1 = CLHEP::RandGaussQ::shoot(hre, 0.,
108  float smearing_stat_thr2 = CLHEP::RandGaussQ::shoot(hre, 0.,
110  finalToA1 += smearing_stat_thr1;
111  finalToA2 += smearing_stat_thr1 + smearing_stat_thr2;
112  }
113 
114 
115  // --- Add in quadrature the uncertainties due to the SiPM timing resolution, the SiPM DCR,
116  // the electronic noise and the clock distribution:
117  float slew2 = ScintillatorDecayTime2_/Npe/Npe;
118 
119  float sigma2_tot_thr1 = SPTR2_/TimeThreshold1_ + (DCRxRiseTime_ + SigmaElectronicNoise2_)*slew2 + SigmaClock2_;
120  float sigma2_tot_thr2 = SPTR2_/TimeThreshold2_ + (DCRxRiseTime_ + SigmaElectronicNoise2_)*slew2 + SigmaClock2_;
121 
122 
123  // --- Smear the arrival times using the correlated uncertainties:
124  float smearing_thr1_uncorr = CLHEP::RandGaussQ::shoot(hre, 0., sqrt(sigma2_tot_thr1));
125  float smearing_thr2_uncorr = CLHEP::RandGaussQ::shoot(hre, 0., sqrt(sigma2_tot_thr2));
126 
127  finalToA1 += cosPhi_*smearing_thr1_uncorr + sinPhi_*smearing_thr2_uncorr;
128  finalToA2 += sinPhi_*smearing_thr1_uncorr + cosPhi_*smearing_thr2_uncorr;
129 
130  chargeColl[i] = Npe*Npe_to_pC_; // the p.e. number is here converted to pC
131 
132  toa1[i] = finalToA1;
133  toa2[i] = finalToA2;
134 
135  }
136 
137  //run the shaper to create a new data frame
138  BTLDataFrame rawDataFrame( it->first.detid_ );
139  runTrivialShaper(rawDataFrame,chargeColl,toa1,toa2,it->first.row_, it->first.column_);
140  updateOutput(output,rawDataFrame);
141 
142  }
143 
144 }
const float Npe_to_pC_
const float DCRxRiseTime_
float sigma2_pe(const float &Q, const float &R) const
std::array< MTDSimData_t, nSamples > MTDSimHitData
const float TimeThreshold2_
static std::string const input
Definition: EdmProvDump.cc:48
void updateOutput(BTLDigiCollection &coll, const BTLDataFrame &rawDataFrame) const
const float ScintillatorDecayTime2_
const BTLPulseShape btlPulseShape_
T sqrt(T t)
Definition: SSEVec.h:18
double f[11][100]
const float SigmaElectronicNoise2_
const float EnergyThreshold_
std::array< float, 3 > timeAtThr(const float scale, const float threshold1, const float threshold2) const
Definition: MTDShapeBase.cc:15
const float ScintillatorDecayTime_
const float TimeThreshold1_
const float ChannelTimeOffset_
Readout digi for HGC.
Definition: FTLDataFrameT.h:14
const float testBeamMIPTimeRes_
void runTrivialShaper(BTLDataFrame &dataFrame, const mtd::MTDSimHitData &chargeColl, const mtd::MTDSimHitData &toa1, const mtd::MTDSimHitData &toa2, const uint8_t row, const uint8_t col) const
const float smearChannelTimeOffset_
const float SigmaClock2_
const float ReferencePulseNpe_
void BTLElectronicsSim::runTrivialShaper ( BTLDataFrame dataFrame,
const mtd::MTDSimHitData chargeColl,
const mtd::MTDSimHitData toa1,
const mtd::MTDSimHitData toa2,
const uint8_t  row,
const uint8_t  col 
) const

Definition at line 147 of file BTLElectronicsSim.cc.

References ecalMGPA::adc(), adcBitSaturation_, adcLSB_MIP_, adcThreshold_MIP_, debug, debug_, createfilelist::int, min(), mps_check::msg, FTLDataFrameT< D, S, DECODE >::print(), BTLSample::set(), FTLDataFrameT< D, S, DECODE >::setSample(), tdcBitSaturation_, and toaLSB_ns_.

Referenced by run().

151  {
152  bool debug = debug_;
153 #ifdef EDM_ML_DEBUG
154  for(int it=0; it<(int)(chargeColl.size()); it++) debug |= (chargeColl[it]>adcThreshold_fC_);
155 #endif
156 
157  if(debug) edm::LogVerbatim("BTLElectronicsSim") << "[runTrivialShaper]" << std::endl;
158 
159  //set new ADCs
160  for(int it=0; it<(int)(chargeColl.size()); it++) {
161 
162  BTLSample newSample;
163  newSample.set(false,false,0,0,0,row,col);
164 
165  //brute force saturation, maybe could to better with an exponential like saturation
166  const uint32_t adc = std::min( (uint32_t) std::floor(chargeColl[it]/adcLSB_MIP_), adcBitSaturation_ );
167  const uint32_t tdc_time1 = std::min( (uint32_t) std::floor(toa1[it]/toaLSB_ns_), tdcBitSaturation_);
168  const uint32_t tdc_time2 = std::min( (uint32_t) std::floor(toa2[it]/toaLSB_ns_), tdcBitSaturation_);
169 
170  newSample.set(chargeColl[it] > adcThreshold_MIP_,tdc_time1 == tdcBitSaturation_,
171  tdc_time2,tdc_time1,adc,row,col);
172  dataFrame.setSample(it,newSample);
173 
174  if(debug) edm::LogVerbatim("BTLElectronicsSim") << adc << " ("
175  << chargeColl[it] << "/"
176  << adcLSB_MIP_ << ") ";
177  }
178 
179  if(debug) {
180  std::ostringstream msg;
181  dataFrame.print(msg);
182  edm::LogVerbatim("BTLElectronicsSim") << msg.str() << std::endl;
183  }
184 }
const float adcThreshold_MIP_
wrapper for a data word
Definition: BTLSample.h:13
const float adcLSB_MIP_
const float toaLSB_ns_
const uint32_t adcBitSaturation_
void setSample(int i, const S &sample)
Definition: FTLDataFrameT.h:59
T min(T a, T b)
Definition: MathUtil.h:58
constexpr int adc(sample_type sample)
get the ADC sample (12 bits)
#define debug
Definition: HDRShower.cc:19
tuple msg
Definition: mps_check.py:285
const uint32_t tdcBitSaturation_
void set(bool thr, bool mode, uint16_t toa2, uint16_t toa, uint16_t data, uint8_t row, uint8_t col)
Definition: BTLSample.h:38
col
Definition: cuy.py:1010
void print(std::ostream &out=std::cout)
Definition: FTLDataFrameT.h:60
float BTLElectronicsSim::sigma2_pe ( const float &  Q,
const float &  R 
) const
private

Definition at line 202 of file BTLElectronicsSim.cc.

References dttmaxenums::R.

Referenced by run().

202  {
203 
204  float OneOverR = 1./R;
205  float OneOverR2 = OneOverR*OneOverR;
206 
207  // --- This is Eq. (17) from Nucl. Instr. Meth. A 564 (2006) 185
208  float sigma2 = Q * OneOverR2 * ( 1. + 2.*(Q+1.)*OneOverR +
209  (Q+1.)*(6.*Q+11)*OneOverR2 +
210  (Q+1.)*(Q+2.)*(2.*Q+5.)*OneOverR2*OneOverR );
211 
212  return sigma2;
213 
214 }
void BTLElectronicsSim::updateOutput ( BTLDigiCollection coll,
const BTLDataFrame rawDataFrame 
) const

Definition at line 186 of file BTLElectronicsSim.cc.

References dfSIZE, FTLDataFrameT< D, S, DECODE >::id(), edm::SortedCollection< T, SORT >::push_back(), and FTLDataFrameT< D, S, DECODE >::resize().

Referenced by run().

187  {
188 
189  BTLDataFrame dataFrame( rawDataFrame.id() );
190  dataFrame.resize(dfSIZE);
191  bool putInEvent(false);
192  for(int it=0;it<dfSIZE; ++it) {
193  dataFrame.setSample(it, rawDataFrame[it]);
194  if(it==0) putInEvent = rawDataFrame[it].threshold();
195  }
196 
197  if(putInEvent) {
198  coll.push_back(dataFrame);
199  }
200 }
void push_back(T const &t)
void resize(size_t s)
allow to set size
Definition: FTLDataFrameT.h:52
Readout digi for HGC.
Definition: FTLDataFrameT.h:14
const D & id() const
det id
Definition: FTLDataFrameT.h:32

Member Data Documentation

const uint32_t BTLElectronicsSim::adcBitSaturation_
private

Definition at line 78 of file BTLElectronicsSim.h.

Referenced by runTrivialShaper().

const float BTLElectronicsSim::adcLSB_MIP_
private

Definition at line 79 of file BTLElectronicsSim.h.

Referenced by runTrivialShaper().

const uint32_t BTLElectronicsSim::adcNbits_
private

Definition at line 74 of file BTLElectronicsSim.h.

const float BTLElectronicsSim::adcSaturation_MIP_
private

Definition at line 77 of file BTLElectronicsSim.h.

const float BTLElectronicsSim::adcThreshold_MIP_
private

Definition at line 80 of file BTLElectronicsSim.h.

Referenced by runTrivialShaper().

const BTLPulseShape BTLElectronicsSim::btlPulseShape_
private

Definition at line 94 of file BTLElectronicsSim.h.

Referenced by run().

const float BTLElectronicsSim::bxTime_
private

Definition at line 53 of file BTLElectronicsSim.h.

const float BTLElectronicsSim::ChannelTimeOffset_
private

Definition at line 57 of file BTLElectronicsSim.h.

Referenced by run().

const float BTLElectronicsSim::CorrCoeff_
private

Definition at line 84 of file BTLElectronicsSim.h.

const float BTLElectronicsSim::cosPhi_
private

Definition at line 85 of file BTLElectronicsSim.h.

Referenced by run().

const float BTLElectronicsSim::DarkCountRate_
private

Definition at line 66 of file BTLElectronicsSim.h.

const float BTLElectronicsSim::DCRxRiseTime_
private

Definition at line 90 of file BTLElectronicsSim.h.

Referenced by run().

const bool BTLElectronicsSim::debug_
private

Definition at line 51 of file BTLElectronicsSim.h.

Referenced by runTrivialShaper().

int BTLElectronicsSim::dfSIZE = 2
static

Definition at line 44 of file BTLElectronicsSim.h.

Referenced by updateOutput().

const float BTLElectronicsSim::EnergyThreshold_
private

Definition at line 60 of file BTLElectronicsSim.h.

Referenced by run().

const float BTLElectronicsSim::Npe_to_pC_
private

Definition at line 70 of file BTLElectronicsSim.h.

Referenced by run().

const float BTLElectronicsSim::Npe_to_V_
private

Definition at line 71 of file BTLElectronicsSim.h.

Referenced by run().

const float BTLElectronicsSim::ReferencePulseNpe_
private

Definition at line 63 of file BTLElectronicsSim.h.

Referenced by run().

const float BTLElectronicsSim::ScintillatorDecayTime2_
private

Definition at line 88 of file BTLElectronicsSim.h.

Referenced by run().

const float BTLElectronicsSim::ScintillatorDecayTime_
private

Definition at line 56 of file BTLElectronicsSim.h.

Referenced by run().

const float BTLElectronicsSim::ScintillatorRiseTime_
private

Definition at line 55 of file BTLElectronicsSim.h.

const float BTLElectronicsSim::SigmaClock2_
private

Definition at line 92 of file BTLElectronicsSim.h.

Referenced by run().

const float BTLElectronicsSim::SigmaClock_
private

Definition at line 68 of file BTLElectronicsSim.h.

const float BTLElectronicsSim::SigmaElectronicNoise2_
private

Definition at line 91 of file BTLElectronicsSim.h.

Referenced by run().

const float BTLElectronicsSim::SigmaElectronicNoise_
private

Definition at line 67 of file BTLElectronicsSim.h.

const float BTLElectronicsSim::SinglePhotonTimeResolution_
private

Definition at line 65 of file BTLElectronicsSim.h.

const float BTLElectronicsSim::sinPhi_
private

Definition at line 86 of file BTLElectronicsSim.h.

Referenced by run().

const float BTLElectronicsSim::smearChannelTimeOffset_
private

Definition at line 58 of file BTLElectronicsSim.h.

Referenced by run().

const float BTLElectronicsSim::SPTR2_
private

Definition at line 89 of file BTLElectronicsSim.h.

Referenced by run().

const uint32_t BTLElectronicsSim::tdcBitSaturation_
private

Definition at line 82 of file BTLElectronicsSim.h.

Referenced by runTrivialShaper().

const uint32_t BTLElectronicsSim::tdcNbits_
private

Definition at line 74 of file BTLElectronicsSim.h.

const float BTLElectronicsSim::testBeamMIPTimeRes_
private

Definition at line 54 of file BTLElectronicsSim.h.

Referenced by run().

const float BTLElectronicsSim::TimeThreshold1_
private

Definition at line 61 of file BTLElectronicsSim.h.

Referenced by run().

const float BTLElectronicsSim::TimeThreshold2_
private

Definition at line 62 of file BTLElectronicsSim.h.

Referenced by run().

const float BTLElectronicsSim::toaLSB_ns_
private

Definition at line 81 of file BTLElectronicsSim.h.

Referenced by runTrivialShaper().