CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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 setRandomEngine (CLHEP::HepRandomEngine &engine)
 
void setThresholdDAC (unsigned int DAC)
 
void timing (const CaloSamples &lf, HcalUpgradeDataFrame &digi) const
 adds timing information to the digi More...
 
 ~HcalTDC ()
 

Private Member Functions

double getThreshold (const HcalGenericDetId &detId) const
 

Private Attributes

unsigned int theDAC
 
const HcalDbServicetheDbService
 
CLHEP::RandGaussQ * theRandGaussQ
 
HcalTDCParameters theTDCParameters
 

Detailed Description

Definition at line 11 of file HcalTDC.h.

Constructor & Destructor Documentation

HcalTDC::HcalTDC ( unsigned int  thresholdDAC = 12)

Definition at line 6 of file HcalTDC.cc.

6  : theTDCParameters(),
7  theDbService(0),
8  theDAC(thresholdDAC),
9  theRandGaussQ(0) {}
unsigned int theDAC
Definition: HcalTDC.h:32
const HcalDbService * theDbService
Definition: HcalTDC.h:30
CLHEP::RandGaussQ * theRandGaussQ
Definition: HcalTDC.h:34
HcalTDCParameters theTDCParameters
Definition: HcalTDC.h:29
HcalTDC::~HcalTDC ( )

Definition at line 11 of file HcalTDC.cc.

References theRandGaussQ.

11  {
12  if (theRandGaussQ) delete theRandGaussQ;
13 }
CLHEP::RandGaussQ * theRandGaussQ
Definition: HcalTDC.h:34

Member Function Documentation

double HcalTDC::getThreshold ( const HcalGenericDetId detId) const
private

Definition at line 88 of file HcalTDC.cc.

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

Referenced by timing().

88  {
89  // subtract off pedestal and noise once
90  double pedestal = theDbService->getHcalCalibrations(detId).pedestal(0);
91  double pedestalWidth = theDbService->getHcalCalibrationWidths(detId).pedestal(0);
92  // here the TDCthreshold_ is a multiple of the least significant bit
93  // for the TDC portion of the QIE. The nominal reference is 40 uA which is
94  // divided by an 8 bit DAC. This means the least significant bit is 0.135 uA
95  // in the TDC circuit or 3.74 uA at the input current.
96 
97  // the pedestal is assumed to be evenly distributed in time with some
98  // random variation. No hysteresis is implemented here.
99 
100  double const lsb(3.74);
101  return lsb*theDAC - theRandGaussQ->shoot(pedestal, pedestalWidth)/theTDCParameters.deltaT()/theTDCParameters.nbins();
102 }
float deltaT() const
unsigned int theDAC
Definition: HcalTDC.h:32
const HcalDbService * theDbService
Definition: HcalTDC.h:30
double pedestal(int fCapId) const
get pedestal for capid=0..3
double pedestal(int fCapId) const
get pedestal width for capid=0..3
CLHEP::RandGaussQ * theRandGaussQ
Definition: HcalTDC.h:34
const HcalCalibrationWidths & getHcalCalibrationWidths(const HcalGenericDetId &fId) const
const HcalCalibrations & getHcalCalibrations(const HcalGenericDetId &fId) const
HcalTDCParameters theTDCParameters
Definition: HcalTDC.h:29
unsigned int HcalTDC::getThresholdDAC ( )
inline

Definition at line 25 of file HcalTDC.h.

References theDAC.

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

the Producer will probably update this every event

Definition at line 108 of file HcalTDC.cc.

References theDbService.

Referenced by HcalElectronicsSim::setDbService().

108  {
109  theDbService = service;
110 }
const HcalDbService * theDbService
Definition: HcalTDC.h:30
void HcalTDC::setRandomEngine ( CLHEP::HepRandomEngine &  engine)

Definition at line 104 of file HcalTDC.cc.

References theRandGaussQ.

Referenced by HcalElectronicsSim::setRandomEngine().

104  {
105  theRandGaussQ = new CLHEP::RandGaussQ(engine);
106 }
CLHEP::RandGaussQ * theRandGaussQ
Definition: HcalTDC.h:34
void HcalTDC::setThresholdDAC ( unsigned int  DAC)
inline

Definition at line 24 of file HcalTDC.h.

References theDAC.

24 { theDAC = DAC; }
unsigned int theDAC
Definition: HcalTDC.h:32
void HcalTDC::timing ( const CaloSamples lf,
HcalUpgradeDataFrame digi 
) const

adds timing information to the digi

Definition at line 15 of file HcalTDC.cc.

References HcalUpgradeDataFrame::adc(), HcalTDCParameters::alreadyTransitionCode(), getThreshold(), i, HcalUpgradeDataFrame::id(), HcalTDCParameters::nbins(), HcalTDCParameters::noTransitionCode(), CaloSamples::preciseAt(), CaloSamples::preciseSize(), HcalUpgradeDataFrame::setSample(), CaloSamples::size(), and theTDCParameters.

Referenced by HcalElectronicsSim::analogToDigital().

15  {
16 
17  float TDC_Threshold = getThreshold(digi.id());
18  bool alreadyOn = false;
19  int tdcBins = theTDCParameters.nbins();
20  // start with a loop over 10 samples
21  bool hasTDCValues=true;
22  if (lf.preciseSize()==0 ) hasTDCValues=false;
23 
24  // if (hasTDCValues)
25  // std::cout << digi.id()
26  // << " threshold: " << TDC_Threshold
27  // << " hasTDCValues: " << hasTDCValues
28  // << '\n';
29  for (int ibin = 0; ibin < lf.size(); ++ibin) {
30  /*
31  If in a given 25ns bunch/time sample, the pulse is above
32  TDC_Thresh already, then TDC_RisingEdge=0 if it was low in the
33  last precision bin on the previous bunch crossing, otherwise,
34  TDC_RisingEdge=63 if the pulse never crosses the threshold
35  having started off, then the special code is 62 and then
36  one can still have a TDC_FallingEdge that is valid. If the pulse
37  never falls below threshold having started above threshold (or
38  goes above threshold in the bunch crossing and doesn't come down),
39  then TDC_FallingEdge=. If the pulse never went above
40  threshold, then TDC_RisingEdge=63 and
41  TDC_FallingEdge=62.
42  */
43  // special codes
44  int TDC_RisingEdge = (alreadyOn) ? theTDCParameters.alreadyTransitionCode()
46  int TDC_FallingEdge = (alreadyOn) ? theTDCParameters.noTransitionCode() :
48  int preciseBegin = ibin * tdcBins;
49  int preciseEnd = preciseBegin + tdcBins;
50  if ( hasTDCValues) {
51  // std::cout << " alreadyOn: " << alreadyOn << '\n';
52  for(int i = preciseBegin; i < preciseEnd; ++i) {
53  // std::cout << " preciseBin: " << i
54  // << " preciseAt(i): " << lf.preciseAt(i);
55  if (alreadyOn) {
56  if( (i%3 == 0) && (lf.preciseAt(i) < TDC_Threshold) ) {
57  alreadyOn = false;
58  TDC_FallingEdge = i-preciseBegin;
59  // std::cout << " falling ";
60  }
61  } else {
62  if (lf.preciseAt(i) > TDC_Threshold) {
63  alreadyOn = true;
64  TDC_RisingEdge = i-preciseBegin;
65  // the flag for hasn't gone low yet
66  TDC_FallingEdge = theTDCParameters.noTransitionCode();
67  // std::cout << " rising ";
68  }
69  }
70  // std::cout << '\n';
71  }
72  }
73  // change packing to allow for special codes
74  int packedTDC = TDC_RisingEdge + (tdcBins*2) * TDC_FallingEdge;
75  digi.setSample(ibin, digi.adc(ibin), packedTDC, true);
76  // if ( hasTDCValues) {
77  // std::cout << " sample: " << ibin
78  // << " adc: " << digi.adc(ibin)
79  // << " fC: " << digi[ibin].nominal_fC()
80  // << " risingEdge: " << TDC_RisingEdge
81  // << " fallingEdge: " << TDC_FallingEdge
82  // << " packedTDC: " << packedTDC
83  // << std::endl;
84  // }
85  } // loop over bunch crossing bins
86 }
double getThreshold(const HcalGenericDetId &detId) const
Definition: HcalTDC.cc:88
int i
Definition: DBlmapReader.cc:9
int preciseSize() const
get the size
Definition: CaloSamples.h:64
float preciseAt(int i) const
const function to access precise samples
Definition: CaloSamples.h:35
int noTransitionCode() const
int alreadyTransitionCode() const
void setSample(int iSample, uint16_t adc, uint16_t tdc, bool dv)
int size() const
get the size
Definition: CaloSamples.h:26
const HcalDetId & id() const
uint16_t adc(int iSample=0) const
HcalTDCParameters theTDCParameters
Definition: HcalTDC.h:29

Member Data Documentation

unsigned int HcalTDC::theDAC
private

Definition at line 32 of file HcalTDC.h.

Referenced by getThreshold(), getThresholdDAC(), and setThresholdDAC().

const HcalDbService* HcalTDC::theDbService
private

Definition at line 30 of file HcalTDC.h.

Referenced by getThreshold(), and setDbService().

CLHEP::RandGaussQ* HcalTDC::theRandGaussQ
mutableprivate

Definition at line 34 of file HcalTDC.h.

Referenced by getThreshold(), setRandomEngine(), and ~HcalTDC().

HcalTDCParameters HcalTDC::theTDCParameters
private

Definition at line 29 of file HcalTDC.h.

Referenced by getThreshold(), and timing().