37 DataMixingEMDigiWorker::DataMixingEMDigiWorker() { }
41 label_(ps.getParameter<
std::
string>(
"Label"))
82 LogInfo(
"DataMixingEMDigiWorker")<<
"===============> adding MC signals for "<<e.
id();
92 LogDebug(
"DataMixingEMDigiWorker") <<
"total # EB digis: " << EBDigis->
size();
101 it != EBDigis->
end(); ++it) {
122 LogDebug(
"DataMixingEMDigiWorker") <<
"total # EE digis: " << EEDigis->
size();
130 it != EEDigis->
end(); ++it) {
152 LogDebug(
"DataMixingEMDigiWorker") <<
"total # ES digis: " << ESDigis->
size();
162 it != ESDigis->
end(); ++it) {
181 LogInfo(
"DataMixingEMDigiWorker") <<
"\n===============> adding pileups from event "<<ep->
id()<<
" for bunchcrossing "<<bcr;
187 std::shared_ptr<Wrapper<EBDigiCollection>
const> EBDigisPTR =
194 LogDebug(
"DataMixingEMDigiWorker") <<
"total # EB digis: " << EBDigis->
size();
198 it != EBDigis->
end(); ++it) {
213 std::shared_ptr<Wrapper<EEDigiCollection>
const> EEDigisPTR =
220 LogDebug(
"DataMixingEMDigiWorker") <<
"total # EE digis: " << EEDigis->
size();
223 it != EEDigis->
end(); ++it) {
237 std::shared_ptr<Wrapper<ESDigiCollection>
const> ESDigisPTR =
244 LogDebug(
"DataMixingEMDigiWorker") <<
"total # ES digis: " << ESDigis->
size();
247 it != ESDigis->
end(); ++it) {
280 int gain_consensus = 0;
288 EBDigiMap::const_iterator iEBchk;
295 currentID = iEB->first;
297 if (currentID == formerID) {
309 unsigned int sizenew = (iEB->second).
size();
310 unsigned int sizeold = EB_old.
size();
312 unsigned int max_samp =
std::max(sizenew, sizeold);
318 int sw_gain_consensus=0;
321 for(
unsigned int isamp = 0; isamp<max_samp; isamp++) {
322 if(isamp < sizenew) {
323 gain_new = (iEB->second)[isamp].
gainId();
324 adc_new = (iEB->second)[isamp].
adc();
328 if(isamp < sizeold) {
329 gain_old = EB_old[isamp].gainId();
330 adc_old = EB_old[isamp].adc();
334 const std::vector<float> pedeStals =
GetPedestals(ES,currentID);
335 const std::vector<float> gainRatios =
GetGainRatios(ES,currentID);
337 if(adc_new>0 && adc_old>0) {
338 if(gain_old == gain_new) {
339 gain_consensus = gain_old;
344 if(gain_old < gain_new) {
347 float ratio = gainRatios[gain_new-1]/gainRatios[gain_old-1];
348 adc_old = (
int) round ((adc_old - pedeStals[gain_old-1]) / ratio + pedeStals[gain_new-1] );
349 gain_consensus = gain_new;
352 float ratio = gainRatios[gain_old-1]/gainRatios[gain_new-1];
353 adc_new = (
int) round ( (adc_new - pedeStals[gain_new-1]) / ratio+ pedeStals[gain_old-1] );
354 gain_consensus = gain_old;
361 adc_sum = adc_new + adc_old - (
int) round (pedeStals[gain_consensus-1]);
366 if (gain_consensus<3){
368 double ratio = gainRatios[gain_consensus]/gainRatios[gain_consensus-1];
369 adc_sum = (
int) round ((adc_sum - pedeStals[gain_consensus-1])/ ratio + pedeStals[gain_consensus] ) ;
370 sw_gain_consensus=++gain_consensus;
378 if (gain_consensus<sw_gain_consensus){
380 double ratio = gainRatios[sw_gain_consensus-1]/gainRatios[gain_consensus-1];
381 adc_sum = (
int) round((adc_sum - pedeStals[gain_consensus-1] )/ratio + pedeStals[sw_gain_consensus-1]);
382 gain_consensus = sw_gain_consensus;
393 EBdigis->push_back( formerID, EB_old.
frame().
begin() );
396 formerID = currentID;
397 EB_old = iEB->second;
404 EBdigis->push_back( currentID, (iEB->second).frame().begin()) ;
413 EEDigiMap::const_iterator iEEchk;
418 currentID = iEE->first;
420 if (currentID == formerID) {
423 unsigned int sizenew = (iEE->second).
size();
424 unsigned int sizeold = EE_old.
size();
426 unsigned int max_samp =
std::max(sizenew, sizeold);
432 for(
unsigned int isamp = 0; isamp<max_samp; isamp++) {
433 if(isamp < sizenew) {
434 gain_new = (iEE->second)[isamp].
gainId();
435 adc_new = (iEE->second)[isamp].
adc();
439 if(isamp < sizeold) {
440 gain_old = EE_old[isamp].gainId();
441 adc_old = EE_old[isamp].adc();
445 const std::vector<float> pedeStals =
GetPedestals(ES,currentID);
446 const std::vector<float> gainRatios =
GetGainRatios(ES,currentID);
448 if(adc_new>0 && adc_old>0) {
449 if(gain_old == gain_new) {
450 gain_consensus = gain_old;
454 if(gain_old < gain_new) {
457 float ratio = gainRatios[gain_new-1]/gainRatios[gain_old-1];
458 adc_old = (
int) round ((adc_old - pedeStals[gain_old-1]) / ratio + pedeStals[gain_new-1] );
459 gain_consensus = gain_new;
462 float ratio = gainRatios[gain_old-1]/gainRatios[gain_new-1];
463 adc_new = (
int) round ( (adc_new - pedeStals[gain_new-1]) / ratio+ pedeStals[gain_old-1] );
464 gain_consensus = gain_old;
472 adc_sum = adc_new + adc_old - (
int) round (pedeStals[gain_consensus-1]);
476 if (gain_consensus<3){
478 double ratio = gainRatios[gain_consensus]/gainRatios[gain_consensus-1];
479 adc_sum = (
int) round ((adc_sum - pedeStals[gain_consensus-1])/ ratio + pedeStals[gain_consensus] ) ;
493 EEdigis->push_back(formerID, EE_old.
frame().
begin() );
497 formerID = currentID;
498 EE_old = iEE->second;
503 EEdigis->push_back(currentID, (iEE->second).frame().begin());
513 ESDigiMap::const_iterator iESchk;
518 currentID = iES->first;
520 if (currentID == formerID) {
523 unsigned int sizenew = (iES->second).
size();
524 unsigned int sizeold = ES_old.
size();
526 unsigned int max_samp =
std::max(sizenew, sizeold);
532 for(
unsigned int isamp = 0; isamp<max_samp; isamp++) {
533 if(isamp < sizenew) {
534 adc_new = (iES->second)[isamp].
adc();
535 rawdat = (iES->second)[isamp].raw();
539 if(isamp < sizeold) {
540 adc_old = ES_old[isamp].adc();
541 rawdat = ES_old[isamp].raw();
546 adc_sum = adc_new + adc_old;
549 data = adc_sum+(rawdat&0xF000);
556 ESdigis->push_back(ES_old);
559 formerID = currentID;
560 ES_old = iES->second;
565 ESdigis->push_back(iES->second);
577 LogInfo(
"DataMixingEMDigiWorker") <<
"total # EB Merged digis: " << EBdigis->size() ;
578 LogInfo(
"DataMixingEMDigiWorker") <<
"total # EE Merged digis: " << EEdigis->size() ;
579 LogInfo(
"DataMixingEMDigiWorker") <<
"total # ES Merged digis: " << ESdigis->size() ;
594 std::vector<float> pedeStals(3);
606 pedIter = pedMap.
find(detid);
607 if( pedIter != pedMap.
end() ) {
613 edm::LogError(
"DataMixingMissingInput") <<
"Cannot find pedestals";
625 std::vector<float> gainRatios(3);
int adc(sample_type sample)
get the ADC sample (12 bits)
edm::InputTag EEPileInputTag_
T getParameter(std::string const &) const
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
boost::transform_iterator< IterHelp, boost::counting_iterator< int > > const_iterator
edm::EDGetTokenT< EEDigiCollection > EEDigiPileToken_
int gainId(sample_type sample)
get the gainId (2 bits)
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
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
EcalPedestalsMap::const_iterator EcalPedestalsMapIterator
edm::InputTag EEProducerSig_
void setSample(int i, const ESSample &sam)
T const * product() const
edm::DataFrame const & frame() const
virtual ~DataMixingEMDigiWorker()
float gain12Over6() const
edm::InputTag ESPileInputTag_
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_
void addEMSignals(const edm::Event &e, const edm::EventSetup &ES)
T const * product() const
edm::EDGetTokenT< EBDigiCollection > EBDigiToken_
edm::EDGetTokenT< ESDigiCollection > ESDigiToken_
edm::InputTag EBPileInputTag_
edm::EDGetTokenT< EEDigiCollection > EEDigiToken_
edm::EDGetTokenT< EBDigiCollection > EBDigiPileToken_