00001
00002
00003
00004
00005
00006
00007 #include <map>
00008 #include "FWCore/MessageLogger/interface/MessageLogger.h"
00009 #include "FWCore/Utilities/interface/EDMException.h"
00010 #include "FWCore/Framework/interface/ConstProductRegistry.h"
00011 #include "FWCore/ServiceRegistry/interface/Service.h"
00012 #include "FWCore/Framework/interface/Selector.h"
00013 #include "FWCore/Framework/interface/ESHandle.h"
00014 #include "FWCore/Framework/interface/EventSetup.h"
00015 #include "DataFormats/Common/interface/Handle.h"
00016 #include "DataFormats/Provenance/interface/Provenance.h"
00017 #include "DataFormats/Provenance/interface/BranchDescription.h"
00018
00019 #include "CalibFormats/HcalObjects/interface/HcalCoderDb.h"
00020 #include "CalibFormats/HcalObjects/interface/HcalCalibrations.h"
00021 #include "CalibFormats/HcalObjects/interface/HcalDbService.h"
00022 #include "CalibFormats/HcalObjects/interface/HcalDbRecord.h"
00023
00024
00025 #include "DataMixingHcalDigiWorker.h"
00026
00027
00028 using namespace std;
00029
00030 namespace edm
00031 {
00032
00033
00034
00035 DataMixingHcalDigiWorker::DataMixingHcalDigiWorker() {sel_=0;}
00036
00037
00038 DataMixingHcalDigiWorker::DataMixingHcalDigiWorker(const edm::ParameterSet& ps) :
00039 label_(ps.getParameter<std::string>("Label"))
00040
00041 {
00042
00043
00044
00045
00046
00047 if (label_.size()>0){
00048 sel_=new Selector( ModuleLabelSelector(label_));
00049 }
00050 else {
00051 sel_=new Selector( MatchAllSelector());
00052 }
00053
00054
00055
00056
00057
00058 HBHEdigiCollectionSig_ = ps.getParameter<edm::InputTag>("HBHEdigiCollectionSig");
00059 HOdigiCollectionSig_ = ps.getParameter<edm::InputTag>("HOdigiCollectionSig");
00060 HFdigiCollectionSig_ = ps.getParameter<edm::InputTag>("HFdigiCollectionSig");
00061 ZDCdigiCollectionSig_ = ps.getParameter<edm::InputTag>("ZDCdigiCollectionSig");
00062
00063 HBHEPileInputTag_ = ps.getParameter<edm::InputTag>("HBHEPileInputTag");
00064 HOPileInputTag_ = ps.getParameter<edm::InputTag>("HOPileInputTag");
00065 HFPileInputTag_ = ps.getParameter<edm::InputTag>("HFPileInputTag");
00066 ZDCPileInputTag_ = ps.getParameter<edm::InputTag>("ZDCPileInputTag");
00067
00068 DoZDC_ = false;
00069 if(ZDCPileInputTag_.label() != "") DoZDC_ = true;
00070
00071 HBHEDigiCollectionDM_ = ps.getParameter<std::string>("HBHEDigiCollectionDM");
00072 HODigiCollectionDM_ = ps.getParameter<std::string>("HODigiCollectionDM");
00073 HFDigiCollectionDM_ = ps.getParameter<std::string>("HFDigiCollectionDM");
00074 ZDCDigiCollectionDM_ = ps.getParameter<std::string>("ZDCDigiCollectionDM");
00075
00076
00077 }
00078
00079
00080 DataMixingHcalDigiWorker::~DataMixingHcalDigiWorker() {
00081 delete sel_;
00082 sel_=0;
00083 }
00084
00085 void DataMixingHcalDigiWorker::addHcalSignals(const edm::Event &e,const edm::EventSetup& ES) {
00086
00087
00088
00089 edm::ESHandle<HcalDbService> conditions;
00090 ES.get<HcalDbRecord>().get(conditions);
00091
00092 const HcalQIEShape* shape = conditions->getHcalShape ();
00093
00094
00095
00096
00097 LogInfo("DataMixingHcalDigiWorker")<<"===============> adding MC signals for "<<e.id();
00098
00099
00100
00101 Handle< HBHEDigiCollection > pHBHEDigis;
00102
00103 const HBHEDigiCollection* HBHEDigis = 0;
00104
00105 if( e.getByLabel( HBHEdigiCollectionSig_, pHBHEDigis) ) {
00106 HBHEDigis = pHBHEDigis.product();
00107 LogDebug("DataMixingHcalDigiWorker") << "total # HBHE digis: " << HBHEDigis->size();
00108 }
00109
00110
00111
00112 if (HBHEDigis)
00113 {
00114
00115 for(HBHEDigiCollection::const_iterator it = HBHEDigis->begin();
00116 it != HBHEDigis->end(); ++it) {
00117
00118
00119
00120 HcalDetId cell = it->id();
00121
00122 const HcalQIECoder* channelCoder = conditions->getHcalCoder (cell);
00123 HcalCoderDb coder (*channelCoder, *shape);
00124
00125 CaloSamples tool;
00126 coder.adc2fC((*it),tool);
00127
00128
00129
00130
00131
00132
00133
00134
00135 HBHEDigiStorage_.insert(HBHEDigiMap::value_type( ( it->id() ), tool ));
00136
00137 #ifdef DEBUG
00138 LogDebug("DataMixingHcalDigiWorker") << "processed HBHEDigi with rawId: "
00139 << it->id() << "\n"
00140 << " digi energy: " << it->energy();
00141 #endif
00142
00143 }
00144 }
00145
00146
00147
00148 Handle< HODigiCollection > pHODigis;
00149
00150 const HODigiCollection* HODigis = 0;
00151
00152 if( e.getByLabel( HOdigiCollectionSig_, pHODigis) ){
00153 HODigis = pHODigis.product();
00154 #ifdef DEBUG
00155 LogDebug("DataMixingHcalDigiWorker") << "total # HO digis: " << HODigis->size();
00156 #endif
00157 }
00158
00159
00160 if (HODigis)
00161 {
00162
00163 for(HODigiCollection::const_iterator it = HODigis->begin();
00164 it != HODigis->end(); ++it) {
00165
00166
00167 HcalDetId cell = it->id();
00168
00169 const HcalQIECoder* channelCoder = conditions->getHcalCoder (cell);
00170 HcalCoderDb coder (*channelCoder, *shape);
00171
00172 CaloSamples tool;
00173 coder.adc2fC((*it),tool);
00174
00175 HODigiStorage_.insert(HODigiMap::value_type( ( it->id() ), tool ));
00176
00177 #ifdef DEBUG
00178 LogDebug("DataMixingHcalDigiWorker") << "processed HODigi with rawId: "
00179 << it->id() << "\n"
00180 << " digi energy: " << it->energy();
00181 #endif
00182
00183 }
00184 }
00185
00186
00187
00188 Handle< HFDigiCollection > pHFDigis;
00189
00190 const HFDigiCollection* HFDigis = 0;
00191
00192 if( e.getByLabel( HFdigiCollectionSig_, pHFDigis) ) {
00193 HFDigis = pHFDigis.product();
00194 #ifdef DEBUG
00195 LogDebug("DataMixingHcalDigiWorker") << "total # HF digis: " << HFDigis->size();
00196 #endif
00197 }
00198
00199
00200 if (HFDigis)
00201 {
00202
00203 for(HFDigiCollection::const_iterator it = HFDigis->begin();
00204 it != HFDigis->end(); ++it) {
00205
00206
00207 HcalDetId cell = it->id();
00208
00209 const HcalQIECoder* channelCoder = conditions->getHcalCoder (cell);
00210 HcalCoderDb coder (*channelCoder, *shape);
00211
00212 CaloSamples tool;
00213 coder.adc2fC((*it),tool);
00214
00215 HFDigiStorage_.insert(HFDigiMap::value_type( ( it->id() ), tool ));
00216
00217 #ifdef DEBUG
00218 LogDebug("DataMixingHcalDigiWorker") << "processed HFDigi with rawId: "
00219 << it->id() << "\n"
00220 << " digi energy: " << it->energy();
00221 #endif
00222
00223 }
00224 }
00225
00226
00227
00228 Handle< ZDCDigiCollection > pZDCDigis;
00229
00230 const ZDCDigiCollection* ZDCDigis = 0;
00231
00232 if( e.getByLabel( ZDCdigiCollectionSig_, pZDCDigis) ) {
00233 ZDCDigis = pZDCDigis.product();
00234 #ifdef DEBUG
00235 LogDebug("DataMixingHcalDigiWorker") << "total # ZDC digis: " << ZDCDigis->size();
00236 #endif
00237 }
00238
00239
00240 if (ZDCDigis)
00241 {
00242
00243 for(ZDCDigiCollection::const_iterator it = ZDCDigis->begin();
00244 it != ZDCDigis->end(); ++it) {
00245
00246
00247 HcalDetId cell = it->id();
00248
00249 const HcalQIECoder* channelCoder = conditions->getHcalCoder (cell);
00250 HcalCoderDb coder (*channelCoder, *shape);
00251
00252 CaloSamples tool;
00253 coder.adc2fC((*it),tool);
00254
00255 ZDCDigiStorage_.insert(ZDCDigiMap::value_type( ( it->id() ), tool ));
00256
00257 #ifdef DEBUG
00258 LogDebug("DataMixingHcalDigiWorker") << "processed ZDCDigi with rawId: "
00259 << it->id() << "\n"
00260 << " digi energy: " << it->energy();
00261 #endif
00262
00263 }
00264 }
00265
00266 }
00267
00268 void DataMixingHcalDigiWorker::addHcalPileups(const int bcr, const EventPrincipal *ep, unsigned int eventNr,const edm::EventSetup& ES) {
00269
00270 LogDebug("DataMixingHcalDigiWorker") <<"\n===============> adding pileups from event "<<ep->id()<<" for bunchcrossing "<<bcr;
00271
00272
00273 edm::ESHandle<HcalDbService> conditions;
00274 ES.get<HcalDbRecord>().get(conditions);
00275
00276 const HcalQIEShape* shape = conditions->getHcalShape ();
00277
00278
00279
00280
00281
00282 boost::shared_ptr<Wrapper<HBHEDigiCollection> const> HBHEDigisPTR =
00283 getProductByTag<HBHEDigiCollection>(*ep, HBHEPileInputTag_ );
00284
00285 if(HBHEDigisPTR ) {
00286
00287 const HBHEDigiCollection* HBHEDigis = const_cast< HBHEDigiCollection * >(HBHEDigisPTR->product());
00288
00289 LogInfo("DataMixingHcalDigiWorker") << "total # HBHE digis: " << HBHEDigis->size();
00290
00291
00292 for(HBHEDigiCollection::const_iterator it = HBHEDigis->begin();
00293 it != HBHEDigis->end(); ++it) {
00294
00295
00296 HcalDetId cell = it->id();
00297
00298 const HcalQIECoder* channelCoder = conditions->getHcalCoder (cell);
00299 HcalCoderDb coder (*channelCoder, *shape);
00300
00301 CaloSamples tool;
00302 coder.adc2fC((*it),tool);
00303
00304 HBHEDigiStorage_.insert(HBHEDigiMap::value_type( (it->id()), tool ));
00305
00306 #ifdef DEBUG
00307 LogDebug("DataMixingHcalDigiWorker") << "processed HBHEDigi with rawId: "
00308 << it->id() << "\n"
00309 << " digi energy: " << it->energy();
00310 #endif
00311 }
00312 }
00313
00314
00315 boost::shared_ptr<Wrapper<HODigiCollection> const> HODigisPTR =
00316 getProductByTag<HODigiCollection>(*ep, HOPileInputTag_ );
00317
00318 if(HODigisPTR ) {
00319
00320 const HODigiCollection* HODigis = const_cast< HODigiCollection * >(HODigisPTR->product());
00321
00322 LogDebug("DataMixingHcalDigiWorker") << "total # HO digis: " << HODigis->size();
00323
00324
00325 for(HODigiCollection::const_iterator it = HODigis->begin();
00326 it != HODigis->end(); ++it) {
00327
00328
00329 HcalDetId cell = it->id();
00330
00331 const HcalQIECoder* channelCoder = conditions->getHcalCoder (cell);
00332 HcalCoderDb coder (*channelCoder, *shape);
00333
00334 CaloSamples tool;
00335 coder.adc2fC((*it),tool);
00336
00337 HODigiStorage_.insert(HODigiMap::value_type( (it->id()), tool ));
00338
00339 #ifdef DEBUG
00340 LogDebug("DataMixingHcalDigiWorker") << "processed HODigi with rawId: "
00341 << it->id() << "\n"
00342 << " digi energy: " << it->energy();
00343 #endif
00344 }
00345 }
00346
00347
00348
00349
00350 boost::shared_ptr<Wrapper<HFDigiCollection> const> HFDigisPTR =
00351 getProductByTag<HFDigiCollection>(*ep, HFPileInputTag_ );
00352
00353 if(HFDigisPTR ) {
00354
00355 const HFDigiCollection* HFDigis = const_cast< HFDigiCollection * >(HFDigisPTR->product());
00356
00357 LogDebug("DataMixingHcalDigiWorker") << "total # HF digis: " << HFDigis->size();
00358
00359
00360 for(HFDigiCollection::const_iterator it = HFDigis->begin();
00361 it != HFDigis->end(); ++it) {
00362
00363
00364 HcalDetId cell = it->id();
00365
00366 const HcalQIECoder* channelCoder = conditions->getHcalCoder (cell);
00367 HcalCoderDb coder (*channelCoder, *shape);
00368
00369 CaloSamples tool;
00370 coder.adc2fC((*it),tool);
00371
00372 HFDigiStorage_.insert(HFDigiMap::value_type( (it->id()), tool ));
00373
00374 #ifdef DEBUG
00375 LogDebug("DataMixingHcalDigiWorker") << "processed HFDigi with rawId: "
00376 << it->id() << "\n"
00377 << " digi energy: " << it->energy();
00378 #endif
00379 }
00380 }
00381
00382
00383
00384
00385 if(DoZDC_) {
00386
00387
00388 boost::shared_ptr<Wrapper<ZDCDigiCollection> const> ZDCDigisPTR =
00389 getProductByTag<ZDCDigiCollection>(*ep, ZDCPileInputTag_ );
00390
00391 if(ZDCDigisPTR ) {
00392
00393 const ZDCDigiCollection* ZDCDigis = const_cast< ZDCDigiCollection * >(ZDCDigisPTR->product());
00394
00395 LogDebug("DataMixingHcalDigiWorker") << "total # ZDC digis: " << ZDCDigis->size();
00396
00397
00398 for(ZDCDigiCollection::const_iterator it = ZDCDigis->begin();
00399 it != ZDCDigis->end(); ++it) {
00400
00401
00402 HcalDetId cell = it->id();
00403
00404 const HcalQIECoder* channelCoder = conditions->getHcalCoder (cell);
00405 HcalCoderDb coder (*channelCoder, *shape);
00406
00407 CaloSamples tool;
00408 coder.adc2fC((*it),tool);
00409
00410 ZDCDigiStorage_.insert(ZDCDigiMap::value_type( (it->id()), tool ));
00411
00412 #ifdef DEBUG
00413 LogDebug("DataMixingHcalDigiWorker") << "processed ZDCDigi with rawId: "
00414 << it->id() << "\n"
00415 << " digi energy: " << it->energy();
00416 #endif
00417 }
00418 }
00419 }
00420
00421
00422 }
00423
00424 void DataMixingHcalDigiWorker::putHcal(edm::Event &e,const edm::EventSetup& ES) {
00425
00426
00427 std::auto_ptr< HBHEDigiCollection > HBHEdigis( new HBHEDigiCollection );
00428 std::auto_ptr< HODigiCollection > HOdigis( new HODigiCollection );
00429 std::auto_ptr< HFDigiCollection > HFdigis( new HFDigiCollection );
00430 std::auto_ptr< ZDCDigiCollection > ZDCdigis( new ZDCDigiCollection );
00431
00432
00433 edm::ESHandle<HcalDbService> conditions;
00434 ES.get<HcalDbRecord>().get(conditions);
00435
00436
00437 const HcalQIEShape* shape = conditions->getHcalShape ();
00438
00439
00440 DetId formerID = 0;
00441 DetId currentID;
00442
00443 CaloSamples HB_old;
00444
00445 double fC_new;
00446 double fC_old;
00447 double fC_sum;
00448
00449
00450
00451 HBHEDigiMap::const_iterator iHBchk;
00452
00453 for(HBHEDigiMap::const_iterator iHB = HBHEDigiStorage_.begin();
00454 iHB != HBHEDigiStorage_.end(); ++iHB) {
00455
00456 currentID = iHB->first;
00457
00458 if (currentID == formerID) {
00459
00460
00461
00462 unsigned int sizenew = (iHB->second).size();
00463 unsigned int sizeold = HB_old.size();
00464
00465 bool usenew = false;
00466
00467 if(sizenew > sizeold) usenew = true;
00468
00469 unsigned int max_samp = std::max(sizenew, sizeold);
00470
00471 CaloSamples HB_bigger(currentID,max_samp);
00472
00473
00474
00475
00476
00477
00478 for(unsigned int isamp = 0; isamp<max_samp; isamp++) {
00479 if(isamp < sizenew) {
00480 fC_new = (iHB->second)[isamp];
00481 }
00482 else { fC_new = 0;}
00483
00484 if(isamp < sizeold) {
00485 fC_old = HB_old[isamp];
00486 }
00487 else { fC_old = 0;}
00488
00489
00490 fC_sum = fC_new + fC_old;
00491
00492
00493
00494
00495
00496 if(usenew) {HB_bigger[isamp] = fC_sum; }
00497 else { HB_old[isamp] = fC_sum; }
00498
00499 }
00500 if(usenew) HB_old = HB_bigger;
00501
00502 }
00503 else {
00504 if(formerID>0) {
00505
00506 HBHEdigis->push_back(HBHEDataFrame(formerID));
00507
00508
00509
00510 HcalDetId cell = HB_old.id();
00511 const HcalQIECoder* channelCoder = conditions->getHcalCoder (cell);
00512 HcalCoderDb coder (*channelCoder, *shape);
00513
00514 unsigned int sizeold = HB_old.size();
00515 for(unsigned int isamp = 0; isamp<sizeold; isamp++) {
00516 coder.fC2adc(HB_old,(HBHEdigis->back()), 0 );
00517 }
00518 }
00519
00520 formerID = currentID;
00521 HB_old = iHB->second;
00522
00523 }
00524
00525 iHBchk = iHB;
00526 if((++iHBchk) == HBHEDigiStorage_.end()) {
00527
00528
00529 HBHEdigis->push_back(HBHEDataFrame(currentID));
00530
00531
00532
00533 HcalDetId cell = (iHB->second).id();
00534 const HcalQIECoder* channelCoder = conditions->getHcalCoder (cell);
00535 HcalCoderDb coder (*channelCoder, *shape);
00536
00537 unsigned int sizenew = (iHB->second).size();
00538 for(unsigned int isamp = 0; isamp<sizenew; isamp++) {
00539 coder.fC2adc(HB_old,(HBHEdigis->back()), 0 );
00540 }
00541 }
00542 }
00543
00544
00545
00546
00547
00548 formerID = 0;
00549 CaloSamples HO_old;
00550
00551 HODigiMap::const_iterator iHOchk;
00552
00553 for(HODigiMap::const_iterator iHO = HODigiStorage_.begin();
00554 iHO != HODigiStorage_.end(); ++iHO) {
00555
00556 currentID = iHO->first;
00557
00558 if (currentID == formerID) {
00559
00560
00561 unsigned int sizenew = (iHO->second).size();
00562 unsigned int sizeold = HO_old.size();
00563
00564 unsigned int max_samp = std::max(sizenew, sizeold);
00565
00566 CaloSamples HO_bigger(currentID,max_samp);
00567
00568 bool usenew = false;
00569
00570 if(sizenew > sizeold) usenew = true;
00571
00572
00573
00574
00575 for(unsigned int isamp = 0; isamp<max_samp; isamp++) {
00576 if(isamp < sizenew) {
00577 fC_new = (iHO->second)[isamp];
00578 }
00579 else { fC_new = 0;}
00580
00581 if(isamp < sizeold) {
00582 fC_old = HO_old[isamp];
00583 }
00584 else { fC_old = 0;}
00585
00586
00587 fC_sum = fC_new + fC_old;
00588
00589 if(usenew) {HO_bigger[isamp] = fC_sum; }
00590 else { HO_old[isamp] = fC_sum; }
00591
00592 }
00593 if(usenew) HO_old = HO_bigger;
00594
00595 }
00596 else {
00597 if(formerID>0) {
00598
00599 HOdigis->push_back(HODataFrame(formerID));
00600
00601
00602
00603 HcalDetId cell = HO_old.id();
00604 const HcalQIECoder* channelCoder = conditions->getHcalCoder (cell);
00605 HcalCoderDb coder (*channelCoder, *shape);
00606
00607 unsigned int sizeold = HO_old.size();
00608 for(unsigned int isamp = 0; isamp<sizeold; isamp++) {
00609 coder.fC2adc(HO_old,(HOdigis->back()), 0 );
00610 }
00611 }
00612
00613 formerID = currentID;
00614 HO_old = iHO->second;
00615 }
00616
00617 iHOchk = iHO;
00618 if((++iHOchk) == HODigiStorage_.end()) {
00619
00620 HOdigis->push_back(HODataFrame(currentID));
00621
00622
00623
00624 HcalDetId cell = (iHO->second).id();
00625 const HcalQIECoder* channelCoder = conditions->getHcalCoder (cell);
00626 HcalCoderDb coder (*channelCoder, *shape);
00627
00628 unsigned int sizeold = (iHO->second).size();
00629 for(unsigned int isamp = 0; isamp<sizeold; isamp++) {
00630 coder.fC2adc(HO_old,(HOdigis->back()), 0 );
00631 }
00632
00633 }
00634 }
00635
00636
00637
00638
00639 formerID = 0;
00640 CaloSamples HF_old;
00641
00642 HFDigiMap::const_iterator iHFchk;
00643
00644 for(HFDigiMap::const_iterator iHF = HFDigiStorage_.begin();
00645 iHF != HFDigiStorage_.end(); ++iHF) {
00646
00647 currentID = iHF->first;
00648
00649 if (currentID == formerID) {
00650
00651
00652 unsigned int sizenew = (iHF->second).size();
00653 unsigned int sizeold = HF_old.size();
00654
00655 unsigned int max_samp = std::max(sizenew, sizeold);
00656
00657 CaloSamples HF_bigger(currentID,max_samp);
00658
00659 bool usenew = false;
00660
00661 if(sizenew > sizeold) usenew = true;
00662
00663
00664
00665
00666 for(unsigned int isamp = 0; isamp<max_samp; isamp++) {
00667 if(isamp < sizenew) {
00668 fC_new = (iHF->second)[isamp];
00669 }
00670 else { fC_new = 0;}
00671
00672 if(isamp < sizeold) {
00673 fC_old = HF_old[isamp];
00674 }
00675 else { fC_old = 0;}
00676
00677
00678 fC_sum = fC_new + fC_old;
00679
00680 if(usenew) {HF_bigger[isamp] = fC_sum; }
00681 else { HF_old[isamp] = fC_sum; }
00682
00683 }
00684 if(usenew) HF_old = HF_bigger;
00685
00686 }
00687 else {
00688 if(formerID>0) {
00689
00690 HFdigis->push_back(HFDataFrame(formerID));
00691
00692
00693
00694 HcalDetId cell = HF_old.id();
00695 const HcalQIECoder* channelCoder = conditions->getHcalCoder (cell);
00696 HcalCoderDb coder (*channelCoder, *shape);
00697
00698 unsigned int sizeold = HF_old.size();
00699 for(unsigned int isamp = 0; isamp<sizeold; isamp++) {
00700 coder.fC2adc(HF_old,(HFdigis->back()), 0 );
00701 }
00702 }
00703
00704 formerID = currentID;
00705 HF_old = iHF->second;
00706 }
00707
00708 iHFchk = iHF;
00709 if((++iHFchk) == HFDigiStorage_.end()) {
00710
00711 HFdigis->push_back(HFDataFrame(currentID));
00712
00713
00714
00715 HcalDetId cell = (iHF->second).id();
00716 const HcalQIECoder* channelCoder = conditions->getHcalCoder (cell);
00717 HcalCoderDb coder (*channelCoder, *shape);
00718
00719 unsigned int sizeold = (iHF->second).size();
00720 for(unsigned int isamp = 0; isamp<sizeold; isamp++) {
00721 coder.fC2adc(HF_old,(HFdigis->back()), 0 );
00722 }
00723
00724 }
00725 }
00726
00727
00728
00729
00730
00731 formerID = 0;
00732 CaloSamples ZDC_old;
00733
00734 ZDCDigiMap::const_iterator iZDCchk;
00735
00736 for(ZDCDigiMap::const_iterator iZDC = ZDCDigiStorage_.begin();
00737 iZDC != ZDCDigiStorage_.end(); ++iZDC) {
00738
00739 currentID = iZDC->first;
00740
00741 if (currentID == formerID) {
00742
00743
00744 unsigned int sizenew = (iZDC->second).size();
00745 unsigned int sizeold = ZDC_old.size();
00746
00747 unsigned int max_samp = std::max(sizenew, sizeold);
00748
00749 CaloSamples ZDC_bigger(currentID,max_samp);
00750
00751 bool usenew = false;
00752
00753 if(sizenew > sizeold) usenew = true;
00754
00755
00756
00757
00758 for(unsigned int isamp = 0; isamp<max_samp; isamp++) {
00759 if(isamp < sizenew) {
00760 fC_new = (iZDC->second)[isamp];
00761 }
00762 else { fC_new = 0;}
00763
00764 if(isamp < sizeold) {
00765 fC_old = ZDC_old[isamp];
00766 }
00767 else { fC_old = 0;}
00768
00769
00770 fC_sum = fC_new + fC_old;
00771
00772 if(usenew) {ZDC_bigger[isamp] = fC_sum; }
00773 else { ZDC_old[isamp] = fC_sum; }
00774
00775 }
00776 if(usenew) ZDC_old = ZDC_bigger;
00777
00778 }
00779 else {
00780 if(formerID>0) {
00781
00782 ZDCdigis->push_back(ZDCDataFrame(formerID));
00783
00784
00785
00786 HcalDetId cell = ZDC_old.id();
00787 const HcalQIECoder* channelCoder = conditions->getHcalCoder (cell);
00788 HcalCoderDb coder (*channelCoder, *shape);
00789
00790 unsigned int sizeold = ZDC_old.size();
00791 for(unsigned int isamp = 0; isamp<sizeold; isamp++) {
00792 coder.fC2adc(ZDC_old,(ZDCdigis->back()), 0 );
00793 }
00794 }
00795
00796 formerID = currentID;
00797 ZDC_old = iZDC->second;
00798 }
00799
00800 iZDCchk = iZDC;
00801 if((++iZDCchk) == ZDCDigiStorage_.end()) {
00802
00803 ZDCdigis->push_back(ZDCDataFrame(currentID));
00804
00805
00806
00807 HcalDetId cell = (iZDC->second).id();
00808 const HcalQIECoder* channelCoder = conditions->getHcalCoder (cell);
00809 HcalCoderDb coder (*channelCoder, *shape);
00810
00811 unsigned int sizeold = (iZDC->second).size();
00812 for(unsigned int isamp = 0; isamp<sizeold; isamp++) {
00813 coder.fC2adc(ZDC_old,(ZDCdigis->back()), 0 );
00814 }
00815
00816 }
00817 }
00818
00819
00820
00821
00822
00823
00824 LogInfo("DataMixingHcalDigiWorker") << "total # HBHE Merged digis: " << HBHEdigis->size() ;
00825 LogInfo("DataMixingHcalDigiWorker") << "total # HO Merged digis: " << HOdigis->size() ;
00826 LogInfo("DataMixingHcalDigiWorker") << "total # HF Merged digis: " << HFdigis->size() ;
00827 LogInfo("DataMixingHcalDigiWorker") << "total # ZDC Merged digis: " << ZDCdigis->size() ;
00828
00829 e.put( HBHEdigis, HBHEDigiCollectionDM_ );
00830 e.put( HOdigis, HODigiCollectionDM_ );
00831 e.put( HFdigis, HFDigiCollectionDM_ );
00832 e.put( ZDCdigis, ZDCDigiCollectionDM_ );
00833
00834
00835 HBHEDigiStorage_.clear();
00836 HODigiStorage_.clear();
00837 HFDigiStorage_.clear();
00838 ZDCDigiStorage_.clear();
00839
00840 }
00841
00842 }