diff --git a/DataFormats/HcalDigi/interface/QIE11DataFrame.h b/DataFormats/HcalDigi/interface/QIE11DataFrame.h index 84ae171f38b21..d2433a54f8e32 100644 --- a/DataFormats/HcalDigi/interface/QIE11DataFrame.h +++ b/DataFormats/HcalDigi/interface/QIE11DataFrame.h @@ -99,6 +99,13 @@ class QIE11DataFrame { } /// get the sample constexpr inline Sample operator[](edm::DataFrame::size_type i) const { return Sample(m_data, i + HEADER_WORDS); } + + // set flavor + constexpr void setFlavor(int flavor) { + m_data[0] &= 0x9FFF; // inversion of flavor mask + m_data[0] |= ((flavor & MASK_FLAVOR) << OFFSET_FLAVOR); + } + constexpr void setCapid0(int cap0) { if (flavor() == FLAVOR_HB) { for (int i = 0; i < samples(); i++) { diff --git a/DataFormats/HcalDigi/src/QIE11DataFrame.cc b/DataFormats/HcalDigi/src/QIE11DataFrame.cc index 09b5ba7a49237..9e8811ca9a475 100644 --- a/DataFormats/HcalDigi/src/QIE11DataFrame.cc +++ b/DataFormats/HcalDigi/src/QIE11DataFrame.cc @@ -3,7 +3,7 @@ std::ostream& operator<<(std::ostream& s, const QIE11DataFrame& digi) { if (digi.detid().det() == DetId::Hcal) { - s << HcalGenericDetId(digi.detid()); + s << "DetID=" << HcalGenericDetId(digi.detid()) << " flavor=" << digi.flavor(); } else { s << "DetId(" << digi.detid().rawId() << ")"; } diff --git a/EventFilter/HcalRawToDigi/plugins/HcalDigiToRawuHTR.cc b/EventFilter/HcalRawToDigi/plugins/HcalDigiToRawuHTR.cc index defe0a922fea2..d637dab1192ba 100644 --- a/EventFilter/HcalRawToDigi/plugins/HcalDigiToRawuHTR.cc +++ b/EventFilter/HcalRawToDigi/plugins/HcalDigiToRawuHTR.cc @@ -118,7 +118,7 @@ void HcalDigiToRawuHTR::produce(edm::StreamID id, edm::Event& iEvent, const edm: int presamples = qiedf.presamples(); /* Defining a custom index that will encode only - the information about the crate and slot of a + the information about the crate and slot of a given channel: crate: bits 0-7 slot: bits 8-12 */ @@ -144,6 +144,10 @@ void HcalDigiToRawuHTR::produce(edm::StreamID id, edm::Event& iEvent, const edm: int uhtrIndex = ((slotId & 0xF) << 8) | (crateId & 0xFF); int presamples = qiedf.presamples(); + // convert to hb qie data if hb + if (HcalDetId(detid.rawId()).subdet() == HcalSubdetector::HcalBarrel) + qiedf = convertHB(qiedf); + if (!uhtrs.exist(uhtrIndex)) { uhtrs.newUHTR(uhtrIndex, presamples); } diff --git a/EventFilter/HcalRawToDigi/plugins/PackerHelp.h b/EventFilter/HcalRawToDigi/plugins/PackerHelp.h index 923085f0769d4..95973433bc6de 100644 --- a/EventFilter/HcalRawToDigi/plugins/PackerHelp.h +++ b/EventFilter/HcalRawToDigi/plugins/PackerHelp.h @@ -114,7 +114,9 @@ namespace QIE10HeaderSpec { static const int MASK_HEADER_BIT = 0x1; } // namespace QIE10HeaderSpec -namespace QIE11HeaderSpec { +// QIE11 specifications for various flavors + +namespace QIE11HeaderSpec0 { static const int OFFSET_FIBERCHAN = 0; static const int MASK_FIBERCHAN = 0x7; static const int OFFSET_FIBER = 3; @@ -127,7 +129,22 @@ namespace QIE11HeaderSpec { static const int MASK_FLAVOR = 0x7; static const int OFFSET_HEADER_BIT = 15; static const int MASK_HEADER_BIT = 0x1; -} // namespace QIE11HeaderSpec +} // namespace QIE11HeaderSpec0 + +namespace QIE11HeaderSpec3 { + static const int OFFSET_FIBERCHAN = 0; + static const int MASK_FIBERCHAN = 0x7; + static const int OFFSET_FIBER = 3; + static const int MASK_FIBER = 0x1F; + static const int OFFSET_MP = 8; + static const int MASK_MP = 0x1; + static const int OFFSET_LINKERROR = 11; + static const int MASK_LINKERROR = 0x1; + static const int OFFSET_FLAVOR = 12; + static const int MASK_FLAVOR = 0x7; + static const int OFFSET_HEADER_BIT = 15; + static const int MASK_HEADER_BIT = 0x1; +} // namespace QIE11HeaderSpec3 namespace TPHeaderSpec { static const int OFFSET_TOWER = 0; @@ -334,14 +351,14 @@ class UHTRpacker { int fiber = eid.fiberIndex() + 1; int fiberchan = eid.fiberChanId(); - int fiberErr = qieSample.er(); - int capid0 = qieSample.capid(); header |= (fiberchan & QIE8HeaderSpec::MASK_FIBERCHAN) << QIE8HeaderSpec::OFFSET_FIBERCHAN; header |= ((fiber - 1) & QIE8HeaderSpec::MASK_FIBER) << QIE8HeaderSpec::OFFSET_FIBER; if (flavor == 7) { header |= (15 & QIE8HeaderSpec::MASK_TECHNICAL_DATA_TYPE) << QIE8HeaderSpec::OFFSET_TECHNICAL_DATA_TYPE; } else { + int fiberErr = qieSample.er(); + int capid0 = qieSample.capid(); header |= (capid0 & QIE8HeaderSpec::MASK_CAPID) << QIE8HeaderSpec::OFFSET_CAPID; header |= (fiberErr & QIE8HeaderSpec::MASK_FIBERERR) << QIE8HeaderSpec::OFFSET_FIBERERR; } @@ -401,14 +418,24 @@ class UHTRpacker { int fiber = eid.fiberIndex(); int fiberchan = eid.fiberChanId(); - int capid0 = qiedf.samples() == 0 ? 0 : qiedf[0].capid(); // capacitor id for the first sample - - header |= (fiberchan & QIE11HeaderSpec::MASK_FIBERCHAN) << QIE11HeaderSpec::OFFSET_FIBERCHAN; - header |= (fiber & QIE11HeaderSpec::MASK_FIBER) << QIE11HeaderSpec::OFFSET_FIBER; - header |= (capid0 & QIE11HeaderSpec::MASK_CAPID) << QIE11HeaderSpec::OFFSET_CAPID; - header |= (0x0 & QIE11HeaderSpec::MASK_FIBERERR) << QIE11HeaderSpec::OFFSET_FIBERERR; - header |= (0x0 & QIE11HeaderSpec::MASK_FLAVOR) << QIE11HeaderSpec::OFFSET_FLAVOR; //flavor - header |= (0x1 & QIE11HeaderSpec::MASK_HEADER_BIT) << QIE11HeaderSpec::OFFSET_HEADER_BIT; + int flavor = qiedf[0].flavor(); + + if (flavor == 3) { + header |= (fiberchan & QIE11HeaderSpec3::MASK_FIBERCHAN) << QIE11HeaderSpec3::OFFSET_FIBERCHAN; + header |= (fiber & QIE11HeaderSpec3::MASK_FIBER) << QIE11HeaderSpec3::OFFSET_FIBER; + header |= (0x0 & QIE11HeaderSpec3::MASK_MP) << QIE11HeaderSpec3::OFFSET_MP; + header |= (0x0 & QIE11HeaderSpec3::MASK_LINKERROR) << QIE11HeaderSpec3::OFFSET_LINKERROR; + header |= (flavor & QIE11HeaderSpec3::MASK_FLAVOR) << QIE11HeaderSpec3::OFFSET_FLAVOR; //flavor + header |= (0x1 & QIE11HeaderSpec3::MASK_HEADER_BIT) << QIE11HeaderSpec3::OFFSET_HEADER_BIT; + } else { + int capid0 = qiedf[0].capid(); + header |= (fiberchan & QIE11HeaderSpec0::MASK_FIBERCHAN) << QIE11HeaderSpec0::OFFSET_FIBERCHAN; + header |= (fiber & QIE11HeaderSpec0::MASK_FIBER) << QIE11HeaderSpec0::OFFSET_FIBER; + header |= (capid0 & QIE11HeaderSpec0::MASK_CAPID) << QIE11HeaderSpec0::OFFSET_CAPID; + header |= (0x0 & QIE11HeaderSpec0::MASK_FIBERERR) << QIE11HeaderSpec0::OFFSET_FIBERERR; + header |= (flavor & QIE11HeaderSpec0::MASK_FLAVOR) << QIE11HeaderSpec0::OFFSET_FLAVOR; //flavor + header |= (0x1 & QIE11HeaderSpec0::MASK_HEADER_BIT) << QIE11HeaderSpec0::OFFSET_HEADER_BIT; + } return header; } @@ -587,4 +614,44 @@ class UHTRpacker { }; }; +// converts HE QIE digies to HB data format + +QIE11DataFrame convertHB(QIE11DataFrame qiehe) { + QIE11DataFrame qiehb = qiehe; + int adc, tdc; + bool soi; + int is = 0; + + // flavor for HB digies is hardcoded here + static const int hbflavor = 3; + + // iterator over samples + for (edm::DataFrame::const_iterator it = qiehe.begin(); it != qiehe.end(); ++it) { + if (it == qiehe.begin()) + continue; + adc = qiehe[is].adc(); + tdc = qiehe[is].tdc(); + soi = qiehe[is].soi(); + + if (tdc >= 0 && tdc <= 24) + tdc = 0; + else if (tdc >= 25 && tdc <= 49) + tdc = 1; + else if (tdc == 63) + tdc = 2; + else if (tdc == 62) + tdc = 3; + + qiehb.setSample(is, adc, tdc, soi); + is++; + }; + + // puting flavor is safe here because flavor is stored in the same bits for all flavors + qiehb.setFlavor(hbflavor); + int capid = qiehe[0].capid(); + qiehb.setCapid0(capid); + + return qiehb; +} + #endif diff --git a/SimCalorimetry/HcalSimAlgos/interface/HcalElectronicsSim.h b/SimCalorimetry/HcalSimAlgos/interface/HcalElectronicsSim.h index 6136c39d7b239..90a3548803911 100644 --- a/SimCalorimetry/HcalSimAlgos/interface/HcalElectronicsSim.h +++ b/SimCalorimetry/HcalSimAlgos/interface/HcalElectronicsSim.h @@ -9,6 +9,7 @@ #include "SimCalorimetry/HcalSimAlgos/interface/HcalTDC.h" #include "SimCalorimetry/HcalSimAlgos/interface/HcalAmplifier.h" #include "SimCalorimetry/HcalSimAlgos/interface/HcalCoderFactory.h" +#include "SimCalorimetry/HcalSimAlgos/interface/HcalSimParameterMap.h" class HBHEDataFrame; class HODataFrame; @@ -23,7 +24,10 @@ namespace CLHEP { class HcalElectronicsSim { public: - HcalElectronicsSim(HcalAmplifier* amplifier, const HcalCoderFactory* coderFactory, bool PreMix); + HcalElectronicsSim(const HcalSimParameterMap* parameterMap, + HcalAmplifier* amplifier, + const HcalCoderFactory* coderFactory, + bool PreMix); ~HcalElectronicsSim(); void setDbService(const HcalDbService* service); @@ -73,6 +77,7 @@ class HcalElectronicsSim { template void premix(CaloSamples& frame, Digi& result, double preMixFactor, unsigned preMixBits); + const HcalSimParameterMap* theParameterMap; HcalAmplifier* theAmplifier; const HcalCoderFactory* theCoderFactory; HcalTDC theTDC; diff --git a/SimCalorimetry/HcalSimAlgos/interface/HcalSimParameters.h b/SimCalorimetry/HcalSimAlgos/interface/HcalSimParameters.h index 5f369efcc7b61..42457ea1424ac 100644 --- a/SimCalorimetry/HcalSimAlgos/interface/HcalSimParameters.h +++ b/SimCalorimetry/HcalSimAlgos/interface/HcalSimParameters.h @@ -41,6 +41,7 @@ class HcalSimParameters : public CaloSimParameters { int pixels(const DetId& detId) const; bool doSiPMSmearing() const { return theSiPMSmearing; } + double threshold_currentTDC() const { return threshold_currentTDC_; } double sipmTau() const { return theSiPMTau; } double sipmDarkCurrentuA(const DetId& detId) const; double sipmCrossTalk(const DetId& detId) const; @@ -59,6 +60,7 @@ class HcalSimParameters : public CaloSimParameters { bool doTimeSmear_; HcalTimeSmearSettings theSmearSettings; double theSiPMTau; + double threshold_currentTDC_; }; #endif diff --git a/SimCalorimetry/HcalSimAlgos/interface/HcalTDC.h b/SimCalorimetry/HcalSimAlgos/interface/HcalTDC.h index 1fc0ad400d4bb..f337e030c920e 100644 --- a/SimCalorimetry/HcalSimAlgos/interface/HcalTDC.h +++ b/SimCalorimetry/HcalSimAlgos/interface/HcalTDC.h @@ -5,6 +5,8 @@ #include "CalibFormats/CaloObjects/interface/CaloSamples.h" #include "DataFormats/HcalDetId/interface/HcalGenericDetId.h" #include "SimCalorimetry/HcalSimAlgos/interface/HcalTDCParameters.h" +#include "DataFormats/HcalDigi/interface/QIE11DataFrame.h" +#include "DataFormats/HcalDetId/interface/HcalDetId.h" class HcalDbService; @@ -14,28 +16,26 @@ namespace CLHEP { class HcalTDC { public: - HcalTDC(unsigned int thresholdDAC = 12); + HcalTDC(double threshold_currentTDC = 0.); ~HcalTDC(); /// adds timing information to the digi - template - void timing(const CaloSamples& lf, Digi& digi, CLHEP::HepRandomEngine*) const; + /// template + void timing(const CaloSamples& lf, QIE11DataFrame& digi) const; /// the Producer will probably update this every event void setDbService(const HcalDbService* service); void setThresholdDAC(unsigned int DAC) { theDAC = DAC; } unsigned int getThresholdDAC() { return theDAC; } + double getThreshold() const { return threshold_currentTDC_; }; private: - double getThreshold(const HcalGenericDetId& detId, CLHEP::HepRandomEngine*) const; - double getHysteresisThreshold(double nominal) const; - HcalTDCParameters theTDCParameters; const HcalDbService* theDbService; unsigned int theDAC; - + double threshold_currentTDC_; double const lsb; }; diff --git a/SimCalorimetry/HcalSimAlgos/src/HcalElectronicsSim.cc b/SimCalorimetry/HcalSimAlgos/src/HcalElectronicsSim.cc index 5458d920ac317..5208fb4def48e 100644 --- a/SimCalorimetry/HcalSimAlgos/src/HcalElectronicsSim.cc +++ b/SimCalorimetry/HcalSimAlgos/src/HcalElectronicsSim.cc @@ -1,4 +1,6 @@ #include "SimCalorimetry/HcalSimAlgos/interface/HcalElectronicsSim.h" +#include "SimCalorimetry/HcalSimAlgos/interface/HcalSimParameters.h" +#include "SimCalorimetry/HcalSimAlgos/interface/HcalTDC.h" #include "DataFormats/HcalDigi/interface/HBHEDataFrame.h" #include "DataFormats/HcalDigi/interface/HODataFrame.h" #include "DataFormats/HcalDigi/interface/HFDataFrame.h" @@ -8,8 +10,12 @@ #include "CLHEP/Random/RandFlat.h" #include -HcalElectronicsSim::HcalElectronicsSim(HcalAmplifier* amplifier, const HcalCoderFactory* coderFactory, bool PreMixing) - : theAmplifier(amplifier), +HcalElectronicsSim::HcalElectronicsSim(const HcalSimParameterMap* parameterMap, + HcalAmplifier* amplifier, + const HcalCoderFactory* coderFactory, + bool PreMixing) + : theParameterMap(parameterMap), + theAmplifier(amplifier), theCoderFactory(coderFactory), theStartingCapId(0), theStartingCapIdIsRandom(true), @@ -137,6 +143,11 @@ void HcalElectronicsSim::analogToDigital( void HcalElectronicsSim::analogToDigital( CLHEP::HepRandomEngine* engine, CaloSamples& lf, QIE11DataFrame& result, double preMixFactor, unsigned preMixBits) { analogToDigitalImpl(engine, lf, result, preMixFactor, preMixBits); + if (!PreMixDigis) { + const HcalSimParameters& pars = static_cast(theParameterMap->simParameters(lf.id())); + HcalTDC theTDC((pars.threshold_currentTDC())); + theTDC.timing(lf, result); + } } void HcalElectronicsSim::newEvent(CLHEP::HepRandomEngine* engine) { diff --git a/SimCalorimetry/HcalSimAlgos/src/HcalSimParameters.cc b/SimCalorimetry/HcalSimAlgos/src/HcalSimParameters.cc index 3b739fd7e146c..c731e663483db 100644 --- a/SimCalorimetry/HcalSimAlgos/src/HcalSimParameters.cc +++ b/SimCalorimetry/HcalSimAlgos/src/HcalSimParameters.cc @@ -46,7 +46,8 @@ HcalSimParameters::HcalSimParameters(const edm::ParameterSet& p) theSamplingFactors(p.getParameter >("samplingFactors")), theSiPMSmearing(p.getParameter("doSiPMSmearing")), doTimeSmear_(p.getParameter("timeSmearing")), - theSiPMTau(p.getParameter("sipmTau")) { + theSiPMTau(p.getParameter("sipmTau")), + threshold_currentTDC_(p.getParameter("threshold_currentTDC")) { defaultTimeSmearing(); edm::LogInfo("HcalSimParameters:") << " doSiPMsmearing = " << theSiPMSmearing; diff --git a/SimCalorimetry/HcalSimAlgos/src/HcalTDC.cc b/SimCalorimetry/HcalSimAlgos/src/HcalTDC.cc index 935dfef245c33..058e51680912d 100644 --- a/SimCalorimetry/HcalSimAlgos/src/HcalTDC.cc +++ b/SimCalorimetry/HcalSimAlgos/src/HcalTDC.cc @@ -2,34 +2,22 @@ #include "CalibFormats/HcalObjects/interface/HcalCalibrations.h" #include "CalibFormats/HcalObjects/interface/HcalDbService.h" #include "FWCore/MessageLogger/interface/MessageLogger.h" - #include "CLHEP/Random/RandGaussQ.h" -HcalTDC::HcalTDC(unsigned int thresholdDAC) - : theTDCParameters(), theDbService(nullptr), theDAC(thresholdDAC), lsb(3.74) {} +HcalTDC::HcalTDC(double threshold_currentTDC) + : theTDCParameters(), theDbService(nullptr), threshold_currentTDC_(threshold_currentTDC), lsb(3.74) {} HcalTDC::~HcalTDC() {} -template -void HcalTDC::timing(const CaloSamples& lf, Digi& digi, CLHEP::HepRandomEngine* engine) const { - float const TDC_Threshold(getThreshold(digi.id(), engine)); - float const TDC_Threshold_hyst(TDC_Threshold); - bool risingReady(true), fallingReady(false); +//template +void HcalTDC::timing(const CaloSamples& lf, QIE11DataFrame& digi) const { + float const TDC_Threshold(getThreshold()); + bool risingReady(true); int tdcBins = theTDCParameters.nbins(); - // start with a loop over 10 samples bool hasTDCValues = true; if (lf.preciseSize() == 0) hasTDCValues = false; - // "AC" hysteresis from Tom: There cannot be a second transition - // within the QIE within 3ns - int const rising_ac_hysteresis(5); - int lastRisingEdge(0); - - // if (hasTDCValues) - // std::cout << digi.id() - // << " threshold: " << TDC_Threshold - // << '\n'; for (int ibin = 0; ibin < lf.size(); ++ibin) { /* If in a given 25ns bunch/time sample, the pulse is above @@ -46,82 +34,44 @@ void HcalTDC::timing(const CaloSamples& lf, Digi& digi, CLHEP::HepRandomEngine* */ // special codes int TDC_RisingEdge = (risingReady) ? theTDCParameters.noTransitionCode() : theTDCParameters.alreadyTransitionCode(); - int TDC_FallingEdge = - (fallingReady) ? theTDCParameters.alreadyTransitionCode() : theTDCParameters.noTransitionCode(); int preciseBegin = ibin * tdcBins; int preciseEnd = preciseBegin + tdcBins; - if (hasTDCValues) { - // std::cout << " alreadyOn: " << alreadyOn << '\n'; - for (int i = preciseBegin; i < preciseEnd; ++i) { - // std::cout << " preciseBin: " << i - // << " preciseAt(i): " << lf.preciseAt(i); - if ((fallingReady) && (i % 3 == 0) && (lf.preciseAt(i) < TDC_Threshold)) { - fallingReady = false; - TDC_FallingEdge = i - preciseBegin; - // std::cout << " falling "; - } - if ((risingReady) && (lf.preciseAt(i) > TDC_Threshold)) { - risingReady = false; - TDC_RisingEdge = i - preciseBegin; - lastRisingEdge = 0; - // std::cout << " rising "; - } - // std::cout << '\n'; - //This is the place for hysteresis code. Need to to arm the - //tdc by setting the risingReady or fallingReady to true. + if (hasTDCValues) { + for (int i = preciseBegin; i < preciseEnd; ++i) { //find the TDC time value in each TS - if ((!fallingReady) && (lf.preciseAt(i) > TDC_Threshold)) { - fallingReady = true; - if (TDC_FallingEdge == theTDCParameters.alreadyTransitionCode()) - TDC_FallingEdge = theTDCParameters.noTransitionCode(); + if ((!risingReady) && (i == preciseBegin) && (i != 0)) { + if (((lf.preciseAt(i + 1) - lf.preciseAt(i - 1)) > TDC_Threshold)) { + TDC_RisingEdge = theTDCParameters.alreadyTransitionCode(); + break; + } else + risingReady = true; } - if ((!risingReady) && (lastRisingEdge > rising_ac_hysteresis) && (lf.preciseAt(i) < TDC_Threshold_hyst)) { - risingReady = true; - if (TDC_RisingEdge == theTDCParameters.alreadyTransitionCode()) + + if (risingReady) { + if (i != 399 && i != 0 && (lf.preciseAt(i + 1) - lf.preciseAt(i - 1)) > TDC_Threshold) { + risingReady = false; + TDC_RisingEdge = i - preciseBegin; + } else if (i == 0 && (lf.preciseAt(i + 1) - lf.preciseAt(i)) / 0.5 > TDC_Threshold) { + risingReady = false; + TDC_RisingEdge = i - preciseBegin; + } else if (i == (preciseEnd - 1)) TDC_RisingEdge = theTDCParameters.noTransitionCode(); } - ++lastRisingEdge; - } - } - // change packing to allow for special codes - int packedTDC = TDC_RisingEdge + (tdcBins * 2) * TDC_FallingEdge; - digi.setSample(ibin, digi.adc(ibin), packedTDC, true); - // if ( hasTDCValues) { - // std::cout << " sample: " << ibin - // << " adc: " << digi.adc(ibin) - // << " fC: " << digi[ibin].nominal_fC() - // << " risingEdge: " << TDC_RisingEdge - // << " fallingEdge: " << TDC_FallingEdge - // << " packedTDC: " << packedTDC - // << std::endl; - // } - } // loop over bunch crossing bins -} - -double HcalTDC::getThreshold(const HcalGenericDetId& detId, CLHEP::HepRandomEngine* engine) const { - // subtract off pedestal and noise once - double pedestal = theDbService->getHcalCalibrations(detId).pedestal(0); - double pedestalWidth = theDbService->getHcalCalibrationWidths(detId).pedestal(0); - // here the TDCthreshold_ is a multiple of the least significant bit - // for the TDC portion of the QIE. The nominal reference is 40 uA which is - // divided by an 8 bit DAC. This means the least significant bit is 0.135 uA - // in the TDC circuit or 3.74 uA at the input current. - // the pedestal is assumed to be evenly distributed in time with some - // random variation. - - return lsb * theDAC - CLHEP::RandGaussQ::shoot(engine, pedestal, pedestalWidth) / theTDCParameters.deltaT() / - theTDCParameters.nbins(); -} + if ((!risingReady) && (i == (preciseEnd - 1)) && (i != 399)) { + if (((lf.preciseAt(i + 1) - lf.preciseAt(i - 1)) < TDC_Threshold)) { + risingReady = true; + } + } + } //end of looping precise bins + } -double HcalTDC::getHysteresisThreshold(double nominal) const { - // the TDC will "re-arm" when it crosses the threshold minus 2.5 mV. - // the lsb is 44kOhm * (3.74 uA / 24) = 6.86 mV. 2.5 mV is 0.36 lsb. - // with the this means that the hysteresis it isn't far from the nominal - // threshold + // change packing to allow for special codes + int packedTDC = TDC_RisingEdge; + digi.setSample(ibin, digi[ibin].adc(), packedTDC, digi[ibin].soi()); - return nominal - 0.365 * lsb; + } // loop over bunch crossing bins } void HcalTDC::setDbService(const HcalDbService* service) { theDbService = service; } diff --git a/SimCalorimetry/HcalSimAlgos/test/HcalDigitizerTest.cc b/SimCalorimetry/HcalSimAlgos/test/HcalDigitizerTest.cc index ab1919942b7d0..d8259419a7652 100644 --- a/SimCalorimetry/HcalSimAlgos/test/HcalDigitizerTest.cc +++ b/SimCalorimetry/HcalSimAlgos/test/HcalDigitizerTest.cc @@ -230,7 +230,7 @@ void HcalDigitizerTest::analyze(const edm::Event& iEvent, const edm::EventSetup& bool PM2 = false; HcalAmplifier amplifier(¶meterMap, addNoise, PM1, PM2); HcalCoderFactory coderFactory(HcalCoderFactory::NOMINAL); - HcalElectronicsSim electronicsSim(&lifier, &coderFactory, PM1); + HcalElectronicsSim electronicsSim(¶meterMap, &lifier, &coderFactory, PM1); amplifier.setDbService(&calibratorHandle); amplifier.setTimeSlew(hcalTimeSlew_delay_); parameterMap.setDbService(&calibratorHandle); diff --git a/SimCalorimetry/HcalSimProducers/python/hcalSimParameters_cfi.py b/SimCalorimetry/HcalSimProducers/python/hcalSimParameters_cfi.py index 8dff034d149f4..b4d937acca452 100644 --- a/SimCalorimetry/HcalSimProducers/python/hcalSimParameters_cfi.py +++ b/SimCalorimetry/HcalSimProducers/python/hcalSimParameters_cfi.py @@ -21,6 +21,7 @@ timePhase = cms.double(14.0), doSiPMSmearing = cms.bool(False), sipmTau = cms.double(0.), + threshold_currentTDC = cms.double(18.7), ), hf2 = cms.PSet( readoutFrameSize = cms.int32(4), @@ -33,6 +34,7 @@ timePhase = cms.double(13.0), doSiPMSmearing = cms.bool(False), sipmTau = cms.double(0.), + threshold_currentTDC = cms.double(18.7), ), ho = cms.PSet( readoutFrameSize = cms.int32(10), @@ -50,6 +52,7 @@ siPMCode = cms.int32(2), doSiPMSmearing = cms.bool(False), sipmTau = cms.double(5.), + threshold_currentTDC = cms.double(18.7), ), hb = cms.PSet( readoutFrameSize = cms.int32(10), @@ -67,6 +70,7 @@ timeSmearing = cms.bool(True), doSiPMSmearing = cms.bool(False), sipmTau = cms.double(0.), + threshold_currentTDC = cms.double(18.7), ), he = cms.PSet( readoutFrameSize = cms.int32(10), @@ -83,6 +87,7 @@ timeSmearing = cms.bool(True), doSiPMSmearing = cms.bool(False), sipmTau = cms.double(0.), + threshold_currentTDC = cms.double(18.7), ), zdc = cms.PSet( readoutFrameSize = cms.int32(10), @@ -95,6 +100,7 @@ timePhase = cms.double(-4.0), doSiPMSmearing = cms.bool(False), sipmTau = cms.double(0.), + threshold_currentTDC = cms.double(18.7), ), ) diff --git a/SimCalorimetry/HcalSimProducers/src/HcalDigitizer.cc b/SimCalorimetry/HcalSimProducers/src/HcalDigitizer.cc index 1fe45aba5819d..bce520ca5c497 100644 --- a/SimCalorimetry/HcalSimProducers/src/HcalDigitizer.cc +++ b/SimCalorimetry/HcalSimProducers/src/HcalDigitizer.cc @@ -129,16 +129,22 @@ HcalDigitizer::HcalDigitizer(const edm::ParameterSet &ps, edm::ConsumesCollector theCoderFactory = std::make_unique(HcalCoderFactory::DB); - theHBHEElectronicsSim = std::make_unique(theHBHEAmplifier.get(), theCoderFactory.get(), PreMix1); - theHFElectronicsSim = std::make_unique(theHFAmplifier.get(), theCoderFactory.get(), PreMix1); - theHOElectronicsSim = std::make_unique(theHOAmplifier.get(), theCoderFactory.get(), PreMix1); - theZDCElectronicsSim = std::make_unique(theZDCAmplifier.get(), theCoderFactory.get(), PreMix1); + theHBHEElectronicsSim = + std::make_unique(&theParameterMap, theHBHEAmplifier.get(), theCoderFactory.get(), PreMix1); + theHFElectronicsSim = + std::make_unique(&theParameterMap, theHFAmplifier.get(), theCoderFactory.get(), PreMix1); + theHOElectronicsSim = + std::make_unique(&theParameterMap, theHOAmplifier.get(), theCoderFactory.get(), PreMix1); + theZDCElectronicsSim = + std::make_unique(&theParameterMap, theZDCAmplifier.get(), theCoderFactory.get(), PreMix1); theHFQIE10ElectronicsSim = - std::make_unique(theHFQIE10Amplifier.get(), + std::make_unique(&theParameterMap, + theHFQIE10Amplifier.get(), theCoderFactory.get(), PreMix1); // should this use a different coder factory? theHBHEQIE11ElectronicsSim = - std::make_unique(theHBHEQIE11Amplifier.get(), + std::make_unique(&theParameterMap, + theHBHEQIE11Amplifier.get(), theCoderFactory.get(), PreMix1); // should this use a different coder factory? diff --git a/SimCalorimetry/HcalTestBeam/interface/HcalTBDigiProducer.h b/SimCalorimetry/HcalTestBeam/interface/HcalTBDigiProducer.h index cb9cafa856cf6..d8536ad332365 100644 --- a/SimCalorimetry/HcalTestBeam/interface/HcalTBDigiProducer.h +++ b/SimCalorimetry/HcalTestBeam/interface/HcalTBDigiProducer.h @@ -17,6 +17,7 @@ #include "SimCalorimetry/HcalTestBeam/interface/HcalTBSimParameterMap.h" #include "SimDataFormats/CaloHit/interface/PCaloHitContainer.h" #include "SimGeneral/MixingModule/interface/DigiAccumulatorMixMod.h" +#include "SimCalorimetry/HcalSimAlgos/interface/HcalSimParameters.h" #include #include @@ -62,6 +63,7 @@ class HcalTBDigiProducer : public DigiAccumulatorMixMod { typedef CaloTDigitizer HODigitizer; HcalTBSimParameterMap *theParameterMap; + HcalSimParameterMap *paraMap; CaloVShape *theHcalShape; CaloVShape *theHcalIntegratedShape; diff --git a/SimCalorimetry/HcalTestBeam/src/HcalTBDigiProducer.cc b/SimCalorimetry/HcalTestBeam/src/HcalTBDigiProducer.cc index 9ee62197a0a7c..bb943afb7f439 100644 --- a/SimCalorimetry/HcalTestBeam/src/HcalTBDigiProducer.cc +++ b/SimCalorimetry/HcalTestBeam/src/HcalTBDigiProducer.cc @@ -23,6 +23,7 @@ HcalTBDigiProducer::HcalTBDigiProducer(const edm::ParameterSet &ps, edm::ProducesCollector producesCollector, edm::ConsumesCollector &iC) : theParameterMap(new HcalTBSimParameterMap(ps)), + paraMap(new HcalSimParameterMap(ps)), theHcalShape(new HcalShape()), theHcalIntegratedShape(new CaloShapeIntegrator(theHcalShape)), theHBHEResponse(new CaloHitResponse(theParameterMap, theHcalIntegratedShape)), @@ -53,7 +54,7 @@ HcalTBDigiProducer::HcalTBDigiProducer(const edm::ParameterSet &ps, bool dummy2 = false; // extra arguments for premixing theAmplifier = new HcalAmplifier(theParameterMap, doNoise, dummy1, dummy2); theCoderFactory = new HcalCoderFactory(HcalCoderFactory::DB); - theElectronicsSim = new HcalElectronicsSim(theAmplifier, theCoderFactory, dummy1); + theElectronicsSim = new HcalElectronicsSim(paraMap, theAmplifier, theCoderFactory, dummy1); double minFCToDelay = ps.getParameter("minFCToDelay"); bool doTimeSlew = ps.getParameter("doTimeSlew");