CMS 3D CMS Logo

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

#include <HcalElectronicsSim.h>

Public Member Functions

void analogToDigital (CLHEP::HepRandomEngine *, CaloSamples &linearFrame, HBHEDataFrame &result, double preMixFactor=10.0, unsigned preMixBits=126)
 
void analogToDigital (CLHEP::HepRandomEngine *, CaloSamples &linearFrame, HFDataFrame &result, double preMixFactor=10.0, unsigned preMixBits=126)
 
void analogToDigital (CLHEP::HepRandomEngine *, CaloSamples &linearFrame, HODataFrame &result, double preMixFactor=10.0, unsigned preMixBits=126)
 
void analogToDigital (CLHEP::HepRandomEngine *, CaloSamples &linearFrame, QIE10DataFrame &result, double preMixFactor=10.0, unsigned preMixBits=126)
 
void analogToDigital (CLHEP::HepRandomEngine *, CaloSamples &linearFrame, QIE11DataFrame &result, double preMixFactor=10.0, unsigned preMixBits=126)
 
void analogToDigital (CLHEP::HepRandomEngine *, CaloSamples &linearFrame, ZDCDataFrame &result, double preMixFactor=10.0, unsigned preMixBits=126)
 
 HcalElectronicsSim (const HcalSimParameterMap *parameterMap, HcalAmplifier *amplifier, const HcalCoderFactory *coderFactory, bool PreMix)
 
void newEvent (CLHEP::HepRandomEngine *)
 
void setDbService (const HcalDbService *service)
 
void setStartingCapId (int startingCapId)
 
 ~HcalElectronicsSim ()
 

Private Member Functions

template<class Digi >
void analogToDigitalImpl (CLHEP::HepRandomEngine *, CaloSamples &linearFrame, Digi &result, double preMixFactor, unsigned preMixBits)
 
template<class Digi >
void convert (CaloSamples &frame, Digi &result, CLHEP::HepRandomEngine *)
 
template<>
void convert (CaloSamples &frame, QIE10DataFrame &result, CLHEP::HepRandomEngine *engine)
 
template<>
void convert (CaloSamples &frame, QIE11DataFrame &result, CLHEP::HepRandomEngine *engine)
 
template<class Digi >
void premix (CaloSamples &frame, Digi &result, double preMixFactor, unsigned preMixBits)
 
template<>
void premix (CaloSamples &frame, QIE10DataFrame &result, double preMixFactor, unsigned preMixBits)
 
template<>
void premix (CaloSamples &frame, QIE11DataFrame &result, double preMixFactor, unsigned preMixBits)
 

Private Attributes

bool PreMixDigis
 
HcalAmplifiertheAmplifier
 
const HcalCoderFactorytheCoderFactory
 
const HcalSimParameterMaptheParameterMap
 
int theStartingCapId
 
bool theStartingCapIdIsRandom
 
HcalTDC theTDC
 

Detailed Description

Definition at line 25 of file HcalElectronicsSim.h.

Constructor & Destructor Documentation

◆ HcalElectronicsSim()

HcalElectronicsSim::HcalElectronicsSim ( const HcalSimParameterMap parameterMap,
HcalAmplifier amplifier,
const HcalCoderFactory coderFactory,
bool  PreMix 
)

Definition at line 13 of file HcalElectronicsSim.cc.

17  : theParameterMap(parameterMap),
18  theAmplifier(amplifier),
19  theCoderFactory(coderFactory),
22  PreMixDigis(PreMixing) {}

◆ ~HcalElectronicsSim()

HcalElectronicsSim::~HcalElectronicsSim ( )

Definition at line 24 of file HcalElectronicsSim.cc.

24 {}

Member Function Documentation

◆ analogToDigital() [1/6]

void HcalElectronicsSim::analogToDigital ( CLHEP::HepRandomEngine *  engine,
CaloSamples linearFrame,
HBHEDataFrame result,
double  preMixFactor = 10.0,
unsigned  preMixBits = 126 
)

Definition at line 118 of file HcalElectronicsSim.cc.

119  {
120  analogToDigitalImpl(engine, lf, result, preMixFactor, preMixBits);
121 }

References analogToDigitalImpl(), and mps_fire::result.

◆ analogToDigital() [2/6]

void HcalElectronicsSim::analogToDigital ( CLHEP::HepRandomEngine *  engine,
CaloSamples linearFrame,
HFDataFrame result,
double  preMixFactor = 10.0,
unsigned  preMixBits = 126 
)

Definition at line 128 of file HcalElectronicsSim.cc.

129  {
130  analogToDigitalImpl(engine, lf, result, preMixFactor, preMixBits);
131 }

References analogToDigitalImpl(), and mps_fire::result.

◆ analogToDigital() [3/6]

void HcalElectronicsSim::analogToDigital ( CLHEP::HepRandomEngine *  engine,
CaloSamples linearFrame,
HODataFrame result,
double  preMixFactor = 10.0,
unsigned  preMixBits = 126 
)

Definition at line 123 of file HcalElectronicsSim.cc.

124  {
125  analogToDigitalImpl(engine, lf, result, preMixFactor, preMixBits);
126 }

References analogToDigitalImpl(), and mps_fire::result.

◆ analogToDigital() [4/6]

void HcalElectronicsSim::analogToDigital ( CLHEP::HepRandomEngine *  engine,
CaloSamples linearFrame,
QIE10DataFrame result,
double  preMixFactor = 10.0,
unsigned  preMixBits = 126 
)

Definition at line 138 of file HcalElectronicsSim.cc.

139  {
140  analogToDigitalImpl(engine, lf, result, preMixFactor, preMixBits);
141 }

References analogToDigitalImpl(), and mps_fire::result.

◆ analogToDigital() [5/6]

void HcalElectronicsSim::analogToDigital ( CLHEP::HepRandomEngine *  engine,
CaloSamples linearFrame,
QIE11DataFrame result,
double  preMixFactor = 10.0,
unsigned  preMixBits = 126 
)

Definition at line 143 of file HcalElectronicsSim.cc.

144  {
145  analogToDigitalImpl(engine, lf, result, preMixFactor, preMixBits);
146  if (!PreMixDigis) {
147  const HcalSimParameters& pars = static_cast<const HcalSimParameters&>(theParameterMap->simParameters(lf.id()));
148  if (pars.threshold_currentTDC() > 0.) {
150  theTDC.timing(lf, result);
151  }
152  }
153 }

References analogToDigitalImpl(), CaloSamples::id(), PreMixDigis, mps_fire::result, HcalSimParameterMap::simParameters(), theParameterMap, theTDC, HcalSimParameters::threshold_currentTDC(), and HcalTDC::timing().

◆ analogToDigital() [6/6]

void HcalElectronicsSim::analogToDigital ( CLHEP::HepRandomEngine *  engine,
CaloSamples linearFrame,
ZDCDataFrame result,
double  preMixFactor = 10.0,
unsigned  preMixBits = 126 
)

Definition at line 133 of file HcalElectronicsSim.cc.

134  {
135  analogToDigitalImpl(engine, lf, result, preMixFactor, preMixBits);
136 }

References analogToDigitalImpl(), and mps_fire::result.

◆ analogToDigitalImpl()

template<class Digi >
void HcalElectronicsSim::analogToDigitalImpl ( CLHEP::HepRandomEngine *  engine,
CaloSamples linearFrame,
Digi &  result,
double  preMixFactor,
unsigned  preMixBits 
)
private

Definition at line 108 of file HcalElectronicsSim.cc.

109  {
110  convert<Digi>(lf, result, engine);
111  if (PreMixDigis)
112  premix(lf, result, preMixFactor, preMixBits);
113 }

References premix(), PreMixDigis, and mps_fire::result.

Referenced by analogToDigital().

◆ convert() [1/3]

template<class Digi >
void HcalElectronicsSim::convert ( CaloSamples frame,
Digi &  result,
CLHEP::HepRandomEngine *  engine 
)
private

◆ convert() [2/3]

template<>
void HcalElectronicsSim::convert ( CaloSamples frame,
QIE10DataFrame result,
CLHEP::HepRandomEngine *  engine 
)
private

◆ convert() [3/3]

template<>
void HcalElectronicsSim::convert ( CaloSamples frame,
QIE11DataFrame result,
CLHEP::HepRandomEngine *  engine 
)
private

◆ newEvent()

void HcalElectronicsSim::newEvent ( CLHEP::HepRandomEngine *  engine)

Things that need to be initialized every event sets starting CapID randomly

Definition at line 155 of file HcalElectronicsSim.cc.

155  {
156  // pick a new starting Capacitor ID
158  theStartingCapId = CLHEP::RandFlat::shootInt(engine, 4);
160  }
161 }

References HcalAmplifier::setStartingCapId(), theAmplifier, theStartingCapId, and theStartingCapIdIsRandom.

◆ premix() [1/3]

template<class Digi >
void HcalElectronicsSim::premix ( CaloSamples frame,
Digi &  result,
double  preMixFactor,
unsigned  preMixBits 
)
private

Definition at line 55 of file HcalElectronicsSim.cc.

55  {
56  for (int isample = 0; isample != frame.size(); ++isample) {
57  uint16_t theADC = round(preMixFactor * frame[isample]);
58  unsigned capId = result[isample].capid();
59 
60  if (theADC > preMixBits) {
61  uint16_t keepADC = result[isample].adc();
62  result.setSample(isample, HcalQIESample(keepADC, capId, 0, 0, true, true)); // set error bit as a flag
63  } else {
64  result.setSample(isample, HcalQIESample(theADC, capId, 0, 0)); // preserve fC, no noise
65  }
66  }
67 }

References amptDefault_cfi::frame, and mps_fire::result.

Referenced by analogToDigitalImpl().

◆ premix() [2/3]

template<>
void HcalElectronicsSim::premix ( CaloSamples frame,
QIE10DataFrame result,
double  preMixFactor,
unsigned  preMixBits 
)
private

Definition at line 70 of file HcalElectronicsSim.cc.

73  {
74  for (int isample = 0; isample != frame.size(); ++isample) {
75  uint16_t theADC = round(preMixFactor * frame[isample]);
76  unsigned capId = result[isample].capid();
77  bool ok = true;
78 
79  if (theADC > preMixBits) {
80  theADC = result[isample].adc();
81  ok = false; // set error bit as a flag
82  }
83 
84  result.setSample(
85  isample, theADC, result[isample].le_tdc(), result[isample].te_tdc(), capId, result[isample].soi(), ok);
86  }
87 }

References amptDefault_cfi::frame, convertSQLiteXML::ok, and mps_fire::result.

◆ premix() [3/3]

template<>
void HcalElectronicsSim::premix ( CaloSamples frame,
QIE11DataFrame result,
double  preMixFactor,
unsigned  preMixBits 
)
private

Definition at line 90 of file HcalElectronicsSim.cc.

93  {
94  for (int isample = 0; isample != frame.size(); ++isample) {
95  uint16_t theADC = round(preMixFactor * frame[isample]);
96  int tdcErrorBit = 0;
97 
98  if (theADC > preMixBits) {
99  theADC = result[isample].adc();
100  tdcErrorBit = 1; //use TDC bits for error bit
101  }
102 
103  result.setSample(isample, theADC, tdcErrorBit, result[isample].soi());
104  }
105 }

References amptDefault_cfi::frame, and mps_fire::result.

◆ setDbService()

void HcalElectronicsSim::setDbService ( const HcalDbService service)

Definition at line 26 of file HcalElectronicsSim.cc.

26  {
27  // theAmplifier->setDbService(service);
29 }

References HcalTDC::setDbService(), and theTDC.

◆ setStartingCapId()

void HcalElectronicsSim::setStartingCapId ( int  startingCapId)

Definition at line 163 of file HcalElectronicsSim.cc.

163  {
164  theStartingCapId = startingCapId;
166  // turns off random capIDs forever for this instance
167  theStartingCapIdIsRandom = false;
168 }

References HcalAmplifier::setStartingCapId(), theAmplifier, theStartingCapId, and theStartingCapIdIsRandom.

Referenced by HcalSignalGenerator< HBHEDigitizerTraits >::fillDigis().

Member Data Documentation

◆ PreMixDigis

bool HcalElectronicsSim::PreMixDigis
private

Definition at line 87 of file HcalElectronicsSim.h.

Referenced by analogToDigital(), and analogToDigitalImpl().

◆ theAmplifier

HcalAmplifier* HcalElectronicsSim::theAmplifier
private

Definition at line 81 of file HcalElectronicsSim.h.

Referenced by convert(), newEvent(), and setStartingCapId().

◆ theCoderFactory

const HcalCoderFactory* HcalElectronicsSim::theCoderFactory
private

Definition at line 82 of file HcalElectronicsSim.h.

Referenced by convert().

◆ theParameterMap

const HcalSimParameterMap* HcalElectronicsSim::theParameterMap
private

Definition at line 80 of file HcalElectronicsSim.h.

Referenced by analogToDigital().

◆ theStartingCapId

int HcalElectronicsSim::theStartingCapId
private

Definition at line 85 of file HcalElectronicsSim.h.

Referenced by convert(), newEvent(), and setStartingCapId().

◆ theStartingCapIdIsRandom

bool HcalElectronicsSim::theStartingCapIdIsRandom
private

Definition at line 86 of file HcalElectronicsSim.h.

Referenced by newEvent(), and setStartingCapId().

◆ theTDC

HcalTDC HcalElectronicsSim::theTDC
private

Definition at line 83 of file HcalElectronicsSim.h.

Referenced by analogToDigital(), and setDbService().

service
Definition: service.py:1
HcalAmplifier::amplify
virtual void amplify(CaloSamples &linearFrame, CLHEP::HepRandomEngine *) const
Definition: HcalAmplifier.cc:41
HcalAmplifier::setStartingCapId
void setStartingCapId(int capId)
Definition: HcalAmplifier.h:42
convertSQLiteXML.ok
bool ok
Definition: convertSQLiteXML.py:98
HcalQIESample
Definition: HcalQIESample.h:32
HcalElectronicsSim::theCoderFactory
const HcalCoderFactory * theCoderFactory
Definition: HcalElectronicsSim.h:82
HcalElectronicsSim::theStartingCapId
int theStartingCapId
Definition: HcalElectronicsSim.h:85
HcalElectronicsSim::analogToDigitalImpl
void analogToDigitalImpl(CLHEP::HepRandomEngine *, CaloSamples &linearFrame, Digi &result, double preMixFactor, unsigned preMixBits)
Definition: HcalElectronicsSim.cc:108
HcalTDC
Definition: HcalTDC.h:17
HcalCoderFactory::coder
std::unique_ptr< HcalCoder > coder(const DetId &detId) const
user gets control of the pointer
Definition: HcalCoderFactory.cc:7
HcalElectronicsSim::theParameterMap
const HcalSimParameterMap * theParameterMap
Definition: HcalElectronicsSim.h:80
HcalElectronicsSim::theStartingCapIdIsRandom
bool theStartingCapIdIsRandom
Definition: HcalElectronicsSim.h:86
HcalSimParameters
Definition: HcalSimParameters.h:10
HcalElectronicsSim::premix
void premix(CaloSamples &frame, Digi &result, double preMixFactor, unsigned preMixBits)
Definition: HcalElectronicsSim.cc:55
amptDefault_cfi.frame
frame
Definition: amptDefault_cfi.py:12
HcalElectronicsSim::PreMixDigis
bool PreMixDigis
Definition: HcalElectronicsSim.h:87
mps_fire.result
result
Definition: mps_fire.py:311
HcalTDC::timing
void timing(const CaloSamples &lf, QIE11DataFrame &digi) const
Definition: HcalTDC.cc:13
HcalSimParameters::threshold_currentTDC
double threshold_currentTDC() const
Definition: HcalSimParameters.h:44
HcalElectronicsSim::theAmplifier
HcalAmplifier * theAmplifier
Definition: HcalElectronicsSim.h:81
HcalTDC::setDbService
void setDbService(const HcalDbService *service)
the Producer will probably update this every event
Definition: HcalTDC.cc:74
HcalSimParameterMap::simParameters
const CaloSimParameters & simParameters(const DetId &id) const override
Definition: HcalSimParameterMap.cc:30
HcalElectronicsSim::theTDC
HcalTDC theTDC
Definition: HcalElectronicsSim.h:83