26 DataMixingEMDigiWorker::DataMixingEMDigiWorker() {}
30 : label_(ps.getParameter<std::
string>(
"Label"))
69 LogInfo(
"DataMixingEMDigiWorker") <<
"===============> adding MC signals for " << e.
id();
79 LogDebug(
"DataMixingEMDigiWorker") <<
"total # EB digis: " << EBDigis->
size();
104 LogDebug(
"DataMixingEMDigiWorker") <<
"total # EE digis: " << EEDigis->
size();
128 LogDebug(
"DataMixingEMDigiWorker") <<
"total # ES digis: " << ESDigis->
size();
150 unsigned int eventNr,
153 LogInfo(
"DataMixingEMDigiWorker") <<
"\n===============> adding pileups from event " << ep->
id()
154 <<
" for bunchcrossing " << bcr;
161 std::shared_ptr<Wrapper<EBDigiCollection>
const> EBDigisPTR =
167 LogDebug(
"DataMixingEMDigiWorker") <<
"total # EB digis: " << EBDigis->
size();
184 std::shared_ptr<Wrapper<EEDigiCollection>
const> EEDigisPTR =
190 LogDebug(
"DataMixingEMDigiWorker") <<
"total # EE digis: " << EEDigis->
size();
205 std::shared_ptr<Wrapper<ESDigiCollection>
const> ESDigisPTR =
211 LogDebug(
"DataMixingEMDigiWorker") <<
"total # ES digis: " << ESDigis->
size();
241 int gain_consensus = 0;
249 EBDigiMap::const_iterator iEBchk;
252 currentID = iEB->first;
254 if (currentID == formerID) {
268 unsigned int sizenew = (iEB->second).
size();
269 unsigned int sizeold = EB_old.
size();
271 unsigned int max_samp =
std::max(sizenew, sizeold);
277 int sw_gain_consensus = 0;
279 for (
unsigned int isamp = 0; isamp < max_samp; isamp++) {
280 if (isamp < sizenew) {
281 gain_new = (iEB->second)[isamp].
gainId();
282 adc_new = (iEB->second)[isamp].
adc();
287 if (isamp < sizeold) {
288 gain_old = EB_old[isamp].gainId();
289 adc_old = EB_old[isamp].adc();
294 const std::vector<float> pedeStals =
GetPedestals(ES, currentID);
295 const std::vector<float> gainRatios =
GetGainRatios(ES, currentID);
297 if (adc_new > 0 && adc_old > 0) {
298 if (gain_old == gain_new) {
299 gain_consensus = gain_old;
302 if (gain_old < gain_new) {
304 float ratio = gainRatios[gain_new - 1] / gainRatios[gain_old - 1];
305 adc_old = (int)round((adc_old - pedeStals[gain_old - 1]) / ratio + pedeStals[gain_new - 1]);
306 gain_consensus = gain_new;
308 float ratio = gainRatios[gain_old - 1] / gainRatios[gain_new - 1];
309 adc_new = (int)round((adc_new - pedeStals[gain_new - 1]) / ratio + pedeStals[gain_old - 1]);
310 gain_consensus = gain_old;
316 adc_sum = adc_new + adc_old - (int)round(pedeStals[gain_consensus - 1]);
319 if (adc_sum > 4096) {
320 if (gain_consensus < 3) {
321 double ratio = gainRatios[gain_consensus] / gainRatios[gain_consensus - 1];
322 adc_sum = (int)round((adc_sum - pedeStals[gain_consensus - 1]) / ratio + pedeStals[gain_consensus]);
323 sw_gain_consensus = ++gain_consensus;
330 if (gain_consensus < sw_gain_consensus) {
331 double ratio = gainRatios[sw_gain_consensus - 1] / gainRatios[gain_consensus - 1];
332 adc_sum = (int)round((adc_sum - pedeStals[gain_consensus - 1]) / ratio + pedeStals[sw_gain_consensus - 1]);
333 gain_consensus = sw_gain_consensus;
344 EBdigis->push_back(formerID, EB_old.
frame().
begin());
347 formerID = currentID;
348 EB_old = iEB->second;
353 EBdigis->push_back(currentID, (iEB->second).frame().begin());
362 EEDigiMap::const_iterator iEEchk;
365 currentID = iEE->first;
367 if (currentID == formerID) {
370 unsigned int sizenew = (iEE->second).
size();
371 unsigned int sizeold = EE_old.
size();
373 unsigned int max_samp =
std::max(sizenew, sizeold);
379 for (
unsigned int isamp = 0; isamp < max_samp; isamp++) {
380 if (isamp < sizenew) {
381 gain_new = (iEE->second)[isamp].
gainId();
382 adc_new = (iEE->second)[isamp].
adc();
387 if (isamp < sizeold) {
388 gain_old = EE_old[isamp].gainId();
389 adc_old = EE_old[isamp].adc();
394 const std::vector<float> pedeStals =
GetPedestals(ES, currentID);
395 const std::vector<float> gainRatios =
GetGainRatios(ES, currentID);
397 if (adc_new > 0 && adc_old > 0) {
398 if (gain_old == gain_new) {
399 gain_consensus = gain_old;
402 if (gain_old < gain_new) {
404 float ratio = gainRatios[gain_new - 1] / gainRatios[gain_old - 1];
405 adc_old = (int)round((adc_old - pedeStals[gain_old - 1]) / ratio + pedeStals[gain_new - 1]);
406 gain_consensus = gain_new;
408 float ratio = gainRatios[gain_old - 1] / gainRatios[gain_new - 1];
409 adc_new = (int)round((adc_new - pedeStals[gain_new - 1]) / ratio + pedeStals[gain_old - 1]);
410 gain_consensus = gain_old;
416 adc_sum = adc_new + adc_old - (int)round(pedeStals[gain_consensus - 1]);
419 if (adc_sum > 4096) {
420 if (gain_consensus < 3) {
421 double ratio = gainRatios[gain_consensus] / gainRatios[gain_consensus - 1];
422 adc_sum = (int)round((adc_sum - pedeStals[gain_consensus - 1]) / ratio + pedeStals[gain_consensus]);
434 EEdigis->push_back(formerID, EE_old.
frame().
begin());
437 formerID = currentID;
438 EE_old = iEE->second;
443 EEdigis->push_back(currentID, (iEE->second).frame().begin());
452 ESDigiMap::const_iterator iESchk;
455 currentID = iES->first;
457 if (currentID == formerID) {
460 unsigned int sizenew = (iES->second).
size();
461 unsigned int sizeold = ES_old.
size();
463 unsigned int max_samp =
std::max(sizenew, sizeold);
469 for (
unsigned int isamp = 0; isamp < max_samp; isamp++) {
470 if (isamp < sizenew) {
471 adc_new = (iES->second)[isamp].
adc();
472 rawdat = (iES->second)[isamp].raw();
477 if (isamp < sizeold) {
478 adc_old = ES_old[isamp].adc();
479 rawdat = ES_old[isamp].raw();
485 adc_sum = adc_new + adc_old;
488 data = adc_sum + (rawdat & 0xF000);
494 ESdigis->push_back(ES_old);
497 formerID = currentID;
498 ES_old = iES->second;
503 ESdigis->push_back(iES->second);
514 LogInfo(
"DataMixingEMDigiWorker") <<
"total # EB Merged digis: " << EBdigis->size();
515 LogInfo(
"DataMixingEMDigiWorker") <<
"total # EE Merged digis: " << EEdigis->size();
516 LogInfo(
"DataMixingEMDigiWorker") <<
"total # ES Merged digis: " << ESdigis->size();
529 std::vector<float> pedeStals(3);
538 pedIter = pedMap.
find(detid);
539 if (pedIter != pedMap.
end()) {
541 pedeStals[0] = aped.mean_x12;
542 pedeStals[1] = aped.mean_x6;
543 pedeStals[2] = aped.mean_x1;
545 edm::LogError(
"DataMixingMissingInput") <<
"Cannot find pedestals";
555 std::vector<float> gainRatios(3);
edm::InputTag EEPileInputTag_
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
std::string EEDigiCollectionDM_
const std::vector< float > GetGainRatios(const edm::EventSetup &ES, const DetId &detid)
retrieve gain ratios for that detid [0]=g12, [1]=g6, [2]=g12
edm::EDGetTokenT< EEDigiCollection > EEDigiPileToken_
bool getByToken(EDGetToken token, Handle< PROD > &result) const
edm::EDGetTokenT< ESDigiCollection > ESDigiPileToken_
const self & getMap() const
std::string ESDigiCollectionDM_
EventID const & id() const
const std::vector< float > GetPedestals(const edm::EventSetup &ES, const DetId &detid)
retrieve pedestals for that detid [0]=g12, [1]=g6, [2]=g12
const_iterator begin() const
The iterator returned can not safely be used across threads.
Log< level::Error, false > LogError
void addEMPileups(const int bcr, const edm::EventPrincipal *, unsigned int EventId, const edm::EventSetup &ES, ModuleCallingContext const *)
std::string EBDigiCollectionDM_
void putEM(edm::Event &e, const edm::EventSetup &ES)
edm::InputTag EBProducerSig_
Container::value_type value_type
EcalGainRatioMap EcalGainRatios
EcalPedestalsMap::const_iterator EcalPedestalsMapIterator
edm::InputTag EEProducerSig_
void setSample(int i, const ESSample &sam)
Log< level::Info, false > LogInfo
EcalPedestalsMap EcalPedestals
constexpr int gainId(sample_type sample)
get the gainId (2 bits)
T const * product() const
constexpr iterator begin()
edm::DataFrame const & frame() const
T getParameter(std::string const &) const
virtual ~DataMixingEMDigiWorker()
float gain12Over6() const
edm::ESGetToken< EcalPedestals, EcalPedestalsRcd > pedToken_
edm::InputTag ESPileInputTag_
boost::transform_iterator< IterHelp, boost::counting_iterator< int > > const_iterator
const_iterator end() const
char data[epos_bytes_allocation]
void setSample(int i, EcalMGPASample sam)
const_iterator find(uint32_t rawId) const
const_iterator end() const
edm::InputTag ESProducerSig_
ESHandle< T > getHandle(const ESGetToken< T, R > &iToken) const
edm::ESGetToken< EcalGainRatios, EcalGainRatiosRcd > grToken_
void addEMSignals(const edm::Event &e, const edm::EventSetup &ES)
tuple size
Write out results.
edm::EDGetTokenT< EBDigiCollection > EBDigiToken_
edm::EDGetTokenT< ESDigiCollection > ESDigiToken_
edm::InputTag EBPileInputTag_
edm::EDGetTokenT< EEDigiCollection > EEDigiToken_
uint16_t *__restrict__ uint16_t const *__restrict__ adc
edm::EDGetTokenT< EBDigiCollection > EBDigiPileToken_