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 
void setSample(edm::DataFrame::size_type isample, int adc, int tdc, bool soi=false)
set the sample contents
#define nullptr
const HcalDbService * theDbService
Definition: HcalTDC.h:35
int preciseSize() const
get the size
Definition: CaloSamples.h:70
void timing(const CaloSamples &lf, QIE11DataFrame &digi) const
Definition: HcalTDC.cc:13
float preciseAt(int i) const
const function to access precise samples
Definition: CaloSamples.h:33
double getThreshold() const
Definition: HcalTDC.h:31
int noTransitionCode() const
constexpr int adc(sample_type sample)
get the ADC sample (12 bits)
int alreadyTransitionCode() const
HcalTDC(double threshold_currentTDC=0.)
Definition: HcalTDC.cc:7
int size() const
get the size
Definition: CaloSamples.h:24
~HcalTDC()
Definition: HcalTDC.cc:10
int nbins() const
void setDbService(const HcalDbService *service)
the Producer will probably update this every event
Definition: HcalTDC.cc:77
HcalTDCParameters theTDCParameters
Definition: HcalTDC.h:31