36 DataMixingEMDigiWorker::DataMixingEMDigiWorker() { }
40 label_(ps.getParameter<std::
string>(
"Label"))
80 LogInfo(
"DataMixingEMDigiWorker")<<
"===============> adding MC signals for "<<e.
id();
90 LogDebug(
"DataMixingEMDigiWorker") <<
"total # EB digis: " << EBDigis->
size();
100 it != EBDigis->
end(); ++it) {
104 LogDebug(
"DataMixingEMDigiWorker") <<
"processed EBDigi with rawId: "
105 << it->id().rawId() <<
"\n"
106 <<
" digi energy: " << it->energy();
120 LogDebug(
"DataMixingEMDigiWorker") <<
"total # EE digis: " << EEDigis->
size();
128 it != EEDigis->
end(); ++it) {
132 LogDebug(
"DataMixingEMDigiWorker") <<
"processed EEDigi with rawId: "
133 << it->id().rawId() <<
"\n"
134 <<
" digi energy: " << it->energy();
149 LogDebug(
"DataMixingEMDigiWorker") <<
"total # ES digis: " << ESDigis->
size();
159 it != ESDigis->
end(); ++it) {
164 LogDebug(
"DataMixingEMDigiWorker") <<
"processed ESDigi with rawId: "
165 << it->id().rawId() <<
"\n"
166 <<
" digi energy: " << it->energy();
176 LogInfo(
"DataMixingEMDigiWorker") <<
"\n===============> adding pileups from event "<<ep->
id()<<
" for bunchcrossing "<<bcr;
182 boost::shared_ptr<Wrapper<EBDigiCollection>
const> EBDigisPTR =
189 LogDebug(
"DataMixingEMDigiWorker") <<
"total # EB digis: " << EBDigis->
size();
193 it != EBDigis->
end(); ++it) {
198 LogDebug(
"DataMixingEMDigiWorker") <<
"processed EBDigi with rawId: "
199 << it->id().rawId() <<
"\n"
200 <<
" digi energy: " << it->energy();
207 boost::shared_ptr<Wrapper<EEDigiCollection>
const> EEDigisPTR =
214 LogDebug(
"DataMixingEMDigiWorker") <<
"total # EE digis: " << EEDigis->
size();
217 it != EEDigis->
end(); ++it) {
222 LogDebug(
"DataMixingEMDigiWorker") <<
"processed EEDigi with rawId: "
223 << it->id().rawId() <<
"\n"
224 <<
" digi energy: " << it->energy();
230 boost::shared_ptr<Wrapper<ESDigiCollection>
const> ESDigisPTR =
237 LogDebug(
"DataMixingEMDigiWorker") <<
"total # ES digis: " << ESDigis->
size();
240 it != ESDigis->
end(); ++it) {
245 LogDebug(
"DataMixingEMDigiWorker") <<
"processed ESDigi with rawId: "
246 << it->id().rawId() <<
"\n"
247 <<
" digi energy: " << it->energy();
272 int gain_consensus = 0;
280 EBDigiMap::const_iterator iEBchk;
287 currentID = iEB->first;
289 if (currentID == formerID) {
301 unsigned int sizenew = (iEB->second).
size();
302 unsigned int sizeold = EB_old.
size();
304 unsigned int max_samp =
std::max(sizenew, sizeold);
310 int sw_gain_consensus=0;
313 for(
unsigned int isamp = 0; isamp<max_samp; isamp++) {
314 if(isamp < sizenew) {
315 gain_new = (iEB->second)[isamp].
gainId();
316 adc_new = (iEB->second)[isamp].
adc();
320 if(isamp < sizeold) {
321 gain_old = EB_old[isamp].gainId();
322 adc_old = EB_old[isamp].adc();
326 const std::vector<float> pedeStals =
GetPedestals(ES,currentID);
327 const std::vector<float> gainRatios =
GetGainRatios(ES,currentID);
329 if(adc_new>0 && adc_old>0) {
330 if(gain_old == gain_new) {
331 gain_consensus = gain_old;
336 if(gain_old < gain_new) {
339 float ratio = gainRatios[gain_new-1]/gainRatios[gain_old-1];
340 adc_old = (int) round ((adc_old - pedeStals[gain_old-1]) / ratio + pedeStals[gain_new-1] );
341 gain_consensus = gain_new;
344 float ratio = gainRatios[gain_old-1]/gainRatios[gain_new-1];
345 adc_new = (int) round ( (adc_new - pedeStals[gain_new-1]) / ratio+ pedeStals[gain_old-1] );
346 gain_consensus = gain_old;
353 adc_sum = adc_new + adc_old - (int) round (pedeStals[gain_consensus-1]);
358 if (gain_consensus<3){
360 double ratio = gainRatios[gain_consensus]/gainRatios[gain_consensus-1];
361 adc_sum = (int) round ((adc_sum - pedeStals[gain_consensus-1])/ ratio + pedeStals[gain_consensus] ) ;
362 sw_gain_consensus=++gain_consensus;
370 if (gain_consensus<sw_gain_consensus){
372 double ratio = gainRatios[sw_gain_consensus-1]/gainRatios[gain_consensus-1];
373 adc_sum = (int) round((adc_sum - pedeStals[gain_consensus-1] )/ratio + pedeStals[sw_gain_consensus-1]);
374 gain_consensus = sw_gain_consensus;
385 EBdigis->push_back( formerID, EB_old.
frame().
begin() );
388 formerID = currentID;
389 EB_old = iEB->second;
396 EBdigis->push_back( currentID, (iEB->second).frame().begin()) ;
405 EEDigiMap::const_iterator iEEchk;
410 currentID = iEE->first;
412 if (currentID == formerID) {
415 unsigned int sizenew = (iEE->second).
size();
416 unsigned int sizeold = EE_old.
size();
418 unsigned int max_samp =
std::max(sizenew, sizeold);
424 for(
unsigned int isamp = 0; isamp<max_samp; isamp++) {
425 if(isamp < sizenew) {
426 gain_new = (iEE->second)[isamp].
gainId();
427 adc_new = (iEE->second)[isamp].
adc();
431 if(isamp < sizeold) {
432 gain_old = EE_old[isamp].gainId();
433 adc_old = EE_old[isamp].adc();
437 const std::vector<float> pedeStals =
GetPedestals(ES,currentID);
438 const std::vector<float> gainRatios =
GetGainRatios(ES,currentID);
440 if(adc_new>0 && adc_old>0) {
441 if(gain_old == gain_new) {
442 gain_consensus = gain_old;
446 if(gain_old < gain_new) {
449 float ratio = gainRatios[gain_new-1]/gainRatios[gain_old-1];
450 adc_old = (int) round ((adc_old - pedeStals[gain_old-1]) / ratio + pedeStals[gain_new-1] );
451 gain_consensus = gain_new;
454 float ratio = gainRatios[gain_old-1]/gainRatios[gain_new-1];
455 adc_new = (int) round ( (adc_new - pedeStals[gain_new-1]) / ratio+ pedeStals[gain_old-1] );
456 gain_consensus = gain_old;
464 adc_sum = adc_new + adc_old;
468 if (gain_consensus<3){
470 double ratio = gainRatios[gain_consensus]/gainRatios[gain_consensus-1];
471 adc_sum = (int) round ((adc_sum - pedeStals[gain_consensus-1])/ ratio + pedeStals[gain_consensus] ) ;
485 EEdigis->push_back(formerID, EE_old.
frame().
begin() );
489 formerID = currentID;
490 EE_old = iEE->second;
495 EEdigis->push_back(currentID, (iEE->second).frame().begin());
505 ESDigiMap::const_iterator iESchk;
510 currentID = iES->first;
512 if (currentID == formerID) {
515 unsigned int sizenew = (iES->second).
size();
516 unsigned int sizeold = ES_old.
size();
518 unsigned int max_samp =
std::max(sizenew, sizeold);
524 for(
unsigned int isamp = 0; isamp<max_samp; isamp++) {
525 if(isamp < sizenew) {
526 adc_new = (iES->second)[isamp].
adc();
527 rawdat = (iES->second)[isamp].raw();
531 if(isamp < sizeold) {
532 adc_old = ES_old[isamp].adc();
533 rawdat = ES_old[isamp].raw();
538 adc_sum = adc_new + adc_old;
541 data = adc_sum+(rawdat&0xF000);
548 ESdigis->push_back(ES_old);
551 formerID = currentID;
552 ES_old = iES->second;
557 ESdigis->push_back(iES->second);
569 LogInfo(
"DataMixingEMDigiWorker") <<
"total # EB Merged digis: " << EBdigis->size() ;
570 LogInfo(
"DataMixingEMDigiWorker") <<
"total # EE Merged digis: " << EEdigis->size() ;
571 LogInfo(
"DataMixingEMDigiWorker") <<
"total # ES Merged digis: " << ESdigis->size() ;
586 std::vector<float> pedeStals(3);
598 pedIter = pedMap.
find(detid);
599 if( pedIter != pedMap.
end() ) {
601 pedeStals[0] = aped.mean_x12;
602 pedeStals[1] = aped.mean_x6;
603 pedeStals[2] = aped.mean_x1;
605 edm::LogError(
"DataMixingMissingInput") <<
"Cannot find pedestals";
617 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_