55 m_EBdigiCollection(
params.getParameter<
std::
string>(
"EBdigiCollection")),
56 m_EEdigiCollection(
params.getParameter<
std::
string>(
"EEdigiCollection")),
57 m_ESdigiCollection(
params.getParameter<
std::
string>(
"ESdigiCollection")),
68 m_useLCcorrection(
params.getUntrackedParameter<
bool>(
"UseLCcorrection")),
69 m_apdSeparateDigi(
params.getParameter<
bool>(
"apdSeparateDigi")),
71 m_EBs25notCont(
params.getParameter<double>(
"EBs25notContainment")),
72 m_EEs25notCont(
params.getParameter<double>(
"EEs25notContainment")),
74 m_readoutFrameSize(
ecalPh1::sampleSize),
76 params.getParameter<double>(
"simHitToPhotoelectronsEndcap"),
77 params.getParameter<double>(
"photoelectronsToAnalogBarrel"),
78 params.getParameter<double>(
"photoelectronsToAnalogEndcap"),
79 params.getParameter<double>(
"samplingFactor"),
80 params.getParameter<double>(
"timePhase"),
83 params.getParameter<
bool>(
"doPhotostatistics"),
89 params.getParameter<double>(
"apdSimToPELow"),
90 params.getParameter<double>(
"apdSimToPEHigh"),
91 params.getParameter<double>(
"apdTimeOffset"),
92 params.getParameter<double>(
"apdTimeOffWidth"),
105 m_apdParameters.
get(),
112 m_addESNoise(
params.getParameter<
bool>(
"doESNoise")),
113 m_PreMix1(
params.getParameter<
bool>(
"EcalPreMixStage1")),
114 m_PreMix2(
params.getParameter<
bool>(
"EcalPreMixStage2")),
116 m_doFastES(
params.getParameter<
bool>(
"doFast")),
122 m_ESElectronicsSim(m_doFastES ? nullptr : new
ESElectronicsSim(m_addESNoise)),
124 m_ESOldDigitizer(m_doFastES ? nullptr
127 m_ESElectronicsSimFast(!m_doFastES ? nullptr : new
ESElectronicsSimFast(m_addESNoise, m_PreMix1)),
129 m_ESDigitizer(!m_doFastES ? nullptr
130 : new
ESDigitizer(m_ESResponse.
get(), m_ESElectronicsSimFast.
get(), m_addESNoise)),
132 m_APDDigitizer(nullptr),
133 m_BarrelDigitizer(nullptr),
134 m_EndcapDigitizer(nullptr),
135 m_ElectronicsSim(nullptr),
137 m_APDElectronicsSim(nullptr),
140 m_EBCorrNoise({{
nullptr,
nullptr,
nullptr}}),
141 m_EECorrNoise({{
nullptr,
nullptr,
nullptr}}) {
148 iC.consumes<std::vector<PCaloHit>>(
edm::InputTag(m_hitsProducerTag,
"EcalHitsEB"));
150 iC.consumes<std::vector<PCaloHit>>(
edm::InputTag(m_hitsProducerTag,
"EcalHitsEE"));
152 iC.consumes<std::vector<PCaloHit>>(
edm::InputTag(m_hitsProducerTag,
"EcalHitsES"));
153 m_esGainToken = iC.esConsumes();
154 m_esMIPToGeVToken = iC.esConsumes();
155 m_esPedestalsToken = iC.esConsumes();
156 m_esMIPsToken = iC.esConsumes();
159 const std::vector<double> ebCorMatG12 =
params.getParameter<std::vector<double>>(
"EBCorrNoiseMatrixG12");
160 const std::vector<double> eeCorMatG12 =
params.getParameter<std::vector<double>>(
"EECorrNoiseMatrixG12");
161 const std::vector<double> ebCorMatG06 =
params.getParameter<std::vector<double>>(
"EBCorrNoiseMatrixG06");
162 const std::vector<double> eeCorMatG06 =
params.getParameter<std::vector<double>>(
"EECorrNoiseMatrixG06");
163 const std::vector<double> ebCorMatG01 =
params.getParameter<std::vector<double>>(
"EBCorrNoiseMatrixG01");
164 const std::vector<double> eeCorMatG01 =
params.getParameter<std::vector<double>>(
"EECorrNoiseMatrixG01");
167 const double rmsConstantTerm =
params.getParameter<
double>(
"ConstantTerm");
169 const bool addNoise =
params.getParameter<
bool>(
"doENoise");
186 assert(ebCorMatG12.size() == m_readoutFrameSize);
187 assert(eeCorMatG12.size() == m_readoutFrameSize);
188 assert(ebCorMatG06.size() == m_readoutFrameSize);
189 assert(eeCorMatG06.size() == m_readoutFrameSize);
190 assert(ebCorMatG01.size() == m_readoutFrameSize);
191 assert(eeCorMatG01.size() == m_readoutFrameSize);
193 assert(1.
e-7 > fabs(ebCorMatG12[0] - 1.0));
194 assert(1.
e-7 > fabs(ebCorMatG06[0] - 1.0));
195 assert(1.
e-7 > fabs(ebCorMatG01[0] - 1.0));
196 assert(1.
e-7 > fabs(eeCorMatG12[0] - 1.0));
197 assert(1.
e-7 > fabs(eeCorMatG06[0] - 1.0));
198 assert(1.
e-7 > fabs(eeCorMatG01[0] - 1.0));
200 for (
unsigned int row(0); row != m_readoutFrameSize; ++row) {
201 assert(0 == row || 1. >= ebCorMatG12[row]);
202 assert(0 == row || 1. >= ebCorMatG06[row]);
203 assert(0 == row || 1. >= ebCorMatG01[row]);
204 assert(0 == row || 1. >= eeCorMatG12[row]);
205 assert(0 == row || 1. >= eeCorMatG06[row]);
206 assert(0 == row || 1. >= eeCorMatG01[row]);
207 for (
unsigned int column(0); column <= row; ++column) {
208 const unsigned int index(row - column);
209 ebMatrix[0](row, column) = ebCorMatG12[
index];
210 eeMatrix[0](row, column) = eeCorMatG12[
index];
211 ebMatrix[1](row, column) = ebCorMatG06[
index];
212 eeMatrix[1](row, column) = eeCorMatG06[
index];
213 ebMatrix[2](row, column) = ebCorMatG01[
index];
214 eeMatrix[2](row, column) = eeCorMatG01[
index];
218 m_EBCorrNoise[0] = std::make_unique<CorrelatedNoisifier<EcalCorrMatrix>>(ebMatrix[0]);
219 m_EECorrNoise[0] = std::make_unique<CorrelatedNoisifier<EcalCorrMatrix>>(eeMatrix[0]);
220 m_EBCorrNoise[1] = std::make_unique<CorrelatedNoisifier<EcalCorrMatrix>>(ebMatrix[1]);
221 m_EECorrNoise[1] = std::make_unique<CorrelatedNoisifier<EcalCorrMatrix>>(eeMatrix[1]);
222 m_EBCorrNoise[2] = std::make_unique<CorrelatedNoisifier<EcalCorrMatrix>>(ebMatrix[2]);
223 m_EECorrNoise[2] = std::make_unique<CorrelatedNoisifier<EcalCorrMatrix>>(eeMatrix[2]);
225 m_Coder = std::make_unique<EcalCoder>(addNoise,
227 m_EBCorrNoise[0].get(),
228 m_EECorrNoise[0].get(),
229 m_EBCorrNoise[1].get(),
230 m_EECorrNoise[1].get(),
231 m_EBCorrNoise[2].get(),
232 m_EECorrNoise[2].get());
235 std::make_unique<EcalElectronicsSim_Ph1>(m_ParameterMap.get(), m_Coder.get(),
applyConstantTerm, rmsConstantTerm);
237 if (m_apdSeparateDigi) {
238 m_APDCoder = std::make_unique<EcalCoder>(
false,
240 m_EBCorrNoise[0].get(),
241 m_EECorrNoise[0].get(),
242 m_EBCorrNoise[1].get(),
243 m_EECorrNoise[1].get(),
244 m_EBCorrNoise[2].get(),
245 m_EECorrNoise[2].get());
247 m_APDElectronicsSim = std::make_unique<EcalElectronicsSim_Ph1>(
250 m_APDDigitizer = std::make_unique<EBDigitizer>(m_APDResponse.get(), m_APDElectronicsSim.get(),
false);
254 m_BarrelDigitizer = std::make_unique<EBDigitizer>(m_EBResponse.get(), m_ElectronicsSim.get(), addNoise);
258 m_EndcapDigitizer = std::make_unique<EEDigitizer>(m_EEResponse.get(), m_ElectronicsSim.get(), addNoise);
338 e.getByLabel(ebTag, ebHandle);
344 e.getByLabel(eeTag, eeHandle);
350 e.getByLabel(esTag, esHandle);
369 edm::LogInfo(
"DigiInfo") <<
"EB Digis: " << barrelResult->size();
373 edm::LogInfo(
"DigiInfo") <<
"APD Digis: " << apdResult->size();
379 edm::LogInfo(
"EcalDigi") <<
"EE Digis: " << endcapResult->size();
388 edm::LogInfo(
"EcalDigi") <<
"ES Digis: " << preshowerResult->size();
406 throw cms::Exception(
"Configuration") <<
"RandomNumberGenerator service is not available.\n" 407 "You must add the service in the configuration file\n" 408 "or remove the module that requires it.";
410 CLHEP::HepRandomEngine *engine = &rng->
getEngine(
lumi.index());
424 m_Coder->setPedestals(pedestals);
431 m_Coder->setIntercalibConstants(ical);
461 double theGains[
m_Coder->NGAINS + 1];
465 theGains[1] = theGains[2] * (defaultRatios->
gain12Over6());
469 <<
" g1 = " << theGains[1] <<
"\n" 470 <<
" g2 = " << theGains[2] <<
"\n" 471 <<
" g3 = " << theGains[3];
473 delete defaultRatios;
487 m_Coder->setFullScaleEnergy(EBscale, EEscale);
489 m_APDCoder->setFullScaleEnergy(EBscale, EEscale);
535 const std::vector<DetId> *theESDets(
std::unique_ptr< EcalCoder > m_APDCoder
edm::ESWatcher< CaloGeometryRecord > m_geometryWatcher
const edm::EDGetTokenT< std::vector< PCaloHit > > m_HitsEEToken_
float getESValueHigh() const
std::unique_ptr< ESDigitizer > m_ESDigitizer
edm::ESGetToken< ESMIPToGeVConstant, ESMIPToGeVConstantRcd > m_esMIPToGeVToken
const std::string m_ESdigiCollection
const edm::ESGetToken< EcalIntercalibConstantsMC, EcalIntercalibConstantsMCRcd > m_icalToken
ProductRegistryHelper::BranchAliasSetterT< ProductType > produces()
std::unique_ptr< EEDigitizer > m_EndcapDigitizer
void setGain(const int gain)
std::unique_ptr< EBHitResponse > m_APDResponse
const edm::ESGetToken< EcalLaserDbService, EcalLaserDbRecord > m_laserToken
const std::string m_hitsProducerTag
const edm::EDGetTokenT< std::vector< PCaloHit > > m_HitsESToken_
std::unique_ptr< EcalCoder > m_Coder
T const * product() const
virtual void cacheEBDigis(const EBDigiCollection *ebDigiPtr) const
edm::ESGetToken< ESGain, ESGainRcd > m_esGainToken
const edm::EDGetTokenT< std::vector< PCaloHit > > m_HitsEBToken_
virtual CLHEP::HepRandomEngine & getEngine(StreamID const &)=0
Use this engine in event methods.
const edm::ESGetToken< CaloGeometry, CaloGeometryRecord > m_geometryToken
const std::string m_EEdigiCollection
std::unique_ptr< ESHitResponse > m_ESResponse
void setEENoiseSignalGenerator(EcalBaseSignalGenerator *noiseGenerator)
void initializeEvent(edm::Event const &e, edm::EventSetup const &c) override
void setEBNoiseSignalGenerator(EcalBaseSignalGenerator *noiseGenerator)
void setESNoiseSignalGenerator(EcalBaseSignalGenerator *noiseGenerator)
void accumulateCaloHits(HitsHandle const &ebHandle, HitsHandle const &eeHandle, HitsHandle const &esHandle, int bunchCrossing)
void accumulate(edm::Event const &e, edm::EventSetup const &c) override
Creates electronics signals from hits.
const double m_EBs25notCont
edm::ESGetToken< ESIntercalibConstants, ESIntercalibConstantsRcd > m_esMIPsToken
std::unique_ptr< CaloHitResponse > m_ESOldResponse
float getESValueLow() const
virtual const std::vector< DetId > & getValidDetIds(DetId::Detector det=DetId::Detector(0), int subdet=0) const
Get a list of valid detector ids (for the given subdetector)
void beginLuminosityBlock(edm::LuminosityBlock const &lumi, edm::EventSetup const &setup) override
unsigned long long TimeValue_t
const CaloGeometry * m_Geometry
void checkCalibrations(const edm::Event &event, const edm::EventSetup &eventSetup)
void checkGeometry(const edm::EventSetup &eventSetup)
std::unique_ptr< EBDigitizer > m_BarrelDigitizer
std::unique_ptr< ESElectronicsSimFast > m_ESElectronicsSimFast
Log< level::Info, false > LogInfo
float gain12Over6() const
const edm::ESGetToken< EcalADCToGeVConstant, EcalADCToGeVConstantRcd > m_agcToken
CLHEP::HepRandomEngine * randomEngine_
std::unique_ptr< EEHitResponse > m_EEResponse
edm::ESGetToken< ESPedestals, ESPedestalsRcd > m_esPedestalsToken
bool check(const edm::EventSetup &iSetup)
const bool m_apdSeparateDigi
std::unique_ptr< ESElectronicsSim > m_ESElectronicsSim
const std::string m_apdDigiTag
void setEventSetup(const edm::EventSetup &evtSetup)
const edm::ESGetToken< EcalPedestals, EcalPedestalsRcd > m_pedestalsToken
std::unique_ptr< EBHitResponse > m_EBResponse
std::unique_ptr< ESOldDigitizer > m_ESOldDigitizer
virtual void cacheEEDigis(const EEDigiCollection *eeDigiPtr) const
~EcalDigiProducer() override
EcalDigiProducer(const edm::ParameterSet ¶ms, edm::ProducesCollector, edm::ConsumesCollector &iC)
const std::string m_EBdigiCollection
std::unique_ptr< EBDigitizer > m_APDDigitizer
const CaloSubdetectorGeometry * getSubdetectorGeometry(const DetId &id) const
access the subdetector geometry for the given subdetector directly
void finalizeEvent(edm::Event &e, edm::EventSetup const &c) override
const edm::ESGetToken< EcalGainRatios, EcalGainRatiosRcd > m_grToken
const double m_EEs25notCont