test
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 setThresholdDAC (unsigned int DAC)
 
void timing (const CaloSamples &lf, HcalUpgradeDataFrame &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 16 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 123 of file HcalTDC.cc.

References lsb.

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

Definition at line 108 of file HcalTDC.cc.

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

Referenced by timing().

108  {
109  // subtract off pedestal and noise once
111  double pedestalWidth = theDbService->getHcalCalibrationWidths(detId).pedestal(0);
112  // here the TDCthreshold_ is a multiple of the least significant bit
113  // for the TDC portion of the QIE. The nominal reference is 40 uA which is
114  // divided by an 8 bit DAC. This means the least significant bit is 0.135 uA
115  // in the TDC circuit or 3.74 uA at the input current.
116 
117  // the pedestal is assumed to be evenly distributed in time with some
118  // random variation.
119 
120  return lsb*theDAC - CLHEP::RandGaussQ::shoot(engine, pedestal, pedestalWidth)/theTDCParameters.deltaT()/theTDCParameters.nbins();
121 }
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.

References theDAC.

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 132 of file HcalTDC.cc.

References theDbService.

Referenced by HcalElectronicsSim::setDbService().

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

Definition at line 28 of file HcalTDC.h.

References theDAC.

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

adds timing information to the digi

Definition at line 16 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().

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

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().