36 DataMixingEMDigiWorker::DataMixingEMDigiWorker() { }
40 label_(ps.getParameter<std::
string>(
"Label"))
81 LogInfo(
"DataMixingEMDigiWorker")<<
"===============> adding MC signals for "<<e.
id();
91 LogDebug(
"DataMixingEMDigiWorker") <<
"total # EB digis: " << EBDigis->
size();
100 it != EBDigis->
end(); ++it) {
121 LogDebug(
"DataMixingEMDigiWorker") <<
"total # EE digis: " << EEDigis->
size();
129 it != EEDigis->
end(); ++it) {
151 LogDebug(
"DataMixingEMDigiWorker") <<
"total # ES digis: " << ESDigis->
size();
161 it != ESDigis->
end(); ++it) {
180 LogInfo(
"DataMixingEMDigiWorker") <<
"\n===============> adding pileups from event "<<ep->
id()<<
" for bunchcrossing "<<bcr;
186 boost::shared_ptr<Wrapper<EBDigiCollection>
const> EBDigisPTR =
193 LogDebug(
"DataMixingEMDigiWorker") <<
"total # EB digis: " << EBDigis->
size();
197 it != EBDigis->
end(); ++it) {
212 boost::shared_ptr<Wrapper<EEDigiCollection>
const> EEDigisPTR =
219 LogDebug(
"DataMixingEMDigiWorker") <<
"total # EE digis: " << EEDigis->
size();
222 it != EEDigis->
end(); ++it) {
236 boost::shared_ptr<Wrapper<ESDigiCollection>
const> ESDigisPTR =
243 LogDebug(
"DataMixingEMDigiWorker") <<
"total # ES digis: " << ESDigis->
size();
246 it != ESDigis->
end(); ++it) {
279 int gain_consensus = 0;
287 EBDigiMap::const_iterator iEBchk;
294 currentID = iEB->first;
296 if (currentID == formerID) {
308 unsigned int sizenew = (iEB->second).
size();
309 unsigned int sizeold = EB_old.
size();
311 unsigned int max_samp =
std::max(sizenew, sizeold);
317 int sw_gain_consensus=0;
320 for(
unsigned int isamp = 0; isamp<max_samp; isamp++) {
321 if(isamp < sizenew) {
322 gain_new = (iEB->second)[isamp].
gainId();
323 adc_new = (iEB->second)[isamp].
adc();
327 if(isamp < sizeold) {
328 gain_old = EB_old[isamp].gainId();
329 adc_old = EB_old[isamp].adc();
333 const std::vector<float> pedeStals =
GetPedestals(ES,currentID);
334 const std::vector<float> gainRatios =
GetGainRatios(ES,currentID);
336 if(adc_new>0 && adc_old>0) {
337 if(gain_old == gain_new) {
338 gain_consensus = gain_old;
343 if(gain_old < gain_new) {
346 float ratio = gainRatios[gain_new-1]/gainRatios[gain_old-1];
347 adc_old = (int) round ((adc_old - pedeStals[gain_old-1]) / ratio + pedeStals[gain_new-1] );
348 gain_consensus = gain_new;
351 float ratio = gainRatios[gain_old-1]/gainRatios[gain_new-1];
352 adc_new = (int) round ( (adc_new - pedeStals[gain_new-1]) / ratio+ pedeStals[gain_old-1] );
353 gain_consensus = gain_old;
360 adc_sum = adc_new + adc_old - (int) round (pedeStals[gain_consensus-1]);
365 if (gain_consensus<3){
367 double ratio = gainRatios[gain_consensus]/gainRatios[gain_consensus-1];
368 adc_sum = (int) round ((adc_sum - pedeStals[gain_consensus-1])/ ratio + pedeStals[gain_consensus] ) ;
369 sw_gain_consensus=++gain_consensus;
377 if (gain_consensus<sw_gain_consensus){
379 double ratio = gainRatios[sw_gain_consensus-1]/gainRatios[gain_consensus-1];
380 adc_sum = (int) round((adc_sum - pedeStals[gain_consensus-1] )/ratio + pedeStals[sw_gain_consensus-1]);
381 gain_consensus = sw_gain_consensus;
392 EBdigis->push_back( formerID, EB_old.
frame().
begin() );
395 formerID = currentID;
396 EB_old = iEB->second;
403 EBdigis->push_back( currentID, (iEB->second).frame().begin()) ;
412 EEDigiMap::const_iterator iEEchk;
417 currentID = iEE->first;
419 if (currentID == formerID) {
422 unsigned int sizenew = (iEE->second).
size();
423 unsigned int sizeold = EE_old.
size();
425 unsigned int max_samp =
std::max(sizenew, sizeold);
431 for(
unsigned int isamp = 0; isamp<max_samp; isamp++) {
432 if(isamp < sizenew) {
433 gain_new = (iEE->second)[isamp].
gainId();
434 adc_new = (iEE->second)[isamp].
adc();
438 if(isamp < sizeold) {
439 gain_old = EE_old[isamp].gainId();
440 adc_old = EE_old[isamp].adc();
444 const std::vector<float> pedeStals =
GetPedestals(ES,currentID);
445 const std::vector<float> gainRatios =
GetGainRatios(ES,currentID);
447 if(adc_new>0 && adc_old>0) {
448 if(gain_old == gain_new) {
449 gain_consensus = gain_old;
453 if(gain_old < gain_new) {
456 float ratio = gainRatios[gain_new-1]/gainRatios[gain_old-1];
457 adc_old = (int) round ((adc_old - pedeStals[gain_old-1]) / ratio + pedeStals[gain_new-1] );
458 gain_consensus = gain_new;
461 float ratio = gainRatios[gain_old-1]/gainRatios[gain_new-1];
462 adc_new = (int) round ( (adc_new - pedeStals[gain_new-1]) / ratio+ pedeStals[gain_old-1] );
463 gain_consensus = gain_old;
471 adc_sum = adc_new + adc_old;
475 if (gain_consensus<3){
477 double ratio = gainRatios[gain_consensus]/gainRatios[gain_consensus-1];
478 adc_sum = (int) round ((adc_sum - pedeStals[gain_consensus-1])/ ratio + pedeStals[gain_consensus] ) ;
492 EEdigis->push_back(formerID, EE_old.
frame().
begin() );
496 formerID = currentID;
497 EE_old = iEE->second;
502 EEdigis->push_back(currentID, (iEE->second).frame().begin());
512 ESDigiMap::const_iterator iESchk;
517 currentID = iES->first;
519 if (currentID == formerID) {
522 unsigned int sizenew = (iES->second).
size();
523 unsigned int sizeold = ES_old.
size();
525 unsigned int max_samp =
std::max(sizenew, sizeold);
531 for(
unsigned int isamp = 0; isamp<max_samp; isamp++) {
532 if(isamp < sizenew) {
533 adc_new = (iES->second)[isamp].
adc();
534 rawdat = (iES->second)[isamp].raw();
538 if(isamp < sizeold) {
539 adc_old = ES_old[isamp].adc();
540 rawdat = ES_old[isamp].raw();
545 adc_sum = adc_new + adc_old;
548 data = adc_sum+(rawdat&0xF000);
555 ESdigis->push_back(ES_old);
558 formerID = currentID;
559 ES_old = iES->second;
564 ESdigis->push_back(iES->second);
576 LogInfo(
"DataMixingEMDigiWorker") <<
"total # EB Merged digis: " << EBdigis->size() ;
577 LogInfo(
"DataMixingEMDigiWorker") <<
"total # EE Merged digis: " << EEdigis->size() ;
578 LogInfo(
"DataMixingEMDigiWorker") <<
"total # ES Merged digis: " << ESdigis->size() ;
593 std::vector<float> pedeStals(3);
605 pedIter = pedMap.
find(detid);
606 if( pedIter != pedMap.
end() ) {
612 edm::LogError(
"DataMixingMissingInput") <<
"Cannot find pedestals";
624 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
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_
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_
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.
edm::InputTag EEProducerSig_
Container::value_type value_type
void setSample(int i, const ESSample &sam)
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::EDGetTokenT< EBDigiCollection > EBDigiToken_
edm::EDGetTokenT< ESDigiCollection > ESDigiToken_
edm::InputTag EBPileInputTag_
edm::EDGetTokenT< EEDigiCollection > EEDigiToken_
edm::EDGetTokenT< EBDigiCollection > EBDigiPileToken_