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, ModuleCallingContext const *)
 
void addHcalSignals (const edm::Event &e, const edm::EventSetup &ES)
 
 DataMixingHcalDigiWorker ()
 
 DataMixingHcalDigiWorker (const edm::ParameterSet &ps, edm::ConsumesCollector &&iC)
 
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_
 
edm::EDGetTokenT
< HBHEDigiCollection
HBHEDigiPToken_
 
HBHEDigiMap HBHEDigiStorage_
 
edm::EDGetTokenT
< HBHEDigiCollection
HBHEDigiToken_
 
edm::InputTag HBHEPileInputTag_
 
std::string HFDigiCollectionDM_
 
edm::InputTag HFdigiCollectionSig_
 
edm::EDGetTokenT
< HFDigiCollection
HFDigiPToken_
 
HFDigiMap HFDigiStorage_
 
edm::EDGetTokenT
< HFDigiCollection
HFDigiToken_
 
edm::InputTag HFPileInputTag_
 
std::string HODigiCollectionDM_
 
edm::InputTag HOdigiCollectionSig_
 
edm::EDGetTokenT
< HODigiCollection
HODigiPToken_
 
HODigiMap HODigiStorage_
 
edm::EDGetTokenT
< HODigiCollection
HODigiToken_
 
edm::InputTag HOPileInputTag_
 
std::string label_
 
std::string ZDCDigiCollectionDM_
 
edm::InputTag ZDCdigiCollectionSig_
 
edm::EDGetTokenT
< ZDCDigiCollection
ZDCDigiPToken_
 
ZDCDigiMap ZDCDigiStorage_
 
edm::EDGetTokenT
< ZDCDigiCollection
ZDCDigiToken_
 
edm::InputTag ZDCPileInputTag_
 

Detailed Description

Definition at line 41 of file DataMixingHcalDigiWorker.h.

Member Typedef Documentation

Definition at line 89 of file DataMixingHcalDigiWorker.h.

Definition at line 90 of file DataMixingHcalDigiWorker.h.

Definition at line 91 of file DataMixingHcalDigiWorker.h.

Definition at line 92 of file DataMixingHcalDigiWorker.h.

Constructor & Destructor Documentation

DataMixingHcalDigiWorker::DataMixingHcalDigiWorker ( )

Definition at line 34 of file DataMixingHcalDigiWorker.cc.

34 { }
DataMixingHcalDigiWorker::DataMixingHcalDigiWorker ( const edm::ParameterSet ps,
edm::ConsumesCollector &&  iC 
)
explicit

standard constructor

Definition at line 37 of file DataMixingHcalDigiWorker.cc.

References DoZDC_, edm::ParameterSet::getParameter(), HBHEDigiCollectionDM_, HBHEdigiCollectionSig_, HBHEDigiPToken_, HBHEDigiToken_, HBHEPileInputTag_, HFDigiCollectionDM_, HFdigiCollectionSig_, HFDigiPToken_, HFDigiToken_, HFPileInputTag_, HODigiCollectionDM_, HOdigiCollectionSig_, HODigiPToken_, HODigiToken_, HOPileInputTag_, edm::InputTag::label(), AlCaHLTBitMon_QueryRunRegistry::string, ZDCDigiCollectionDM_, ZDCdigiCollectionSig_, ZDCDigiPToken_, ZDCDigiToken_, 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 
62 
66 
67  DoZDC_ = false;
68  if(ZDCPileInputTag_.label() != "") DoZDC_ = true;
69 
70  if(DoZDC_) {
73  }
74 
75 
76  HBHEDigiCollectionDM_ = ps.getParameter<std::string>("HBHEDigiCollectionDM");
77  HODigiCollectionDM_ = ps.getParameter<std::string>("HODigiCollectionDM");
78  HFDigiCollectionDM_ = ps.getParameter<std::string>("HFDigiCollectionDM");
79  ZDCDigiCollectionDM_ = ps.getParameter<std::string>("ZDCDigiCollectionDM");
80 
81 
82  }
EDGetTokenT< ProductType > consumes(edm::InputTag const &tag)
T getParameter(std::string const &) const
edm::EDGetTokenT< HBHEDigiCollection > HBHEDigiPToken_
edm::EDGetTokenT< HODigiCollection > HODigiToken_
edm::EDGetTokenT< ZDCDigiCollection > ZDCDigiToken_
edm::EDGetTokenT< HODigiCollection > HODigiPToken_
edm::EDGetTokenT< ZDCDigiCollection > ZDCDigiPToken_
edm::EDGetTokenT< HFDigiCollection > HFDigiPToken_
edm::EDGetTokenT< HFDigiCollection > HFDigiToken_
std::string const & label() const
Definition: InputTag.h:42
edm::EDGetTokenT< HBHEDigiCollection > HBHEDigiToken_
DataMixingHcalDigiWorker::~DataMixingHcalDigiWorker ( )
virtual

Default destructor

Definition at line 85 of file DataMixingHcalDigiWorker.cc.

85  {
86  }

Member Function Documentation

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

Definition at line 280 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().

281  {
282 
283  LogDebug("DataMixingHcalDigiWorker") <<"\n===============> adding pileups from event "<<ep->id()<<" for bunchcrossing "<<bcr;
284 
285  // get conditions
286  edm::ESHandle<HcalDbService> conditions;
287  ES.get<HcalDbRecord>().get(conditions);
288 
289  // fill in maps of hits; same code as addSignals, except now applied to the pileup events
290 
291  // HBHE first
292 
293 
294  boost::shared_ptr<Wrapper<HBHEDigiCollection> const> HBHEDigisPTR =
295  getProductByTag<HBHEDigiCollection>(*ep, HBHEPileInputTag_, mcc);
296 
297  if(HBHEDigisPTR ) {
298 
299  const HBHEDigiCollection* HBHEDigis = const_cast< HBHEDigiCollection * >(HBHEDigisPTR->product());
300 
301  LogInfo("DataMixingHcalDigiWorker") << "total # HBHE digis: " << HBHEDigis->size();
302 
303  // loop over digis, adding these to the existing maps
304  for(HBHEDigiCollection::const_iterator it = HBHEDigis->begin();
305  it != HBHEDigis->end(); ++it) {
306 
307  // calibration, for future reference: (same block for all Hcal types)
308  HcalDetId cell = it->id();
309  // const HcalCalibrations& calibrations=conditions->getHcalCalibrations(cell);
310  const HcalQIECoder* channelCoder = conditions->getHcalCoder (cell);
311  const HcalQIEShape* shape = conditions->getHcalShape (channelCoder); // this one is generic
312  HcalCoderDb coder (*channelCoder, *shape);
313 
314  CaloSamples tool;
315  coder.adc2fC((*it),tool);
316 
317  HBHEDigiStorage_.insert(HBHEDigiMap::value_type( (it->id()), tool ));
318 
319 #ifdef DEBUG
320  // Commented out because this does not compile anymore
321  // LogDebug("DataMixingHcalDigiWorker") << "processed HBHEDigi with rawId: "
322  // << it->id() << "\n"
323  // << " digi energy: " << it->energy();
324 #endif
325  }
326  }
327  //else {std::cout << "NO HBHE Digis!!!!" << std::endl;}
328  // HO Next
329 
330  boost::shared_ptr<Wrapper<HODigiCollection> const> HODigisPTR =
331  getProductByTag<HODigiCollection>(*ep, HOPileInputTag_, mcc);
332 
333  if(HODigisPTR ) {
334 
335  const HODigiCollection* HODigis = const_cast< HODigiCollection * >(HODigisPTR->product());
336 
337  LogDebug("DataMixingHcalDigiWorker") << "total # HO digis: " << HODigis->size();
338 
339  // loop over digis, adding these to the existing maps
340  for(HODigiCollection::const_iterator it = HODigis->begin();
341  it != HODigis->end(); ++it) {
342 
343  // calibration, for future reference: (same block for all Hcal types)
344  HcalDetId cell = it->id();
345  // const HcalCalibrations& calibrations=conditions->getHcalCalibrations(cell);
346  const HcalQIECoder* channelCoder = conditions->getHcalCoder (cell);
347  const HcalQIEShape* shape = conditions->getHcalShape (channelCoder); // this one is generic
348  HcalCoderDb coder (*channelCoder, *shape);
349 
350  CaloSamples tool;
351  coder.adc2fC((*it),tool);
352 
353  HODigiStorage_.insert(HODigiMap::value_type( (it->id()), tool ));
354 
355 #ifdef DEBUG
356  // Commented out because this does not compile anymore
357  // LogDebug("DataMixingHcalDigiWorker") << "processed HODigi with rawId: "
358  // << it->id() << "\n"
359  // << " digi energy: " << it->energy();
360 #endif
361  }
362  }
363 
364 
365  // HF Next
366 
367  boost::shared_ptr<Wrapper<HFDigiCollection> const> HFDigisPTR =
368  getProductByTag<HFDigiCollection>(*ep, HFPileInputTag_, mcc);
369 
370  if(HFDigisPTR ) {
371 
372  const HFDigiCollection* HFDigis = const_cast< HFDigiCollection * >(HFDigisPTR->product());
373 
374  LogDebug("DataMixingHcalDigiWorker") << "total # HF digis: " << HFDigis->size();
375 
376  // loop over digis, adding these to the existing maps
377  for(HFDigiCollection::const_iterator it = HFDigis->begin();
378  it != HFDigis->end(); ++it) {
379 
380  // calibration, for future reference: (same block for all Hcal types)
381  HcalDetId cell = it->id();
382  // const HcalCalibrations& calibrations=conditions->getHcalCalibrations(cell);
383  const HcalQIECoder* channelCoder = conditions->getHcalCoder (cell);
384  const HcalQIEShape* shape = conditions->getHcalShape (channelCoder); // this one is generic
385  HcalCoderDb coder (*channelCoder, *shape);
386 
387  CaloSamples tool;
388  coder.adc2fC((*it),tool);
389 
390  HFDigiStorage_.insert(HFDigiMap::value_type( (it->id()), tool ));
391 
392 #ifdef DEBUG
393  // Commented out because this does not compile anymore
394  // LogDebug("DataMixingHcalDigiWorker") << "processed HFDigi with rawId: "
395  // << it->id() << "\n"
396  // << " digi energy: " << it->energy();
397 #endif
398  }
399  }
400 
401 
402  // ZDC Next
403 
404  if(DoZDC_) {
405 
406 
407  boost::shared_ptr<Wrapper<ZDCDigiCollection> const> ZDCDigisPTR =
408  getProductByTag<ZDCDigiCollection>(*ep, ZDCPileInputTag_, mcc);
409 
410  if(ZDCDigisPTR ) {
411 
412  const ZDCDigiCollection* ZDCDigis = const_cast< ZDCDigiCollection * >(ZDCDigisPTR->product());
413 
414  LogDebug("DataMixingHcalDigiWorker") << "total # ZDC digis: " << ZDCDigis->size();
415 
416  // loop over digis, adding these to the existing maps
417  for(ZDCDigiCollection::const_iterator it = ZDCDigis->begin();
418  it != ZDCDigis->end(); ++it) {
419 
420  // calibration, for future reference: (same block for all Hcal types)
421  HcalDetId cell = it->id();
422  // const HcalCalibrations& calibrations=conditions->getHcalCalibrations(cell);
423  const HcalQIECoder* channelCoder = conditions->getHcalCoder (cell);
424  const HcalQIEShape* shape = conditions->getHcalShape (channelCoder); // this one is generic
425  HcalCoderDb coder (*channelCoder, *shape);
426 
427  CaloSamples tool;
428  coder.adc2fC((*it),tool);
429 
430  ZDCDigiStorage_.insert(ZDCDigiMap::value_type( (it->id()), tool ));
431 
432 #ifdef DEBUG
433  // Commented out because this does not compile anymore
434  // LogDebug("DataMixingHcalDigiWorker") << "processed ZDCDigi with rawId: "
435  // << it->id() << "\n"
436  // << " digi energy: " << it->energy();
437 #endif
438  }
439  }
440  }
441 
442 
443  }
#define LogDebug(id)
EventID const & id() const
std::vector< HBHEDataFrame >::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 88 of file DataMixingHcalDigiWorker.cc.

References HcalCoderDb::adc2fC(), edm::SortedCollection< T, SORT >::begin(), DoZDC_, edm::SortedCollection< T, SORT >::end(), edm::EventSetup::get(), edm::Event::getByToken(), HBHEDigiStorage_, HBHEDigiToken_, HFDigiStorage_, HFDigiToken_, HODigiStorage_, HODigiToken_, edm::EventBase::id(), LogDebug, edm::Handle< T >::product(), edm::SortedCollection< T, SORT >::size(), ZDCDigiStorage_, and ZDCDigiToken_.

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

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

Definition at line 445 of file DataMixingHcalDigiWorker.cc.

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

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

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

Member Data Documentation

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

Definition at line 84 of file DataMixingHcalDigiWorker.h.

Referenced by DataMixingHcalDigiWorker(), and putHcal().

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

Definition at line 63 of file DataMixingHcalDigiWorker.h.

Referenced by DataMixingHcalDigiWorker().

edm::EDGetTokenT<HBHEDigiCollection> edm::DataMixingHcalDigiWorker::HBHEDigiPToken_
private

Definition at line 78 of file DataMixingHcalDigiWorker.h.

Referenced by DataMixingHcalDigiWorker().

HBHEDigiMap edm::DataMixingHcalDigiWorker::HBHEDigiStorage_
private

Definition at line 99 of file DataMixingHcalDigiWorker.h.

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

edm::EDGetTokenT<HBHEDigiCollection> edm::DataMixingHcalDigiWorker::HBHEDigiToken_
private

Definition at line 73 of file DataMixingHcalDigiWorker.h.

Referenced by addHcalSignals(), and DataMixingHcalDigiWorker().

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

Definition at line 68 of file DataMixingHcalDigiWorker.h.

Referenced by addHcalPileups(), and DataMixingHcalDigiWorker().

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

Definition at line 86 of file DataMixingHcalDigiWorker.h.

Referenced by DataMixingHcalDigiWorker(), and putHcal().

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

Definition at line 65 of file DataMixingHcalDigiWorker.h.

Referenced by DataMixingHcalDigiWorker().

edm::EDGetTokenT<HFDigiCollection> edm::DataMixingHcalDigiWorker::HFDigiPToken_
private

Definition at line 80 of file DataMixingHcalDigiWorker.h.

Referenced by DataMixingHcalDigiWorker().

HFDigiMap edm::DataMixingHcalDigiWorker::HFDigiStorage_
private

Definition at line 100 of file DataMixingHcalDigiWorker.h.

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

edm::EDGetTokenT<HFDigiCollection> edm::DataMixingHcalDigiWorker::HFDigiToken_
private

Definition at line 75 of file DataMixingHcalDigiWorker.h.

Referenced by addHcalSignals(), and DataMixingHcalDigiWorker().

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

Definition at line 70 of file DataMixingHcalDigiWorker.h.

Referenced by addHcalPileups(), and DataMixingHcalDigiWorker().

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

Definition at line 85 of file DataMixingHcalDigiWorker.h.

Referenced by DataMixingHcalDigiWorker(), and putHcal().

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

Definition at line 64 of file DataMixingHcalDigiWorker.h.

Referenced by DataMixingHcalDigiWorker().

edm::EDGetTokenT<HODigiCollection> edm::DataMixingHcalDigiWorker::HODigiPToken_
private

Definition at line 79 of file DataMixingHcalDigiWorker.h.

Referenced by DataMixingHcalDigiWorker().

HODigiMap edm::DataMixingHcalDigiWorker::HODigiStorage_
private

Definition at line 101 of file DataMixingHcalDigiWorker.h.

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

edm::EDGetTokenT<HODigiCollection> edm::DataMixingHcalDigiWorker::HODigiToken_
private

Definition at line 74 of file DataMixingHcalDigiWorker.h.

Referenced by addHcalSignals(), and DataMixingHcalDigiWorker().

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

Definition at line 69 of file DataMixingHcalDigiWorker.h.

Referenced by addHcalPileups(), and DataMixingHcalDigiWorker().

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

Definition at line 87 of file DataMixingHcalDigiWorker.h.

Referenced by DataMixingHcalDigiWorker(), and putHcal().

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

Definition at line 66 of file DataMixingHcalDigiWorker.h.

Referenced by DataMixingHcalDigiWorker().

edm::EDGetTokenT<ZDCDigiCollection> edm::DataMixingHcalDigiWorker::ZDCDigiPToken_
private

Definition at line 81 of file DataMixingHcalDigiWorker.h.

Referenced by DataMixingHcalDigiWorker().

ZDCDigiMap edm::DataMixingHcalDigiWorker::ZDCDigiStorage_
private

Definition at line 102 of file DataMixingHcalDigiWorker.h.

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

edm::EDGetTokenT<ZDCDigiCollection> edm::DataMixingHcalDigiWorker::ZDCDigiToken_
private

Definition at line 76 of file DataMixingHcalDigiWorker.h.

Referenced by addHcalSignals(), and DataMixingHcalDigiWorker().

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

Definition at line 71 of file DataMixingHcalDigiWorker.h.

Referenced by addHcalPileups(), and DataMixingHcalDigiWorker().