00001
00010 #include "Validation/GlobalDigis/interface/GlobalDigisProducer.h"
00011 #include "DataFormats/TrackerCommon/interface/TrackerTopology.h"
00012 #include "Geometry/Records/interface/IdealGeometryRecord.h"
00013
00014 GlobalDigisProducer::GlobalDigisProducer(const edm::ParameterSet& iPSet) :
00015 fName(""), verbosity(0), frequency(0), label(""), getAllProvenances(false),
00016 printProvenanceInfo(false), theCSCStripPedestalSum(0),
00017 theCSCStripPedestalCount(0), count(0)
00018 {
00019 std::string MsgLoggerCat = "GlobalDigisProducer_GlobalDigisProducer";
00020
00021
00022 fName = iPSet.getUntrackedParameter<std::string>("Name");
00023 verbosity = iPSet.getUntrackedParameter<int>("Verbosity");
00024 frequency = iPSet.getUntrackedParameter<int>("Frequency");
00025 label = iPSet.getParameter<std::string>("Label");
00026 edm::ParameterSet m_Prov =
00027 iPSet.getParameter<edm::ParameterSet>("ProvenanceLookup");
00028 getAllProvenances =
00029 m_Prov.getUntrackedParameter<bool>("GetAllProvenances");
00030 printProvenanceInfo =
00031 m_Prov.getUntrackedParameter<bool>("PrintProvenanceInfo");
00032
00033
00034 ECalEBSrc_ = iPSet.getParameter<edm::InputTag>("ECalEBSrc");
00035 ECalEESrc_ = iPSet.getParameter<edm::InputTag>("ECalEESrc");
00036 ECalESSrc_ = iPSet.getParameter<edm::InputTag>("ECalESSrc");
00037 HCalSrc_ = iPSet.getParameter<edm::InputTag>("HCalSrc");
00038 HCalDigi_ = iPSet.getParameter<edm::InputTag>("HCalDigi");
00039 SiStripSrc_ = iPSet.getParameter<edm::InputTag>("SiStripSrc");
00040 SiPxlSrc_ = iPSet.getParameter<edm::InputTag>("SiPxlSrc");
00041 MuDTSrc_ = iPSet.getParameter<edm::InputTag>("MuDTSrc");
00042 MuCSCStripSrc_ = iPSet.getParameter<edm::InputTag>("MuCSCStripSrc");
00043 MuCSCWireSrc_ = iPSet.getParameter<edm::InputTag>("MuCSCWireSrc");
00044
00045
00046
00047 verbosity %= 10;
00048
00049
00050 produces<PGlobalDigi>(label);
00051
00052
00053 if (verbosity >= 0) {
00054 edm::LogInfo(MsgLoggerCat)
00055 << "\n===============================\n"
00056 << "Initialized as EDProducer with parameter values:\n"
00057 << " Name = " << fName << "\n"
00058 << " Verbosity = " << verbosity << "\n"
00059 << " Frequency = " << frequency << "\n"
00060 << " Label = " << label << "\n"
00061 << " GetProv = " << getAllProvenances << "\n"
00062 << " PrintProv = " << printProvenanceInfo << "\n"
00063 << " ECalEBSrc = " << ECalEBSrc_.label()
00064 << ":" << ECalEBSrc_.instance() << "\n"
00065 << " ECalEESrc = " << ECalEESrc_.label()
00066 << ":" << ECalEESrc_.instance() << "\n"
00067 << " ECalESSrc = " << ECalESSrc_.label()
00068 << ":" << ECalESSrc_.instance() << "\n"
00069 << " HCalSrc = " << HCalSrc_.label()
00070 << ":" << HCalSrc_.instance() << "\n"
00071 << " HCalDigi = " << HCalDigi_.label()
00072 << ":" << HCalDigi_.instance() << "\n"
00073 << " SiStripSrc = " << SiStripSrc_.label()
00074 << ":" << SiStripSrc_.instance() << "\n"
00075 << " SiPixelSrc = " << SiPxlSrc_.label()
00076 << ":" << SiPxlSrc_.instance() << "\n"
00077 << " MuDTSrc = " << MuDTSrc_.label()
00078 << ":" << MuDTSrc_.instance() << "\n"
00079 << " MuCSCStripSrc = " << MuCSCStripSrc_.label()
00080 << ":" << MuCSCStripSrc_.instance() << "\n"
00081 << " MuCSCWireSrc = " << MuCSCWireSrc_.label()
00082 << ":" << MuCSCWireSrc_.instance() << "\n"
00083 << "===============================\n";
00084 }
00085
00086
00087
00088 ECalgainConv_[0] = 0.;
00089 ECalgainConv_[1] = 1.;
00090 ECalgainConv_[2] = 2.;
00091 ECalgainConv_[3] = 12.;
00092 ECalbarrelADCtoGeV_ = 0.035;
00093 ECalendcapADCtoGeV_ = 0.06;
00094
00095 }
00096
00097 GlobalDigisProducer::~GlobalDigisProducer()
00098 {
00099 }
00100
00101 void GlobalDigisProducer::beginJob( void )
00102 {
00103 std::string MsgLoggerCat = "GlobalDigisProducer_beginJob";
00104
00105
00106
00107
00108
00109
00110 EcalMGPAGainRatio * defaultRatios = new EcalMGPAGainRatio();
00111
00112 ECalgainConv_[0] = 0.;
00113 ECalgainConv_[1] = 1.;
00114 ECalgainConv_[2] = defaultRatios->gain12Over6() ;
00115 ECalgainConv_[3] = ECalgainConv_[2]*(defaultRatios->gain6Over1()) ;
00116
00117 delete defaultRatios;
00118
00119
00120
00121
00122 if (verbosity >= 0) {
00123 edm::LogInfo(MsgLoggerCat)
00124 << "Modified Calorimeter gain constants: g0 = " << ECalgainConv_[0]
00125 << ", g1 = " << ECalgainConv_[1] << ", g2 = " << ECalgainConv_[2]
00126 << ", g3 = " << ECalgainConv_[3];
00127
00128
00129
00130 }
00131
00132
00133 clear();
00134 return;
00135 }
00136
00137 void GlobalDigisProducer::endJob()
00138 {
00139 std::string MsgLoggerCat = "GlobalDigisProducer_endJob";
00140 if (verbosity >= 0)
00141 edm::LogInfo(MsgLoggerCat)
00142 << "Terminating having processed " << count << " events.";
00143 return;
00144 }
00145
00146 void GlobalDigisProducer::produce(edm::Event& iEvent,
00147 const edm::EventSetup& iSetup)
00148 {
00149 std::string MsgLoggerCat = "GlobalDigisProducer_produce";
00150
00151
00152 ++count;
00153
00154
00155
00156
00157 edm::ESHandle<EcalADCToGeVConstant> pAgc;
00158 iSetup.get<EcalADCToGeVConstantRcd>().get(pAgc);
00159 const EcalADCToGeVConstant* agc = pAgc.product();
00160 ECalbarrelADCtoGeV_ = agc->getEBValue();
00161 ECalendcapADCtoGeV_ = agc->getEEValue();
00162 if (verbosity >= 0) {
00163 edm::LogInfo(MsgLoggerCat)
00164 << "Modified Calorimeter ADCtoGeV constants: barrel = "
00165 << ECalbarrelADCtoGeV_ << ", endcap = " << ECalendcapADCtoGeV_;
00166 }
00167
00168
00169
00170 int nrun = iEvent.id().run();
00171 int nevt = iEvent.id().event();
00172
00173 if (verbosity > 0) {
00174 edm::LogInfo(MsgLoggerCat)
00175 << "Processing run " << nrun << ", event " << nevt
00176 << " (" << count << " events total)";
00177 } else if (verbosity == 0) {
00178 if (nevt%frequency == 0 || nevt == 1) {
00179 edm::LogInfo(MsgLoggerCat)
00180 << "Processing run " << nrun << ", event " << nevt
00181 << " (" << count << " events total)";
00182 }
00183 }
00184
00185
00186 clear();
00187
00188
00189 if (getAllProvenances) {
00190
00191 std::vector<const edm::Provenance*> AllProv;
00192 iEvent.getAllProvenance(AllProv);
00193
00194 if (verbosity >= 0)
00195 edm::LogInfo(MsgLoggerCat)
00196 << "Number of Provenances = " << AllProv.size();
00197
00198 if (printProvenanceInfo && (verbosity >= 0)) {
00199 TString eventout("\nProvenance info:\n");
00200
00201 for (unsigned int i = 0; i < AllProv.size(); ++i) {
00202 eventout += "\n ******************************";
00203 eventout += "\n Module : ";
00204
00205 eventout += AllProv[i]->moduleLabel();
00206 eventout += "\n ProductID : ";
00207
00208 eventout += AllProv[i]->productID().id();
00209 eventout += "\n ClassName : ";
00210
00211 eventout += AllProv[i]->className();
00212 eventout += "\n InstanceName : ";
00213
00214 eventout += AllProv[i]->productInstanceName();
00215 eventout += "\n BranchName : ";
00216
00217 eventout += AllProv[i]->branchName();
00218 }
00219 eventout += "\n ******************************\n";
00220 edm::LogInfo(MsgLoggerCat) << eventout << "\n";
00221 printProvenanceInfo = false;
00222 }
00223 getAllProvenances = false;
00224 }
00225
00226
00227
00228 fillECal(iEvent, iSetup);
00229
00230 fillHCal(iEvent, iSetup);
00231
00232 fillTrk(iEvent, iSetup);
00233
00234 fillMuon(iEvent, iSetup);
00235
00236 if (verbosity > 0)
00237 edm::LogInfo (MsgLoggerCat)
00238 << "Done gathering data from event.";
00239
00240
00241 std::auto_ptr<PGlobalDigi> pOut(new PGlobalDigi);
00242
00243 if (verbosity > 2)
00244 edm::LogInfo (MsgLoggerCat)
00245 << "Saving event contents:";
00246
00247
00248
00249 storeECal(*pOut);
00250
00251 storeHCal(*pOut);
00252
00253 storeTrk(*pOut);
00254
00255 storeMuon(*pOut);
00256
00257
00258 iEvent.put(pOut,label);
00259
00260 return;
00261 }
00262
00263 void GlobalDigisProducer::fillECal(edm::Event& iEvent,
00264 const edm::EventSetup& iSetup)
00265 {
00266 std::string MsgLoggerCat = "GlobalDigisProducer_fillECal";
00267
00268 TString eventout;
00269 if (verbosity > 0)
00270 eventout = "\nGathering info:";
00271
00272
00273
00274 edm::Handle<CrossingFrame<PCaloHit> > crossingFrame;
00275
00276
00277
00278
00279
00280
00281
00283
00285 bool isBarrel = true;
00286 edm::Handle<EBDigiCollection> EcalDigiEB;
00287 iEvent.getByLabel(ECalEBSrc_, EcalDigiEB);
00288 if (!EcalDigiEB.isValid()) {
00289 edm::LogWarning(MsgLoggerCat)
00290 << "Unable to find EcalDigiEB in event!";
00291 return;
00292 }
00293 if ( EcalDigiEB->size() == 0) isBarrel = false;
00294
00295 if (isBarrel) {
00296
00297
00298 const std::string barrelHitsName("EcalHitsEB");
00299 iEvent.getByLabel("mix",barrelHitsName,crossingFrame);
00300 if (!crossingFrame.isValid()) {
00301 edm::LogWarning(MsgLoggerCat)
00302 << "Unable to find cal barrel crossingFrame in event!";
00303 return;
00304 }
00305
00306
00307
00308 std::auto_ptr<MixCollection<PCaloHit> >
00309 barrelHits(new MixCollection<PCaloHit>(crossingFrame.product()));
00310
00311
00312 MapType ebSimMap;
00313 for (MixCollection<PCaloHit>::MixItr hitItr
00314 = barrelHits->begin();
00315 hitItr != barrelHits->end();
00316 ++hitItr) {
00317
00318 EBDetId ebid = EBDetId(hitItr->id());
00319
00320 uint32_t crystid = ebid.rawId();
00321 ebSimMap[crystid] += hitItr->energy();
00322 }
00323
00324
00325 const EBDigiCollection *barrelDigi = EcalDigiEB.product();
00326
00327 std::vector<double> ebAnalogSignal;
00328 std::vector<double> ebADCCounts;
00329 std::vector<double> ebADCGains;
00330 ebAnalogSignal.reserve(EBDataFrame::MAXSAMPLES);
00331 ebADCCounts.reserve(EBDataFrame::MAXSAMPLES);
00332 ebADCGains.reserve(EBDataFrame::MAXSAMPLES);
00333
00334 int i = 0;
00335 for (unsigned int digis=0; digis<EcalDigiEB->size(); ++digis)
00336 {
00337
00338
00339
00340
00341
00342 ++i;
00343
00344 EBDataFrame ebdf = (*barrelDigi)[digis];
00345 int nrSamples = ebdf.size();
00346
00347 EBDetId ebid = ebdf.id () ;
00348
00349
00350 double Emax = 0;
00351 int Pmax = 0;
00352 double pedestalPreSample = 0.;
00353 double pedestalPreSampleAnalog = 0.;
00354
00355 for (int sample = 0 ; sample < nrSamples; ++sample) {
00356
00357 ebAnalogSignal[sample] = 0.;
00358 ebADCCounts[sample] = 0.;
00359 ebADCGains[sample] = -1.;
00360 }
00361
00362
00363 for (int sample = 0 ; sample < nrSamples; ++sample) {
00364
00365
00366 EcalMGPASample thisSample = ebdf[sample];
00367 ebADCCounts[sample] = (thisSample.adc());
00368 ebADCGains[sample] = (thisSample.gainId());
00369 ebAnalogSignal[sample] =
00370 (ebADCCounts[sample] * ECalgainConv_[(int)ebADCGains[sample]]
00371 * ECalbarrelADCtoGeV_);
00372 if (Emax < ebAnalogSignal[sample]) {
00373 Emax = ebAnalogSignal[sample];
00374 Pmax = sample;
00375 }
00376 if ( sample < 3 ) {
00377 pedestalPreSample += ebADCCounts[sample] ;
00378 pedestalPreSampleAnalog +=
00379 ebADCCounts[sample] * ECalgainConv_[(int)ebADCGains[sample]]
00380 * ECalbarrelADCtoGeV_ ;
00381 }
00382
00383 }
00384 pedestalPreSample /= 3. ;
00385 pedestalPreSampleAnalog /= 3. ;
00386
00387
00388 double Erec = Emax - pedestalPreSampleAnalog
00389 * ECalgainConv_[(int)ebADCGains[Pmax]];
00390
00391
00392 EBCalAEE.push_back(Erec);
00393 EBCalSHE.push_back(ebSimMap[ebid.rawId()]);
00394 EBCalmaxPos.push_back(Pmax);
00395 }
00396
00397 if (verbosity > 1) {
00398 eventout += "\n Number of EBDigis collected:.............. ";
00399 eventout += i;
00400 }
00401 }
00402
00404
00406 bool isEndCap = true;
00407 edm::Handle<EEDigiCollection> EcalDigiEE;
00408 iEvent.getByLabel(ECalEESrc_, EcalDigiEE);
00409 if (!EcalDigiEE.isValid()) {
00410 edm::LogWarning(MsgLoggerCat)
00411 << "Unable to find EcalDigiEE in event!";
00412 return;
00413 }
00414 if (EcalDigiEE->size() == 0) isEndCap = false;
00415
00416 if (isEndCap) {
00417
00418
00419 const std::string endcapHitsName("EcalHitsEE");
00420 iEvent.getByLabel("mix",endcapHitsName,crossingFrame);
00421 if (!crossingFrame.isValid()) {
00422 edm::LogWarning(MsgLoggerCat)
00423 << "Unable to find cal endcap crossingFrame in event!";
00424 return;
00425 }
00426
00427
00428
00429 std::auto_ptr<MixCollection<PCaloHit> >
00430 endcapHits(new MixCollection<PCaloHit>(crossingFrame.product()));
00431
00432
00433 MapType eeSimMap;
00434 for (MixCollection<PCaloHit>::MixItr hitItr
00435 = endcapHits->begin();
00436 hitItr != endcapHits->end();
00437 ++hitItr) {
00438
00439 EEDetId eeid = EEDetId(hitItr->id());
00440
00441 uint32_t crystid = eeid.rawId();
00442 eeSimMap[crystid] += hitItr->energy();
00443 }
00444
00445
00446 const EEDigiCollection *endcapDigi = EcalDigiEE.product();
00447
00448 std::vector<double> eeAnalogSignal;
00449 std::vector<double> eeADCCounts;
00450 std::vector<double> eeADCGains;
00451 eeAnalogSignal.reserve(EEDataFrame::MAXSAMPLES);
00452 eeADCCounts.reserve(EEDataFrame::MAXSAMPLES);
00453 eeADCGains.reserve(EEDataFrame::MAXSAMPLES);
00454
00455 int i = 0;
00456
00457
00458
00459
00460 for (unsigned int digis=0; digis<EcalDigiEE->size(); ++digis){
00461
00462 ++i;
00463
00464 EEDataFrame eedf = (*endcapDigi)[digis];
00465 int nrSamples = eedf.size();
00466
00467 EEDetId eeid = eedf.id () ;
00468
00469
00470 double Emax = 0;
00471 int Pmax = 0;
00472 double pedestalPreSample = 0.;
00473 double pedestalPreSampleAnalog = 0.;
00474
00475 for (int sample = 0 ; sample < nrSamples; ++sample) {
00476
00477 eeAnalogSignal[sample] = 0.;
00478 eeADCCounts[sample] = 0.;
00479 eeADCGains[sample] = -1.;
00480 }
00481
00482
00483 for (int sample = 0 ; sample < nrSamples; ++sample) {
00484
00485
00486 EcalMGPASample thisSample = eedf[sample];
00487
00488 eeADCCounts[sample] = (thisSample.adc());
00489 eeADCGains[sample] = (thisSample.gainId());
00490 eeAnalogSignal[sample] =
00491 (eeADCCounts[sample] * ECalgainConv_[(int)eeADCGains[sample]]
00492 * ECalbarrelADCtoGeV_);
00493 if (Emax < eeAnalogSignal[sample]) {
00494 Emax = eeAnalogSignal[sample];
00495 Pmax = sample;
00496 }
00497 if ( sample < 3 ) {
00498 pedestalPreSample += eeADCCounts[sample] ;
00499 pedestalPreSampleAnalog +=
00500 eeADCCounts[sample] * ECalgainConv_[(int)eeADCGains[sample]]
00501 * ECalbarrelADCtoGeV_ ;
00502 }
00503
00504 }
00505 pedestalPreSample /= 3. ;
00506 pedestalPreSampleAnalog /= 3. ;
00507
00508
00509 double Erec = Emax - pedestalPreSampleAnalog
00510 * ECalgainConv_[(int)eeADCGains[Pmax]];
00511
00512
00513 EECalAEE.push_back(Erec);
00514 EECalSHE.push_back(eeSimMap[eeid.rawId()]);
00515 EECalmaxPos.push_back(Pmax);
00516 }
00517
00518 if (verbosity > 1) {
00519 eventout += "\n Number of EEDigis collected:.............. ";
00520 eventout += i;
00521 }
00522 }
00523
00525
00527 bool isPreshower = true;
00528 edm::Handle<ESDigiCollection> EcalDigiES;
00529 iEvent.getByLabel(ECalESSrc_, EcalDigiES);
00530 if (!EcalDigiES.isValid()) {
00531 edm::LogWarning(MsgLoggerCat)
00532 << "Unable to find EcalDigiES in event!";
00533 return;
00534 }
00535 if (EcalDigiES->size() == 0) isPreshower = false;
00536
00537 if (isPreshower) {
00538
00539
00540 const std::string preshowerHitsName("EcalHitsES");
00541 iEvent.getByLabel("mix",preshowerHitsName,crossingFrame);
00542 if (!crossingFrame.isValid()) {
00543 edm::LogWarning(MsgLoggerCat)
00544 << "Unable to find cal preshower crossingFrame in event!";
00545 return;
00546 }
00547
00548
00549
00550 std::auto_ptr<MixCollection<PCaloHit> >
00551 preshowerHits(new MixCollection<PCaloHit>(crossingFrame.product()));
00552
00553
00554 MapType esSimMap;
00555 for (MixCollection<PCaloHit>::MixItr hitItr
00556 = preshowerHits->begin();
00557 hitItr != preshowerHits->end();
00558 ++hitItr) {
00559
00560 ESDetId esid = ESDetId(hitItr->id());
00561
00562 uint32_t crystid = esid.rawId();
00563 esSimMap[crystid] += hitItr->energy();
00564 }
00565
00566
00567 const ESDigiCollection *preshowerDigi = EcalDigiES.product();
00568
00569 std::vector<double> esADCCounts;
00570 esADCCounts.reserve(ESDataFrame::MAXSAMPLES);
00571
00572 int i = 0;
00573 for (unsigned int digis=0; digis<EcalDigiES->size(); ++digis) {
00574
00575
00576
00577
00578
00579 ++i;
00580
00581
00582 ESDataFrame esdf = (*preshowerDigi)[digis];
00583 int nrSamples = esdf.size();
00584
00585 ESDetId esid = esdf.id () ;
00586
00587
00588 for (int sample = 0 ; sample < nrSamples; ++sample) {
00589
00590 esADCCounts[sample] = 0.;
00591 }
00592
00593
00594 for (int sample = 0 ; sample < nrSamples; ++sample) {
00595
00596 ESSample thisSample = esdf[sample];
00597
00598 esADCCounts[sample] = (thisSample.adc());
00599 }
00600
00601 ESCalADC0.push_back(esADCCounts[0]);
00602 ESCalADC1.push_back(esADCCounts[1]);
00603 ESCalADC2.push_back(esADCCounts[2]);
00604 ESCalSHE.push_back(esSimMap[esid.rawId()]);
00605 }
00606
00607 if (verbosity > 1) {
00608 eventout += "\n Number of ESDigis collected:.............. ";
00609 eventout += i;
00610 }
00611 }
00612
00613 if (verbosity > 0)
00614 edm::LogInfo(MsgLoggerCat) << eventout << "\n";
00615
00616 return;
00617 }
00618
00619 void GlobalDigisProducer::storeECal(PGlobalDigi& product)
00620 {
00621 std::string MsgLoggerCat = "GlobalDigisProducer_storeECal";
00622
00623 if (verbosity > 2) {
00624 TString eventout("\n nEBDigis = ");
00625 eventout += EBCalmaxPos.size();
00626 for (unsigned int i = 0; i < EBCalmaxPos.size(); ++i) {
00627 eventout += "\n (maxPos, AEE, SHE) = (";
00628 eventout += EBCalmaxPos[i];
00629 eventout += ", ";
00630 eventout += EBCalAEE[i];
00631 eventout += ", ";
00632 eventout += EBCalSHE[i];
00633 eventout += ")";
00634 }
00635 eventout += "\n nEEDigis = ";
00636 eventout += EECalmaxPos.size();
00637 for (unsigned int i = 0; i < EECalmaxPos.size(); ++i) {
00638 eventout += "\n (maxPos, AEE, SHE) = (";
00639 eventout += EECalmaxPos[i];
00640 eventout += ", ";
00641 eventout += EECalAEE[i];
00642 eventout += ", ";
00643 eventout += EECalSHE[i];
00644 eventout += ")";
00645 }
00646 eventout += "\n nESDigis = ";
00647 eventout += ESCalADC0.size();
00648 for (unsigned int i = 0; i < ESCalADC0.size(); ++i) {
00649 eventout += "\n (ADC0, ADC1, ADC2, SHE) = (";
00650 eventout += ESCalADC0[i];
00651 eventout += ", ";
00652 eventout += ESCalADC1[i];
00653 eventout += ", ";
00654 eventout += ESCalADC2[i];
00655 eventout += ", ";
00656 eventout += ESCalSHE[i];
00657 eventout += ")";
00658 }
00659 edm::LogInfo(MsgLoggerCat) << eventout << "\n";
00660 }
00661
00662 product.putEBCalDigis(EBCalmaxPos,EBCalAEE,EBCalSHE);
00663 product.putEECalDigis(EECalmaxPos,EECalAEE,EECalSHE);
00664 product.putESCalDigis(ESCalADC0,ESCalADC1,ESCalADC2,ESCalSHE);
00665
00666 return;
00667 }
00668
00669 void GlobalDigisProducer::fillHCal(edm::Event& iEvent,
00670 const edm::EventSetup& iSetup)
00671 {
00672 std::string MsgLoggerCat = "GlobalDigisProducer_fillHCal";
00673
00674 TString eventout;
00675 if (verbosity > 0)
00676 eventout = "\nGathering info:";
00677
00678
00679 edm::ESHandle<HcalDbService> HCalconditions;
00680 iSetup.get<HcalDbRecord>().get(HCalconditions);
00681 if (!HCalconditions.isValid()) {
00682 edm::LogWarning(MsgLoggerCat)
00683 << "Unable to find HCalconditions in event!";
00684 return;
00685 }
00686
00687 CaloSamples tool;
00688
00690
00692 edm::Handle<edm::PCaloHitContainer> hcalHits;
00693 iEvent.getByLabel(HCalSrc_,hcalHits);
00694 if (!hcalHits.isValid()) {
00695 edm::LogWarning(MsgLoggerCat)
00696 << "Unable to find hcalHits in event!";
00697 return;
00698 }
00699 const edm::PCaloHitContainer *simhitResult = hcalHits.product();
00700
00701 MapType fHBEnergySimHits;
00702 MapType fHEEnergySimHits;
00703 MapType fHOEnergySimHits;
00704 MapType fHFEnergySimHits;
00705 for (std::vector<PCaloHit>::const_iterator simhits = simhitResult->begin();
00706 simhits != simhitResult->end();
00707 ++simhits) {
00708
00709 HcalDetId detId(simhits->id());
00710 uint32_t cellid = detId.rawId();
00711
00712 if (detId.subdet() == sdHcalBrl){
00713 fHBEnergySimHits[cellid] += simhits->energy();
00714 }
00715 if (detId.subdet() == sdHcalEC){
00716 fHEEnergySimHits[cellid] += simhits->energy();
00717 }
00718 if (detId.subdet() == sdHcalOut){
00719 fHOEnergySimHits[cellid] += simhits->energy();
00720 }
00721 if (detId.subdet() == sdHcalFwd){
00722 fHFEnergySimHits[cellid] += simhits->energy();
00723 }
00724 }
00725
00727
00729 edm::Handle<edm::SortedCollection<HBHEDataFrame> > hbhe;
00730 iEvent.getByLabel(HCalDigi_,hbhe);
00731 if (!hbhe.isValid()) {
00732 edm::LogWarning(MsgLoggerCat)
00733 << "Unable to find HBHEDataFrame in event!";
00734 return;
00735 }
00736 edm::SortedCollection<HBHEDataFrame>::const_iterator ihbhe;
00737
00738 int iHB = 0;
00739 int iHE = 0;
00740 for (ihbhe = hbhe->begin(); ihbhe != hbhe->end(); ++ihbhe) {
00741 HcalDetId cell(ihbhe->id());
00742
00743 if ((cell.subdet() == sdHcalBrl) || (cell.subdet() == sdHcalEC)) {
00744
00745
00746 const HcalCalibrations& calibrations =
00747 HCalconditions->getHcalCalibrations(cell);
00748 const HcalQIECoder *channelCoder = HCalconditions->getHcalCoder(cell);
00749 const HcalQIEShape *shape = HCalconditions->getHcalShape(channelCoder);
00750
00751 HcalCoderDb coder(*channelCoder, *shape);
00752 coder.adc2fC(*ihbhe, tool);
00753
00754
00755 if (cell.subdet() == sdHcalBrl) {
00756
00757 ++iHB;
00758 float fDigiSum = 0.0;
00759 for (int ii = 0; ii < tool.size(); ++ii) {
00760
00761 int capid = (*ihbhe)[ii].capid();
00762 fDigiSum += (tool[ii] - calibrations.pedestal(capid));
00763 }
00764
00765 HBCalAEE.push_back(fDigiSum);
00766 HBCalSHE.push_back(fHBEnergySimHits[cell.rawId()]);
00767 }
00768
00769
00770 if (cell.subdet() == sdHcalEC) {
00771
00772 ++iHE;
00773 float fDigiSum = 0.0;
00774 for (int ii = 0; ii < tool.size(); ++ii) {
00775 int capid = (*ihbhe)[ii].capid();
00776 fDigiSum += (tool[ii]-calibrations.pedestal(capid));
00777 }
00778
00779 HECalAEE.push_back(fDigiSum);
00780 HECalSHE.push_back(fHEEnergySimHits[cell.rawId()]);
00781 }
00782 }
00783 }
00784
00785 if (verbosity > 1) {
00786 eventout += "\n Number of HBDigis collected:.............. ";
00787 eventout += iHB;
00788 }
00789
00790 if (verbosity > 1) {
00791 eventout += "\n Number of HEDigis collected:.............. ";
00792 eventout += iHE;
00793 }
00794
00796
00798 edm::Handle<edm::SortedCollection<HODataFrame> > ho;
00799 iEvent.getByLabel(HCalDigi_,ho);
00800 if (!ho.isValid()) {
00801 edm::LogWarning(MsgLoggerCat)
00802 << "Unable to find HODataFrame in event!";
00803 return;
00804 }
00805 edm::SortedCollection<HODataFrame>::const_iterator iho;
00806
00807 int iHO = 0;
00808 for (iho = ho->begin(); iho != ho->end(); ++iho) {
00809 HcalDetId cell(iho->id());
00810
00811 if (cell.subdet() == sdHcalOut) {
00812
00813
00814 const HcalCalibrations& calibrations =
00815 HCalconditions->getHcalCalibrations(cell);
00816 const HcalQIECoder *channelCoder = HCalconditions->getHcalCoder(cell);
00817 const HcalQIEShape *shape = HCalconditions->getHcalShape(channelCoder);
00818
00819 HcalCoderDb coder (*channelCoder, *shape);
00820 coder.adc2fC(*iho, tool);
00821
00822 ++iHO;
00823 float fDigiSum = 0.0;
00824 for (int ii = 0; ii < tool.size(); ++ii) {
00825
00826 int capid = (*iho)[ii].capid();
00827 fDigiSum += (tool[ii] - calibrations.pedestal(capid));
00828 }
00829
00830 HOCalAEE.push_back(fDigiSum);
00831 HOCalSHE.push_back(fHOEnergySimHits[cell.rawId()]);
00832 }
00833 }
00834
00835 if (verbosity > 1) {
00836 eventout += "\n Number of HODigis collected:.............. ";
00837 eventout += iHO;
00838 }
00839
00841
00843 edm::Handle<edm::SortedCollection<HFDataFrame> > hf;
00844 iEvent.getByLabel(HCalDigi_,hf);
00845 if (!hf.isValid()) {
00846 edm::LogWarning(MsgLoggerCat)
00847 << "Unable to find HFDataFrame in event!";
00848 return;
00849 }
00850 edm::SortedCollection<HFDataFrame>::const_iterator ihf;
00851
00852 int iHF = 0;
00853 for (ihf = hf->begin(); ihf != hf->end(); ++ihf) {
00854 HcalDetId cell(ihf->id());
00855
00856 if (cell.subdet() == sdHcalFwd) {
00857
00858
00859 const HcalCalibrations& calibrations =
00860 HCalconditions->getHcalCalibrations(cell);
00861 const HcalQIECoder *channelCoder = HCalconditions->getHcalCoder(cell);
00862 const HcalQIEShape *shape = HCalconditions->getHcalShape(channelCoder);
00863
00864 HcalCoderDb coder (*channelCoder, *shape);
00865 coder.adc2fC(*ihf, tool);
00866
00867 ++iHF;
00868 float fDigiSum = 0.0;
00869 for (int ii = 0; ii < tool.size(); ++ii) {
00870
00871 int capid = (*ihf)[ii].capid();
00872 fDigiSum += (tool[ii] - calibrations.pedestal(capid));
00873 }
00874
00875 HFCalAEE.push_back(fDigiSum);
00876 HFCalSHE.push_back(fHFEnergySimHits[cell.rawId()]);
00877 }
00878 }
00879
00880 if (verbosity > 1) {
00881 eventout += "\n Number of HFDigis collected:.............. ";
00882 eventout += iHF;
00883 }
00884
00885 if (verbosity > 0)
00886 edm::LogInfo(MsgLoggerCat) << eventout << "\n";
00887
00888 return;
00889 }
00890
00891 void GlobalDigisProducer::storeHCal(PGlobalDigi& product)
00892 {
00893 std::string MsgLoggerCat = "GlobalDigisProducer_storeHCal";
00894
00895 if (verbosity > 2) {
00896 TString eventout("\n nHBDigis = ");
00897 eventout += HBCalAEE.size();
00898 for (unsigned int i = 0; i < HBCalAEE.size(); ++i) {
00899 eventout += "\n (AEE, SHE) = (";
00900 eventout += HBCalAEE[i];
00901 eventout += ", ";
00902 eventout += HBCalSHE[i];
00903 eventout += ")";
00904 }
00905 eventout += "\n nHEDigis = ";
00906 eventout += HECalAEE.size();
00907 for (unsigned int i = 0; i < HECalAEE.size(); ++i) {
00908 eventout += "\n (AEE, SHE) = (";
00909 eventout += HECalAEE[i];
00910 eventout += ", ";
00911 eventout += HECalSHE[i];
00912 eventout += ")";
00913 }
00914 eventout += "\n nHODigis = ";
00915 eventout += HOCalAEE.size();
00916 for (unsigned int i = 0; i < HOCalAEE.size(); ++i) {
00917 eventout += "\n (AEE, SHE) = (";
00918 eventout += HOCalAEE[i];
00919 eventout += ", ";
00920 eventout += HOCalSHE[i];
00921 eventout += ")";
00922 }
00923 eventout += "\n nHFDigis = ";
00924 eventout += HFCalAEE.size();
00925 for (unsigned int i = 0; i < HFCalAEE.size(); ++i) {
00926 eventout += "\n (AEE, SHE) = (";
00927 eventout += HFCalAEE[i];
00928 eventout += ", ";
00929 eventout += HFCalSHE[i];
00930 eventout += ")";
00931 }
00932
00933 edm::LogInfo(MsgLoggerCat) << eventout << "\n";
00934 }
00935
00936 product.putHBCalDigis(HBCalAEE,HBCalSHE);
00937 product.putHECalDigis(HECalAEE,HECalSHE);
00938 product.putHOCalDigis(HOCalAEE,HOCalSHE);
00939 product.putHFCalDigis(HFCalAEE,HFCalSHE);
00940
00941 return;
00942 }
00943
00944 void GlobalDigisProducer::fillTrk(edm::Event& iEvent,
00945 const edm::EventSetup& iSetup)
00946 {
00947
00948 edm::ESHandle<TrackerTopology> tTopoHandle;
00949 iSetup.get<IdealGeometryRecord>().get(tTopoHandle);
00950 const TrackerTopology* const tTopo = tTopoHandle.product();
00951
00952
00953 std::string MsgLoggerCat = "GlobalDigisProducer_fillTrk";
00954
00955 TString eventout;
00956 if (verbosity > 0)
00957 eventout = "\nGathering info:";
00958
00959
00960 edm::Handle<edm::DetSetVector<SiStripDigi> > stripDigis;
00961 iEvent.getByLabel(SiStripSrc_, stripDigis);
00962 if (!stripDigis.isValid()) {
00963 edm::LogWarning(MsgLoggerCat)
00964 << "Unable to find stripDigis in event!";
00965 return;
00966 }
00967
00968 int nStripBrl = 0, nStripFwd = 0;
00969 edm::DetSetVector<SiStripDigi>::const_iterator DSViter;
00970 for (DSViter = stripDigis->begin(); DSViter != stripDigis->end();
00971 ++DSViter) {
00972 unsigned int id = DSViter->id;
00973 DetId detId(id);
00974 edm::DetSet<SiStripDigi>::const_iterator begin = DSViter->data.begin();
00975 edm::DetSet<SiStripDigi>::const_iterator end = DSViter->data.end();
00976 edm::DetSet<SiStripDigi>::const_iterator iter;
00977
00978
00979 if (detId.subdetId() == sdSiTIB) {
00980
00981 for (iter = begin; iter != end; ++iter) {
00982 ++nStripBrl;
00983 if (tTopo->tibLayer(id) == 1) {
00984 TIBL1ADC.push_back((*iter).adc());
00985 TIBL1Strip.push_back((*iter).strip());
00986 }
00987 if (tTopo->tibLayer(id) == 2) {
00988 TIBL2ADC.push_back((*iter).adc());
00989 TIBL2Strip.push_back((*iter).strip());
00990 }
00991 if (tTopo->tibLayer(id) == 3) {
00992 TIBL3ADC.push_back((*iter).adc());
00993 TIBL3Strip.push_back((*iter).strip());
00994 }
00995 if (tTopo->tibLayer(id) == 4) {
00996 TIBL4ADC.push_back((*iter).adc());
00997 TIBL4Strip.push_back((*iter).strip());
00998 }
00999 }
01000 }
01001
01002
01003 if (detId.subdetId() == sdSiTOB) {
01004
01005 for (iter = begin; iter != end; ++iter) {
01006 ++nStripBrl;
01007 if (tTopo->tobLayer(id) == 1) {
01008 TOBL1ADC.push_back((*iter).adc());
01009 TOBL1Strip.push_back((*iter).strip());
01010 }
01011 if (tTopo->tobLayer(id) == 2) {
01012 TOBL2ADC.push_back((*iter).adc());
01013 TOBL2Strip.push_back((*iter).strip());
01014 }
01015 if (tTopo->tobLayer(id) == 3) {
01016 TOBL3ADC.push_back((*iter).adc());
01017 TOBL3Strip.push_back((*iter).strip());
01018 }
01019 if (tTopo->tobLayer(id) == 4) {
01020 TOBL4ADC.push_back((*iter).adc());
01021 TOBL4Strip.push_back((*iter).strip());
01022 }
01023 }
01024 }
01025
01026
01027 if (detId.subdetId() == sdSiTID) {
01028
01029 for (iter = begin; iter != end; ++iter) {
01030 ++nStripFwd;
01031 if (tTopo->tidWheel(id) == 1) {
01032 TIDW1ADC.push_back((*iter).adc());
01033 TIDW1Strip.push_back((*iter).strip());
01034 }
01035 if (tTopo->tidWheel(id) == 2) {
01036 TIDW2ADC.push_back((*iter).adc());
01037 TIDW2Strip.push_back((*iter).strip());
01038 }
01039 if (tTopo->tidWheel(id) == 3) {
01040 TIDW3ADC.push_back((*iter).adc());
01041 TIDW3Strip.push_back((*iter).strip());
01042 }
01043 }
01044 }
01045
01046
01047 if (detId.subdetId() == sdSiTEC) {
01048
01049 for (iter = begin; iter != end; ++iter) {
01050 ++nStripFwd;
01051 if (tTopo->tecWheel(id) == 1) {
01052 TECW1ADC.push_back((*iter).adc());
01053 TECW1Strip.push_back((*iter).strip());
01054 }
01055 if (tTopo->tecWheel(id) == 2) {
01056 TECW2ADC.push_back((*iter).adc());
01057 TECW2Strip.push_back((*iter).strip());
01058 }
01059 if (tTopo->tecWheel(id) == 3) {
01060 TECW3ADC.push_back((*iter).adc());
01061 TECW3Strip.push_back((*iter).strip());
01062 }
01063 if (tTopo->tecWheel(id) == 4) {
01064 TECW4ADC.push_back((*iter).adc());
01065 TECW4Strip.push_back((*iter).strip());
01066 }
01067 if (tTopo->tecWheel(id) == 5) {
01068 TECW5ADC.push_back((*iter).adc());
01069 TECW5Strip.push_back((*iter).strip());
01070 }
01071 if (tTopo->tecWheel(id) == 6) {
01072 TECW6ADC.push_back((*iter).adc());
01073 TECW6Strip.push_back((*iter).strip());
01074 }
01075 if (tTopo->tecWheel(id) == 7) {
01076 TECW7ADC.push_back((*iter).adc());
01077 TECW7Strip.push_back((*iter).strip());
01078 }
01079 if (tTopo->tecWheel(id) == 8) {
01080 TECW8ADC.push_back((*iter).adc());
01081 TECW8Strip.push_back((*iter).strip());
01082 }
01083 }
01084 }
01085 }
01086
01087 if (verbosity > 1) {
01088 eventout += "\n Number of BrlStripDigis collected:........ ";
01089 eventout += nStripBrl;
01090 }
01091
01092 if (verbosity > 1) {
01093 eventout += "\n Number of FrwdStripDigis collected:....... ";
01094 eventout += nStripFwd;
01095 }
01096
01097
01098 edm::Handle<edm::DetSetVector<PixelDigi> > pixelDigis;
01099 iEvent.getByLabel(SiPxlSrc_, pixelDigis);
01100 if (!pixelDigis.isValid()) {
01101 edm::LogWarning(MsgLoggerCat)
01102 << "Unable to find pixelDigis in event!";
01103 return;
01104 }
01105
01106 int nPxlBrl = 0, nPxlFwd = 0;
01107 edm::DetSetVector<PixelDigi>::const_iterator DPViter;
01108 for (DPViter = pixelDigis->begin(); DPViter != pixelDigis->end();
01109 ++DPViter) {
01110 unsigned int id = DPViter->id;
01111 DetId detId(id);
01112 edm::DetSet<PixelDigi>::const_iterator begin = DPViter->data.begin();
01113 edm::DetSet<PixelDigi>::const_iterator end = DPViter->data.end();
01114 edm::DetSet<PixelDigi>::const_iterator iter;
01115
01116
01117 if (detId.subdetId() == sdPxlBrl) {
01118
01119 for (iter = begin; iter != end; ++iter) {
01120 ++nPxlBrl;
01121 if (tTopo->pxbLayer(id) == 1) {
01122 BRL1ADC.push_back((*iter).adc());
01123 BRL1Row.push_back((*iter).row());
01124 BRL1Col.push_back((*iter).column());
01125 }
01126 if (tTopo->pxbLayer(id) == 2) {
01127 BRL2ADC.push_back((*iter).adc());
01128 BRL2Row.push_back((*iter).row());
01129 BRL2Col.push_back((*iter).column());
01130 }
01131 if (tTopo->pxbLayer(id) == 3) {
01132 BRL3ADC.push_back((*iter).adc());
01133 BRL3Row.push_back((*iter).row());
01134 BRL3Col.push_back((*iter).column());
01135 }
01136 }
01137 }
01138
01139
01140 if (detId.subdetId() == sdPxlFwd) {
01141
01142 for (iter = begin; iter != end; ++iter) {
01143 ++nPxlFwd;
01144 if (tTopo->pxfDisk(id) == 1) {
01145 if (tTopo->pxfSide(id) == 1) {
01146 FWD1nADC.push_back((*iter).adc());
01147 FWD1nRow.push_back((*iter).row());
01148 FWD1nCol.push_back((*iter).column());
01149 }
01150 if (tTopo->pxfSide(id) == 2) {
01151 FWD1pADC.push_back((*iter).adc());
01152 FWD1pRow.push_back((*iter).row());
01153 FWD1pCol.push_back((*iter).column());
01154 }
01155 }
01156 if (tTopo->pxfDisk(id) == 2) {
01157 if (tTopo->pxfSide(id) == 1) {
01158 FWD2nADC.push_back((*iter).adc());
01159 FWD2nRow.push_back((*iter).row());
01160 FWD2nCol.push_back((*iter).column());
01161 }
01162 if (tTopo->pxfSide(id) == 2) {
01163 FWD2pADC.push_back((*iter).adc());
01164 FWD2pRow.push_back((*iter).row());
01165 FWD2pCol.push_back((*iter).column());
01166 }
01167 }
01168 }
01169 }
01170 }
01171
01172 if (verbosity > 1) {
01173 eventout += "\n Number of BrlPixelDigis collected:........ ";
01174 eventout += nPxlBrl;
01175 }
01176
01177 if (verbosity > 1) {
01178 eventout += "\n Number of FrwdPixelDigis collected:....... ";
01179 eventout += nPxlFwd;
01180 }
01181
01182 if (verbosity > 0)
01183 edm::LogInfo(MsgLoggerCat) << eventout << "\n";
01184
01185 return;
01186 }
01187
01188 void GlobalDigisProducer::storeTrk(PGlobalDigi& product)
01189 {
01190 std::string MsgLoggerCat = "GlobalDigisProducer_storeTrk";
01191
01192 if (verbosity > 2) {
01193
01194
01195 TString eventout("\n nTIBL1 = ");
01196 eventout += TIBL1ADC.size();
01197 for (unsigned int i = 0; i < TIBL1ADC.size(); ++i) {
01198 eventout += "\n (ADC, strip) = (";
01199 eventout += TIBL1ADC[i];
01200 eventout += ", ";
01201 eventout += TIBL1Strip[i];
01202 eventout += ")";
01203 }
01204 eventout += "\n nTIBL2 = ";
01205 eventout += TIBL2ADC.size();
01206 for (unsigned int i = 0; i < TIBL2ADC.size(); ++i) {
01207 eventout += "\n (ADC, strip) = (";
01208 eventout += TIBL2ADC[i];
01209 eventout += ", ";
01210 eventout += TIBL2Strip[i];
01211 eventout += ")";
01212 }
01213 eventout += "\n nTIBL3 = ";
01214 eventout += TIBL3ADC.size();
01215 for (unsigned int i = 0; i < TIBL3ADC.size(); ++i) {
01216 eventout += "\n (ADC, strip) = (";
01217 eventout += TIBL3ADC[i];
01218 eventout += ", ";
01219 eventout += TIBL3Strip[i];
01220 eventout += ")";
01221 }
01222 eventout += "\n nTIBL4 = ";
01223 eventout += TIBL4ADC.size();
01224 for (unsigned int i = 0; i < TIBL4ADC.size(); ++i) {
01225 eventout += "\n (ADC, strip) = (";
01226 eventout += TIBL4ADC[i];
01227 eventout += ", ";
01228 eventout += TIBL4Strip[i];
01229 eventout += ")";
01230 }
01231 eventout += "\n nTOBL1 = ";
01232 eventout += TOBL1ADC.size();
01233 for (unsigned int i = 0; i < TOBL1ADC.size(); ++i) {
01234 eventout += "\n (ADC, strip) = (";
01235 eventout += TOBL1ADC[i];
01236 eventout += ", ";
01237 eventout += TOBL1Strip[i];
01238 eventout += ")";
01239 }
01240 eventout += "\n nTOBL2 = ";
01241 eventout += TOBL2ADC.size();
01242 for (unsigned int i = 0; i < TOBL2ADC.size(); ++i) {
01243 eventout += "\n (ADC, strip) = (";
01244 eventout += TOBL2ADC[i];
01245 eventout += ", ";
01246 eventout += TOBL2Strip[i];
01247 eventout += ")";
01248 }
01249 eventout += "\n nTOBL3 = ";
01250 eventout += TOBL3ADC.size();
01251 for (unsigned int i = 0; i < TOBL3ADC.size(); ++i) {
01252 eventout += "\n (ADC, strip) = (";
01253 eventout += TOBL3ADC[i];
01254 eventout += ", ";
01255 eventout += TOBL3Strip[i];
01256 eventout += ")";
01257 }
01258 eventout += "\n nTOBL4 = ";
01259 eventout += TOBL4ADC.size();
01260 for (unsigned int i = 0; i < TOBL4ADC.size(); ++i) {
01261 eventout += "\n (ADC, strip) = (";
01262 eventout += TOBL4ADC[i];
01263 eventout += ", ";
01264 eventout += TOBL4Strip[i];
01265 eventout += ")";
01266 }
01267 eventout += "\n nTIDW1 = ";
01268 eventout += TIDW1ADC.size();
01269 for (unsigned int i = 0; i < TIDW1ADC.size(); ++i) {
01270 eventout += "\n (ADC, strip) = (";
01271 eventout += TIDW1ADC[i];
01272 eventout += ", ";
01273 eventout += TIDW1Strip[i];
01274 eventout += ")";
01275 }
01276 eventout += "\n nTIDW2 = ";
01277 eventout += TIDW2ADC.size();
01278 for (unsigned int i = 0; i < TIDW2ADC.size(); ++i) {
01279 eventout += "\n (ADC, strip) = (";
01280 eventout += TIDW2ADC[i];
01281 eventout += ", ";
01282 eventout += TIDW2Strip[i];
01283 eventout += ")";
01284 }
01285 eventout += "\n nTIDW3 = ";
01286 eventout += TIDW3ADC.size();
01287 for (unsigned int i = 0; i < TIDW3ADC.size(); ++i) {
01288 eventout += "\n (ADC, strip) = (";
01289 eventout += TIDW3ADC[i];
01290 eventout += ", ";
01291 eventout += TIDW3Strip[i];
01292 eventout += ")";
01293 }
01294 eventout += "\n nTECW1 = ";
01295 eventout += TECW1ADC.size();
01296 for (unsigned int i = 0; i < TECW1ADC.size(); ++i) {
01297 eventout += "\n (ADC, strip) = (";
01298 eventout += TECW1ADC[i];
01299 eventout += ", ";
01300 eventout += TECW1Strip[i];
01301 eventout += ")";
01302 }
01303 eventout += "\n nTECW2 = ";
01304 eventout += TECW2ADC.size();
01305 for (unsigned int i = 0; i < TECW2ADC.size(); ++i) {
01306 eventout += "\n (ADC, strip) = (";
01307 eventout += TECW2ADC[i];
01308 eventout += ", ";
01309 eventout += TECW2Strip[i];
01310 eventout += ")";
01311 }
01312 eventout += "\n nTECW3 = ";
01313 eventout += TECW3ADC.size();
01314 for (unsigned int i = 0; i < TECW3ADC.size(); ++i) {
01315 eventout += "\n (ADC, strip) = (";
01316 eventout += TECW3ADC[i];
01317 eventout += ", ";
01318 eventout += TECW3Strip[i];
01319 eventout += ")";
01320 }
01321 eventout += "\n nTECW4 = ";
01322 eventout += TECW4ADC.size();
01323 for (unsigned int i = 0; i < TECW4ADC.size(); ++i) {
01324 eventout += "\n (ADC, strip) = (";
01325 eventout += TECW4ADC[i];
01326 eventout += ", ";
01327 eventout += TECW4Strip[i];
01328 eventout += ")";
01329 }
01330 eventout += "\n nTECW5 = ";
01331 eventout += TECW5ADC.size();
01332 for (unsigned int i = 0; i < TECW5ADC.size(); ++i) {
01333 eventout += "\n (ADC, strip) = (";
01334 eventout += TECW5ADC[i];
01335 eventout += ", ";
01336 eventout += TECW5Strip[i];
01337 eventout += ")";
01338 }
01339 eventout += "\n nTECW6 = ";
01340 eventout += TECW6ADC.size();
01341 for (unsigned int i = 0; i < TECW6ADC.size(); ++i) {
01342 eventout += "\n (ADC, strip) = (";
01343 eventout += TECW6ADC[i];
01344 eventout += ", ";
01345 eventout += TECW6Strip[i];
01346 eventout += ")";
01347 }
01348 eventout += "\n nTECW7 = ";
01349 eventout += TECW7ADC.size();
01350 for (unsigned int i = 0; i < TECW7ADC.size(); ++i) {
01351 eventout += "\n (ADC, strip) = (";
01352 eventout += TECW7ADC[i];
01353 eventout += ", ";
01354 eventout += TECW7Strip[i];
01355 eventout += ")";
01356 }
01357 eventout += "\n nTECW8 = ";
01358 eventout += TECW8ADC.size();
01359 for (unsigned int i = 0; i < TECW8ADC.size(); ++i) {
01360 eventout += "\n (ADC, strip) = (";
01361 eventout += TECW8ADC[i];
01362 eventout += ", ";
01363 eventout += TECW8Strip[i];
01364 eventout += ")";
01365 }
01366
01367
01368 eventout += "\n nBRL1 = ";
01369 eventout += BRL1ADC.size();
01370 for (unsigned int i = 0; i < BRL1ADC.size(); ++i) {
01371 eventout += "\n (ADC, row, column) = (";
01372 eventout += BRL1ADC[i];
01373 eventout += ", ";
01374 eventout += BRL1Row[i];
01375 eventout += ", ";
01376 eventout += BRL1Col[i];
01377 eventout += ")";
01378 }
01379 eventout += "\n nBRL2 = ";
01380 eventout += BRL2ADC.size();
01381 for (unsigned int i = 0; i < BRL2ADC.size(); ++i) {
01382 eventout += "\n (ADC, row, column) = (";
01383 eventout += BRL2ADC[i];
01384 eventout += ", ";
01385 eventout += BRL2Row[i];
01386 eventout += ", ";
01387 eventout += BRL2Col[i];
01388 eventout += ")";
01389 }
01390 eventout += "\n nBRL3 = ";
01391 eventout += BRL3ADC.size();
01392 for (unsigned int i = 0; i < BRL3ADC.size(); ++i) {
01393 eventout += "\n (ADC, row, column) = (";
01394 eventout += BRL3ADC[i];
01395 eventout += ", ";
01396 eventout += BRL3Row[i];
01397 eventout += ", ";
01398 eventout += BRL3Col[i];
01399 eventout += ")";
01400 }
01401 eventout += "\n nFWD1p = ";
01402 eventout += FWD1pADC.size();
01403 for (unsigned int i = 0; i < FWD1pADC.size(); ++i) {
01404 eventout += "\n (ADC, row, column) = (";
01405 eventout += FWD1pADC[i];
01406 eventout += ", ";
01407 eventout += FWD1pRow[i];
01408 eventout += ", ";
01409 eventout += FWD1pCol[i];
01410 eventout += ")";
01411 }
01412 eventout += "\n nFWD1p = ";
01413 eventout += FWD1nADC.size();
01414 for (unsigned int i = 0; i < FWD1nADC.size(); ++i) {
01415 eventout += "\n (ADC, row, column) = (";
01416 eventout += FWD1nADC[i];
01417 eventout += ", ";
01418 eventout += FWD1nRow[i];
01419 eventout += ", ";
01420 eventout += FWD1nCol[i];
01421 eventout += ")";
01422 }
01423 eventout += "\n nFWD1p = ";
01424 eventout += FWD2pADC.size();
01425 for (unsigned int i = 0; i < FWD2pADC.size(); ++i) {
01426 eventout += "\n (ADC, row, column) = (";
01427 eventout += FWD2pADC[i];
01428 eventout += ", ";
01429 eventout += FWD2pRow[i];
01430 eventout += ", ";
01431 eventout += FWD2pCol[i];
01432 eventout += ")";
01433 }
01434 eventout += "\n nFWD2p = ";
01435 eventout += FWD2nADC.size();
01436 for (unsigned int i = 0; i < FWD2nADC.size(); ++i) {
01437 eventout += "\n (ADC, row, column) = (";
01438 eventout += FWD2nADC[i];
01439 eventout += ", ";
01440 eventout += FWD2nRow[i];
01441 eventout += ", ";
01442 eventout += FWD2nCol[i];
01443 eventout += ")";
01444 }
01445
01446 edm::LogInfo(MsgLoggerCat) << eventout << "\n";
01447 }
01448
01449
01450 product.putTIBL1Digis(TIBL1ADC,TIBL1Strip);
01451 product.putTIBL2Digis(TIBL2ADC,TIBL2Strip);
01452 product.putTIBL3Digis(TIBL3ADC,TIBL3Strip);
01453 product.putTIBL4Digis(TIBL4ADC,TIBL4Strip);
01454 product.putTOBL1Digis(TOBL1ADC,TOBL1Strip);
01455 product.putTOBL2Digis(TOBL2ADC,TOBL2Strip);
01456 product.putTOBL3Digis(TOBL3ADC,TOBL3Strip);
01457 product.putTOBL4Digis(TOBL4ADC,TOBL4Strip);
01458 product.putTIDW1Digis(TIDW1ADC,TIDW1Strip);
01459 product.putTIDW2Digis(TIDW2ADC,TIDW2Strip);
01460 product.putTIDW3Digis(TIDW3ADC,TIDW3Strip);
01461 product.putTECW1Digis(TECW1ADC,TECW1Strip);
01462 product.putTECW2Digis(TECW2ADC,TECW2Strip);
01463 product.putTECW3Digis(TECW3ADC,TECW3Strip);
01464 product.putTECW4Digis(TECW4ADC,TECW4Strip);
01465 product.putTECW5Digis(TECW5ADC,TECW5Strip);
01466 product.putTECW6Digis(TECW6ADC,TECW6Strip);
01467 product.putTECW7Digis(TECW7ADC,TECW7Strip);
01468 product.putTECW8Digis(TECW8ADC,TECW8Strip);
01469
01470
01471 product.putBRL1Digis(BRL1ADC, BRL1Row, BRL1Col);
01472 product.putBRL2Digis(BRL2ADC, BRL2Row, BRL2Col);
01473 product.putBRL3Digis(BRL3ADC, BRL3Row, BRL3Col);
01474 product.putFWD1pDigis(FWD1pADC, FWD1pRow, FWD1pCol);
01475 product.putFWD1nDigis(FWD1nADC, FWD1nRow, FWD1nCol);
01476 product.putFWD2pDigis(FWD2pADC, FWD2pRow, FWD2pCol);
01477 product.putFWD2nDigis(FWD2nADC, FWD2nRow, FWD2nCol);
01478
01479 return;
01480 }
01481
01482 void GlobalDigisProducer::fillMuon(edm::Event& iEvent,
01483 const edm::EventSetup& iSetup)
01484 {
01485 std::string MsgLoggerCat = "GlobalDigisProducer_fillMuon";
01486
01487 TString eventout;
01488 if (verbosity > 0)
01489 eventout = "\nGathering info:";
01490
01491
01492 edm::Handle<DTDigiCollection> dtDigis;
01493 iEvent.getByLabel(MuDTSrc_, dtDigis);
01494 if (!dtDigis.isValid()) {
01495 edm::LogWarning(MsgLoggerCat)
01496 << "Unable to find dtDigis in event!";
01497 return;
01498 }
01499
01500 int nDt = 0;
01501 DTDigiCollection::DigiRangeIterator detUnitIt;
01502 for (detUnitIt = dtDigis->begin(); detUnitIt != dtDigis->end();
01503 ++detUnitIt) {
01504
01505 const DTLayerId& id = (*detUnitIt).first;
01506 const DTDigiCollection::Range& range = (*detUnitIt).second;
01507
01508 for (DTDigiCollection::const_iterator digiIt = range.first;
01509 digiIt != range.second;
01510 ++digiIt) {
01511
01512 ++nDt;
01513
01514 DTWireId wireId(id,(*digiIt).wire());
01515 if (wireId.station() == 1) {
01516 MB1SLayer.push_back(id.superlayer());
01517 MB1Time.push_back((*digiIt).time());
01518 MB1Layer.push_back(id.layer());
01519 }
01520 if (wireId.station() == 2) {
01521 MB2SLayer.push_back(id.superlayer());
01522 MB2Time.push_back((*digiIt).time());
01523 MB2Layer.push_back(id.layer());
01524 }
01525 if (wireId.station() == 3) {
01526 MB3SLayer.push_back(id.superlayer());
01527 MB3Time.push_back((*digiIt).time());
01528 MB3Layer.push_back(id.layer());
01529 }
01530 if (wireId.station() == 4) {
01531 MB4SLayer.push_back(id.superlayer());
01532 MB4Time.push_back((*digiIt).time());
01533 MB4Layer.push_back(id.layer());
01534 }
01535 }
01536 }
01537
01538 if (verbosity > 1) {
01539 eventout += "\n Number of DtMuonDigis collected:.......... ";
01540 eventout += nDt;
01541 }
01542
01543
01544 edm::Handle<CSCStripDigiCollection> strips;
01545 iEvent.getByLabel(MuCSCStripSrc_, strips);
01546 if (!strips.isValid()) {
01547 edm::LogWarning(MsgLoggerCat)
01548 << "Unable to find muon strips in event!";
01549 return;
01550 }
01551
01552 int nStrips = 0;
01553 for (CSCStripDigiCollection::DigiRangeIterator j = strips->begin();
01554 j != strips->end();
01555 ++j) {
01556
01557 std::vector<CSCStripDigi>::const_iterator digiItr = (*j).second.first;
01558 std::vector<CSCStripDigi>::const_iterator last = (*j).second.second;
01559
01560 for ( ; digiItr != last; ++digiItr) {
01561 ++nStrips;
01562
01563
01564 std::vector<int> adcCounts = digiItr->getADCCounts();
01565 theCSCStripPedestalSum += adcCounts[0];
01566 theCSCStripPedestalSum += adcCounts[1];
01567 theCSCStripPedestalCount += 2;
01568
01569
01570 if (theCSCStripPedestalCount > 100) {
01571 float pedestal = theCSCStripPedestalSum / theCSCStripPedestalCount;
01572 if (adcCounts[5] > (pedestal + 100))
01573 CSCStripADC.push_back(adcCounts[4] - pedestal);
01574 }
01575 }
01576 }
01577
01578 if (verbosity > 1) {
01579 eventout += "\n Number of CSCStripDigis collected:........ ";
01580 eventout += nStrips;
01581 }
01582
01583
01584 edm::Handle<CSCWireDigiCollection> wires;
01585 iEvent.getByLabel(MuCSCWireSrc_, wires);
01586 if (!wires.isValid()) {
01587 edm::LogWarning(MsgLoggerCat)
01588 << "Unable to find muon wires in event!";
01589 return;
01590 }
01591
01592 int nWires = 0;
01593 for (CSCWireDigiCollection::DigiRangeIterator j = wires->begin();
01594 j != wires->end();
01595 ++j) {
01596
01597 std::vector<CSCWireDigi>::const_iterator digiItr = (*j).second.first;
01598 std::vector<CSCWireDigi>::const_iterator endDigi = (*j).second.second;
01599
01600 for ( ; digiItr != endDigi; ++digiItr) {
01601 ++nWires;
01602
01603 CSCWireTime.push_back(digiItr->getTimeBin());
01604 }
01605 }
01606
01607 if (verbosity > 1) {
01608 eventout += "\n Number of CSCWireDigis collected:......... ";
01609 eventout += nWires;
01610 }
01611
01612 if (verbosity > 0)
01613 edm::LogInfo(MsgLoggerCat) << eventout << "\n";
01614
01615 return;
01616 }
01617
01618 void GlobalDigisProducer::storeMuon(PGlobalDigi& product)
01619 {
01620 std::string MsgLoggerCat = "GlobalDigisProducer_storeMuon";
01621
01622 if (verbosity > 2) {
01623
01624
01625 TString eventout("\n nMB1 = ");
01626 eventout += MB1SLayer.size();
01627 for (unsigned int i = 0; i < MB1SLayer.size(); ++i) {
01628 eventout += "\n (slayer, time, layer) = (";
01629 eventout += MB1SLayer[i];
01630 eventout += ", ";
01631 eventout += MB1Time[i];
01632 eventout += ", ";
01633 eventout += MB1Layer[i];
01634 eventout += ")";
01635 }
01636 eventout += "\n nMB2 = ";
01637 eventout += MB2SLayer.size();
01638 for (unsigned int i = 0; i < MB2SLayer.size(); ++i) {
01639 eventout += "\n (slayer, time, layer) = (";
01640 eventout += MB2SLayer[i];
01641 eventout += ", ";
01642 eventout += MB2Time[i];
01643 eventout += ", ";
01644 eventout += MB2Layer[i];
01645 eventout += ")";
01646 }
01647 eventout += "\n nMB3 = ";
01648 eventout += MB3SLayer.size();
01649 for (unsigned int i = 0; i < MB3SLayer.size(); ++i) {
01650 eventout += "\n (slayer, time, layer) = (";
01651 eventout += MB3SLayer[i];
01652 eventout += ", ";
01653 eventout += MB3Time[i];
01654 eventout += ", ";
01655 eventout += MB3Layer[i];
01656 eventout += ")";
01657 }
01658 eventout += "\n nMB2 = ";
01659 eventout += MB4SLayer.size();
01660 for (unsigned int i = 0; i < MB4SLayer.size(); ++i) {
01661 eventout += "\n (slayer, time, layer) = (";
01662 eventout += MB4SLayer[i];
01663 eventout += ", ";
01664 eventout += MB4Time[i];
01665 eventout += ", ";
01666 eventout += MB4Layer[i];
01667 eventout += ")";
01668 }
01669
01670
01671 eventout += "\n nCSCStrip = ";
01672 eventout += CSCStripADC.size();
01673 for (unsigned int i = 0; i < CSCStripADC.size(); ++i) {
01674 eventout += "\n (adc) = (";
01675 eventout += CSCStripADC[i];
01676 eventout += ")";
01677 }
01678
01679
01680 eventout += "\n nCSCWire = ";
01681 eventout += CSCWireTime.size();
01682 for (unsigned int i = 0; i < CSCWireTime.size(); ++i) {
01683 eventout += "\n (time) = (";
01684 eventout += CSCWireTime[i];
01685 eventout += ")";
01686 }
01687
01688 edm::LogInfo(MsgLoggerCat) << eventout << "\n";
01689 }
01690
01691 product.putMB1Digis(MB1SLayer,MB1Time,MB1Layer);
01692 product.putMB2Digis(MB2SLayer,MB2Time,MB2Layer);
01693 product.putMB3Digis(MB3SLayer,MB3Time,MB3Layer);
01694 product.putMB4Digis(MB4SLayer,MB4Time,MB4Layer);
01695
01696 product.putCSCstripDigis(CSCStripADC);
01697
01698 product.putCSCwireDigis(CSCWireTime);
01699
01700 return;
01701 }
01702
01703 void GlobalDigisProducer::clear()
01704 {
01705 std::string MsgLoggerCat = "GlobalDigisProducer_clear";
01706
01707 if (verbosity > 0)
01708 edm::LogInfo(MsgLoggerCat)
01709 << "Clearing event holders";
01710
01711
01712
01713 EECalmaxPos.clear();
01714 EECalAEE.clear();
01715 EECalSHE.clear();
01716
01717 EBCalmaxPos.clear();
01718 EBCalAEE.clear();
01719 EBCalSHE.clear();
01720
01721 ESCalADC0.clear();
01722 ESCalADC1.clear();
01723 ESCalADC2.clear();
01724 ESCalSHE.clear();
01725
01726
01727 HBCalAEE.clear();
01728 HBCalSHE.clear();
01729 HECalAEE.clear();
01730 HECalSHE.clear();
01731 HOCalAEE.clear();
01732 HOCalSHE.clear();
01733 HFCalAEE.clear();
01734 HFCalSHE.clear();
01735
01736
01737 TIBL1ADC.clear();
01738 TIBL2ADC.clear();
01739 TIBL3ADC.clear();
01740 TIBL4ADC.clear();
01741 TIBL1Strip.clear();
01742 TIBL2Strip.clear();
01743 TIBL3Strip.clear();
01744 TIBL4Strip.clear();
01745
01746 TOBL1ADC.clear();
01747 TOBL2ADC.clear();
01748 TOBL3ADC.clear();
01749 TOBL4ADC.clear();
01750 TOBL1Strip.clear();
01751 TOBL2Strip.clear();
01752 TOBL3Strip.clear();
01753 TOBL4Strip.clear();
01754
01755 TIDW1ADC.clear();
01756 TIDW2ADC.clear();
01757 TIDW3ADC.clear();
01758 TIDW1Strip.clear();
01759 TIDW2Strip.clear();
01760 TIDW3Strip.clear();
01761
01762 TECW1ADC.clear();
01763 TECW2ADC.clear();
01764 TECW3ADC.clear();
01765 TECW4ADC.clear();
01766 TECW5ADC.clear();
01767 TECW6ADC.clear();
01768 TECW7ADC.clear();
01769 TECW8ADC.clear();
01770 TECW1Strip.clear();
01771 TECW2Strip.clear();
01772 TECW3Strip.clear();
01773 TECW4Strip.clear();
01774 TECW5Strip.clear();
01775 TECW6Strip.clear();
01776 TECW7Strip.clear();
01777 TECW8Strip.clear();
01778
01779 BRL1ADC.clear();
01780 BRL1Row.clear();
01781 BRL1Col.clear();
01782 BRL2ADC.clear();
01783 BRL2Row.clear();
01784 BRL2Col.clear();
01785 BRL3ADC.clear();
01786 BRL3Row.clear();
01787 BRL3Col.clear();
01788
01789 FWD1pADC.clear();
01790 FWD1pRow.clear();
01791 FWD1pCol.clear();
01792 FWD1nADC.clear();
01793 FWD1nRow.clear();
01794 FWD1nCol.clear();
01795 FWD2pADC.clear();
01796 FWD2pRow.clear();
01797 FWD2pCol.clear();
01798 FWD2nADC.clear();
01799 FWD2nRow.clear();
01800 FWD2nCol.clear();
01801
01802
01803 MB1SLayer.clear();
01804 MB1Time.clear();
01805 MB1Layer.clear();
01806 MB2SLayer.clear();
01807 MB2Time.clear();
01808 MB2Layer.clear();
01809 MB3SLayer.clear();
01810 MB3Time.clear();
01811 MB3Layer.clear();
01812 MB4SLayer.clear();
01813 MB4Time.clear();
01814 MB4Layer.clear();
01815
01816 CSCStripADC.clear();
01817
01818 CSCWireTime.clear();
01819
01820 return;
01821 }
01822
01823
01824