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  std::vector<int> packedTDCs = leadingEdgeTDC(lf);
15 
16  for (int ibin = 0; ibin < lf.size(); ++ibin) {
17  digi.setSample(ibin, digi[ibin].adc(), packedTDCs[ibin], digi[ibin].soi());
18 
19  } // loop over bunch crossing bins
20 }
21 
22 void HcalTDC::timing(const CaloSamples& lf, QIE10DataFrame& digi) const {
23  std::vector<int> packedTDCs = leadingEdgeTDC(lf);
24 
25  for (int ibin = 0; ibin < lf.size(); ++ibin) {
26  QIE10DataFrame::Sample sam = digi[ibin];
27  digi.setSample(ibin, sam.adc(), packedTDCs[ibin] /*LE TDC*/, 0. /*TE TDC*/, sam.capid(), sam.soi(), sam.ok());
28 
29  } // loop over bunch crossing bins
30 }
31 
32 //leading edge TDC
33 std::vector<int> HcalTDC::leadingEdgeTDC(const CaloSamples& lf) const {
34  std::vector<int> result;
35 
36  float const TDC_Threshold(getThreshold());
37  bool risingReady(true);
38  int tdcBins = theTDCParameters.nbins();
39  bool hasTDCValues = true;
40  if (lf.preciseSize() == 0)
41  hasTDCValues = false;
42 
43  for (int ibin = 0; ibin < lf.size(); ++ibin) {
44  /*
45  If in a given 25ns bunch/time sample, the pulse is above
46  TDC_Thresh, then TDC_RisingEdge set to time when threshold
47  was crossed.
48  TDC_RisingEdge=0 if it was low in the last precision bin
49  on the previous bunch crossing, but above by first precision
50  bin in current bunch crossing.
51  TDC_RisingEdge=62 if pulse starts above threshold by end of
52  previous bunch crossing and stays above threshold in current
53  bunch crossing.
54  TDC_RisingEdge=63 if the pulse never crosses the threshold.
55  */
56  // special codes
57  int TDC_RisingEdge = (risingReady) ? theTDCParameters.noTransitionCode() : theTDCParameters.alreadyTransitionCode();
58  int preciseBegin = ibin * tdcBins;
59  int preciseEnd = preciseBegin + tdcBins;
60 
61  if (hasTDCValues) {
62  for (int i = preciseBegin; i < preciseEnd; ++i) {
63  if ((!risingReady) && (i == preciseBegin) && (i != 0)) {
64  if (lf.preciseAt(i) / theTDCParameters.deltaT() > TDC_Threshold) {
65  TDC_RisingEdge = theTDCParameters.alreadyTransitionCode();
66  } else {
67  risingReady = true;
68  }
69  }
70 
71  if (risingReady) {
72  if (lf.preciseAt(i) / theTDCParameters.deltaT() > TDC_Threshold) {
73  TDC_RisingEdge = i - preciseBegin;
74  risingReady = false;
75  } else if (i == (preciseEnd - 1)) {
76  TDC_RisingEdge = theTDCParameters.noTransitionCode();
77  }
78  }
79 
80  if ((!risingReady) && (i == (preciseEnd - 1))) {
81  if (lf.preciseAt(i) / theTDCParameters.deltaT() < TDC_Threshold) {
82  risingReady = true;
83  }
84  }
85 
86  } //end of looping precise bins
87  }
88 
89  // change packing to allow for special codes
90  int packedTDC = TDC_RisingEdge;
91 
92  result.push_back(packedTDC);
93 
94  } // loop over bunch crossing bins
95 
96  return result;
97 }
98 
int size() const
get the size
Definition: CaloSamples.h:24
float deltaT() const
double getThreshold() const
Definition: HcalTDC.h:35
constexpr void setSample(edm::DataFrame::size_type isample, int adc, int le_tdc, int te_tdc, int capid, bool soi=false, bool ok=true)
set the sample contents
const HcalDbService * theDbService
Definition: HcalTDC.h:39
std::vector< int > leadingEdgeTDC(const CaloSamples &lf) const
Definition: HcalTDC.cc:33
constexpr int adc() const
void timing(const CaloSamples &lf, QIE11DataFrame &digi) const
Definition: HcalTDC.cc:13
int alreadyTransitionCode() const
int preciseSize() const
get the size
Definition: CaloSamples.h:70
constexpr bool ok() const
constexpr void setSample(edm::DataFrame::size_type isample, int adc, int tdc, bool soi=false)
set the sample contents
HcalTDC(double threshold_currentTDC=0.)
Definition: HcalTDC.cc:7
constexpr int capid() const
constexpr bool soi() const
~HcalTDC()
Definition: HcalTDC.cc:10
int noTransitionCode() const
float preciseAt(int i) const
const function to access precise samples
Definition: CaloSamples.h:33
uint16_t *__restrict__ uint16_t const *__restrict__ adc
void setDbService(const HcalDbService *service)
the Producer will probably update this every event
Definition: HcalTDC.cc:99
HcalTDCParameters theTDCParameters
Definition: HcalTDC.h:35