56 m_ComponentShapes(iC),
60 m_EBdigiCollection(
params.getParameter<
std::
string>(
"EBdigiCollection")),
61 m_EEdigiCollection(
params.getParameter<
std::
string>(
"EEdigiCollection")),
62 m_ESdigiCollection(
params.getParameter<
std::
string>(
"ESdigiCollection")),
73 m_useLCcorrection(
params.getUntrackedParameter<
bool>(
"UseLCcorrection")),
74 m_apdSeparateDigi(
params.getParameter<
bool>(
"apdSeparateDigi")),
75 m_componentSeparateDigi(
params.getParameter<
bool>(
"componentSeparateDigi")),
77 m_EBs25notCont(
params.getParameter<double>(
"EBs25notContainment")),
78 m_EEs25notCont(
params.getParameter<double>(
"EEs25notContainment")),
80 m_readoutFrameSize(
ecalPh1::sampleSize),
82 params.getParameter<double>(
"simHitToPhotoelectronsEndcap"),
83 params.getParameter<double>(
"photoelectronsToAnalogBarrel"),
84 params.getParameter<double>(
"photoelectronsToAnalogEndcap"),
85 params.getParameter<double>(
"samplingFactor"),
86 params.getParameter<double>(
"timePhase"),
89 params.getParameter<
bool>(
"doPhotostatistics"),
95 params.getParameter<double>(
"apdSimToPELow"),
96 params.getParameter<double>(
"apdSimToPEHigh"),
97 params.getParameter<double>(
"apdTimeOffset"),
98 params.getParameter<double>(
"apdTimeOffWidth"),
103 m_componentDigiTag(
params.getParameter<
std::
string>(
"componentDigiTag")),
104 m_componentParameters(
106 m_componentSeparateDigi,
107 params.getParameter<double>(
"simHitToPhotoelectronsBarrel"),
109 params.getParameter<double>(
"photoelectronsToAnalogBarrel"),
111 params.getParameter<double>(
"samplingFactor"),
112 params.getParameter<double>(
"componentTimePhase"),
114 params.getParameter<
int>(
"binOfMaximum"),
115 params.getParameter<
bool>(
"doPhotostatistics"),
118 m_APDResponse(!m_apdSeparateDigi ? nullptr
123 m_apdParameters.
get(),
125 m_componentParameters.
get(),
126 &m_ComponentShapes)),
128 m_ComponentResponse(!m_componentSeparateDigi
131 m_ParameterMap.
get(),
135 m_apdParameters.
get(),
137 m_componentParameters.
get(),
138 &m_ComponentShapes)),
144 m_apdParameters.
get(),
146 m_componentParameters.
get(),
147 &m_ComponentShapes)),
153 m_addESNoise(
params.getParameter<
bool>(
"doESNoise")),
154 m_PreMix1(
params.getParameter<
bool>(
"EcalPreMixStage1")),
155 m_PreMix2(
params.getParameter<
bool>(
"EcalPreMixStage2")),
157 m_doFastES(
params.getParameter<
bool>(
"doFast")),
163 m_ESElectronicsSim(m_doFastES ? nullptr : new
ESElectronicsSim(m_addESNoise)),
165 m_ESOldDigitizer(m_doFastES ? nullptr
168 m_ESElectronicsSimFast(!m_doFastES ? nullptr : new
ESElectronicsSimFast(m_addESNoise, m_PreMix1)),
170 m_ESDigitizer(!m_doFastES ? nullptr
171 : new
ESDigitizer(m_ESResponse.
get(), m_ESElectronicsSimFast.
get(), m_addESNoise)),
173 m_APDDigitizer(nullptr),
174 m_ComponentDigitizer(nullptr),
175 m_BarrelDigitizer(nullptr),
176 m_EndcapDigitizer(nullptr),
177 m_ElectronicsSim(nullptr),
179 m_APDElectronicsSim(nullptr),
182 m_EBCorrNoise({{
nullptr,
nullptr,
nullptr}}),
183 m_EECorrNoise({{
nullptr,
nullptr,
nullptr}}) {
190 iC.consumes<std::vector<PCaloHit>>(
edm::InputTag(m_hitsProducerTag,
"EcalHitsEB"));
192 iC.consumes<std::vector<PCaloHit>>(
edm::InputTag(m_hitsProducerTag,
"EcalHitsEE"));
194 iC.consumes<std::vector<PCaloHit>>(
edm::InputTag(m_hitsProducerTag,
"EcalHitsES"));
195 m_esGainToken = iC.esConsumes();
196 m_esMIPToGeVToken = iC.esConsumes();
197 m_esPedestalsToken = iC.esConsumes();
198 m_esMIPsToken = iC.esConsumes();
201 const std::vector<double> ebCorMatG12 =
params.getParameter<std::vector<double>>(
"EBCorrNoiseMatrixG12");
202 const std::vector<double> eeCorMatG12 =
params.getParameter<std::vector<double>>(
"EECorrNoiseMatrixG12");
203 const std::vector<double> ebCorMatG06 =
params.getParameter<std::vector<double>>(
"EBCorrNoiseMatrixG06");
204 const std::vector<double> eeCorMatG06 =
params.getParameter<std::vector<double>>(
"EECorrNoiseMatrixG06");
205 const std::vector<double> ebCorMatG01 =
params.getParameter<std::vector<double>>(
"EBCorrNoiseMatrixG01");
206 const std::vector<double> eeCorMatG01 =
params.getParameter<std::vector<double>>(
"EECorrNoiseMatrixG01");
209 const double rmsConstantTerm =
params.getParameter<
double>(
"ConstantTerm");
211 const bool addNoise =
params.getParameter<
bool>(
"doENoise");
228 assert(ebCorMatG12.size() == m_readoutFrameSize);
229 assert(eeCorMatG12.size() == m_readoutFrameSize);
230 assert(ebCorMatG06.size() == m_readoutFrameSize);
231 assert(eeCorMatG06.size() == m_readoutFrameSize);
232 assert(ebCorMatG01.size() == m_readoutFrameSize);
233 assert(eeCorMatG01.size() == m_readoutFrameSize);
235 assert(1.
e-7 > fabs(ebCorMatG12[0] - 1.0));
236 assert(1.
e-7 > fabs(ebCorMatG06[0] - 1.0));
237 assert(1.
e-7 > fabs(ebCorMatG01[0] - 1.0));
238 assert(1.
e-7 > fabs(eeCorMatG12[0] - 1.0));
239 assert(1.
e-7 > fabs(eeCorMatG06[0] - 1.0));
240 assert(1.
e-7 > fabs(eeCorMatG01[0] - 1.0));
242 for (
unsigned int row(0); row != m_readoutFrameSize; ++row) {
243 assert(0 == row || 1. >= ebCorMatG12[row]);
244 assert(0 == row || 1. >= ebCorMatG06[row]);
245 assert(0 == row || 1. >= ebCorMatG01[row]);
246 assert(0 == row || 1. >= eeCorMatG12[row]);
247 assert(0 == row || 1. >= eeCorMatG06[row]);
248 assert(0 == row || 1. >= eeCorMatG01[row]);
250 const unsigned int index(row - column);
260 m_EBCorrNoise[0] = std::make_unique<CorrelatedNoisifier<EcalCorrMatrix>>(ebMatrix[0]);
261 m_EECorrNoise[0] = std::make_unique<CorrelatedNoisifier<EcalCorrMatrix>>(eeMatrix[0]);
262 m_EBCorrNoise[1] = std::make_unique<CorrelatedNoisifier<EcalCorrMatrix>>(ebMatrix[1]);
263 m_EECorrNoise[1] = std::make_unique<CorrelatedNoisifier<EcalCorrMatrix>>(eeMatrix[1]);
264 m_EBCorrNoise[2] = std::make_unique<CorrelatedNoisifier<EcalCorrMatrix>>(ebMatrix[2]);
265 m_EECorrNoise[2] = std::make_unique<CorrelatedNoisifier<EcalCorrMatrix>>(eeMatrix[2]);
267 m_Coder = std::make_unique<EcalCoder>(addNoise,
269 m_EBCorrNoise[0].get(),
270 m_EECorrNoise[0].get(),
271 m_EBCorrNoise[1].get(),
272 m_EECorrNoise[1].get(),
273 m_EBCorrNoise[2].get(),
274 m_EECorrNoise[2].get());
277 std::make_unique<EcalElectronicsSim_Ph1>(m_ParameterMap.get(), m_Coder.get(),
applyConstantTerm, rmsConstantTerm);
279 if (m_apdSeparateDigi) {
280 m_APDCoder = std::make_unique<EcalCoder>(
false,
282 m_EBCorrNoise[0].get(),
283 m_EECorrNoise[0].get(),
284 m_EBCorrNoise[1].get(),
285 m_EECorrNoise[1].get(),
286 m_EBCorrNoise[2].get(),
287 m_EECorrNoise[2].get());
289 m_APDElectronicsSim = std::make_unique<EcalElectronicsSim_Ph1>(
292 m_APDDigitizer = std::make_unique<EBDigitizer>(m_APDResponse.get(), m_APDElectronicsSim.get(),
false);
294 if (m_componentSeparateDigi) {
295 m_ComponentCoder = std::make_unique<EcalCoder>(addNoise,
297 m_EBCorrNoise[0].get(),
298 m_EECorrNoise[0].get(),
299 m_EBCorrNoise[1].get(),
300 m_EECorrNoise[1].get(),
301 m_EBCorrNoise[2].get(),
302 m_EECorrNoise[2].get());
303 m_ComponentElectronicsSim = std::make_unique<EcalElectronicsSim_Ph1>(
304 m_ParameterMap.get(), m_ComponentCoder.get(),
applyConstantTerm, rmsConstantTerm);
305 m_ComponentDigitizer =
306 std::make_unique<EBDigitizer>(m_ComponentResponse.get(), m_ComponentElectronicsSim.get(), addNoise);
310 m_BarrelDigitizer = std::make_unique<EBDigitizer>(m_EBResponse.get(), m_ElectronicsSim.get(), addNoise);
314 m_EndcapDigitizer = std::make_unique<EEDigitizer>(m_EEResponse.get(), m_ElectronicsSim.get(), addNoise);
401 e.getByLabel(ebTag, ebHandle);
407 e.getByLabel(eeTag, eeHandle);
413 e.getByLabel(esTag, esHandle);
434 edm::LogInfo(
"DigiInfo") <<
"EB Digis: " << barrelResult->size();
438 edm::LogInfo(
"DigiInfo") <<
"APD Digis: " << apdResult->size();
442 edm::LogInfo(
"DigiInfo") <<
"Component Digis: " << componentResult->size();
448 edm::LogInfo(
"EcalDigi") <<
"EE Digis: " << endcapResult->size();
457 edm::LogInfo(
"EcalDigi") <<
"ES Digis: " << preshowerResult->size();
478 throw cms::Exception(
"Configuration") <<
"RandomNumberGenerator service is not available.\n" 479 "You must add the service in the configuration file\n" 480 "or remove the module that requires it.";
482 CLHEP::HepRandomEngine *engine = &rng->
getEngine(
lumi.index());
498 m_Coder->setPedestals(pedestals);
507 m_Coder->setIntercalibConstants(ical);
543 double theGains[
m_Coder->NGAINS + 1];
547 theGains[1] = theGains[2] * (defaultRatios->
gain12Over6());
551 <<
" g1 = " << theGains[1] <<
"\n" 552 <<
" g2 = " << theGains[2] <<
"\n" 553 <<
" g3 = " << theGains[3];
555 delete defaultRatios;
569 m_Coder->setFullScaleEnergy(EBscale, EEscale);
571 m_APDCoder->setFullScaleEnergy(EBscale, EEscale);
621 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)
const std::string m_componentDigiTag
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
std::unique_ptr< EBHitResponse > m_ComponentResponse
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< EcalCoder > m_ComponentCoder
ComponentShapeCollection m_ComponentShapes
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 setEventSetup(const edm::EventSetup &evtSetup)
void beginLuminosityBlock(edm::LuminosityBlock const &lumi, edm::EventSetup const &setup) override
unsigned long long TimeValue_t
void setEventSetup(const edm::EventSetup &evtSetup, bool normalize=true)
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
std::unique_ptr< EBDigitizer > m_ComponentDigitizer
bool check(const edm::EventSetup &iSetup)
const bool m_apdSeparateDigi
std::unique_ptr< ESElectronicsSim > m_ESElectronicsSim
const bool m_componentSeparateDigi
const std::string m_apdDigiTag
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