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, HODataFrame &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, ZDCDataFrame &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)
 
 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<>
void convert (CaloSamples &frame, QIE10DataFrame &result, CLHEP::HepRandomEngine *engine)
 
template<>
void convert (CaloSamples &frame, QIE11DataFrame &result, CLHEP::HepRandomEngine *engine)
 
template<class Digi >
void convert (CaloSamples &frame, Digi &result, CLHEP::HepRandomEngine *)
 
template<>
void premix (CaloSamples &frame, QIE10DataFrame &result, double preMixFactor, unsigned preMixBits)
 
template<class Digi >
void premix (CaloSamples &frame, Digi &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) {}
HcalAmplifier * theAmplifier
const HcalSimParameterMap * theParameterMap
const HcalCoderFactory * theCoderFactory

◆ ~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.

References analogToDigitalImpl(), and mps_fire::result.

119  {
120  analogToDigitalImpl(engine, lf, result, preMixFactor, preMixBits);
121 }
void analogToDigitalImpl(CLHEP::HepRandomEngine *, CaloSamples &linearFrame, Digi &result, double preMixFactor, unsigned preMixBits)

◆ analogToDigital() [2/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.

References analogToDigitalImpl(), and mps_fire::result.

124  {
125  analogToDigitalImpl(engine, lf, result, preMixFactor, preMixBits);
126 }
void analogToDigitalImpl(CLHEP::HepRandomEngine *, CaloSamples &linearFrame, Digi &result, double preMixFactor, unsigned preMixBits)

◆ analogToDigital() [3/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.

References analogToDigitalImpl(), and mps_fire::result.

129  {
130  analogToDigitalImpl(engine, lf, result, preMixFactor, preMixBits);
131 }
void analogToDigitalImpl(CLHEP::HepRandomEngine *, CaloSamples &linearFrame, Digi &result, double preMixFactor, unsigned preMixBits)

◆ analogToDigital() [4/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.

References analogToDigitalImpl(), and mps_fire::result.

134  {
135  analogToDigitalImpl(engine, lf, result, preMixFactor, preMixBits);
136 }
void analogToDigitalImpl(CLHEP::HepRandomEngine *, CaloSamples &linearFrame, Digi &result, double preMixFactor, unsigned preMixBits)

◆ analogToDigital() [5/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.

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

139  {
140  analogToDigitalImpl(engine, lf, result, preMixFactor, preMixBits);
141  if (!PreMixDigis) {
142  const HFSimParameters& pars = static_cast<const HFSimParameters&>(theParameterMap->simParameters(lf.id()));
143  if (pars.threshold_currentTDC() > 0.) {
145  theTDC.timing(lf, result);
146  }
147  }
148 }
const CaloSimParameters & simParameters(const DetId &id) const override
double threshold_currentTDC() const
void timing(const CaloSamples &lf, QIE11DataFrame &digi) const
Definition: HcalTDC.cc:13
const HcalSimParameterMap * theParameterMap
void analogToDigitalImpl(CLHEP::HepRandomEngine *, CaloSamples &linearFrame, Digi &result, double preMixFactor, unsigned preMixBits)

◆ analogToDigital() [6/6]

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

Definition at line 150 of file HcalElectronicsSim.cc.

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

151  {
152  analogToDigitalImpl(engine, lf, result, preMixFactor, preMixBits);
153  if (!PreMixDigis) {
154  const HcalSimParameters& pars = static_cast<const HcalSimParameters&>(theParameterMap->simParameters(lf.id()));
155  if (pars.threshold_currentTDC() > 0.) {
157  theTDC.timing(lf, result);
158  }
159  }
160 }
const CaloSimParameters & simParameters(const DetId &id) const override
void timing(const CaloSamples &lf, QIE11DataFrame &digi) const
Definition: HcalTDC.cc:13
const HcalSimParameterMap * theParameterMap
void analogToDigitalImpl(CLHEP::HepRandomEngine *, CaloSamples &linearFrame, Digi &result, double preMixFactor, unsigned preMixBits)
double threshold_currentTDC() const

◆ 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.

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

Referenced by analogToDigital().

109  {
110  convert<Digi>(lf, result, engine);
111  if (PreMixDigis)
112  premix(lf, result, preMixFactor, preMixBits);
113 }
void premix(CaloSamples &frame, Digi &result, double preMixFactor, unsigned preMixBits)

◆ convert() [1/3]

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

Definition at line 39 of file HcalElectronicsSim.cc.

References mps_fire::result.

41  {
42  theAmplifier->amplify(frame, engine);
44 }
HcalAmplifier * theAmplifier
const HcalCoderFactory * theCoderFactory
virtual void amplify(CaloSamples &linearFrame, CLHEP::HepRandomEngine *) const
std::unique_ptr< HcalCoder > coder(const DetId &detId) const
user gets control of the pointer

◆ convert() [2/3]

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

Definition at line 47 of file HcalElectronicsSim.cc.

References mps_fire::result.

49  {
50  theAmplifier->amplify(frame, engine);
52 }
HcalAmplifier * theAmplifier
const HcalCoderFactory * theCoderFactory
virtual void amplify(CaloSamples &linearFrame, CLHEP::HepRandomEngine *) const
std::unique_ptr< HcalCoder > coder(const DetId &detId) const
user gets control of the pointer

◆ convert() [3/3]

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

Definition at line 32 of file HcalElectronicsSim.cc.

References HcalAmplifier::amplify(), HcalCoderFactory::coder(), mps_fire::result, theAmplifier, theCoderFactory, and theStartingCapId.

32  {
33  result.setSize(frame.size());
34  theAmplifier->amplify(frame, engine);
36 }
HcalAmplifier * theAmplifier
const HcalCoderFactory * theCoderFactory
virtual void amplify(CaloSamples &linearFrame, CLHEP::HepRandomEngine *) const
std::unique_ptr< HcalCoder > coder(const DetId &detId) const
user gets control of the pointer

◆ newEvent()

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

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

Definition at line 162 of file HcalElectronicsSim.cc.

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

162  {
163  // pick a new starting Capacitor ID
165  theStartingCapId = CLHEP::RandFlat::shootInt(engine, 4);
167  }
168 }
HcalAmplifier * theAmplifier
void setStartingCapId(int capId)
Definition: HcalAmplifier.h:42

◆ premix() [1/3]

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

Definition at line 70 of file HcalElectronicsSim.cc.

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

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 }

◆ premix() [2/3]

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

Definition at line 55 of file HcalElectronicsSim.cc.

References mps_fire::result.

Referenced by analogToDigitalImpl().

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 }

◆ premix() [3/3]

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

Definition at line 90 of file HcalElectronicsSim.cc.

References mps_fire::result.

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 }

◆ setDbService()

void HcalElectronicsSim::setDbService ( const HcalDbService service)

Definition at line 26 of file HcalElectronicsSim.cc.

References HcalTDC::setDbService(), and theTDC.

26  {
27  // theAmplifier->setDbService(service);
29 }
void setDbService(const HcalDbService *service)
the Producer will probably update this every event
Definition: HcalTDC.cc:99

◆ setStartingCapId()

void HcalElectronicsSim::setStartingCapId ( int  startingCapId)

Definition at line 170 of file HcalElectronicsSim.cc.

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

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

170  {
171  theStartingCapId = startingCapId;
173  // turns off random capIDs forever for this instance
174  theStartingCapIdIsRandom = false;
175 }
HcalAmplifier * theAmplifier
void setStartingCapId(int capId)
Definition: HcalAmplifier.h:42

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