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 (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<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
 
int theStartingCapId
 
bool theStartingCapIdIsRandom
 
HcalTDC theTDC
 

Detailed Description

Definition at line 24 of file HcalElectronicsSim.h.

Constructor & Destructor Documentation

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

Definition at line 11 of file HcalElectronicsSim.cc.

12  : theAmplifier(amplifier),
13  theCoderFactory(coderFactory),
16  PreMixDigis(PreMixing)
17 {
18 }
HcalAmplifier * theAmplifier
const HcalCoderFactory * theCoderFactory
HcalElectronicsSim::~HcalElectronicsSim ( )

Definition at line 21 of file HcalElectronicsSim.cc.

21  {
22 }

Member Function Documentation

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

Definition at line 104 of file HcalElectronicsSim.cc.

References analogToDigitalImpl().

104  {
105  analogToDigitalImpl(engine,lf,result,preMixFactor,preMixBits);
106 }
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 108 of file HcalElectronicsSim.cc.

References analogToDigitalImpl().

108  {
109  analogToDigitalImpl(engine,lf,result,preMixFactor,preMixBits);
110 }
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 112 of file HcalElectronicsSim.cc.

References analogToDigitalImpl().

112  {
113  analogToDigitalImpl(engine,lf,result,preMixFactor,preMixBits);
114 }
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 116 of file HcalElectronicsSim.cc.

References analogToDigitalImpl().

116  {
117  analogToDigitalImpl(engine,lf,result,preMixFactor,preMixBits);
118 }
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 120 of file HcalElectronicsSim.cc.

References analogToDigitalImpl().

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

Definition at line 96 of file HcalElectronicsSim.cc.

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

Referenced by analogToDigital().

96  {
97  convert<Digi>(lf, result, engine);
98  if(PreMixDigis) premix(lf,result,preMixFactor,preMixBits);
99 }
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 37 of file HcalElectronicsSim.cc.

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

37  {
38  theAmplifier->amplify(frame, engine);
39  theCoderFactory->coder(frame.id())->fC2adc(frame, result, theStartingCapId);
40 }
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 43 of file HcalElectronicsSim.cc.

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

43  {
44  theAmplifier->amplify(frame, engine);
45  theCoderFactory->coder(frame.id())->fC2adc(frame, result, theStartingCapId);
46 }
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 30 of file HcalElectronicsSim.cc.

References HcalAmplifier::amplify(), HcalCoderFactory::coder(), CaloSamples::id(), CaloSamples::size(), theAmplifier, theCoderFactory, and theStartingCapId.

30  {
31  result.setSize(frame.size());
32  theAmplifier->amplify(frame, engine);
33  theCoderFactory->coder(frame.id())->fC2adc(frame, result, theStartingCapId);
34 }
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 128 of file HcalElectronicsSim.cc.

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

128  {
129  // pick a new starting Capacitor ID
131  {
132  theStartingCapId = CLHEP::RandFlat::shootInt(engine, 4);
134  }
135 }
HcalAmplifier * theAmplifier
void setStartingCapId(int capId)
Definition: HcalAmplifier.h:40
template<class Digi >
void HcalElectronicsSim::premix ( CaloSamples frame,
Digi &  result,
double  preMixFactor,
unsigned  preMixBits 
)
private

Definition at line 49 of file HcalElectronicsSim.cc.

References CaloSamples::size().

Referenced by analogToDigitalImpl().

49  {
50  for(int isample = 0; isample !=frame.size(); ++isample) {
51  uint16_t theADC = round(preMixFactor*frame[isample]);
52  unsigned capId = result[isample].capid();
53 
54  if(theADC > preMixBits) {
55  uint16_t keepADC = result[isample].adc();
56  result.setSample(isample, HcalQIESample(keepADC, capId, 0, 0, true, true) ); // set error bit as a flag
57  }
58  else {
59  result.setSample(isample, HcalQIESample(theADC, capId, 0, 0) ); // preserve fC, no noise
60  }
61  }
62 }
int size() const
get the size
Definition: CaloSamples.h:24
template<>
void HcalElectronicsSim::premix ( CaloSamples frame,
QIE10DataFrame result,
double  preMixFactor,
unsigned  preMixBits 
)
private

Definition at line 65 of file HcalElectronicsSim.cc.

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

65  {
66  for(int isample = 0; isample !=frame.size(); ++isample) {
67  uint16_t theADC = round(preMixFactor*frame[isample]);
68  unsigned capId = result[isample].capid();
69  bool ok = true;
70 
71  if(theADC > preMixBits) {
72  theADC = result[isample].adc();
73  ok = false; // set error bit as a flag
74  }
75 
76  result.setSample(isample, theADC, result[isample].le_tdc(), result[isample].te_tdc(), capId, result[isample].soi(), ok);
77  }
78 }
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<>
void HcalElectronicsSim::premix ( CaloSamples frame,
QIE11DataFrame result,
double  preMixFactor,
unsigned  preMixBits 
)
private

Definition at line 81 of file HcalElectronicsSim.cc.

References mps_fire::result.

81  {
82  for(int isample = 0; isample !=frame.size(); ++isample) {
83  uint16_t theADC = round(preMixFactor*frame[isample]);
84  int tdcErrorBit = 0;
85 
86  if(theADC > preMixBits) {
87  theADC = result[isample].adc();
88  tdcErrorBit = 1; //use TDC bits for error bit
89  }
90 
91  result.setSample(isample, theADC, tdcErrorBit, result[isample].soi());
92  }
93 }
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 24 of file HcalElectronicsSim.cc.

References HcalTDC::setDbService(), and theTDC.

Referenced by HcalDigitizer::initializeEvent().

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

Definition at line 137 of file HcalElectronicsSim.cc.

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

138 {
139  theStartingCapId = startingCapId;
141  // turns off random capIDs forever for this instance
142  theStartingCapIdIsRandom = false;
143 }
HcalAmplifier * theAmplifier
void setStartingCapId(int capId)
Definition: HcalAmplifier.h:40

Member Data Documentation

bool HcalElectronicsSim::PreMixDigis
private

Definition at line 54 of file HcalElectronicsSim.h.

Referenced by analogToDigitalImpl().

HcalAmplifier* HcalElectronicsSim::theAmplifier
private

Definition at line 48 of file HcalElectronicsSim.h.

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

const HcalCoderFactory* HcalElectronicsSim::theCoderFactory
private

Definition at line 49 of file HcalElectronicsSim.h.

Referenced by convert().

int HcalElectronicsSim::theStartingCapId
private

Definition at line 52 of file HcalElectronicsSim.h.

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

bool HcalElectronicsSim::theStartingCapIdIsRandom
private

Definition at line 53 of file HcalElectronicsSim.h.

Referenced by newEvent(), and setStartingCapId().

HcalTDC HcalElectronicsSim::theTDC
private

Definition at line 50 of file HcalElectronicsSim.h.

Referenced by setDbService().