CMS 3D CMS Logo

HcalTDC.cc
Go to the documentation of this file.
5 #include "CLHEP/Random/RandGaussQ.h"
6 
8  : theTDCParameters(), theDbService(nullptr), threshold_currentTDC_(threshold_currentTDC), lsb(3.74) {}
9 
11 
12 //template <class Digi>
13 void HcalTDC::timing(const CaloSamples& lf, QIE11DataFrame& digi) const {
14  float const TDC_Threshold(getThreshold());
15  bool risingReady(true);
16  int tdcBins = theTDCParameters.nbins();
17  bool hasTDCValues = true;
18  if (lf.preciseSize() == 0)
19  hasTDCValues = false;
20 
21  for (int ibin = 0; ibin < lf.size(); ++ibin) {
22  /*
23  If in a given 25ns bunch/time sample, the pulse is above
24  TDC_Thresh already, then TDC_RisingEdge=0 if it was low in the
25  last precision bin on the previous bunch crossing, otherwise,
26  TDC_RisingEdge=63 if the pulse never crosses the threshold
27  having started off, then the special code is 62 and then
28  one can still have a TDC_FallingEdge that is valid. If the pulse
29  never falls below threshold having started above threshold (or
30  goes above threshold in the bunch crossing and doesn't come down),
31  then TDC_FallingEdge=. If the pulse never went above
32  threshold, then TDC_RisingEdge=63 and
33  TDC_FallingEdge=62.
34  */
35  // special codes
36  int TDC_RisingEdge = (risingReady) ? theTDCParameters.noTransitionCode() : theTDCParameters.alreadyTransitionCode();
37  int preciseBegin = ibin * tdcBins;
38  int preciseEnd = preciseBegin + tdcBins;
39 
40  if (hasTDCValues) {
41  for (int i = preciseBegin; i < preciseEnd; ++i) { //find the TDC time value in each TS
42 
43  if ((!risingReady) && (i == preciseBegin) && (i != 0)) {
44  if (((lf.preciseAt(i + 1) - lf.preciseAt(i - 1)) > TDC_Threshold)) {
45  TDC_RisingEdge = theTDCParameters.alreadyTransitionCode();
46  break;
47  } else
48  risingReady = true;
49  }
50 
51  if (risingReady) {
52  if (i != (lf.size() * tdcBins - 1) && i != 0 && (lf.preciseAt(i + 1) - lf.preciseAt(i - 1)) > TDC_Threshold) {
53  risingReady = false;
54  TDC_RisingEdge = i - preciseBegin;
55  } else if (i == 0 && (lf.preciseAt(i + 1) - lf.preciseAt(i)) / 0.5 > TDC_Threshold) {
56  risingReady = false;
57  TDC_RisingEdge = i - preciseBegin;
58  } else if (i == (preciseEnd - 1))
59  TDC_RisingEdge = theTDCParameters.noTransitionCode();
60  }
61 
62  if ((!risingReady) && (i == (preciseEnd - 1)) && (i != (lf.size() * tdcBins - 1))) {
63  if (((lf.preciseAt(i + 1) - lf.preciseAt(i - 1)) < TDC_Threshold)) {
64  risingReady = true;
65  }
66  }
67  } //end of looping precise bins
68  }
69 
70  // change packing to allow for special codes
71  int packedTDC = TDC_RisingEdge;
72  digi.setSample(ibin, digi[ibin].adc(), packedTDC, digi[ibin].soi());
73 
74  } // loop over bunch crossing bins
75 }
76 
ecalMGPA::adc
constexpr int adc(sample_type sample)
get the ADC sample (12 bits)
Definition: EcalMGPASample.h:11
service
Definition: service.py:1
HcalCalibrations.h
mps_fire.i
i
Definition: mps_fire.py:355
MessageLogger.h
CaloSamples::preciseAt
float preciseAt(int i) const
const function to access precise samples
Definition: CaloSamples.h:33
CaloSamples::size
int size() const
get the size
Definition: CaloSamples.h:24
hcalSimParameters_cfi.threshold_currentTDC
threshold_currentTDC
Definition: hcalSimParameters_cfi.py:24
HcalTDCParameters::alreadyTransitionCode
int alreadyTransitionCode() const
Definition: HcalTDCParameters.h:12
CaloSamples::preciseSize
int preciseSize() const
get the size
Definition: CaloSamples.h:70
HcalTDC::~HcalTDC
~HcalTDC()
Definition: HcalTDC.cc:10
QIE11DataFrame::setSample
constexpr void setSample(edm::DataFrame::size_type isample, int adc, int tdc, bool soi=false)
set the sample contents
Definition: QIE11DataFrame.h:121
CaloSamples
Definition: CaloSamples.h:14
HcalTDC::theTDCParameters
HcalTDCParameters theTDCParameters
Definition: HcalTDC.h:31
HcalTDC.h
HcalTDC::theDbService
const HcalDbService * theDbService
Definition: HcalTDC.h:35
HcalDbService
Definition: HcalDbService.h:26
QIE11DataFrame
Definition: QIE11DataFrame.h:11
HcalDbService.h
HcalTDC::timing
void timing(const CaloSamples &lf, QIE11DataFrame &digi) const
Definition: HcalTDC.cc:13
HcalTDC::getThreshold
double getThreshold() const
Definition: HcalTDC.h:31
HcalTDC::setDbService
void setDbService(const HcalDbService *service)
the Producer will probably update this every event
Definition: HcalTDC.cc:77
HcalTDCParameters::nbins
int nbins() const
Definition: HcalTDCParameters.h:9
HcalTDC::HcalTDC
HcalTDC(double threshold_currentTDC=0.)
Definition: HcalTDC.cc:7
HcalTDCParameters::noTransitionCode
int noTransitionCode() const
Definition: HcalTDCParameters.h:13