36 DataMixingEMDigiWorker::DataMixingEMDigiWorker() { sel_=0;}
40 label_(ps.getParameter<std::string>(
"Label"))
90 LogInfo(
"DataMixingEMDigiWorker")<<
"===============> adding MC signals for "<<e.
id();
100 LogDebug(
"DataMixingEMDigiWorker") <<
"total # EB digis: " << EBDigis->
size();
110 it != EBDigis->
end(); ++it) {
114 LogDebug(
"DataMixingEMDigiWorker") <<
"processed EBDigi with rawId: "
115 << it->id().rawId() <<
"\n"
116 <<
" digi energy: " << it->energy();
130 LogDebug(
"DataMixingEMDigiWorker") <<
"total # EE digis: " << EEDigis->
size();
138 it != EEDigis->
end(); ++it) {
142 LogDebug(
"DataMixingEMDigiWorker") <<
"processed EEDigi with rawId: "
143 << it->id().rawId() <<
"\n"
144 <<
" digi energy: " << it->energy();
159 LogDebug(
"DataMixingEMDigiWorker") <<
"total # ES digis: " << ESDigis->
size();
169 it != ESDigis->
end(); ++it) {
174 LogDebug(
"DataMixingEMDigiWorker") <<
"processed ESDigi with rawId: "
175 << it->id().rawId() <<
"\n"
176 <<
" digi energy: " << it->energy();
186 LogInfo(
"DataMixingEMDigiWorker") <<
"\n===============> adding pileups from event "<<ep->
id()<<
" for bunchcrossing "<<bcr;
192 boost::shared_ptr<Wrapper<EBDigiCollection>
const> EBDigisPTR =
199 LogDebug(
"DataMixingEMDigiWorker") <<
"total # EB digis: " << EBDigis->
size();
203 it != EBDigis->
end(); ++it) {
208 LogDebug(
"DataMixingEMDigiWorker") <<
"processed EBDigi with rawId: "
209 << it->id().rawId() <<
"\n"
210 <<
" digi energy: " << it->energy();
217 boost::shared_ptr<Wrapper<EEDigiCollection>
const> EEDigisPTR =
224 LogDebug(
"DataMixingEMDigiWorker") <<
"total # EE digis: " << EEDigis->
size();
227 it != EEDigis->
end(); ++it) {
232 LogDebug(
"DataMixingEMDigiWorker") <<
"processed EEDigi with rawId: "
233 << it->id().rawId() <<
"\n"
234 <<
" digi energy: " << it->energy();
240 boost::shared_ptr<Wrapper<ESDigiCollection>
const> ESDigisPTR =
247 LogDebug(
"DataMixingEMDigiWorker") <<
"total # ES digis: " << ESDigis->
size();
250 it != ESDigis->
end(); ++it) {
255 LogDebug(
"DataMixingEMDigiWorker") <<
"processed ESDigi with rawId: "
256 << it->id().rawId() <<
"\n"
257 <<
" digi energy: " << it->energy();
282 int gain_consensus = 0;
290 EBDigiMap::const_iterator iEBchk;
297 currentID = iEB->first;
299 if (currentID == formerID) {
311 unsigned int sizenew = (iEB->second).
size();
312 unsigned int sizeold = EB_old.
size();
314 unsigned int max_samp =
std::max(sizenew, sizeold);
320 int sw_gain_consensus=0;
323 for(
unsigned int isamp = 0; isamp<max_samp; isamp++) {
324 if(isamp < sizenew) {
325 gain_new = (iEB->second)[isamp].
gainId();
326 adc_new = (iEB->second)[isamp].
adc();
330 if(isamp < sizeold) {
331 gain_old = EB_old[isamp].gainId();
332 adc_old = EB_old[isamp].adc();
336 const std::vector<float> pedeStals =
GetPedestals(ES,currentID);
337 const std::vector<float> gainRatios =
GetGainRatios(ES,currentID);
339 if(adc_new>0 && adc_old>0) {
340 if(gain_old == gain_new) {
341 gain_consensus = gain_old;
346 if(gain_old < gain_new) {
349 float ratio = gainRatios[gain_new-1]/gainRatios[gain_old-1];
350 adc_old = (int) round ((adc_old - pedeStals[gain_old-1]) / ratio + pedeStals[gain_new-1] );
351 gain_consensus = gain_new;
354 float ratio = gainRatios[gain_old-1]/gainRatios[gain_new-1];
355 adc_new = (int) round ( (adc_new - pedeStals[gain_new-1]) / ratio+ pedeStals[gain_old-1] );
356 gain_consensus = gain_old;
363 adc_sum = adc_new + adc_old - (int) round (pedeStals[gain_consensus-1]);
368 if (gain_consensus<3){
370 double ratio = gainRatios[gain_consensus]/gainRatios[gain_consensus-1];
371 adc_sum = (int) round ((adc_sum - pedeStals[gain_consensus-1])/ ratio + pedeStals[gain_consensus] ) ;
372 sw_gain_consensus=++gain_consensus;
380 if (gain_consensus<sw_gain_consensus){
382 double ratio = gainRatios[sw_gain_consensus-1]/gainRatios[gain_consensus-1];
383 adc_sum = (int) round((adc_sum - pedeStals[gain_consensus-1] )/ratio + pedeStals[sw_gain_consensus-1]);
384 gain_consensus = sw_gain_consensus;
395 EBdigis->push_back( formerID, EB_old.
frame().
begin() );
398 formerID = currentID;
399 EB_old = iEB->second;
406 EBdigis->push_back( currentID, (iEB->second).frame().begin()) ;
415 EEDigiMap::const_iterator iEEchk;
420 currentID = iEE->first;
422 if (currentID == formerID) {
425 unsigned int sizenew = (iEE->second).
size();
426 unsigned int sizeold = EE_old.
size();
428 unsigned int max_samp =
std::max(sizenew, sizeold);
434 for(
unsigned int isamp = 0; isamp<max_samp; isamp++) {
435 if(isamp < sizenew) {
436 gain_new = (iEE->second)[isamp].
gainId();
437 adc_new = (iEE->second)[isamp].
adc();
441 if(isamp < sizeold) {
442 gain_old = EE_old[isamp].gainId();
443 adc_old = EE_old[isamp].adc();
447 const std::vector<float> pedeStals =
GetPedestals(ES,currentID);
448 const std::vector<float> gainRatios =
GetGainRatios(ES,currentID);
450 if(adc_new>0 && adc_old>0) {
451 if(gain_old == gain_new) {
452 gain_consensus = gain_old;
456 if(gain_old < gain_new) {
459 float ratio = gainRatios[gain_new-1]/gainRatios[gain_old-1];
460 adc_old = (int) round ((adc_old - pedeStals[gain_old-1]) / ratio + pedeStals[gain_new-1] );
461 gain_consensus = gain_new;
464 float ratio = gainRatios[gain_old-1]/gainRatios[gain_new-1];
465 adc_new = (int) round ( (adc_new - pedeStals[gain_new-1]) / ratio+ pedeStals[gain_old-1] );
466 gain_consensus = gain_old;
474 adc_sum = adc_new + adc_old;
478 if (gain_consensus<3){
480 double ratio = gainRatios[gain_consensus]/gainRatios[gain_consensus-1];
481 adc_sum = (int) round ((adc_sum - pedeStals[gain_consensus-1])/ ratio + pedeStals[gain_consensus] ) ;
495 EEdigis->push_back(formerID, EE_old.
frame().
begin() );
499 formerID = currentID;
500 EE_old = iEE->second;
505 EEdigis->push_back(currentID, (iEE->second).frame().begin());
515 ESDigiMap::const_iterator iESchk;
520 currentID = iES->first;
522 if (currentID == formerID) {
525 unsigned int sizenew = (iES->second).
size();
526 unsigned int sizeold = ES_old.
size();
528 unsigned int max_samp =
std::max(sizenew, sizeold);
534 for(
unsigned int isamp = 0; isamp<max_samp; isamp++) {
535 if(isamp < sizenew) {
536 adc_new = (iES->second)[isamp].
adc();
537 rawdat = (iES->second)[isamp].raw();
541 if(isamp < sizeold) {
542 adc_old = ES_old[isamp].adc();
543 rawdat = ES_old[isamp].raw();
548 adc_sum = adc_new + adc_old;
551 data = adc_sum+(rawdat&0xF000);
558 ESdigis->push_back(ES_old);
561 formerID = currentID;
562 ES_old = iES->second;
567 ESdigis->push_back(iES->second);
579 LogInfo(
"DataMixingEMDigiWorker") <<
"total # EB Merged digis: " << EBdigis->size() ;
580 LogInfo(
"DataMixingEMDigiWorker") <<
"total # EE Merged digis: " << EEdigis->size() ;
581 LogInfo(
"DataMixingEMDigiWorker") <<
"total # ES Merged digis: " << ESdigis->size() ;
596 std::vector<float> pedeStals(3);
608 pedIter = pedMap.
find(detid);
609 if( pedIter != pedMap.
end() ) {
611 pedeStals[0] = aped.mean_x12;
612 pedeStals[1] = aped.mean_x6;
613 pedeStals[2] = aped.mean_x1;
615 edm::LogError(
"DataMixingMissingInput") <<
"Cannot find pedestals";
627 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
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
int gainId(sample_type sample)
get the gainId (2 bits)
edm::InputTag EBdigiCollectionSig_
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
std::string EBDigiCollectionDM_
void putEM(edm::Event &e, const edm::EventSetup &ES)
edm::InputTag EBProducerSig_
const T & max(const T &a, const T &b)
EcalPedestalsMap::const_iterator EcalPedestalsMapIterator
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
void addEMPileups(const int bcr, const edm::EventPrincipal *, unsigned int EventId, const edm::EventSetup &ES)
edm::InputTag EEProducerSig_
Container::value_type value_type
void setSample(int i, const ESSample &sam)
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
T const * product() const
edm::DataFrame const & frame() const
virtual ~DataMixingEMDigiWorker()
float gain12Over6() const
T const * product() 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)
tuple size
Write out results.
edm::InputTag EBPileInputTag_