CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Member Functions | Private Types | Private Attributes
edm::DataMixingHcalDigiWorker Class Reference

#include <DataMixingHcalDigiWorker.h>

Public Member Functions

void addHcalPileups (const int bcr, const edm::EventPrincipal *, unsigned int EventId, const edm::EventSetup &ES)
 
void addHcalSignals (const edm::Event &e, const edm::EventSetup &ES)
 
 DataMixingHcalDigiWorker ()
 
 DataMixingHcalDigiWorker (const edm::ParameterSet &ps)
 
void putHcal (edm::Event &e, const edm::EventSetup &ES)
 
virtual ~DataMixingHcalDigiWorker ()
 

Private Types

typedef std::multimap< DetId,
CaloSamples
HBHEDigiMap
 
typedef std::multimap< DetId,
CaloSamples
HFDigiMap
 
typedef std::multimap< DetId,
CaloSamples
HODigiMap
 
typedef std::multimap< DetId,
CaloSamples
ZDCDigiMap
 

Private Attributes

bool DoZDC_
 
std::string HBHEDigiCollectionDM_
 
edm::InputTag HBHEdigiCollectionSig_
 
HBHEDigiMap HBHEDigiStorage_
 
edm::InputTag HBHEPileInputTag_
 
std::string HFDigiCollectionDM_
 
edm::InputTag HFdigiCollectionSig_
 
HFDigiMap HFDigiStorage_
 
edm::InputTag HFPileInputTag_
 
std::string HODigiCollectionDM_
 
edm::InputTag HOdigiCollectionSig_
 
HODigiMap HODigiStorage_
 
edm::InputTag HOPileInputTag_
 
std::string label_
 
std::string ZDCDigiCollectionDM_
 
edm::InputTag ZDCdigiCollectionSig_
 
ZDCDigiMap ZDCDigiStorage_
 
edm::InputTag ZDCPileInputTag_
 

Detailed Description

Definition at line 38 of file DataMixingHcalDigiWorker.h.

Member Typedef Documentation

Definition at line 74 of file DataMixingHcalDigiWorker.h.

Definition at line 75 of file DataMixingHcalDigiWorker.h.

Definition at line 76 of file DataMixingHcalDigiWorker.h.

Definition at line 77 of file DataMixingHcalDigiWorker.h.

Constructor & Destructor Documentation

DataMixingHcalDigiWorker::DataMixingHcalDigiWorker ( )

Definition at line 34 of file DataMixingHcalDigiWorker.cc.

34 { }
DataMixingHcalDigiWorker::DataMixingHcalDigiWorker ( const edm::ParameterSet ps)
explicit

standard constructor

Definition at line 37 of file DataMixingHcalDigiWorker.cc.

References DoZDC_, edm::ParameterSet::getParameter(), HBHEDigiCollectionDM_, HBHEdigiCollectionSig_, HBHEPileInputTag_, HFDigiCollectionDM_, HFdigiCollectionSig_, HFPileInputTag_, HODigiCollectionDM_, HOdigiCollectionSig_, HOPileInputTag_, edm::InputTag::label(), AlCaHLTBitMon_QueryRunRegistry::string, ZDCDigiCollectionDM_, ZDCdigiCollectionSig_, and ZDCPileInputTag_.

37  :
38  label_(ps.getParameter<std::string>("Label"))
39 
40  {
41 
42  // get the subdetector names
43  // this->getSubdetectorNames(); //something like this may be useful to check what we are supposed to do...
44 
45  // declare the products to produce
46 
47  // Hcal
48 
49  HBHEdigiCollectionSig_ = ps.getParameter<edm::InputTag>("HBHEdigiCollectionSig");
50  HOdigiCollectionSig_ = ps.getParameter<edm::InputTag>("HOdigiCollectionSig");
51  HFdigiCollectionSig_ = ps.getParameter<edm::InputTag>("HFdigiCollectionSig");
52  ZDCdigiCollectionSig_ = ps.getParameter<edm::InputTag>("ZDCdigiCollectionSig");
53 
54  HBHEPileInputTag_ = ps.getParameter<edm::InputTag>("HBHEPileInputTag");
55  HOPileInputTag_ = ps.getParameter<edm::InputTag>("HOPileInputTag");
56  HFPileInputTag_ = ps.getParameter<edm::InputTag>("HFPileInputTag");
57  ZDCPileInputTag_ = ps.getParameter<edm::InputTag>("ZDCPileInputTag");
58 
59  DoZDC_ = false;
60  if(ZDCPileInputTag_.label() != "") DoZDC_ = true;
61 
62  HBHEDigiCollectionDM_ = ps.getParameter<std::string>("HBHEDigiCollectionDM");
63  HODigiCollectionDM_ = ps.getParameter<std::string>("HODigiCollectionDM");
64  HFDigiCollectionDM_ = ps.getParameter<std::string>("HFDigiCollectionDM");
65  ZDCDigiCollectionDM_ = ps.getParameter<std::string>("ZDCDigiCollectionDM");
66 
67 
68  }
T getParameter(std::string const &) const
std::string const & label() const
Definition: InputTag.h:42
DataMixingHcalDigiWorker::~DataMixingHcalDigiWorker ( )
virtual

Default destructor

Definition at line 71 of file DataMixingHcalDigiWorker.cc.

71  {
72  }

Member Function Documentation

void DataMixingHcalDigiWorker::addHcalPileups ( const int  bcr,
const edm::EventPrincipal ep,
unsigned int  EventId,
const edm::EventSetup ES 
)

Definition at line 263 of file DataMixingHcalDigiWorker.cc.

References HcalCoderDb::adc2fC(), edm::SortedCollection< T, SORT >::begin(), DoZDC_, edm::SortedCollection< T, SORT >::end(), edm::EventSetup::get(), HBHEDigiStorage_, HBHEPileInputTag_, HFDigiStorage_, HFPileInputTag_, HODigiStorage_, HOPileInputTag_, edm::EventPrincipal::id(), LogDebug, edm::SortedCollection< T, SORT >::size(), ZDCDigiStorage_, and ZDCPileInputTag_.

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

263  {
264 
265  LogDebug("DataMixingHcalDigiWorker") <<"\n===============> adding pileups from event "<<ep->id()<<" for bunchcrossing "<<bcr;
266 
267  // get conditions
268  edm::ESHandle<HcalDbService> conditions;
269  ES.get<HcalDbRecord>().get(conditions);
270 
271  // fill in maps of hits; same code as addSignals, except now applied to the pileup events
272 
273  // HBHE first
274 
275  boost::shared_ptr<Wrapper<HBHEDigiCollection> const> HBHEDigisPTR =
276  getProductByTag<HBHEDigiCollection>(*ep, HBHEPileInputTag_ );
277 
278  if(HBHEDigisPTR ) {
279 
280  const HBHEDigiCollection* HBHEDigis = const_cast< HBHEDigiCollection * >(HBHEDigisPTR->product());
281 
282  LogInfo("DataMixingHcalDigiWorker") << "total # HBHE digis: " << HBHEDigis->size();
283 
284  // loop over digis, adding these to the existing maps
285  for(HBHEDigiCollection::const_iterator it = HBHEDigis->begin();
286  it != HBHEDigis->end(); ++it) {
287 
288  // calibration, for future reference: (same block for all Hcal types)
289  HcalDetId cell = it->id();
290  // const HcalCalibrations& calibrations=conditions->getHcalCalibrations(cell);
291  const HcalQIECoder* channelCoder = conditions->getHcalCoder (cell);
292  const HcalQIEShape* shape = conditions->getHcalShape (channelCoder); // this one is generic
293  HcalCoderDb coder (*channelCoder, *shape);
294 
295  CaloSamples tool;
296  coder.adc2fC((*it),tool);
297 
298  HBHEDigiStorage_.insert(HBHEDigiMap::value_type( (it->id()), tool ));
299 
300 #ifdef DEBUG
301  LogDebug("DataMixingHcalDigiWorker") << "processed HBHEDigi with rawId: "
302  << it->id() << "\n"
303  << " digi energy: " << it->energy();
304 #endif
305  }
306  }
307  // HO Next
308 
309  boost::shared_ptr<Wrapper<HODigiCollection> const> HODigisPTR =
310  getProductByTag<HODigiCollection>(*ep, HOPileInputTag_ );
311 
312  if(HODigisPTR ) {
313 
314  const HODigiCollection* HODigis = const_cast< HODigiCollection * >(HODigisPTR->product());
315 
316  LogDebug("DataMixingHcalDigiWorker") << "total # HO digis: " << HODigis->size();
317 
318  // loop over digis, adding these to the existing maps
319  for(HODigiCollection::const_iterator it = HODigis->begin();
320  it != HODigis->end(); ++it) {
321 
322  // calibration, for future reference: (same block for all Hcal types)
323  HcalDetId cell = it->id();
324  // const HcalCalibrations& calibrations=conditions->getHcalCalibrations(cell);
325  const HcalQIECoder* channelCoder = conditions->getHcalCoder (cell);
326  const HcalQIEShape* shape = conditions->getHcalShape (channelCoder); // this one is generic
327  HcalCoderDb coder (*channelCoder, *shape);
328 
329  CaloSamples tool;
330  coder.adc2fC((*it),tool);
331 
332  HODigiStorage_.insert(HODigiMap::value_type( (it->id()), tool ));
333 
334 #ifdef DEBUG
335  LogDebug("DataMixingHcalDigiWorker") << "processed HODigi with rawId: "
336  << it->id() << "\n"
337  << " digi energy: " << it->energy();
338 #endif
339  }
340  }
341 
342 
343  // HF Next
344 
345  boost::shared_ptr<Wrapper<HFDigiCollection> const> HFDigisPTR =
346  getProductByTag<HFDigiCollection>(*ep, HFPileInputTag_ );
347 
348  if(HFDigisPTR ) {
349 
350  const HFDigiCollection* HFDigis = const_cast< HFDigiCollection * >(HFDigisPTR->product());
351 
352  LogDebug("DataMixingHcalDigiWorker") << "total # HF digis: " << HFDigis->size();
353 
354  // loop over digis, adding these to the existing maps
355  for(HFDigiCollection::const_iterator it = HFDigis->begin();
356  it != HFDigis->end(); ++it) {
357 
358  // calibration, for future reference: (same block for all Hcal types)
359  HcalDetId cell = it->id();
360  // const HcalCalibrations& calibrations=conditions->getHcalCalibrations(cell);
361  const HcalQIECoder* channelCoder = conditions->getHcalCoder (cell);
362  const HcalQIEShape* shape = conditions->getHcalShape (channelCoder); // this one is generic
363  HcalCoderDb coder (*channelCoder, *shape);
364 
365  CaloSamples tool;
366  coder.adc2fC((*it),tool);
367 
368  HFDigiStorage_.insert(HFDigiMap::value_type( (it->id()), tool ));
369 
370 #ifdef DEBUG
371  LogDebug("DataMixingHcalDigiWorker") << "processed HFDigi with rawId: "
372  << it->id() << "\n"
373  << " digi energy: " << it->energy();
374 #endif
375  }
376  }
377 
378 
379  // ZDC Next
380 
381  if(DoZDC_) {
382 
383 
384  boost::shared_ptr<Wrapper<ZDCDigiCollection> const> ZDCDigisPTR =
385  getProductByTag<ZDCDigiCollection>(*ep, ZDCPileInputTag_ );
386 
387  if(ZDCDigisPTR ) {
388 
389  const ZDCDigiCollection* ZDCDigis = const_cast< ZDCDigiCollection * >(ZDCDigisPTR->product());
390 
391  LogDebug("DataMixingHcalDigiWorker") << "total # ZDC digis: " << ZDCDigis->size();
392 
393  // loop over digis, adding these to the existing maps
394  for(ZDCDigiCollection::const_iterator it = ZDCDigis->begin();
395  it != ZDCDigis->end(); ++it) {
396 
397  // calibration, for future reference: (same block for all Hcal types)
398  HcalDetId cell = it->id();
399  // const HcalCalibrations& calibrations=conditions->getHcalCalibrations(cell);
400  const HcalQIECoder* channelCoder = conditions->getHcalCoder (cell);
401  const HcalQIEShape* shape = conditions->getHcalShape (channelCoder); // this one is generic
402  HcalCoderDb coder (*channelCoder, *shape);
403 
404  CaloSamples tool;
405  coder.adc2fC((*it),tool);
406 
407  ZDCDigiStorage_.insert(ZDCDigiMap::value_type( (it->id()), tool ));
408 
409 #ifdef DEBUG
410  LogDebug("DataMixingHcalDigiWorker") << "processed ZDCDigi with rawId: "
411  << it->id() << "\n"
412  << " digi energy: " << it->energy();
413 #endif
414  }
415  }
416  }
417 
418 
419  }
#define LogDebug(id)
EventID const & id() const
std::vector< T >::const_iterator const_iterator
Container::value_type value_type
const_iterator end() const
const T & get() const
Definition: EventSetup.h:55
size_type size() const
const_iterator begin() const
void DataMixingHcalDigiWorker::addHcalSignals ( const edm::Event e,
const edm::EventSetup ES 
)

Definition at line 74 of file DataMixingHcalDigiWorker.cc.

References HcalCoderDb::adc2fC(), edm::SortedCollection< T, SORT >::begin(), DoZDC_, edm::SortedCollection< T, SORT >::end(), edm::EventSetup::get(), edm::Event::getByLabel(), HBHEdigiCollectionSig_, HBHEDigiStorage_, HFdigiCollectionSig_, HFDigiStorage_, HOdigiCollectionSig_, HODigiStorage_, edm::EventBase::id(), LogDebug, edm::Handle< T >::product(), edm::SortedCollection< T, SORT >::size(), ZDCdigiCollectionSig_, and ZDCDigiStorage_.

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

74  {
75  // Calibration stuff will look like this:
76 
77  // get conditions
78  edm::ESHandle<HcalDbService> conditions;
79  ES.get<HcalDbRecord>().get(conditions);
80 
81 
82 
83  // fill in maps of hits
84 
85  LogInfo("DataMixingHcalDigiWorker")<<"===============> adding MC signals for "<<e.id();
86 
87  // HBHE first
88 
89  Handle< HBHEDigiCollection > pHBHEDigis;
90 
91  const HBHEDigiCollection* HBHEDigis = 0;
92 
93  if( e.getByLabel( HBHEdigiCollectionSig_, pHBHEDigis) ) {
94  HBHEDigis = pHBHEDigis.product(); // get a ptr to the product
95  LogDebug("DataMixingHcalDigiWorker") << "total # HBHE digis: " << HBHEDigis->size();
96  }
97  // else { std::cout << "NO HBHE Digis " << HBHEdigiCollectionSig_.label() << std::endl;}
98 
99 
100  if (HBHEDigis)
101  {
102  // loop over digis, storing them in a map so we can add pileup later
103  for(HBHEDigiCollection::const_iterator it = HBHEDigis->begin();
104  it != HBHEDigis->end(); ++it) {
105 
106  // calibration, for future reference: (same block for all Hcal types)
107 
108  HcalDetId cell = it->id();
109  // const HcalCalibrations& calibrations=conditions->getHcalCalibrations(cell);
110  const HcalQIECoder* channelCoder = conditions->getHcalCoder (cell);
111  const HcalQIEShape* shape = conditions->getHcalShape (channelCoder); // this one is generic
112  HcalCoderDb coder (*channelCoder, *shape);
113 
114  CaloSamples tool;
115  coder.adc2fC((*it),tool);
116 
117  // put sample values back into digi?
118 
119 
120  // RecHit MyHit = reco_.reconstruct(*it,coder,calibrations));
121  //... can now fish calibrated information from RecHit
122 
123 
124  HBHEDigiStorage_.insert(HBHEDigiMap::value_type( ( it->id() ), tool ));
125 
126 #ifdef DEBUG
127  LogDebug("DataMixingHcalDigiWorker") << "processed HBHEDigi with rawId: "
128  << it->id() << "\n"
129  << " digi energy: " << it->energy();
130 #endif
131 
132  }
133  }
134 
135  // HO next
136 
137  Handle< HODigiCollection > pHODigis;
138 
139  const HODigiCollection* HODigis = 0;
140 
141  if( e.getByLabel( HOdigiCollectionSig_, pHODigis) ){
142  HODigis = pHODigis.product(); // get a ptr to the product
143 #ifdef DEBUG
144  LogDebug("DataMixingHcalDigiWorker") << "total # HO digis: " << HODigis->size();
145 #endif
146  }
147 
148 
149  if (HODigis)
150  {
151  // loop over digis, storing them in a map so we can add pileup later
152  for(HODigiCollection::const_iterator it = HODigis->begin();
153  it != HODigis->end(); ++it) {
154 
155  // calibration, for future reference: (same block for all Hcal types)
156  HcalDetId cell = it->id();
157  // const HcalCalibrations& calibrations=conditions->getHcalCalibrations(cell);
158  const HcalQIECoder* channelCoder = conditions->getHcalCoder (cell);
159  const HcalQIEShape* shape = conditions->getHcalShape (channelCoder); // this one is generic
160  HcalCoderDb coder (*channelCoder, *shape);
161 
162  CaloSamples tool;
163  coder.adc2fC((*it),tool);
164 
165  HODigiStorage_.insert(HODigiMap::value_type( ( it->id() ), tool ));
166 
167 #ifdef DEBUG
168  LogDebug("DataMixingHcalDigiWorker") << "processed HODigi with rawId: "
169  << it->id() << "\n"
170  << " digi energy: " << it->energy();
171 #endif
172 
173  }
174  }
175 
176  // HF next
177 
178  Handle< HFDigiCollection > pHFDigis;
179 
180  const HFDigiCollection* HFDigis = 0;
181 
182  if( e.getByLabel( HFdigiCollectionSig_, pHFDigis) ) {
183  HFDigis = pHFDigis.product(); // get a ptr to the product
184 #ifdef DEBUG
185  LogDebug("DataMixingHcalDigiWorker") << "total # HF digis: " << HFDigis->size();
186 #endif
187  }
188 
189 
190  if (HFDigis)
191  {
192  // loop over digis, storing them in a map so we can add pileup later
193  for(HFDigiCollection::const_iterator it = HFDigis->begin();
194  it != HFDigis->end(); ++it) {
195 
196  // calibration, for future reference: (same block for all Hcal types)
197  HcalDetId cell = it->id();
198  // const HcalCalibrations& calibrations=conditions->getHcalCalibrations(cell);
199  const HcalQIECoder* channelCoder = conditions->getHcalCoder (cell);
200  const HcalQIEShape* shape = conditions->getHcalShape (channelCoder); // this one is generic
201  HcalCoderDb coder (*channelCoder, *shape);
202 
203  CaloSamples tool;
204  coder.adc2fC((*it),tool);
205 
206  HFDigiStorage_.insert(HFDigiMap::value_type( ( it->id() ), tool ));
207 
208 #ifdef DEBUG
209  LogDebug("DataMixingHcalDigiWorker") << "processed HFDigi with rawId: "
210  << it->id() << "\n"
211  << " digi energy: " << it->energy();
212 #endif
213 
214  }
215  }
216 
217  // ZDC next
218 
219  if(DoZDC_){
220 
221  Handle< ZDCDigiCollection > pZDCDigis;
222 
223  const ZDCDigiCollection* ZDCDigis = 0;
224 
225  if( e.getByLabel( ZDCdigiCollectionSig_, pZDCDigis) ) {
226  ZDCDigis = pZDCDigis.product(); // get a ptr to the product
227 #ifdef DEBUG
228  LogDebug("DataMixingHcalDigiWorker") << "total # ZDC digis: " << ZDCDigis->size();
229 #endif
230  }
231 
232 
233  if (ZDCDigis)
234  {
235  // loop over digis, storing them in a map so we can add pileup later
236  for(ZDCDigiCollection::const_iterator it = ZDCDigis->begin();
237  it != ZDCDigis->end(); ++it) {
238 
239  // calibration, for future reference: (same block for all Hcal types)
240  HcalDetId cell = it->id();
241  // const HcalCalibrations& calibrations=conditions->getHcalCalibrations(cell);
242  const HcalQIECoder* channelCoder = conditions->getHcalCoder (cell);
243  const HcalQIEShape* shape = conditions->getHcalShape (channelCoder); // this one is generic
244  HcalCoderDb coder (*channelCoder, *shape);
245 
246  CaloSamples tool;
247  coder.adc2fC((*it),tool);
248 
249  ZDCDigiStorage_.insert(ZDCDigiMap::value_type( ( it->id() ), tool ));
250 
251 #ifdef DEBUG
252  LogDebug("DataMixingHcalDigiWorker") << "processed ZDCDigi with rawId: "
253  << it->id() << "\n"
254  << " digi energy: " << it->energy();
255 #endif
256 
257  }
258  }
259  }
260 
261  } // end of addHCalSignals
#define LogDebug(id)
std::vector< T >::const_iterator const_iterator
Container::value_type value_type
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:361
const_iterator end() const
const T & get() const
Definition: EventSetup.h:55
edm::EventID id() const
Definition: EventBase.h:56
size_type size() const
const_iterator begin() const
void DataMixingHcalDigiWorker::putHcal ( edm::Event e,
const edm::EventSetup ES 
)

Definition at line 421 of file DataMixingHcalDigiWorker.cc.

References HcalCoderDb::fC2adc(), edm::EventSetup::get(), HBHEDigiCollectionDM_, HBHEDigiStorage_, HFDigiCollectionDM_, HFDigiStorage_, HODigiCollectionDM_, HODigiStorage_, CaloSamples::id(), max(), edm::Event::put(), CaloSamples::size(), findQualityFiles::size, ZDCDigiCollectionDM_, and ZDCDigiStorage_.

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

421  {
422 
423  // collection of digis to put in the event
424  std::auto_ptr< HBHEDigiCollection > HBHEdigis( new HBHEDigiCollection );
425  std::auto_ptr< HODigiCollection > HOdigis( new HODigiCollection );
426  std::auto_ptr< HFDigiCollection > HFdigis( new HFDigiCollection );
427  std::auto_ptr< ZDCDigiCollection > ZDCdigis( new ZDCDigiCollection );
428 
429  // get conditions
430  edm::ESHandle<HcalDbService> conditions;
431  ES.get<HcalDbRecord>().get(conditions);
432 
433  // loop over the maps we have, re-making individual hits or digis if necessary.
434  DetId formerID = 0;
435  DetId currentID;
436 
437  CaloSamples HB_old;
438 
439  double fC_new;
440  double fC_old;
441  double fC_sum;
442 
443  // HB first...
444 
445  HBHEDigiMap::const_iterator iHBchk;
446 
447  for(HBHEDigiMap::const_iterator iHB = HBHEDigiStorage_.begin();
448  iHB != HBHEDigiStorage_.end(); ++iHB) {
449 
450  currentID = iHB->first;
451 
452  if (currentID == formerID) { // we have to add these digis together
453 
454  //loop over digi samples in each CaloSample
455 
456  unsigned int sizenew = (iHB->second).size();
457  unsigned int sizeold = HB_old.size();
458 
459  bool usenew = false;
460 
461  if(sizenew > sizeold) usenew = true;
462 
463  unsigned int max_samp = std::max(sizenew, sizeold);
464 
465  CaloSamples HB_bigger(currentID,max_samp);
466 
467  // HB_old.setSize(max_samp); --> can't do this...
468 
469  // samples from different events can be of different lengths - sum all
470  // that overlap.
471 
472  for(unsigned int isamp = 0; isamp<max_samp; isamp++) {
473  if(isamp < sizenew) {
474  fC_new = (iHB->second)[isamp]; // should return nominal_fC();
475  }
476  else { fC_new = 0;}
477 
478  if(isamp < sizeold) {
479  fC_old = HB_old[isamp];
480  }
481  else { fC_old = 0;}
482 
483  // add values
484  fC_sum = fC_new + fC_old;
485 
486  //uint fCS = int(fC_sum);
487  //const HcalQIESample fC(fCS);
488  //HB_old.setSample(isamp, fC);
489 
490  if(usenew) {HB_bigger[isamp] = fC_sum; }
491  else { HB_old[isamp] = fC_sum; } // overwrite old sample, adding new info
492 
493  }
494  if(usenew) HB_old = HB_bigger; // save new, larger sized sample in "old" slot
495 
496  }
497  else {
498  if(formerID>0) {
499  // make new digi
500  HBHEdigis->push_back(HBHEDataFrame(formerID));
501 
502  // set up information to convert back
503 
504  HcalDetId cell = HB_old.id();
505  const HcalQIECoder* channelCoder = conditions->getHcalCoder (cell);
506  const HcalQIEShape* shape = conditions->getHcalShape (channelCoder); // this one is generic
507  HcalCoderDb coder (*channelCoder, *shape);
508 
509  unsigned int sizeold = HB_old.size();
510  for(unsigned int isamp = 0; isamp<sizeold; isamp++) {
511  coder.fC2adc(HB_old,(HBHEdigis->back()), 0 ); // as per simulation, capid=0???
512  }
513  }
514  //save pointers for next iteration
515  formerID = currentID;
516  HB_old = iHB->second;
517  //OldUpAdd = HB_old.id();
518  }
519 
520  iHBchk = iHB;
521  if((++iHBchk) == HBHEDigiStorage_.end()) { //make sure not to lose the last one
522 
523  // make new digi
524  HBHEdigis->push_back(HBHEDataFrame(currentID));
525 
526  // set up information to convert back
527 
528  HcalDetId cell = (iHB->second).id();
529  const HcalQIECoder* channelCoder = conditions->getHcalCoder (cell);
530  const HcalQIEShape* shape = conditions->getHcalShape (channelCoder); // this one is generic
531  HcalCoderDb coder (*channelCoder, *shape);
532 
533  unsigned int sizenew = (iHB->second).size();
534  for(unsigned int isamp = 0; isamp<sizenew; isamp++) {
535  coder.fC2adc(HB_old,(HBHEdigis->back()), 0 ); // as per simulation, capid=0???
536  }
537  }
538  }
539 
540 
541  // HO next...
542 
543  // loop over the maps we have, re-making individual hits or digis if necessary.
544  formerID = 0;
545  CaloSamples HO_old;
546 
547  HODigiMap::const_iterator iHOchk;
548 
549  for(HODigiMap::const_iterator iHO = HODigiStorage_.begin();
550  iHO != HODigiStorage_.end(); ++iHO) {
551 
552  currentID = iHO->first;
553 
554  if (currentID == formerID) { // we have to add these digis together
555 
556  //loop over digi samples in each CaloSample
557  unsigned int sizenew = (iHO->second).size();
558  unsigned int sizeold = HO_old.size();
559 
560  unsigned int max_samp = std::max(sizenew, sizeold);
561 
562  CaloSamples HO_bigger(currentID,max_samp);
563 
564  bool usenew = false;
565 
566  if(sizenew > sizeold) usenew = true;
567 
568  // samples from different events can be of different lengths - sum all
569  // that overlap.
570 
571  for(unsigned int isamp = 0; isamp<max_samp; isamp++) {
572  if(isamp < sizenew) {
573  fC_new = (iHO->second)[isamp];
574  }
575  else { fC_new = 0;}
576 
577  if(isamp < sizeold) {
578  fC_old = HO_old[isamp];
579  }
580  else { fC_old = 0;}
581 
582  // add values
583  fC_sum = fC_new + fC_old;
584 
585  if(usenew) {HO_bigger[isamp] = fC_sum; }
586  else { HO_old[isamp] = fC_sum; } // overwrite old sample, adding new info
587 
588  }
589  if(usenew) HO_old = HO_bigger; // save new, larger sized sample in "old" slot
590 
591  }
592  else {
593  if(formerID>0) {
594  // make new digi
595  HOdigis->push_back(HODataFrame(formerID));
596 
597  // set up information to convert back
598 
599  HcalDetId cell = HO_old.id();
600  const HcalQIECoder* channelCoder = conditions->getHcalCoder (cell);
601  const HcalQIEShape* shape = conditions->getHcalShape (channelCoder); // this one is generic
602  HcalCoderDb coder (*channelCoder, *shape);
603 
604  unsigned int sizeold = HO_old.size();
605  for(unsigned int isamp = 0; isamp<sizeold; isamp++) {
606  coder.fC2adc(HO_old,(HOdigis->back()), 0 ); // as per simulation, capid=0???
607  }
608  }
609  //save pointers for next iteration
610  formerID = currentID;
611  HO_old = iHO->second;
612  }
613 
614  iHOchk = iHO;
615  if((++iHOchk) == HODigiStorage_.end()) { //make sure not to lose the last one
616  // make new digi
617  HOdigis->push_back(HODataFrame(currentID));
618 
619  // set up information to convert back
620 
621  HcalDetId cell = (iHO->second).id();
622  const HcalQIECoder* channelCoder = conditions->getHcalCoder (cell);
623  const HcalQIEShape* shape = conditions->getHcalShape (channelCoder); // this one is generic
624  HcalCoderDb coder (*channelCoder, *shape);
625 
626  unsigned int sizeold = (iHO->second).size();
627  for(unsigned int isamp = 0; isamp<sizeold; isamp++) {
628  coder.fC2adc(HO_old,(HOdigis->back()), 0 ); // as per simulation, capid=0???
629  }
630 
631  }
632  }
633 
634  // HF next...
635 
636  // loop over the maps we have, re-making individual hits or digis if necessary.
637  formerID = 0;
638  CaloSamples HF_old;
639 
640  HFDigiMap::const_iterator iHFchk;
641 
642  for(HFDigiMap::const_iterator iHF = HFDigiStorage_.begin();
643  iHF != HFDigiStorage_.end(); ++iHF) {
644 
645  currentID = iHF->first;
646 
647  if (currentID == formerID) { // we have to add these digis together
648 
649  //loop over digi samples in each CaloSample
650  unsigned int sizenew = (iHF->second).size();
651  unsigned int sizeold = HF_old.size();
652 
653  unsigned int max_samp = std::max(sizenew, sizeold);
654 
655  CaloSamples HF_bigger(currentID,max_samp);
656 
657  bool usenew = false;
658 
659  if(sizenew > sizeold) usenew = true;
660 
661  // samples from different events can be of different lengths - sum all
662  // that overlap.
663 
664  for(unsigned int isamp = 0; isamp<max_samp; isamp++) {
665  if(isamp < sizenew) {
666  fC_new = (iHF->second)[isamp];
667  }
668  else { fC_new = 0;}
669 
670  if(isamp < sizeold) {
671  fC_old = HF_old[isamp];
672  }
673  else { fC_old = 0;}
674 
675  // add values
676  fC_sum = fC_new + fC_old;
677 
678  if(usenew) {HF_bigger[isamp] = fC_sum; }
679  else { HF_old[isamp] = fC_sum; } // overwrite old sample, adding new info
680 
681  }
682  if(usenew) HF_old = HF_bigger; // save new, larger sized sample in "old" slot
683 
684  }
685  else {
686  if(formerID>0) {
687  // make new digi
688  HFdigis->push_back(HFDataFrame(formerID));
689 
690  // set up information to convert back
691 
692  HcalDetId cell = HF_old.id();
693  const HcalQIECoder* channelCoder = conditions->getHcalCoder (cell);
694  const HcalQIEShape* shape = conditions->getHcalShape (channelCoder); // this one is generic
695  HcalCoderDb coder (*channelCoder, *shape);
696 
697  unsigned int sizeold = HF_old.size();
698  for(unsigned int isamp = 0; isamp<sizeold; isamp++) {
699  coder.fC2adc(HF_old,(HFdigis->back()), 0 ); // as per simulation, capid=0???
700  }
701  }
702  //save pointers for next iteration
703  formerID = currentID;
704  HF_old = iHF->second;
705  }
706 
707  iHFchk = iHF;
708  if((++iHFchk) == HFDigiStorage_.end()) { //make sure not to lose the last one
709  // make new digi
710  HFdigis->push_back(HFDataFrame(currentID));
711 
712  // set up information to convert back
713 
714  HcalDetId cell = (iHF->second).id();
715  const HcalQIECoder* channelCoder = conditions->getHcalCoder (cell);
716  const HcalQIEShape* shape = conditions->getHcalShape (channelCoder); // this one is generic
717  HcalCoderDb coder (*channelCoder, *shape);
718 
719  unsigned int sizeold = (iHF->second).size();
720  for(unsigned int isamp = 0; isamp<sizeold; isamp++) {
721  coder.fC2adc(HF_old,(HFdigis->back()), 0 ); // as per simulation, capid=0???
722  }
723 
724  }
725  }
726 
727 
728  // ZDC next...
729 
730  // loop over the maps we have, re-making individual hits or digis if necessary.
731  formerID = 0;
732  CaloSamples ZDC_old;
733 
734  ZDCDigiMap::const_iterator iZDCchk;
735 
736  for(ZDCDigiMap::const_iterator iZDC = ZDCDigiStorage_.begin();
737  iZDC != ZDCDigiStorage_.end(); ++iZDC) {
738 
739  currentID = iZDC->first;
740 
741  if (currentID == formerID) { // we have to add these digis together
742 
743  //loop over digi samples in each CaloSample
744  unsigned int sizenew = (iZDC->second).size();
745  unsigned int sizeold = ZDC_old.size();
746 
747  unsigned int max_samp = std::max(sizenew, sizeold);
748 
749  CaloSamples ZDC_bigger(currentID,max_samp);
750 
751  bool usenew = false;
752 
753  if(sizenew > sizeold) usenew = true;
754 
755  // samples from different events can be of different lengths - sum all
756  // that overlap.
757 
758  for(unsigned int isamp = 0; isamp<max_samp; isamp++) {
759  if(isamp < sizenew) {
760  fC_new = (iZDC->second)[isamp];
761  }
762  else { fC_new = 0;}
763 
764  if(isamp < sizeold) {
765  fC_old = ZDC_old[isamp];
766  }
767  else { fC_old = 0;}
768 
769  // add values
770  fC_sum = fC_new + fC_old;
771 
772  if(usenew) {ZDC_bigger[isamp] = fC_sum; }
773  else { ZDC_old[isamp] = fC_sum; } // overwrite old sample, adding new info
774 
775  }
776  if(usenew) ZDC_old = ZDC_bigger; // save new, larger sized sample in "old" slot
777 
778  }
779  else {
780  if(formerID>0) {
781  // make new digi
782  ZDCdigis->push_back(ZDCDataFrame(formerID));
783 
784  // set up information to convert back
785 
786  HcalDetId cell = ZDC_old.id();
787  const HcalQIECoder* channelCoder = conditions->getHcalCoder (cell);
788  const HcalQIEShape* shape = conditions->getHcalShape (channelCoder); // this one is generic
789  HcalCoderDb coder (*channelCoder, *shape);
790 
791  unsigned int sizeold = ZDC_old.size();
792  for(unsigned int isamp = 0; isamp<sizeold; isamp++) {
793  coder.fC2adc(ZDC_old,(ZDCdigis->back()), 0 ); // as per simulation, capid=0???
794  }
795  }
796  //save pointers for next iteration
797  formerID = currentID;
798  ZDC_old = iZDC->second;
799  }
800 
801  iZDCchk = iZDC;
802  if((++iZDCchk) == ZDCDigiStorage_.end()) { //make sure not to lose the last one
803  // make new digi
804  ZDCdigis->push_back(ZDCDataFrame(currentID));
805 
806  // set up information to convert back
807 
808  HcalDetId cell = (iZDC->second).id();
809  const HcalQIECoder* channelCoder = conditions->getHcalCoder (cell);
810  const HcalQIEShape* shape = conditions->getHcalShape (channelCoder); // this one is generic
811  HcalCoderDb coder (*channelCoder, *shape);
812 
813  unsigned int sizeold = (iZDC->second).size();
814  for(unsigned int isamp = 0; isamp<sizeold; isamp++) {
815  coder.fC2adc(ZDC_old,(ZDCdigis->back()), 0 ); // as per simulation, capid=0???
816  }
817 
818  }
819  }
820 
821 
822 
823  //done merging
824 
825  // put the collection of recunstructed hits in the event
826  LogInfo("DataMixingHcalDigiWorker") << "total # HBHE Merged digis: " << HBHEdigis->size() ;
827  LogInfo("DataMixingHcalDigiWorker") << "total # HO Merged digis: " << HOdigis->size() ;
828  LogInfo("DataMixingHcalDigiWorker") << "total # HF Merged digis: " << HFdigis->size() ;
829  LogInfo("DataMixingHcalDigiWorker") << "total # ZDC Merged digis: " << ZDCdigis->size() ;
830 
831  e.put( HBHEdigis, HBHEDigiCollectionDM_ );
832  e.put( HOdigis, HODigiCollectionDM_ );
833  e.put( HFdigis, HFDigiCollectionDM_ );
834  e.put( ZDCdigis, ZDCDigiCollectionDM_ );
835 
836  // clear local storage after this event
837  HBHEDigiStorage_.clear();
838  HODigiStorage_.clear();
839  HFDigiStorage_.clear();
840  ZDCDigiStorage_.clear();
841 
842  }
const T & max(const T &a, const T &b)
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:94
Definition: DetId.h:20
int size() const
get the size
Definition: CaloSamples.h:26
const T & get() const
Definition: EventSetup.h:55
DetId id() const
get the (generic) id
Definition: CaloSamples.h:23
tuple size
Write out results.

Member Data Documentation

bool edm::DataMixingHcalDigiWorker::DoZDC_
private
std::string edm::DataMixingHcalDigiWorker::HBHEDigiCollectionDM_
private

Definition at line 69 of file DataMixingHcalDigiWorker.h.

Referenced by DataMixingHcalDigiWorker(), and putHcal().

edm::InputTag edm::DataMixingHcalDigiWorker::HBHEdigiCollectionSig_
private

Definition at line 59 of file DataMixingHcalDigiWorker.h.

Referenced by addHcalSignals(), and DataMixingHcalDigiWorker().

HBHEDigiMap edm::DataMixingHcalDigiWorker::HBHEDigiStorage_
private

Definition at line 84 of file DataMixingHcalDigiWorker.h.

Referenced by addHcalPileups(), addHcalSignals(), and putHcal().

edm::InputTag edm::DataMixingHcalDigiWorker::HBHEPileInputTag_
private

Definition at line 64 of file DataMixingHcalDigiWorker.h.

Referenced by addHcalPileups(), and DataMixingHcalDigiWorker().

std::string edm::DataMixingHcalDigiWorker::HFDigiCollectionDM_
private

Definition at line 71 of file DataMixingHcalDigiWorker.h.

Referenced by DataMixingHcalDigiWorker(), and putHcal().

edm::InputTag edm::DataMixingHcalDigiWorker::HFdigiCollectionSig_
private

Definition at line 61 of file DataMixingHcalDigiWorker.h.

Referenced by addHcalSignals(), and DataMixingHcalDigiWorker().

HFDigiMap edm::DataMixingHcalDigiWorker::HFDigiStorage_
private

Definition at line 85 of file DataMixingHcalDigiWorker.h.

Referenced by addHcalPileups(), addHcalSignals(), and putHcal().

edm::InputTag edm::DataMixingHcalDigiWorker::HFPileInputTag_
private

Definition at line 66 of file DataMixingHcalDigiWorker.h.

Referenced by addHcalPileups(), and DataMixingHcalDigiWorker().

std::string edm::DataMixingHcalDigiWorker::HODigiCollectionDM_
private

Definition at line 70 of file DataMixingHcalDigiWorker.h.

Referenced by DataMixingHcalDigiWorker(), and putHcal().

edm::InputTag edm::DataMixingHcalDigiWorker::HOdigiCollectionSig_
private

Definition at line 60 of file DataMixingHcalDigiWorker.h.

Referenced by addHcalSignals(), and DataMixingHcalDigiWorker().

HODigiMap edm::DataMixingHcalDigiWorker::HODigiStorage_
private

Definition at line 86 of file DataMixingHcalDigiWorker.h.

Referenced by addHcalPileups(), addHcalSignals(), and putHcal().

edm::InputTag edm::DataMixingHcalDigiWorker::HOPileInputTag_
private

Definition at line 65 of file DataMixingHcalDigiWorker.h.

Referenced by addHcalPileups(), and DataMixingHcalDigiWorker().

std::string edm::DataMixingHcalDigiWorker::label_
private
std::string edm::DataMixingHcalDigiWorker::ZDCDigiCollectionDM_
private

Definition at line 72 of file DataMixingHcalDigiWorker.h.

Referenced by DataMixingHcalDigiWorker(), and putHcal().

edm::InputTag edm::DataMixingHcalDigiWorker::ZDCdigiCollectionSig_
private

Definition at line 62 of file DataMixingHcalDigiWorker.h.

Referenced by addHcalSignals(), and DataMixingHcalDigiWorker().

ZDCDigiMap edm::DataMixingHcalDigiWorker::ZDCDigiStorage_
private

Definition at line 87 of file DataMixingHcalDigiWorker.h.

Referenced by addHcalPileups(), addHcalSignals(), and putHcal().

edm::InputTag edm::DataMixingHcalDigiWorker::ZDCPileInputTag_
private

Definition at line 67 of file DataMixingHcalDigiWorker.h.

Referenced by addHcalPileups(), and DataMixingHcalDigiWorker().