CMS 3D CMS Logo

List of all members | Public Member Functions | Private Types | Private Member Functions | Private Attributes
edm::DataMixingEMDigiWorker Class Reference

#include <DataMixingEMDigiWorker.h>

Public Member Functions

void addEMPileups (const int bcr, const edm::EventPrincipal *, unsigned int EventId, const edm::EventSetup &ES, ModuleCallingContext const *)
 
void addEMSignals (const edm::Event &e, const edm::EventSetup &ES)
 
 DataMixingEMDigiWorker ()
 
 DataMixingEMDigiWorker (const edm::ParameterSet &ps, edm::ConsumesCollector &&iC)
 
void putEM (edm::Event &e, const edm::EventSetup &ES)
 
virtual ~DataMixingEMDigiWorker ()
 

Private Types

typedef std::multimap< DetId, EBDataFrameEBDigiMap
 
typedef std::multimap< DetId, EEDataFrameEEDigiMap
 
typedef std::multimap< DetId, ESDataFrameESDigiMap
 

Private Member Functions

const std::vector< float > GetGainRatios (const edm::EventSetup &ES, const DetId &detid)
 retrieve gain ratios for that detid [0]=g12, [1]=g6, [2]=g12 More...
 
const std::vector< float > GetPedestals (const edm::EventSetup &ES, const DetId &detid)
 retrieve pedestals for that detid [0]=g12, [1]=g6, [2]=g12 More...
 

Private Attributes

std::string EBDigiCollectionDM_
 
edm::InputTag EBdigiCollectionSig_
 
edm::EDGetTokenT< EBDigiCollectionEBDigiPileToken_
 
EBDigiMap EBDigiStorage_
 
edm::EDGetTokenT< EBDigiCollectionEBDigiToken_
 
edm::InputTag EBPileInputTag_
 
edm::InputTag EBProducerSig_
 
std::string EEDigiCollectionDM_
 
edm::InputTag EEdigiCollectionSig_
 
edm::EDGetTokenT< EEDigiCollectionEEDigiPileToken_
 
EEDigiMap EEDigiStorage_
 
edm::EDGetTokenT< EEDigiCollectionEEDigiToken_
 
edm::InputTag EEPileInputTag_
 
edm::InputTag EEProducerSig_
 
std::string ESDigiCollectionDM_
 
edm::InputTag ESdigiCollectionSig_
 
edm::EDGetTokenT< ESDigiCollectionESDigiPileToken_
 
ESDigiMap ESDigiStorage_
 
edm::EDGetTokenT< ESDigiCollectionESDigiToken_
 
edm::InputTag ESPileInputTag_
 
edm::InputTag ESProducerSig_
 
std::string label_
 

Detailed Description

Definition at line 40 of file DataMixingEMDigiWorker.h.

Member Typedef Documentation

◆ EBDigiMap

typedef std::multimap<DetId, EBDataFrame> edm::DataMixingEMDigiWorker::EBDigiMap
private

Definition at line 97 of file DataMixingEMDigiWorker.h.

◆ EEDigiMap

typedef std::multimap<DetId, EEDataFrame> edm::DataMixingEMDigiWorker::EEDigiMap
private

Definition at line 98 of file DataMixingEMDigiWorker.h.

◆ ESDigiMap

typedef std::multimap<DetId, ESDataFrame> edm::DataMixingEMDigiWorker::ESDigiMap
private

Definition at line 99 of file DataMixingEMDigiWorker.h.

Constructor & Destructor Documentation

◆ DataMixingEMDigiWorker() [1/2]

DataMixingEMDigiWorker::DataMixingEMDigiWorker ( )

Definition at line 30 of file DataMixingEMDigiWorker.cc.

30 {}

◆ DataMixingEMDigiWorker() [2/2]

DataMixingEMDigiWorker::DataMixingEMDigiWorker ( const edm::ParameterSet ps,
edm::ConsumesCollector &&  iC 
)
explicit

standard constructor

Definition at line 33 of file DataMixingEMDigiWorker.cc.

34  : label_(ps.getParameter<std::string>("Label"))
35 
36  {
37  // get the subdetector names
38  // this->getSubdetectorNames(); //something like this may be useful to
39  // check what we are supposed to do...
40 
41  // declare the products to produce, retrieve
42 
43  EBProducerSig_ = ps.getParameter<edm::InputTag>("EBdigiProducerSig");
44  EEProducerSig_ = ps.getParameter<edm::InputTag>("EEdigiProducerSig");
45  ESProducerSig_ = ps.getParameter<edm::InputTag>("ESdigiProducerSig");
46 
50 
51  EBPileInputTag_ = ps.getParameter<edm::InputTag>("EBPileInputTag");
52  EEPileInputTag_ = ps.getParameter<edm::InputTag>("EEPileInputTag");
53  ESPileInputTag_ = ps.getParameter<edm::InputTag>("ESPileInputTag");
54 
58 
59  EBDigiCollectionDM_ = ps.getParameter<std::string>("EBDigiCollectionDM");
60  EEDigiCollectionDM_ = ps.getParameter<std::string>("EEDigiCollectionDM");
61  ESDigiCollectionDM_ = ps.getParameter<std::string>("ESDigiCollectionDM");
62  }

References EBDigiCollectionDM_, EBDigiPileToken_, EBDigiToken_, EBPileInputTag_, EBProducerSig_, EEDigiCollectionDM_, EEDigiPileToken_, EEDigiToken_, EEPileInputTag_, EEProducerSig_, ESDigiCollectionDM_, ESDigiPileToken_, ESDigiToken_, ESPileInputTag_, ESProducerSig_, edm::ParameterSet::getParameter(), and AlCaHLTBitMon_QueryRunRegistry::string.

◆ ~DataMixingEMDigiWorker()

DataMixingEMDigiWorker::~DataMixingEMDigiWorker ( )
virtual

Default destructor

Definition at line 65 of file DataMixingEMDigiWorker.cc.

65 {}

Member Function Documentation

◆ addEMPileups()

void DataMixingEMDigiWorker::addEMPileups ( const int  bcr,
const edm::EventPrincipal ep,
unsigned int  EventId,
const edm::EventSetup ES,
ModuleCallingContext const *  mcc 
)

Definition at line 149 of file DataMixingEMDigiWorker.cc.

153  {
154  LogInfo("DataMixingEMDigiWorker") << "\n===============> adding pileups from event " << ep->id()
155  << " for bunchcrossing " << bcr;
156 
157  // fill in maps of hits; same code as addSignals, except now applied to the
158  // pileup events
159 
160  // EB first
161 
162  std::shared_ptr<Wrapper<EBDigiCollection> const> EBDigisPTR =
163  getProductByTag<EBDigiCollection>(*ep, EBPileInputTag_, mcc);
164 
165  if (EBDigisPTR) {
166  const EBDigiCollection *EBDigis = const_cast<EBDigiCollection *>(EBDigisPTR->product());
167 
168  LogDebug("DataMixingEMDigiWorker") << "total # EB digis: " << EBDigis->size();
169 
170  // loop over digis, adding these to the existing maps
171  for (EBDigiCollection::const_iterator it = EBDigis->begin(); it != EBDigis->end(); ++it) {
172  EBDigiStorage_.insert(EBDigiMap::value_type((it->id()), *it));
173 
174 #ifdef DEBUG
175  // Commented out because this does not compile anymore
176  // LogDebug("DataMixingEMDigiWorker") << "processed EBDigi with rawId: "
177  // << it->id().rawId() << "\n"
178  // << " digi energy: " << it->energy();
179 #endif
180  }
181  }
182 
183  // EE Next
184 
185  std::shared_ptr<Wrapper<EEDigiCollection> const> EEDigisPTR =
186  getProductByTag<EEDigiCollection>(*ep, EEPileInputTag_, mcc);
187 
188  if (EEDigisPTR) {
189  const EEDigiCollection *EEDigis = const_cast<EEDigiCollection *>(EEDigisPTR->product());
190 
191  LogDebug("DataMixingEMDigiWorker") << "total # EE digis: " << EEDigis->size();
192 
193  for (EEDigiCollection::const_iterator it = EEDigis->begin(); it != EEDigis->end(); ++it) {
194  EEDigiStorage_.insert(EEDigiMap::value_type((it->id()), *it));
195 
196 #ifdef DEBUG
197  // Commented out because this does not compile anymore
198  // LogDebug("DataMixingEMDigiWorker") << "processed EEDigi with rawId: "
199  // << it->id().rawId() << "\n"
200  // << " digi energy: " << it->energy();
201 #endif
202  }
203  }
204  // ES Next
205 
206  std::shared_ptr<Wrapper<ESDigiCollection> const> ESDigisPTR =
207  getProductByTag<ESDigiCollection>(*ep, ESPileInputTag_, mcc);
208 
209  if (ESDigisPTR) {
210  const ESDigiCollection *ESDigis = const_cast<ESDigiCollection *>(ESDigisPTR->product());
211 
212  LogDebug("DataMixingEMDigiWorker") << "total # ES digis: " << ESDigis->size();
213 
214  for (ESDigiCollection::const_iterator it = ESDigis->begin(); it != ESDigis->end(); ++it) {
215  ESDigiStorage_.insert(ESDigiMap::value_type((it->id()), *it));
216 
217 #ifdef DEBUG
218  // Commented out because this does not compile anymore
219  // LogDebug("DataMixingEMDigiWorker") << "processed ESDigi with rawId: "
220  // << it->id().rawId() << "\n"
221  // << " digi energy: " << it->energy();
222 #endif
223  }
224  }
225  }

References edm::DataFrameContainer::begin(), EBDigiStorage_, EBPileInputTag_, EEDigiStorage_, EEPileInputTag_, edm::DataFrameContainer::end(), SiStripBadComponentsDQMServiceTemplate_cfg::ep, ESDigiStorage_, ESPileInputTag_, LogDebug, and edm::DataFrameContainer::size().

Referenced by edm::DataMixingModule::pileWorker().

◆ addEMSignals()

void DataMixingEMDigiWorker::addEMSignals ( const edm::Event e,
const edm::EventSetup ES 
)

Definition at line 67 of file DataMixingEMDigiWorker.cc.

67  {
68  // fill in maps of hits
69 
70  LogInfo("DataMixingEMDigiWorker") << "===============> adding MC signals for " << e.id();
71 
72  // EB first
73 
74  Handle<EBDigiCollection> pEBDigis;
75 
76  const EBDigiCollection *EBDigis = nullptr;
77 
78  if (e.getByToken(EBDigiToken_, pEBDigis)) {
79  EBDigis = pEBDigis.product(); // get a ptr to the product
80  LogDebug("DataMixingEMDigiWorker") << "total # EB digis: " << EBDigis->size();
81  }
82 
83  if (EBDigis) {
84  // loop over digis, storing them in a map so we can add pileup later
85 
86  for (EBDigiCollection::const_iterator it = EBDigis->begin(); it != EBDigis->end(); ++it) {
87  EBDigiStorage_.insert(EBDigiMap::value_type((it->id()), *it));
88 #ifdef DEBUG
89  // Commented out because this does not compile anymore
90  // LogDebug("DataMixingEMDigiWorker") << "processed EBDigi with rawId: "
91  // << it->id().rawId() << "\n"
92  // << " digi energy: " << it->energy();
93 #endif
94  }
95  }
96 
97  // EE next
98 
99  Handle<EEDigiCollection> pEEDigis;
100 
101  const EEDigiCollection *EEDigis = nullptr;
102 
103  if (e.getByToken(EEDigiToken_, pEEDigis)) {
104  EEDigis = pEEDigis.product(); // get a ptr to the product
105  LogDebug("DataMixingEMDigiWorker") << "total # EE digis: " << EEDigis->size();
106  }
107 
108  if (EEDigis) {
109  // loop over digis, storing them in a map so we can add pileup later
110  for (EEDigiCollection::const_iterator it = EEDigis->begin(); it != EEDigis->end(); ++it) {
111  EEDigiStorage_.insert(EEDigiMap::value_type((it->id()), *it));
112 #ifdef DEBUG
113  // Commented out because this does not compile anymore
114  // LogDebug("DataMixingEMDigiWorker") << "processed EEDigi with rawId: "
115  // << it->id().rawId() << "\n"
116  // << " digi energy: " << it->energy();
117 #endif
118  }
119  }
120  // ES next
121 
122  Handle<ESDigiCollection> pESDigis;
123 
124  const ESDigiCollection *ESDigis = nullptr;
125 
126  if (e.getByToken(ESDigiToken_, pESDigis)) {
127  ESDigis = pESDigis.product(); // get a ptr to the product
128 #ifdef DEBUG
129  LogDebug("DataMixingEMDigiWorker") << "total # ES digis: " << ESDigis->size();
130 #endif
131  }
132 
133  if (ESDigis) {
134  // loop over digis, storing them in a map so we can add pileup later
135  for (ESDigiCollection::const_iterator it = ESDigis->begin(); it != ESDigis->end(); ++it) {
136  ESDigiStorage_.insert(ESDigiMap::value_type((it->id()), *it));
137 
138 #ifdef DEBUG
139  // Commented out because this does not compile anymore
140  // LogDebug("DataMixingEMDigiWorker") << "processed ESDigi with rawId: "
141  // << it->id().rawId() << "\n"
142  // << " digi energy: " << it->energy();
143 #endif
144  }
145  }
146 
147  } // end of addEMSignals

References edm::DataFrameContainer::begin(), MillePedeFileConverter_cfg::e, EBDigiStorage_, EBDigiToken_, EEDigiStorage_, EEDigiToken_, edm::DataFrameContainer::end(), ESDigiStorage_, ESDigiToken_, LogDebug, edm::Handle< T >::product(), and edm::DataFrameContainer::size().

Referenced by edm::DataMixingModule::addSignals().

◆ GetGainRatios()

const std::vector< float > DataMixingEMDigiWorker::GetGainRatios ( const edm::EventSetup ES,
const DetId detid 
)
private

retrieve gain ratios for that detid [0]=g12, [1]=g6, [2]=g12

Definition at line 556 of file DataMixingEMDigiWorker.cc.

556  {
557  std::vector<float> gainRatios(3);
558  // get gain ratios
560  ES.get<EcalGainRatiosRcd>().get(grHandle);
561  EcalMGPAGainRatio theRatio = (*grHandle)[detid];
562 
563  gainRatios[0] = 1.;
564  gainRatios[1] = theRatio.gain12Over6();
565  gainRatios[2] = theRatio.gain6Over1() * theRatio.gain12Over6();
566 
567  return gainRatios;
568  }

References EcalMGPAGainRatio::gain12Over6(), EcalMGPAGainRatio::gain6Over1(), edm::EventSetup::get(), and edm::get().

Referenced by putEM().

◆ GetPedestals()

const std::vector< float > DataMixingEMDigiWorker::GetPedestals ( const edm::EventSetup ES,
const DetId detid 
)
private

retrieve pedestals for that detid [0]=g12, [1]=g6, [2]=g12

Definition at line 529 of file DataMixingEMDigiWorker.cc.

529  {
530  std::vector<float> pedeStals(3);
531 
532  // get pedestals
534  ES.get<EcalPedestalsRcd>().get(pedHandle);
535 
536  const EcalPedestalsMap &pedMap = pedHandle.product()->getMap(); // map of pedestals
537  EcalPedestalsMapIterator pedIter; // pedestal iterator
538  EcalPedestals::Item aped; // pedestal object for a single xtal
539 
540  pedIter = pedMap.find(detid);
541  if (pedIter != pedMap.end()) {
542  aped = (*pedIter);
543  pedeStals[0] = aped.mean_x12;
544  pedeStals[1] = aped.mean_x6;
545  pedeStals[2] = aped.mean_x1;
546  } else {
547  edm::LogError("DataMixingMissingInput") << "Cannot find pedestals";
548  pedeStals[0] = 0;
549  pedeStals[1] = 0;
550  pedeStals[2] = 0;
551  }
552 
553  return pedeStals;
554  }

References EcalCondObjectContainer< T >::end(), EcalCondObjectContainer< T >::find(), edm::EventSetup::get(), edm::get(), EcalCondObjectContainer< T >::getMap(), and edm::ESHandle< T >::product().

Referenced by putEM().

◆ putEM()

void DataMixingEMDigiWorker::putEM ( edm::Event e,
const edm::EventSetup ES 
)

Definition at line 227 of file DataMixingEMDigiWorker.cc.

227  {
228  // collection of digis to put in the event
229  std::unique_ptr<EBDigiCollection> EBdigis(new EBDigiCollection);
230  std::unique_ptr<EEDigiCollection> EEdigis(new EEDigiCollection);
231  std::unique_ptr<ESDigiCollection> ESdigis(new ESDigiCollection);
232 
233  // loop over the maps we have, re-making individual hits or digis if
234  // necessary.
235  DetId formerID = 0;
236  DetId currentID;
237 
238  EBDataFrame EB_old;
239 
240  int gain_new = 0;
241  int gain_old = 0;
242  int gain_consensus = 0;
243  int adc_new;
244  int adc_old;
245  int adc_sum;
246  uint16_t data;
247 
248  // EB first...
249 
250  EBDigiMap::const_iterator iEBchk;
251 
252  for (EBDigiMap::const_iterator iEB = EBDigiStorage_.begin(); iEB != EBDigiStorage_.end(); iEB++) {
253  currentID = iEB->first;
254 
255  if (currentID == formerID) { // we have to add these digis together
256  /*
257  cout<< " Adding signals " << EBDetId(currentID).ieta() << " "
258  << EBDetId(currentID).iphi() << std::endl;
259 
260  cout << 1 << " " ;
261  for (int i=0; i<10;++i) std::cout << EB_old[i].adc()<<
262  "["<<EB_old[i].gainId()<< "] " ; std::cout << std::endl;
263 
264  cout << 2 << " " ;
265  for (int i=0; i<10;++i) std::cout << (iEB->second)[i].adc()<<
266  "["<<(iEB->second)[i].gainId()<< "] " ; std::cout << std::endl;
267  */
268  // loop over digi samples in each DataFrame
269  unsigned int sizenew = (iEB->second).size();
270  unsigned int sizeold = EB_old.size();
271 
272  unsigned int max_samp = std::max(sizenew, sizeold);
273 
274  // samples from different events can be of different lengths - sum all
275  // that overlap.
276  // check to see if gains match - if not, scale smaller cell down.
277 
278  int sw_gain_consensus = 0;
279 
280  for (unsigned int isamp = 0; isamp < max_samp; isamp++) {
281  if (isamp < sizenew) {
282  gain_new = (iEB->second)[isamp].gainId();
283  adc_new = (iEB->second)[isamp].adc();
284  } else {
285  adc_new = 0;
286  }
287 
288  if (isamp < sizeold) {
289  gain_old = EB_old[isamp].gainId();
290  adc_old = EB_old[isamp].adc();
291  } else {
292  adc_old = 0;
293  }
294 
295  const std::vector<float> pedeStals = GetPedestals(ES, currentID);
296  const std::vector<float> gainRatios = GetGainRatios(ES, currentID);
297 
298  if (adc_new > 0 && adc_old > 0) {
299  if (gain_old == gain_new) { // we're happy - easy case
300  gain_consensus = gain_old;
301  } else { // lower gain sample has more energy
302 
303  if (gain_old < gain_new) { // old has higher gain than new, scale to lower gain
304 
305  float ratio = gainRatios[gain_new - 1] / gainRatios[gain_old - 1];
306  adc_old = (int)round((adc_old - pedeStals[gain_old - 1]) / ratio + pedeStals[gain_new - 1]);
307  gain_consensus = gain_new;
308  } else { // scale to old (lower) gain
309  float ratio = gainRatios[gain_old - 1] / gainRatios[gain_new - 1];
310  adc_new = (int)round((adc_new - pedeStals[gain_new - 1]) / ratio + pedeStals[gain_old - 1]);
311  gain_consensus = gain_old;
312  }
313  }
314  }
315 
316  // add values, but don't count pedestals twice
317  adc_sum = adc_new + adc_old - (int)round(pedeStals[gain_consensus - 1]);
318 
319  // if we are now saturating that gain, switch to the next
320  if (adc_sum > 4096) {
321  if (gain_consensus < 3) {
322  double ratio = gainRatios[gain_consensus] / gainRatios[gain_consensus - 1];
323  adc_sum = (int)round((adc_sum - pedeStals[gain_consensus - 1]) / ratio + pedeStals[gain_consensus]);
324  sw_gain_consensus = ++gain_consensus;
325  } else
326  adc_sum = 4096;
327  }
328 
329  // furthermore, make sure we don't decrease our gain once we've switched
330  // up in case go back
331  if (gain_consensus < sw_gain_consensus) {
332  double ratio = gainRatios[sw_gain_consensus - 1] / gainRatios[gain_consensus - 1];
333  adc_sum = (int)round((adc_sum - pedeStals[gain_consensus - 1]) / ratio + pedeStals[sw_gain_consensus - 1]);
334  gain_consensus = sw_gain_consensus;
335  }
336 
337  EcalMGPASample sample(adc_sum, gain_consensus);
338  EB_old.setSample(isamp,
339  sample); // overwrite old sample, adding new info
340  } // for sample
341 
342  } // if current = former
343  else {
344  if (formerID > 0) {
345  EBdigis->push_back(formerID, EB_old.frame().begin());
346  }
347  // save pointers for next iteration
348  formerID = currentID;
349  EB_old = iEB->second;
350  }
351 
352  iEBchk = iEB;
353  if ((++iEBchk) == EBDigiStorage_.end()) { // make sure not to lose the last one
354  EBdigis->push_back(currentID, (iEB->second).frame().begin());
355  }
356  }
357 
358  // EE next...
359 
360  formerID = 0;
361  EEDataFrame EE_old;
362 
363  EEDigiMap::const_iterator iEEchk;
364 
365  for (EEDigiMap::const_iterator iEE = EEDigiStorage_.begin(); iEE != EEDigiStorage_.end(); iEE++) {
366  currentID = iEE->first;
367 
368  if (currentID == formerID) { // we have to add these digis together
369 
370  // loop over digi samples in each DataFrame
371  unsigned int sizenew = (iEE->second).size();
372  unsigned int sizeold = EE_old.size();
373 
374  unsigned int max_samp = std::max(sizenew, sizeold);
375 
376  // samples from different events can be of different lengths - sum all
377  // that overlap.
378  // check to see if gains match - if not, scale smaller cell down.
379 
380  for (unsigned int isamp = 0; isamp < max_samp; isamp++) {
381  if (isamp < sizenew) {
382  gain_new = (iEE->second)[isamp].gainId();
383  adc_new = (iEE->second)[isamp].adc();
384  } else {
385  adc_new = 0;
386  }
387 
388  if (isamp < sizeold) {
389  gain_old = EE_old[isamp].gainId();
390  adc_old = EE_old[isamp].adc();
391  } else {
392  adc_old = 0;
393  }
394 
395  const std::vector<float> pedeStals = GetPedestals(ES, currentID);
396  const std::vector<float> gainRatios = GetGainRatios(ES, currentID);
397 
398  if (adc_new > 0 && adc_old > 0) {
399  if (gain_old == gain_new) { // we're happy - easy case
400  gain_consensus = gain_old;
401  } else { // lower gain sample has more energy
402 
403  if (gain_old < gain_new) { // old has higher gain than new, scale to lower gain
404 
405  float ratio = gainRatios[gain_new - 1] / gainRatios[gain_old - 1];
406  adc_old = (int)round((adc_old - pedeStals[gain_old - 1]) / ratio + pedeStals[gain_new - 1]);
407  gain_consensus = gain_new;
408  } else { // scale to old (lower) gain
409  float ratio = gainRatios[gain_old - 1] / gainRatios[gain_new - 1];
410  adc_new = (int)round((adc_new - pedeStals[gain_new - 1]) / ratio + pedeStals[gain_old - 1]);
411  gain_consensus = gain_old;
412  }
413  }
414  }
415 
416  // add values, but don't count pedestals twice
417  adc_sum = adc_new + adc_old - (int)round(pedeStals[gain_consensus - 1]);
418 
419  // if the sum saturates this gain, switch
420  if (adc_sum > 4096) {
421  if (gain_consensus < 3) {
422  double ratio = gainRatios[gain_consensus] / gainRatios[gain_consensus - 1];
423  adc_sum = (int)round((adc_sum - pedeStals[gain_consensus - 1]) / ratio + pedeStals[gain_consensus]);
424  ++gain_consensus;
425  } else
426  adc_sum = 4096;
427  }
428 
429  EcalMGPASample sample(adc_sum, gain_consensus);
430  EE_old.setSample(isamp, sample);
431  }
432 
433  } else {
434  if (formerID > 0) {
435  EEdigis->push_back(formerID, EE_old.frame().begin());
436  }
437  // save pointers for next iteration
438  formerID = currentID;
439  EE_old = iEE->second;
440  }
441 
442  iEEchk = iEE;
443  if ((++iEEchk) == EEDigiStorage_.end()) { // make sure not to lose the last one
444  EEdigis->push_back(currentID, (iEE->second).frame().begin());
445  }
446  }
447 
448  // ES next...
449 
450  formerID = 0;
451  ESDataFrame ES_old;
452 
453  ESDigiMap::const_iterator iESchk;
454 
455  for (ESDigiMap::const_iterator iES = ESDigiStorage_.begin(); iES != ESDigiStorage_.end(); iES++) {
456  currentID = iES->first;
457 
458  if (currentID == formerID) { // we have to add these digis together
459 
460  // loop over digi samples in each DataFrame
461  unsigned int sizenew = (iES->second).size();
462  unsigned int sizeold = ES_old.size();
463  uint16_t rawdat = 0;
464  unsigned int max_samp = std::max(sizenew, sizeold);
465 
466  // samples from different events can be of different lengths - sum all
467  // that overlap.
468  // check to see if gains match - if not, scale smaller cell down.
469 
470  for (unsigned int isamp = 0; isamp < max_samp; isamp++) {
471  if (isamp < sizenew) {
472  adc_new = (iES->second)[isamp].adc();
473  rawdat = (iES->second)[isamp].raw();
474  } else {
475  adc_new = 0;
476  }
477 
478  if (isamp < sizeold) {
479  adc_old = ES_old[isamp].adc();
480  rawdat = ES_old[isamp].raw();
481  } else {
482  adc_old = 0;
483  }
484 
485  // add values
486  adc_sum = adc_new + adc_old;
487  // make data word of gain, rawdata
488  adc_sum = std::min(adc_sum, 4095); // first 12 bits of (uint)
489  data = adc_sum + (rawdat & 0xF000); // data is 14 bit word with gain as MSBs
490  ES_old.setSample(isamp, data);
491  }
492 
493  } else {
494  if (formerID > 0) {
495  ESdigis->push_back(ES_old);
496  }
497  // save pointers for next iteration
498  formerID = currentID;
499  ES_old = iES->second;
500  }
501 
502  iESchk = iES;
503  if ((++iESchk) == ESDigiStorage_.end()) { // make sure not to lose the last one
504  ESdigis->push_back(iES->second);
505  // ESDataFrame df( (*ESdigis)->back() );
506  // for(int isamp=0; isamp<(iES->second).size(); isamp++) {
507  // df.setSample(isamp,(iES->second).data[isamp]);
508  // }
509  }
510  }
511 
512  // done merging
513 
514  // put the collection of reconstructed hits in the event
515  LogInfo("DataMixingEMDigiWorker") << "total # EB Merged digis: " << EBdigis->size();
516  LogInfo("DataMixingEMDigiWorker") << "total # EE Merged digis: " << EEdigis->size();
517  LogInfo("DataMixingEMDigiWorker") << "total # ES Merged digis: " << ESdigis->size();
518 
519  e.put(std::move(EBdigis), EBDigiCollectionDM_);
520  e.put(std::move(EEdigis), EEDigiCollectionDM_);
521  e.put(std::move(ESdigis), ESDigiCollectionDM_);
522 
523  // clear local storage after this event
524 
525  EBDigiStorage_.clear();
526  EEDigiStorage_.clear();
527  ESDigiStorage_.clear();
528  }

References ecalLiteDTU::adc(), edm::DataFrame::begin(), data, MillePedeFileConverter_cfg::e, EBDigiCollectionDM_, EBDigiStorage_, EEDigiCollectionDM_, EEDigiStorage_, ESDigiCollectionDM_, ESDigiStorage_, EcalDataFrame::frame(), ecalLiteDTU::gainId(), GetGainRatios(), GetPedestals(), createfilelist::int, SiStripPI::max, min(), eostools::move(), particleFlowDisplacedVertex_cfi::ratio, simplePhotonAnalyzer_cfi::sample, ESDataFrame::setSample(), EcalDataFrame::setSample(), ESDataFrame::size(), EcalDataFrame::size(), and findQualityFiles::size.

Referenced by edm::DataMixingModule::put().

Member Data Documentation

◆ EBDigiCollectionDM_

std::string edm::DataMixingEMDigiWorker::EBDigiCollectionDM_
private

Definition at line 90 of file DataMixingEMDigiWorker.h.

Referenced by DataMixingEMDigiWorker(), and putEM().

◆ EBdigiCollectionSig_

edm::InputTag edm::DataMixingEMDigiWorker::EBdigiCollectionSig_
private

Definition at line 71 of file DataMixingEMDigiWorker.h.

◆ EBDigiPileToken_

edm::EDGetTokenT<EBDigiCollection> edm::DataMixingEMDigiWorker::EBDigiPileToken_
private

Definition at line 86 of file DataMixingEMDigiWorker.h.

Referenced by DataMixingEMDigiWorker().

◆ EBDigiStorage_

EBDigiMap edm::DataMixingEMDigiWorker::EBDigiStorage_
private

Definition at line 101 of file DataMixingEMDigiWorker.h.

Referenced by addEMPileups(), addEMSignals(), and putEM().

◆ EBDigiToken_

edm::EDGetTokenT<EBDigiCollection> edm::DataMixingEMDigiWorker::EBDigiToken_
private

Definition at line 82 of file DataMixingEMDigiWorker.h.

Referenced by addEMSignals(), and DataMixingEMDigiWorker().

◆ EBPileInputTag_

edm::InputTag edm::DataMixingEMDigiWorker::EBPileInputTag_
private

Definition at line 78 of file DataMixingEMDigiWorker.h.

Referenced by addEMPileups(), and DataMixingEMDigiWorker().

◆ EBProducerSig_

edm::InputTag edm::DataMixingEMDigiWorker::EBProducerSig_
private

Definition at line 67 of file DataMixingEMDigiWorker.h.

Referenced by DataMixingEMDigiWorker().

◆ EEDigiCollectionDM_

std::string edm::DataMixingEMDigiWorker::EEDigiCollectionDM_
private

Definition at line 92 of file DataMixingEMDigiWorker.h.

Referenced by DataMixingEMDigiWorker(), and putEM().

◆ EEdigiCollectionSig_

edm::InputTag edm::DataMixingEMDigiWorker::EEdigiCollectionSig_
private

Definition at line 73 of file DataMixingEMDigiWorker.h.

◆ EEDigiPileToken_

edm::EDGetTokenT<EEDigiCollection> edm::DataMixingEMDigiWorker::EEDigiPileToken_
private

Definition at line 87 of file DataMixingEMDigiWorker.h.

Referenced by DataMixingEMDigiWorker().

◆ EEDigiStorage_

EEDigiMap edm::DataMixingEMDigiWorker::EEDigiStorage_
private

Definition at line 102 of file DataMixingEMDigiWorker.h.

Referenced by addEMPileups(), addEMSignals(), and putEM().

◆ EEDigiToken_

edm::EDGetTokenT<EEDigiCollection> edm::DataMixingEMDigiWorker::EEDigiToken_
private

Definition at line 83 of file DataMixingEMDigiWorker.h.

Referenced by addEMSignals(), and DataMixingEMDigiWorker().

◆ EEPileInputTag_

edm::InputTag edm::DataMixingEMDigiWorker::EEPileInputTag_
private

Definition at line 79 of file DataMixingEMDigiWorker.h.

Referenced by addEMPileups(), and DataMixingEMDigiWorker().

◆ EEProducerSig_

edm::InputTag edm::DataMixingEMDigiWorker::EEProducerSig_
private

Definition at line 68 of file DataMixingEMDigiWorker.h.

Referenced by DataMixingEMDigiWorker().

◆ ESDigiCollectionDM_

std::string edm::DataMixingEMDigiWorker::ESDigiCollectionDM_
private

Definition at line 94 of file DataMixingEMDigiWorker.h.

Referenced by DataMixingEMDigiWorker(), and putEM().

◆ ESdigiCollectionSig_

edm::InputTag edm::DataMixingEMDigiWorker::ESdigiCollectionSig_
private

Definition at line 75 of file DataMixingEMDigiWorker.h.

◆ ESDigiPileToken_

edm::EDGetTokenT<ESDigiCollection> edm::DataMixingEMDigiWorker::ESDigiPileToken_
private

Definition at line 88 of file DataMixingEMDigiWorker.h.

Referenced by DataMixingEMDigiWorker().

◆ ESDigiStorage_

ESDigiMap edm::DataMixingEMDigiWorker::ESDigiStorage_
private

Definition at line 103 of file DataMixingEMDigiWorker.h.

Referenced by addEMPileups(), addEMSignals(), and putEM().

◆ ESDigiToken_

edm::EDGetTokenT<ESDigiCollection> edm::DataMixingEMDigiWorker::ESDigiToken_
private

Definition at line 84 of file DataMixingEMDigiWorker.h.

Referenced by addEMSignals(), and DataMixingEMDigiWorker().

◆ ESPileInputTag_

edm::InputTag edm::DataMixingEMDigiWorker::ESPileInputTag_
private

Definition at line 80 of file DataMixingEMDigiWorker.h.

Referenced by addEMPileups(), and DataMixingEMDigiWorker().

◆ ESProducerSig_

edm::InputTag edm::DataMixingEMDigiWorker::ESProducerSig_
private

Definition at line 69 of file DataMixingEMDigiWorker.h.

Referenced by DataMixingEMDigiWorker().

◆ label_

std::string edm::DataMixingEMDigiWorker::label_
private
EcalCondObjectContainer::getMap
const self & getMap() const
Definition: EcalCondObjectContainer.h:80
edm::DataMixingEMDigiWorker::EBPileInputTag_
edm::InputTag EBPileInputTag_
Definition: DataMixingEMDigiWorker.h:78
edm::ESHandle::product
T const * product() const
Definition: ESHandle.h:86
EcalCondObjectContainer::end
const_iterator end() const
Definition: EcalCondObjectContainer.h:76
ecalLiteDTU::gainId
constexpr int gainId(sample_type sample)
get the gainId (2 bits)
Definition: EcalLiteDTUSample.h:14
edm::DataMixingEMDigiWorker::ESDigiCollectionDM_
std::string ESDigiCollectionDM_
Definition: DataMixingEMDigiWorker.h:94
edm::DataMixingEMDigiWorker::EEDigiStorage_
EEDigiMap EEDigiStorage_
Definition: DataMixingEMDigiWorker.h:102
EcalDataFrame::frame
edm::DataFrame const & frame() const
Definition: EcalDataFrame.h:50
edm::DataMixingEMDigiWorker::EEDigiPileToken_
edm::EDGetTokenT< EEDigiCollection > EEDigiPileToken_
Definition: DataMixingEMDigiWorker.h:87
edm::DataMixingEMDigiWorker::GetPedestals
const std::vector< float > GetPedestals(const edm::EventSetup &ES, const DetId &detid)
retrieve pedestals for that detid [0]=g12, [1]=g6, [2]=g12
Definition: DataMixingEMDigiWorker.cc:529
edm::DataFrameContainer::const_iterator
boost::transform_iterator< IterHelp, boost::counting_iterator< int > > const_iterator
Definition: DataFrameContainer.h:61
simplePhotonAnalyzer_cfi.sample
sample
Definition: simplePhotonAnalyzer_cfi.py:12
edm::DataMixingEMDigiWorker::EBDigiStorage_
EBDigiMap EBDigiStorage_
Definition: DataMixingEMDigiWorker.h:101
min
T min(T a, T b)
Definition: MathUtil.h:58
edm::DataMixingEMDigiWorker::EBDigiPileToken_
edm::EDGetTokenT< EBDigiCollection > EBDigiPileToken_
Definition: DataMixingEMDigiWorker.h:86
edm::DataMixingEMDigiWorker::GetGainRatios
const std::vector< float > GetGainRatios(const edm::EventSetup &ES, const DetId &detid)
retrieve gain ratios for that detid [0]=g12, [1]=g6, [2]=g12
Definition: DataMixingEMDigiWorker.cc:556
EBDataFrame
Definition: EBDataFrame.h:11
edm::DataMixingEMDigiWorker::EEPileInputTag_
edm::InputTag EEPileInputTag_
Definition: DataMixingEMDigiWorker.h:79
ESDataFrame::size
int size() const
Definition: ESDataFrame.h:21
edm::DataMixingEMDigiWorker::ESDigiPileToken_
edm::EDGetTokenT< ESDigiCollection > ESDigiPileToken_
Definition: DataMixingEMDigiWorker.h:88
edm::DataMixingEMDigiWorker::EEDigiCollectionDM_
std::string EEDigiCollectionDM_
Definition: DataMixingEMDigiWorker.h:92
edm::LogInfo
Log< level::Info, false > LogInfo
Definition: MessageLogger.h:125
EcalCondObjectContainer
Definition: EcalCondObjectContainer.h:13
edm::DataMixingEMDigiWorker::EBDigiCollectionDM_
std::string EBDigiCollectionDM_
Definition: DataMixingEMDigiWorker.h:90
ESDataFrame
Definition: ESDataFrame.h:10
ecalLiteDTU::adc
constexpr int adc(sample_type sample)
get the ADC sample (12 bits)
Definition: EcalLiteDTUSample.h:12
DetId
Definition: DetId.h:17
edm::EventSetup::get
T get() const
Definition: EventSetup.h:80
edm::ESHandle
Definition: DTSurvey.h:22
edm::DataMixingEMDigiWorker::EBProducerSig_
edm::InputTag EBProducerSig_
Definition: DataMixingEMDigiWorker.h:67
edm::ConsumesCollector::consumes
EDGetTokenT< ProductType > consumes(edm::InputTag const &tag)
Definition: ConsumesCollector.h:55
EcalCondObjectContainer::find
const_iterator find(uint32_t rawId) const
Definition: EcalCondObjectContainer.h:53
edm::DataMixingEMDigiWorker::label_
std::string label_
Definition: DataMixingEMDigiWorker.h:107
edm::DataMixingEMDigiWorker::ESDigiStorage_
ESDigiMap ESDigiStorage_
Definition: DataMixingEMDigiWorker.h:103
EcalMGPAGainRatio::gain12Over6
float gain12Over6() const
Definition: EcalMGPAGainRatio.h:19
particleFlowDisplacedVertex_cfi.ratio
ratio
Definition: particleFlowDisplacedVertex_cfi.py:93
EcalGainRatiosRcd
Definition: EcalGainRatiosRcd.h:5
ESDigiCollection
Definition: EcalDigiCollections.h:82
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
ESDataFrame::setSample
void setSample(int i, const ESSample &sam)
Definition: ESDataFrame.h:28
LogDebug
#define LogDebug(id)
Definition: MessageLogger.h:223
SiStripPI::max
Definition: SiStripPayloadInspectorHelper.h:169
EcalCondObjectContainer::Item
T Item
Definition: EcalCondObjectContainer.h:15
EBDigiCollection
Definition: EcalDigiCollections.h:56
EEDigiCollection
Definition: EcalDigiCollections.h:69
edm::get
T const & get(Event const &event, InputTag const &tag) noexcept(false)
Definition: Event.h:671
EcalPedestalsMapIterator
EcalPedestalsMap::const_iterator EcalPedestalsMapIterator
Definition: EcalPedestals.h:49
edm::DataMixingEMDigiWorker::EEProducerSig_
edm::InputTag EEProducerSig_
Definition: DataMixingEMDigiWorker.h:68
createfilelist.int
int
Definition: createfilelist.py:10
edm::DataFrameContainer::begin
const_iterator begin() const
The iterator returned can not safely be used across threads.
Definition: DataFrameContainer.h:149
reco::JetExtendedAssociation::value_type
Container::value_type value_type
Definition: JetExtendedAssociation.h:30
edm::LogError
Log< level::Error, false > LogError
Definition: MessageLogger.h:123
EcalMGPASample
Definition: EcalMGPASample.h:22
eostools.move
def move(src, dest)
Definition: eostools.py:511
edm::DataMixingEMDigiWorker::ESPileInputTag_
edm::InputTag ESPileInputTag_
Definition: DataMixingEMDigiWorker.h:80
EcalMGPAGainRatio::gain6Over1
float gain6Over1() const
Definition: EcalMGPAGainRatio.h:20
edm::DataMixingEMDigiWorker::ESDigiToken_
edm::EDGetTokenT< ESDigiCollection > ESDigiToken_
Definition: DataMixingEMDigiWorker.h:84
edm::DataMixingEMDigiWorker::EEDigiToken_
edm::EDGetTokenT< EEDigiCollection > EEDigiToken_
Definition: DataMixingEMDigiWorker.h:83
edm::ParameterSet::getParameter
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
data
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:79
EcalDataFrame::size
int size() const
Definition: EcalDataFrame.h:26
EcalPedestalsRcd
Definition: EcalPedestalsRcd.h:5
edm::DataMixingEMDigiWorker::EBDigiToken_
edm::EDGetTokenT< EBDigiCollection > EBDigiToken_
Definition: DataMixingEMDigiWorker.h:82
EEDataFrame
Definition: EEDataFrame.h:12
edm::DataMixingEMDigiWorker::ESProducerSig_
edm::InputTag ESProducerSig_
Definition: DataMixingEMDigiWorker.h:69
EcalDataFrame::setSample
void setSample(int i, EcalMGPASample sam)
Definition: EcalDataFrame.h:43
SiStripBadComponentsDQMServiceTemplate_cfg.ep
ep
Definition: SiStripBadComponentsDQMServiceTemplate_cfg.py:86
edm::DataFrameContainer::end
const_iterator end() const
Definition: DataFrameContainer.h:152
edm::InputTag
Definition: InputTag.h:15
edm::DataFrame::begin
constexpr iterator begin()
Definition: DataFrame.h:33
EcalMGPAGainRatio
Definition: EcalMGPAGainRatio.h:13
edm::DataFrameContainer::size
size_type size() const
Definition: DataFrameContainer.h:162
findQualityFiles.size
size
Write out results.
Definition: findQualityFiles.py:443
MillePedeFileConverter_cfg.e
e
Definition: MillePedeFileConverter_cfg.py:37