10 #include "CLHEP/Random/RandFlat.h"
17 : theParameterMap(parameterMap),
18 theAmplifier(amplifier),
19 theCoderFactory(coderFactory),
21 theStartingCapIdIsRandom(
true),
22 PreMixDigis(PreMixing) {}
33 result.setSize(frame.
size());
39 void HcalElectronicsSim::convert<QIE10DataFrame>(
CaloSamples& frame,
41 CLHEP::HepRandomEngine* engine) {
42 theAmplifier->amplify(frame, engine);
43 theCoderFactory->coder(frame.id())->fC2adc(frame,
result, theStartingCapId);
47 void HcalElectronicsSim::convert<QIE11DataFrame>(
CaloSamples& frame,
49 CLHEP::HepRandomEngine* engine) {
50 theAmplifier->amplify(frame, engine);
51 theCoderFactory->coder(frame.id())->fC2adc(frame,
result, theStartingCapId);
56 for (
int isample = 0; isample != frame.
size(); ++isample) {
57 uint16_t theADC = round(preMixFactor * frame[isample]);
58 unsigned capId = result[isample].capid();
60 if (theADC > preMixBits) {
61 uint16_t keepADC = result[isample].adc();
62 result.setSample(isample,
HcalQIESample(keepADC, capId, 0, 0,
true,
true));
64 result.setSample(isample,
HcalQIESample(theADC, capId, 0, 0));
70 void HcalElectronicsSim::premix<QIE10DataFrame>(
CaloSamples& frame,
73 unsigned preMixBits) {
74 for (
int isample = 0; isample != frame.size(); ++isample) {
75 uint16_t theADC = round(preMixFactor * frame[isample]);
76 unsigned capId =
result[isample].capid();
79 if (theADC > preMixBits) {
80 theADC =
result[isample].adc();
85 isample, theADC,
result[isample].le_tdc(),
result[isample].te_tdc(), capId,
result[isample].soi(), ok);
90 void HcalElectronicsSim::premix<QIE11DataFrame>(
CaloSamples& frame,
93 unsigned preMixBits) {
94 for (
int isample = 0; isample != frame.size(); ++isample) {
95 uint16_t theADC = round(preMixFactor * frame[isample]);
98 if (theADC > preMixBits) {
99 theADC =
result[isample].adc();
103 result.setSample(isample, theADC, tdcErrorBit,
result[isample].soi());
107 template <
class Digi>
109 CLHEP::HepRandomEngine* engine,
CaloSamples& lf, Digi&
result,
double preMixFactor,
unsigned preMixBits) {
110 convert<Digi>(lf,
result, engine);
112 premix(lf, result, preMixFactor, preMixBits);
145 theTDC.
timing(lf, result);
157 theTDC.
timing(lf, result);
HcalAmplifier * theAmplifier
void setStartingCapId(int startingCapId)
void setStartingCapId(int capId)
const CaloSimParameters & simParameters(const DetId &id) const override
void setDbService(const HcalDbService *service)
void timing(const CaloSamples &lf, QIE11DataFrame &digi) const
void newEvent(CLHEP::HepRandomEngine *)
void convert(CaloSamples &frame, Digi &result, CLHEP::HepRandomEngine *)
const HcalSimParameterMap * theParameterMap
const HcalCoderFactory * theCoderFactory
bool theStartingCapIdIsRandom
double threshold_currentTDC() const
virtual void amplify(CaloSamples &linearFrame, CLHEP::HepRandomEngine *) const
int size() const
get the size
void analogToDigitalImpl(CLHEP::HepRandomEngine *, CaloSamples &linearFrame, Digi &result, double preMixFactor, unsigned preMixBits)
double threshold_currentTDC() const
void analogToDigital(CLHEP::HepRandomEngine *, CaloSamples &linearFrame, HBHEDataFrame &result, double preMixFactor=10.0, unsigned preMixBits=126)
HcalElectronicsSim(const HcalSimParameterMap *parameterMap, HcalAmplifier *amplifier, const HcalCoderFactory *coderFactory, bool PreMix)
DetId id() const
get the (generic) id
std::unique_ptr< HcalCoder > coder(const DetId &detId) const
user gets control of the pointer
void premix(CaloSamples &frame, Digi &result, double preMixFactor, unsigned preMixBits)
void setDbService(const HcalDbService *service)
the Producer will probably update this every event