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 35 of file DataMixingHcalDigiWorker.cc.

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

standard constructor

Definition at line 38 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_.

38  :
39  label_(ps.getParameter<std::string>("Label"))
40 
41  {
42 
43  // get the subdetector names
44  // this->getSubdetectorNames(); //something like this may be useful to check what we are supposed to do...
45 
46  // declare the products to produce
47 
48  // Hcal
49 
50  HBHEdigiCollectionSig_ = ps.getParameter<edm::InputTag>("HBHEdigiCollectionSig");
51  HOdigiCollectionSig_ = ps.getParameter<edm::InputTag>("HOdigiCollectionSig");
52  HFdigiCollectionSig_ = ps.getParameter<edm::InputTag>("HFdigiCollectionSig");
53  ZDCdigiCollectionSig_ = ps.getParameter<edm::InputTag>("ZDCdigiCollectionSig");
54 
55  HBHEPileInputTag_ = ps.getParameter<edm::InputTag>("HBHEPileInputTag");
56  HOPileInputTag_ = ps.getParameter<edm::InputTag>("HOPileInputTag");
57  HFPileInputTag_ = ps.getParameter<edm::InputTag>("HFPileInputTag");
58  ZDCPileInputTag_ = ps.getParameter<edm::InputTag>("ZDCPileInputTag");
59 
63 
67 
68  DoZDC_ = false;
69  if(ZDCPileInputTag_.label() != "") DoZDC_ = true;
70 
71  if(DoZDC_) {
74  }
75 
76 
77  HBHEDigiCollectionDM_ = ps.getParameter<std::string>("HBHEDigiCollectionDM");
78  HODigiCollectionDM_ = ps.getParameter<std::string>("HODigiCollectionDM");
79  HFDigiCollectionDM_ = ps.getParameter<std::string>("HFDigiCollectionDM");
80  ZDCDigiCollectionDM_ = ps.getParameter<std::string>("ZDCDigiCollectionDM");
81 
82 
83  }
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:43
edm::EDGetTokenT< HBHEDigiCollection > HBHEDigiToken_
DataMixingHcalDigiWorker::~DataMixingHcalDigiWorker ( )
virtual

Default destructor

Definition at line 86 of file DataMixingHcalDigiWorker.cc.

86  {
87  }

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 281 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().

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

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

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

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