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

Definition at line 24 of file HcalElectronicsSim.cc.

24 {}

Member Function Documentation

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

119  {
120  analogToDigitalImpl(engine, lf, result, preMixFactor, preMixBits);
121 }
void analogToDigitalImpl(CLHEP::HepRandomEngine *, CaloSamples &linearFrame, Digi &result, double preMixFactor, unsigned preMixBits)
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().

124  {
125  analogToDigitalImpl(engine, lf, result, preMixFactor, preMixBits);
126 }
void analogToDigitalImpl(CLHEP::HepRandomEngine *, CaloSamples &linearFrame, Digi &result, double preMixFactor, unsigned preMixBits)
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().

129  {
130  analogToDigitalImpl(engine, lf, result, preMixFactor, preMixBits);
131 }
void analogToDigitalImpl(CLHEP::HepRandomEngine *, CaloSamples &linearFrame, Digi &result, double preMixFactor, unsigned preMixBits)
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().

134  {
135  analogToDigitalImpl(engine, lf, result, preMixFactor, preMixBits);
136 }
void analogToDigitalImpl(CLHEP::HepRandomEngine *, CaloSamples &linearFrame, Digi &result, double preMixFactor, unsigned preMixBits)
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().

139  {
140  analogToDigitalImpl(engine, lf, result, preMixFactor, preMixBits);
141 }
void analogToDigitalImpl(CLHEP::HepRandomEngine *, CaloSamples &linearFrame, Digi &result, double preMixFactor, unsigned preMixBits)
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.

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

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 }
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
const CaloSimParameters & simParameters(const DetId &id) const override
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)
template<>
void HcalElectronicsSim::convert ( CaloSamples frame,
QIE10DataFrame result,
CLHEP::HepRandomEngine *  engine 
)
private

Definition at line 39 of file HcalElectronicsSim.cc.

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

41  {
42  theAmplifier->amplify(frame, engine);
43  theCoderFactory->coder(frame.id())->fC2adc(frame, result, theStartingCapId);
44 }
HcalAmplifier * theAmplifier
const HcalCoderFactory * theCoderFactory
virtual void amplify(CaloSamples &linearFrame, CLHEP::HepRandomEngine *) const
DetId id() const
get the (generic) id
Definition: CaloSamples.h:21
std::unique_ptr< HcalCoder > coder(const DetId &detId) const
user gets control of the pointer
template<>
void HcalElectronicsSim::convert ( CaloSamples frame,
QIE11DataFrame result,
CLHEP::HepRandomEngine *  engine 
)
private

Definition at line 47 of file HcalElectronicsSim.cc.

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

49  {
50  theAmplifier->amplify(frame, engine);
51  theCoderFactory->coder(frame.id())->fC2adc(frame, result, theStartingCapId);
52 }
HcalAmplifier * theAmplifier
const HcalCoderFactory * theCoderFactory
virtual void amplify(CaloSamples &linearFrame, CLHEP::HepRandomEngine *) const
DetId id() const
get the (generic) id
Definition: CaloSamples.h:21
std::unique_ptr< HcalCoder > coder(const DetId &detId) const
user gets control of the pointer
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(), CaloSamples::id(), CaloSamples::size(), theAmplifier, theCoderFactory, and theStartingCapId.

32  {
33  result.setSize(frame.size());
34  theAmplifier->amplify(frame, engine);
35  theCoderFactory->coder(frame.id())->fC2adc(frame, result, theStartingCapId);
36 }
HcalAmplifier * theAmplifier
const HcalCoderFactory * theCoderFactory
virtual void amplify(CaloSamples &linearFrame, CLHEP::HepRandomEngine *) const
int size() const
get the size
Definition: CaloSamples.h:24
DetId id() const
get the (generic) id
Definition: CaloSamples.h:21
std::unique_ptr< HcalCoder > coder(const DetId &detId) const
user gets control of the pointer
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.

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

155  {
156  // pick a new starting Capacitor ID
158  theStartingCapId = CLHEP::RandFlat::shootInt(engine, 4);
160  }
161 }
HcalAmplifier * theAmplifier
void setStartingCapId(int capId)
Definition: HcalAmplifier.h:42
template<>
void HcalElectronicsSim::premix ( CaloSamples frame,
QIE10DataFrame result,
double  preMixFactor,
unsigned  preMixBits 
)
private

Definition at line 70 of file HcalElectronicsSim.cc.

References amptDefault_cfi::frame, 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 }
int size() const
get the size
Definition: CaloSamples.h:24
void setSample(edm::DataFrame::size_type isample, int adc, int le_tdc, int te_tdc, int capid, bool soi=false, bool ok=true)
set the sample contents
template<class Digi >
void HcalElectronicsSim::premix ( CaloSamples frame,
Digi &  result,
double  preMixFactor,
unsigned  preMixBits 
)
private

Definition at line 55 of file HcalElectronicsSim.cc.

References CaloSamples::size().

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 }
int size() const
get the size
Definition: CaloSamples.h:24
template<>
void HcalElectronicsSim::premix ( CaloSamples frame,
QIE11DataFrame result,
double  preMixFactor,
unsigned  preMixBits 
)
private

Definition at line 90 of file HcalElectronicsSim.cc.

References amptDefault_cfi::frame, and 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 }
void setSample(edm::DataFrame::size_type isample, int adc, int tdc, bool soi=false)
set the sample contents
int size() const
get the size
Definition: CaloSamples.h:24
void HcalElectronicsSim::setDbService ( const HcalDbService service)

Definition at line 26 of file HcalElectronicsSim.cc.

References HcalTDC::setDbService(), and theTDC.

26  {
27  // theAmplifier->setDbService(service);
28  theTDC.setDbService(service);
29 }
void setDbService(const HcalDbService *service)
the Producer will probably update this every event
Definition: HcalTDC.cc:77
void HcalElectronicsSim::setStartingCapId ( int  startingCapId)

Definition at line 163 of file HcalElectronicsSim.cc.

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

163  {
164  theStartingCapId = startingCapId;
166  // turns off random capIDs forever for this instance
167  theStartingCapIdIsRandom = false;
168 }
HcalAmplifier * theAmplifier
void setStartingCapId(int capId)
Definition: HcalAmplifier.h:42

Member Data Documentation

bool HcalElectronicsSim::PreMixDigis
private

Definition at line 87 of file HcalElectronicsSim.h.

Referenced by analogToDigital(), and analogToDigitalImpl().

HcalAmplifier* HcalElectronicsSim::theAmplifier
private

Definition at line 81 of file HcalElectronicsSim.h.

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

const HcalCoderFactory* HcalElectronicsSim::theCoderFactory
private

Definition at line 82 of file HcalElectronicsSim.h.

Referenced by convert().

const HcalSimParameterMap* HcalElectronicsSim::theParameterMap
private

Definition at line 80 of file HcalElectronicsSim.h.

Referenced by analogToDigital().

int HcalElectronicsSim::theStartingCapId
private

Definition at line 85 of file HcalElectronicsSim.h.

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

bool HcalElectronicsSim::theStartingCapIdIsRandom
private

Definition at line 86 of file HcalElectronicsSim.h.

Referenced by newEvent(), and setStartingCapId().

HcalTDC HcalElectronicsSim::theTDC
private

Definition at line 83 of file HcalElectronicsSim.h.

Referenced by analogToDigital(), and setDbService().