CMS 3D CMS Logo

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

#include <HcalTDC.h>

Public Member Functions

unsigned int getThresholdDAC ()
 
 HcalTDC (unsigned int thresholdDAC=12)
 
void setDbService (const HcalDbService *service)
 the Producer will probably update this every event More...
 
void setThresholdDAC (unsigned int DAC)
 
template<class Digi >
void timing (const CaloSamples &lf, Digi &digi, CLHEP::HepRandomEngine *) const
 adds timing information to the digi More...
 
 ~HcalTDC ()
 

Private Member Functions

double getHysteresisThreshold (double nominal) const
 
double getThreshold (const HcalGenericDetId &detId, CLHEP::HepRandomEngine *) const
 

Private Attributes

double const lsb
 
unsigned int theDAC
 
const HcalDbServicetheDbService
 
HcalTDCParameters theTDCParameters
 

Detailed Description

Definition at line 15 of file HcalTDC.h.

Constructor & Destructor Documentation

HcalTDC::HcalTDC ( unsigned int  thresholdDAC = 12)

Definition at line 8 of file HcalTDC.cc.

8  : theTDCParameters(),
9  theDbService(0),
10  theDAC(thresholdDAC),
11  lsb(3.74) {}
unsigned int theDAC
Definition: HcalTDC.h:38
const HcalDbService * theDbService
Definition: HcalTDC.h:36
double const lsb
Definition: HcalTDC.h:40
HcalTDCParameters theTDCParameters
Definition: HcalTDC.h:35
HcalTDC::~HcalTDC ( )

Definition at line 13 of file HcalTDC.cc.

13  {
14 }

Member Function Documentation

double HcalTDC::getHysteresisThreshold ( double  nominal) const
private

Definition at line 124 of file HcalTDC.cc.

References lsb.

124  {
125  // the TDC will "re-arm" when it crosses the threshold minus 2.5 mV.
126  // the lsb is 44kOhm * (3.74 uA / 24) = 6.86 mV. 2.5 mV is 0.36 lsb.
127  // with the this means that the hysteresis it isn't far from the nominal
128  // threshold
129 
130  return nominal - 0.365*lsb;
131 }
double const lsb
Definition: HcalTDC.h:40
double HcalTDC::getThreshold ( const HcalGenericDetId detId,
CLHEP::HepRandomEngine *  engine 
) const
private

Definition at line 109 of file HcalTDC.cc.

References HcalTDCParameters::deltaT(), HcalDbService::getHcalCalibrations(), HcalDbService::getHcalCalibrationWidths(), lsb, HcalTDCParameters::nbins(), muonCSCDigis_cfi::pedestal, HcalCalibrationWidths::pedestal(), HcalCalibrations::pedestal(), theDAC, theDbService, and theTDCParameters.

Referenced by timing().

109  {
110  // subtract off pedestal and noise once
112  double pedestalWidth = theDbService->getHcalCalibrationWidths(detId).pedestal(0);
113  // here the TDCthreshold_ is a multiple of the least significant bit
114  // for the TDC portion of the QIE. The nominal reference is 40 uA which is
115  // divided by an 8 bit DAC. This means the least significant bit is 0.135 uA
116  // in the TDC circuit or 3.74 uA at the input current.
117 
118  // the pedestal is assumed to be evenly distributed in time with some
119  // random variation.
120 
121  return lsb*theDAC - CLHEP::RandGaussQ::shoot(engine, pedestal, pedestalWidth)/theTDCParameters.deltaT()/theTDCParameters.nbins();
122 }
float deltaT() const
unsigned int theDAC
Definition: HcalTDC.h:38
const HcalDbService * theDbService
Definition: HcalTDC.h:36
double pedestal(int fCapId) const
get pedestal for capid=0..3
double pedestal(int fCapId) const
get pedestal width for capid=0..3
const HcalCalibrationWidths & getHcalCalibrationWidths(const HcalGenericDetId &fId) const
double const lsb
Definition: HcalTDC.h:40
const HcalCalibrations & getHcalCalibrations(const HcalGenericDetId &fId) const
HcalTDCParameters theTDCParameters
Definition: HcalTDC.h:35
unsigned int HcalTDC::getThresholdDAC ( )
inline

Definition at line 29 of file HcalTDC.h.

29 { return theDAC; }
unsigned int theDAC
Definition: HcalTDC.h:38
void HcalTDC::setDbService ( const HcalDbService service)

the Producer will probably update this every event

Definition at line 133 of file HcalTDC.cc.

References theDbService.

Referenced by HcalElectronicsSim::setDbService().

133  {
134  theDbService = service;
135 }
const HcalDbService * theDbService
Definition: HcalTDC.h:36
void HcalTDC::setThresholdDAC ( unsigned int  DAC)
inline

Definition at line 28 of file HcalTDC.h.

28 { theDAC = DAC; }
unsigned int theDAC
Definition: HcalTDC.h:38
template<class Digi >
void HcalTDC::timing ( const CaloSamples lf,
Digi &  digi,
CLHEP::HepRandomEngine *  engine 
) const

adds timing information to the digi

Definition at line 17 of file HcalTDC.cc.

References HcalTDCParameters::alreadyTransitionCode(), getThreshold(), mps_fire::i, HcalTDCParameters::nbins(), HcalTDCParameters::noTransitionCode(), CaloSamples::preciseAt(), CaloSamples::preciseSize(), CaloSamples::size(), and theTDCParameters.

17  {
18 
19  float const TDC_Threshold(getThreshold(digi.id(), engine));
20  float const TDC_Threshold_hyst(TDC_Threshold);
21  bool risingReady(true), fallingReady(false);
22  int tdcBins = theTDCParameters.nbins();
23  // start with a loop over 10 samples
24  bool hasTDCValues=true;
25  if (lf.preciseSize()==0 ) hasTDCValues=false;
26 
27  // "AC" hysteresis from Tom: There cannot be a second transition
28  // within the QIE within 3ns
29  int const rising_ac_hysteresis(5);
30  int lastRisingEdge(0);
31 
32  // if (hasTDCValues)
33  // std::cout << digi.id()
34  // << " threshold: " << TDC_Threshold
35  // << '\n';
36  for (int ibin = 0; ibin < lf.size(); ++ibin) {
37  /*
38  If in a given 25ns bunch/time sample, the pulse is above
39  TDC_Thresh already, then TDC_RisingEdge=0 if it was low in the
40  last precision bin on the previous bunch crossing, otherwise,
41  TDC_RisingEdge=63 if the pulse never crosses the threshold
42  having started off, then the special code is 62 and then
43  one can still have a TDC_FallingEdge that is valid. If the pulse
44  never falls below threshold having started above threshold (or
45  goes above threshold in the bunch crossing and doesn't come down),
46  then TDC_FallingEdge=. If the pulse never went above
47  threshold, then TDC_RisingEdge=63 and
48  TDC_FallingEdge=62.
49  */
50  // special codes
51  int TDC_RisingEdge = (risingReady) ?
54  int TDC_FallingEdge = (fallingReady) ?
57  int preciseBegin = ibin * tdcBins;
58  int preciseEnd = preciseBegin + tdcBins;
59  if ( hasTDCValues) {
60  // std::cout << " alreadyOn: " << alreadyOn << '\n';
61  for(int i = preciseBegin; i < preciseEnd; ++i) {
62  // std::cout << " preciseBin: " << i
63  // << " preciseAt(i): " << lf.preciseAt(i);
64  if( (fallingReady) && (i%3 == 0) && (lf.preciseAt(i) < TDC_Threshold)) {
65  fallingReady = false;
66  TDC_FallingEdge = i-preciseBegin;
67  // std::cout << " falling ";
68  }
69  if ((risingReady) && (lf.preciseAt(i) > TDC_Threshold)) {
70  risingReady = false;
71  TDC_RisingEdge = i-preciseBegin;
72  lastRisingEdge = 0;
73  // std::cout << " rising ";
74  }
75  // std::cout << '\n';
76 
77  //This is the place for hysteresis code. Need to to arm the
78  //tdc by setting the risingReady or fallingReady to true.
79 
80  if ((!fallingReady) && (lf.preciseAt(i) > TDC_Threshold)) {
81  fallingReady = true;
82  if (TDC_FallingEdge == theTDCParameters.alreadyTransitionCode())
83  TDC_FallingEdge = theTDCParameters.noTransitionCode();
84  }
85  if ((!risingReady) && (lastRisingEdge > rising_ac_hysteresis) &&
86  (lf.preciseAt(i) < TDC_Threshold_hyst)) {
87  risingReady = true;
88  if (TDC_RisingEdge == theTDCParameters.alreadyTransitionCode())
89  TDC_RisingEdge = theTDCParameters.noTransitionCode();
90  }
91  ++lastRisingEdge;
92  }
93  }
94  // change packing to allow for special codes
95  int packedTDC = TDC_RisingEdge + (tdcBins*2) * TDC_FallingEdge;
96  digi.setSample(ibin, digi.adc(ibin), packedTDC, true);
97  // if ( hasTDCValues) {
98  // std::cout << " sample: " << ibin
99  // << " adc: " << digi.adc(ibin)
100  // << " fC: " << digi[ibin].nominal_fC()
101  // << " risingEdge: " << TDC_RisingEdge
102  // << " fallingEdge: " << TDC_FallingEdge
103  // << " packedTDC: " << packedTDC
104  // << std::endl;
105  // }
106  } // loop over bunch crossing bins
107 }
int preciseSize() const
get the size
Definition: CaloSamples.h:62
float preciseAt(int i) const
const function to access precise samples
Definition: CaloSamples.h:33
int noTransitionCode() const
int alreadyTransitionCode() const
int size() const
get the size
Definition: CaloSamples.h:24
double getThreshold(const HcalGenericDetId &detId, CLHEP::HepRandomEngine *) const
Definition: HcalTDC.cc:109
HcalTDCParameters theTDCParameters
Definition: HcalTDC.h:35

Member Data Documentation

double const HcalTDC::lsb
private

Definition at line 40 of file HcalTDC.h.

Referenced by getHysteresisThreshold(), and getThreshold().

unsigned int HcalTDC::theDAC
private

Definition at line 38 of file HcalTDC.h.

Referenced by getThreshold().

const HcalDbService* HcalTDC::theDbService
private

Definition at line 36 of file HcalTDC.h.

Referenced by getThreshold(), and setDbService().

HcalTDCParameters HcalTDC::theTDCParameters
private

Definition at line 35 of file HcalTDC.h.

Referenced by getThreshold(), and timing().