00001
00010 #include "Validation/GlobalHits/interface/GlobalHitsProducer.h"
00011 #include "Geometry/Records/interface/CaloGeometryRecord.h"
00012
00013 GlobalHitsProducer::GlobalHitsProducer(const edm::ParameterSet& iPSet) :
00014 fName(""), verbosity(0), frequency(0), vtxunit(0), label(""),
00015 getAllProvenances(false), printProvenanceInfo(false), nRawGenPart(0),
00016
00017
00018
00019
00020
00021
00022 count(0)
00023 {
00024 std::string MsgLoggerCat = "GlobalHitsProducer_GlobalHitsProducer";
00025
00026
00027 fName = iPSet.getUntrackedParameter<std::string>("Name");
00028 verbosity = iPSet.getUntrackedParameter<int>("Verbosity");
00029 frequency = iPSet.getUntrackedParameter<int>("Frequency");
00030 vtxunit = iPSet.getUntrackedParameter<int>("VtxUnit");
00031 label = iPSet.getParameter<std::string>("Label");
00032 edm::ParameterSet m_Prov =
00033 iPSet.getParameter<edm::ParameterSet>("ProvenanceLookup");
00034 getAllProvenances =
00035 m_Prov.getUntrackedParameter<bool>("GetAllProvenances");
00036 printProvenanceInfo =
00037 m_Prov.getUntrackedParameter<bool>("PrintProvenanceInfo");
00038
00039
00040 PxlBrlLowSrc_ = iPSet.getParameter<edm::InputTag>("PxlBrlLowSrc");
00041 PxlBrlHighSrc_ = iPSet.getParameter<edm::InputTag>("PxlBrlHighSrc");
00042 PxlFwdLowSrc_ = iPSet.getParameter<edm::InputTag>("PxlFwdLowSrc");
00043 PxlFwdHighSrc_ = iPSet.getParameter<edm::InputTag>("PxlFwdHighSrc");
00044
00045 SiTIBLowSrc_ = iPSet.getParameter<edm::InputTag>("SiTIBLowSrc");
00046 SiTIBHighSrc_ = iPSet.getParameter<edm::InputTag>("SiTIBHighSrc");
00047 SiTOBLowSrc_ = iPSet.getParameter<edm::InputTag>("SiTOBLowSrc");
00048 SiTOBHighSrc_ = iPSet.getParameter<edm::InputTag>("SiTOBHighSrc");
00049 SiTIDLowSrc_ = iPSet.getParameter<edm::InputTag>("SiTIDLowSrc");
00050 SiTIDHighSrc_ = iPSet.getParameter<edm::InputTag>("SiTIDHighSrc");
00051 SiTECLowSrc_ = iPSet.getParameter<edm::InputTag>("SiTECLowSrc");
00052 SiTECHighSrc_ = iPSet.getParameter<edm::InputTag>("SiTECHighSrc");
00053
00054 MuonCscSrc_ = iPSet.getParameter<edm::InputTag>("MuonCscSrc");
00055 MuonDtSrc_ = iPSet.getParameter<edm::InputTag>("MuonDtSrc");
00056 MuonRpcSrc_ = iPSet.getParameter<edm::InputTag>("MuonRpcSrc");
00057
00058 ECalEBSrc_ = iPSet.getParameter<edm::InputTag>("ECalEBSrc");
00059 ECalEESrc_ = iPSet.getParameter<edm::InputTag>("ECalEESrc");
00060 ECalESSrc_ = iPSet.getParameter<edm::InputTag>("ECalESSrc");
00061
00062 HCalSrc_ = iPSet.getParameter<edm::InputTag>("HCalSrc");
00063
00064
00065
00066 verbosity %= 10;
00067
00068
00069 produces<PGlobalSimHit>(label);
00070
00071
00072 if (verbosity >= 0) {
00073 edm::LogInfo(MsgLoggerCat)
00074 << "\n===============================\n"
00075 << "Initialized as EDProducer with parameter values:\n"
00076 << " Name = " << fName << "\n"
00077 << " Verbosity = " << verbosity << "\n"
00078 << " Frequency = " << frequency << "\n"
00079 << " VtxUnit = " << vtxunit << "\n"
00080 << " Label = " << label << "\n"
00081 << " GetProv = " << getAllProvenances << "\n"
00082 << " PrintProv = " << printProvenanceInfo << "\n"
00083 << " PxlBrlLowSrc = " << PxlBrlLowSrc_.label()
00084 << ":" << PxlBrlLowSrc_.instance() << "\n"
00085 << " PxlBrlHighSrc = " << PxlBrlHighSrc_.label()
00086 << ":" << PxlBrlHighSrc_.instance() << "\n"
00087 << " PxlFwdLowSrc = " << PxlFwdLowSrc_.label()
00088 << ":" << PxlBrlLowSrc_.instance() << "\n"
00089 << " PxlFwdHighSrc = " << PxlFwdHighSrc_.label()
00090 << ":" << PxlBrlHighSrc_.instance() << "\n"
00091 << " SiTIBLowSrc = " << SiTIBLowSrc_.label()
00092 << ":" << SiTIBLowSrc_.instance() << "\n"
00093 << " SiTIBHighSrc = " << SiTIBHighSrc_.label()
00094 << ":" << SiTIBHighSrc_.instance() << "\n"
00095 << " SiTOBLowSrc = " << SiTOBLowSrc_.label()
00096 << ":" << SiTOBLowSrc_.instance() << "\n"
00097 << " SiTOBHighSrc = " << SiTOBHighSrc_.label()
00098 << ":" << SiTOBHighSrc_.instance() << "\n"
00099 << " SiTIDLowSrc = " << SiTIDLowSrc_.label()
00100 << ":" << SiTIDLowSrc_.instance() << "\n"
00101 << " SiTIDHighSrc = " << SiTIDHighSrc_.label()
00102 << ":" << SiTIDHighSrc_.instance() << "\n"
00103 << " SiTECLowSrc = " << SiTECLowSrc_.label()
00104 << ":" << SiTECLowSrc_.instance() << "\n"
00105 << " SiTECHighSrc = " << SiTECHighSrc_.label()
00106 << ":" << SiTECHighSrc_.instance() << "\n"
00107 << " MuonCscSrc = " << MuonCscSrc_.label()
00108 << ":" << MuonCscSrc_.instance() << "\n"
00109 << " MuonDtSrc = " << MuonDtSrc_.label()
00110 << ":" << MuonDtSrc_.instance() << "\n"
00111 << " MuonRpcSrc = " << MuonRpcSrc_.label()
00112 << ":" << MuonRpcSrc_.instance() << "\n"
00113 << " ECalEBSrc = " << ECalEBSrc_.label()
00114 << ":" << ECalEBSrc_.instance() << "\n"
00115 << " ECalEESrc = " << ECalEESrc_.label()
00116 << ":" << ECalEESrc_.instance() << "\n"
00117 << " ECalESSrc = " << ECalESSrc_.label()
00118 << ":" << ECalESSrc_.instance() << "\n"
00119 << " HCalSrc = " << HCalSrc_.label()
00120 << ":" << HCalSrc_.instance() << "\n"
00121 << "===============================\n";
00122 }
00123 }
00124
00125 GlobalHitsProducer::~GlobalHitsProducer()
00126 {
00127 }
00128
00129 void GlobalHitsProducer::beginJob(const edm::EventSetup& iSetup)
00130 {
00131 clear();
00132 return;
00133 }
00134
00135 void GlobalHitsProducer::endJob()
00136 {
00137 std::string MsgLoggerCat = "GlobalHitsProducer_endJob";
00138 if (verbosity >= 0)
00139 edm::LogInfo(MsgLoggerCat)
00140 << "Terminating having processed " << count << " events.";
00141 return;
00142 }
00143
00144 void GlobalHitsProducer::produce(edm::Event& iEvent,
00145 const edm::EventSetup& iSetup)
00146 {
00147 std::string MsgLoggerCat = "GlobalHitsProducer_produce";
00148
00149
00150 ++count;
00151
00152
00153 int nrun = iEvent.id().run();
00154 int nevt = iEvent.id().event();
00155
00156 if (verbosity > 0) {
00157 edm::LogInfo(MsgLoggerCat)
00158 << "Processing run " << nrun << ", event " << nevt
00159 << " (" << count << " events total)";
00160 } else if (verbosity == 0) {
00161 if (nevt%frequency == 0 || nevt == 1) {
00162 edm::LogInfo(MsgLoggerCat)
00163 << "Processing run " << nrun << ", event " << nevt
00164 << " (" << count << " events total)";
00165 }
00166 }
00167
00168
00169 clear();
00170
00171
00172 if (getAllProvenances) {
00173
00174 std::vector<const edm::Provenance*> AllProv;
00175 iEvent.getAllProvenance(AllProv);
00176
00177 if (verbosity >= 0)
00178 edm::LogInfo(MsgLoggerCat)
00179 << "Number of Provenances = " << AllProv.size();
00180
00181 if (printProvenanceInfo && (verbosity >= 0)) {
00182 TString eventout("\nProvenance info:\n");
00183
00184 for (unsigned int i = 0; i < AllProv.size(); ++i) {
00185 eventout += "\n ******************************";
00186 eventout += "\n Module : ";
00187 eventout += AllProv[i]->moduleLabel();
00188 eventout += "\n ProductID : ";
00189 eventout += AllProv[i]->productID().id();
00190 eventout += "\n ClassName : ";
00191 eventout += AllProv[i]->className();
00192 eventout += "\n InstanceName : ";
00193 eventout += AllProv[i]->productInstanceName();
00194 eventout += "\n BranchName : ";
00195 eventout += AllProv[i]->branchName();
00196 }
00197 eventout += "\n ******************************\n";
00198 edm::LogInfo(MsgLoggerCat) << eventout << "\n";
00199 printProvenanceInfo = false;
00200 }
00201 getAllProvenances = false;
00202 }
00203
00204
00205
00206 fillG4MC(iEvent);
00207
00208 fillTrk(iEvent,iSetup);
00209
00210 fillMuon(iEvent, iSetup);
00211
00212 fillECal(iEvent, iSetup);
00213
00214 fillHCal(iEvent, iSetup);
00215
00216 if (verbosity > 0)
00217 edm::LogInfo (MsgLoggerCat)
00218 << "Done gathering data from event.";
00219
00220
00221 std::auto_ptr<PGlobalSimHit> pOut(new PGlobalSimHit);
00222
00223 if (verbosity > 2)
00224 edm::LogInfo (MsgLoggerCat)
00225 << "Saving event contents:";
00226
00227
00228
00229 storeG4MC(*pOut);
00230
00231 storeTrk(*pOut);
00232
00233 storeMuon(*pOut);
00234
00235 storeECal(*pOut);
00236
00237 storeHCal(*pOut);
00238
00239
00240 iEvent.put(pOut,label);
00241
00242 return;
00243 }
00244
00245
00246 void GlobalHitsProducer::fillG4MC(edm::Event& iEvent)
00247 {
00248
00249 std::string MsgLoggerCat = "GlobalHitsProducer_fillG4MC";
00250
00251 TString eventout;
00252 if (verbosity > 0)
00253 eventout = "\nGathering info:";
00254
00256
00258 edm::Handle<edm::HepMCProduct> HepMCEvt;
00259 std::vector<edm::Handle<edm::HepMCProduct> > AllHepMCEvt;
00260 iEvent.getManyByType(AllHepMCEvt);
00261
00262
00263
00264 for (unsigned int i = 0; i < AllHepMCEvt.size(); ++i) {
00265 HepMCEvt = AllHepMCEvt[i];
00266 if ((HepMCEvt.provenance()->product()).moduleLabel() == "VtxSmeared")
00267 break;
00268 }
00269
00270 if (!HepMCEvt.isValid()) {
00271 edm::LogWarning(MsgLoggerCat)
00272 << "Unable to find HepMCProduct in event!";
00273 return;
00274 } else {
00275 eventout += "\n Using HepMCProduct: ";
00276 eventout += (HepMCEvt.provenance()->product()).moduleLabel();
00277 }
00278 const HepMC::GenEvent* MCEvt = HepMCEvt->GetEvent();
00279 nRawGenPart = MCEvt->particles_size();
00280
00281 if (verbosity > 1) {
00282 eventout += "\n Number of Raw Particles collected:......... ";
00283 eventout += nRawGenPart;
00284 }
00285
00287
00289
00290 float unit = 0.;
00291 if (vtxunit == 0) unit = 1.;
00292 if (vtxunit == 1) unit = 10.;
00293
00294 edm::Handle<edm::SimVertexContainer> G4VtxContainer;
00295 iEvent.getByType(G4VtxContainer);
00296 if (!G4VtxContainer.isValid()) {
00297 edm::LogWarning(MsgLoggerCat)
00298 << "Unable to find SimVertex in event!";
00299 return;
00300 }
00301 int i = 0;
00302 edm::SimVertexContainer::const_iterator itVtx;
00303 for (itVtx = G4VtxContainer->begin(); itVtx != G4VtxContainer->end();
00304 ++itVtx) {
00305
00306 ++i;
00307
00308 const math::XYZTLorentzVector G4Vtx1(itVtx->position().x(),
00309 itVtx->position().y(),
00310 itVtx->position().z(),
00311 itVtx->position().e());
00312 double G4Vtx[4];
00313 G4Vtx1.GetCoordinates(G4Vtx);
00314
00315 G4VtxX.push_back((G4Vtx[0]*unit)/micrometer);
00316 G4VtxY.push_back((G4Vtx[1]*unit)/micrometer);
00317 G4VtxZ.push_back((G4Vtx[2]*unit)/millimeter);
00318 }
00319
00320 if (verbosity > 1) {
00321 eventout += "\n Number of G4Vertices collected:............ ";
00322 eventout += i;
00323 }
00324
00326
00328 edm::Handle<edm::SimTrackContainer> G4TrkContainer;
00329 iEvent.getByType(G4TrkContainer);
00330 if (!G4TrkContainer.isValid()) {
00331 edm::LogWarning(MsgLoggerCat)
00332 << "Unable to find SimTrack in event!";
00333 return;
00334 }
00335 i = 0;
00336 edm::SimTrackContainer::const_iterator itTrk;
00337 for (itTrk = G4TrkContainer->begin(); itTrk != G4TrkContainer->end();
00338 ++itTrk) {
00339
00340 ++i;
00341
00342 const math::XYZTLorentzVector G4Trk1(itTrk->momentum().x(),
00343 itTrk->momentum().y(),
00344 itTrk->momentum().z(),
00345 itTrk->momentum().e());
00346 double G4Trk[4];
00347 G4Trk1.GetCoordinates(G4Trk);
00348
00349 G4TrkPt.push_back(sqrt(G4Trk[0]*G4Trk[0]+G4Trk[1]*G4Trk[1]));
00350 G4TrkE.push_back(G4Trk[3]);
00351 }
00352
00353 if (verbosity > 1) {
00354 eventout += "\n Number of G4Tracks collected:.............. ";
00355 eventout += i;
00356 }
00357
00358 if (verbosity > 0)
00359 edm::LogInfo(MsgLoggerCat) << eventout << "\n";
00360
00361 return;
00362 }
00363
00364 void GlobalHitsProducer::storeG4MC(PGlobalSimHit& product)
00365 {
00366 std::string MsgLoggerCat = "GlobalHitsProducer_storeG4MC";
00367
00368 if (verbosity > 2) {
00369 TString eventout("\n nRawGenPart = ");
00370 eventout += nRawGenPart;
00371 eventout += "\n nG4Vtx = ";
00372 eventout += G4VtxX.size();
00373 for (unsigned int i = 0; i < G4VtxX.size(); ++i) {
00374 eventout += "\n (x,y,z) = (";
00375 eventout += G4VtxX[i];
00376 eventout += ", ";
00377 eventout += G4VtxY[i];
00378 eventout += ", ";
00379 eventout += G4VtxZ[i];
00380 eventout += ")";
00381 }
00382 eventout += "\n nG4Trk = ";
00383 eventout += G4TrkPt.size();
00384 for (unsigned int i = 0; i < G4TrkPt.size(); ++i) {
00385 eventout += "\n (pt,e) = (";
00386 eventout += G4TrkPt[i];
00387 eventout += ", ";
00388 eventout += G4TrkE[i];
00389 eventout += ")";
00390 }
00391 edm::LogInfo(MsgLoggerCat) << eventout << "\n";
00392 }
00393
00394 product.putRawGenPart(nRawGenPart);
00395 product.putG4Vtx(G4VtxX, G4VtxY, G4VtxZ);
00396 product.putG4Trk(G4TrkPt, G4TrkE);
00397
00398 return;
00399 }
00400
00401 void GlobalHitsProducer::fillTrk(edm::Event& iEvent,
00402 const edm::EventSetup& iSetup)
00403 {
00404 std::string MsgLoggerCat = "GlobalHitsProducer_fillTrk";
00405
00406 TString eventout;
00407 if (verbosity > 0)
00408 eventout = "\nGathering info:";
00409
00410
00411 edm::ESHandle<TrackerGeometry> theTrackerGeometry;
00412 iSetup.get<TrackerDigiGeometryRecord>().get(theTrackerGeometry);
00413 if (!theTrackerGeometry.isValid()) {
00414 edm::LogWarning(MsgLoggerCat)
00415 << "Unable to find TrackerDigiGeometryRecord in event!";
00416 return;
00417 }
00418 const TrackerGeometry& theTracker(*theTrackerGeometry);
00419
00420
00421 edm::PSimHitContainer::const_iterator itHit;
00422
00424
00426 edm::PSimHitContainer thePxlBrlHits;
00427
00428 edm::Handle<edm::PSimHitContainer> PxlBrlLowContainer;
00429 iEvent.getByLabel(PxlBrlLowSrc_,PxlBrlLowContainer);
00430 if (!PxlBrlLowContainer.isValid()) {
00431 edm::LogWarning(MsgLoggerCat)
00432 << "Unable to find TrackerHitsPixelBarrelLowTof in event!";
00433 return;
00434 }
00435
00436 edm::Handle<edm::PSimHitContainer> PxlBrlHighContainer;
00437 iEvent.getByLabel(PxlBrlHighSrc_,PxlBrlHighContainer);
00438 if (!PxlBrlHighContainer.isValid()) {
00439 edm::LogWarning(MsgLoggerCat)
00440 << "Unable to find TrackerHitsPixelBarrelHighTof in event!";
00441 return;
00442 }
00443
00444 thePxlBrlHits.insert(thePxlBrlHits.end(),PxlBrlLowContainer->begin(),
00445 PxlBrlLowContainer->end());
00446 thePxlBrlHits.insert(thePxlBrlHits.end(),PxlBrlHighContainer->begin(),
00447 PxlBrlHighContainer->end());
00448
00449
00450 int i = 0, j = 0;
00451 for (itHit = thePxlBrlHits.begin(); itHit != thePxlBrlHits.end(); ++itHit) {
00452
00453 ++i;
00454
00455
00456 DetId theDetUnitId(itHit->detUnitId());
00457 int detector = theDetUnitId.det();
00458 int subdetector = theDetUnitId.subdetId();
00459
00460
00461 if ((detector == dTrk) && (subdetector == sdPxlBrl)) {
00462
00463
00464 const GeomDetUnit *theDet = theTracker.idToDetUnit(theDetUnitId);
00465
00466 if (!theDet) {
00467 edm::LogWarning(MsgLoggerCat)
00468 << "Unable to get GeomDetUnit from PxlBrlHits for Hit " << i;
00469 continue;
00470 }
00471
00472 ++j;
00473
00474
00475 const BoundPlane& bSurface = theDet->surface();
00476
00477
00478 PxlBrlToF.push_back(itHit->tof());
00479 PxlBrlR.push_back(bSurface.toGlobal(itHit->localPosition()).perp());
00480 PxlBrlPhi.push_back(bSurface.toGlobal(itHit->localPosition()).phi());
00481 PxlBrlEta.push_back(bSurface.toGlobal(itHit->localPosition()).eta());
00482
00483 } else {
00484 edm::LogWarning(MsgLoggerCat)
00485 << "PxlBrl PSimHit " << i
00486 << " is expected to be (det,subdet) = ("
00487 << dTrk << "," << sdPxlBrl
00488 << "); value returned is: ("
00489 << detector << "," << subdetector << ")";
00490 continue;
00491 }
00492 }
00493
00494 if (verbosity > 1) {
00495 eventout += "\n Number of Pixel Barrel Hits collected:..... ";
00496 eventout += j;
00497 }
00498
00500
00502 edm::PSimHitContainer thePxlFwdHits;
00503
00504 edm::Handle<edm::PSimHitContainer> PxlFwdLowContainer;
00505 iEvent.getByLabel(PxlFwdLowSrc_,PxlFwdLowContainer);
00506 if (!PxlFwdLowContainer.isValid()) {
00507 edm::LogWarning(MsgLoggerCat)
00508 << "Unable to find TrackerHitsPixelEndcapLowTof in event!";
00509 return;
00510 }
00511
00512 edm::Handle<edm::PSimHitContainer> PxlFwdHighContainer;
00513 iEvent.getByLabel(PxlFwdHighSrc_,PxlFwdHighContainer);
00514 if (!PxlFwdHighContainer.isValid()) {
00515 edm::LogWarning("GlobalHitsProducer_fillTrk")
00516 << "Unable to find TrackerHitsPixelEndcapHighTof in event!";
00517 return;
00518 }
00519
00520 thePxlFwdHits.insert(thePxlFwdHits.end(),PxlFwdLowContainer->begin(),
00521 PxlFwdLowContainer->end());
00522 thePxlFwdHits.insert(thePxlFwdHits.end(),PxlFwdHighContainer->begin(),
00523 PxlFwdHighContainer->end());
00524
00525
00526 i = 0; j = 0;
00527 for (itHit = thePxlFwdHits.begin(); itHit != thePxlFwdHits.end(); ++itHit) {
00528
00529 ++i;
00530
00531
00532 DetId theDetUnitId(itHit->detUnitId());
00533 int detector = theDetUnitId.det();
00534 int subdetector = theDetUnitId.subdetId();
00535
00536
00537 if ((detector == dTrk) && (subdetector == sdPxlFwd)) {
00538
00539
00540 const GeomDetUnit *theDet = theTracker.idToDetUnit(theDetUnitId);
00541
00542 if (!theDet) {
00543 edm::LogWarning(MsgLoggerCat)
00544 << "Unable to get GeomDetUnit from PxlFwdHits for Hit " << i;;
00545 continue;
00546 }
00547
00548 ++j;
00549
00550
00551 const BoundPlane& bSurface = theDet->surface();
00552
00553
00554 PxlFwdToF.push_back(itHit->tof());
00555 PxlFwdZ.push_back(bSurface.toGlobal(itHit->localPosition()).z());
00556 PxlFwdPhi.push_back(bSurface.toGlobal(itHit->localPosition()).phi());
00557 PxlFwdEta.push_back(bSurface.toGlobal(itHit->localPosition()).eta());
00558 } else {
00559 edm::LogWarning(MsgLoggerCat)
00560 << "PxlFwd PSimHit " << i
00561 << " is expected to be (det,subdet) = ("
00562 << dTrk << "," << sdPxlFwd
00563 << "); value returned is: ("
00564 << detector << "," << subdetector << ")";
00565 continue;
00566 }
00567 }
00568
00569 if (verbosity > 1) {
00570 eventout += "\n Number of Pixel Forward Hits collected:.... ";
00571 eventout += j;
00572 }
00573
00575
00577 edm::PSimHitContainer theSiBrlHits;
00578
00579 edm::Handle<edm::PSimHitContainer> SiTIBLowContainer;
00580 iEvent.getByLabel(SiTIBLowSrc_,SiTIBLowContainer);
00581 if (!SiTIBLowContainer.isValid()) {
00582 edm::LogWarning(MsgLoggerCat)
00583 << "Unable to find TrackerHitsTIBLowTof in event!";
00584 return;
00585 }
00586
00587 edm::Handle<edm::PSimHitContainer> SiTIBHighContainer;
00588 iEvent.getByLabel(SiTIBHighSrc_,SiTIBHighContainer);
00589 if (!SiTIBHighContainer.isValid()) {
00590 edm::LogWarning(MsgLoggerCat)
00591 << "Unable to find TrackerHitsTIBHighTof in event!";
00592 return;
00593 }
00594
00595 edm::Handle<edm::PSimHitContainer> SiTOBLowContainer;
00596 iEvent.getByLabel(SiTOBLowSrc_,SiTOBLowContainer);
00597 if (!SiTOBLowContainer.isValid()) {
00598 edm::LogWarning(MsgLoggerCat)
00599 << "Unable to find TrackerHitsTOBLowTof in event!";
00600 return;
00601 }
00602
00603 edm::Handle<edm::PSimHitContainer> SiTOBHighContainer;
00604 iEvent.getByLabel(SiTOBHighSrc_,SiTOBHighContainer);
00605 if (!SiTOBHighContainer.isValid()) {
00606 edm::LogWarning(MsgLoggerCat)
00607 << "Unable to find TrackerHitsTOBHighTof in event!";
00608 return;
00609 }
00610
00611 theSiBrlHits.insert(theSiBrlHits.end(),SiTIBLowContainer->begin(),
00612 SiTIBLowContainer->end());
00613 theSiBrlHits.insert(theSiBrlHits.end(),SiTIBHighContainer->begin(),
00614 SiTIBHighContainer->end());
00615 theSiBrlHits.insert(theSiBrlHits.end(),SiTOBLowContainer->begin(),
00616 SiTOBLowContainer->end());
00617 theSiBrlHits.insert(theSiBrlHits.end(),SiTOBHighContainer->begin(),
00618 SiTOBHighContainer->end());
00619
00620
00621 i = 0; j = 0;
00622 for (itHit = theSiBrlHits.begin(); itHit != theSiBrlHits.end(); ++itHit) {
00623
00624 ++i;
00625
00626
00627 DetId theDetUnitId(itHit->detUnitId());
00628 int detector = theDetUnitId.det();
00629 int subdetector = theDetUnitId.subdetId();
00630
00631
00632 if ((detector == dTrk) &&
00633 ((subdetector == sdSiTIB) ||
00634 (subdetector == sdSiTOB))) {
00635
00636
00637 const GeomDetUnit *theDet = theTracker.idToDetUnit(theDetUnitId);
00638
00639 if (!theDet) {
00640 edm::LogWarning(MsgLoggerCat)
00641 << "Unable to get GeomDetUnit from SiBrlHits for Hit " << i;
00642 continue;
00643 }
00644
00645 ++j;
00646
00647
00648 const BoundPlane& bSurface = theDet->surface();
00649
00650
00651 SiBrlToF.push_back(itHit->tof());
00652 SiBrlR.push_back(bSurface.toGlobal(itHit->localPosition()).perp());
00653 SiBrlPhi.push_back(bSurface.toGlobal(itHit->localPosition()).phi());
00654 SiBrlEta.push_back(bSurface.toGlobal(itHit->localPosition()).eta());
00655 } else {
00656 edm::LogWarning(MsgLoggerCat)
00657 << "SiBrl PSimHit " << i
00658 << " is expected to be (det,subdet) = ("
00659 << dTrk << "," << sdSiTIB
00660 << " || " << sdSiTOB << "); value returned is: ("
00661 << detector << "," << subdetector << ")";
00662 continue;
00663 }
00664 }
00665
00666 if (verbosity > 1) {
00667 eventout += "\n Number of Silicon Barrel Hits collected:... ";
00668 eventout += j;
00669 }
00670
00672
00674 edm::PSimHitContainer theSiFwdHits;
00675
00676 edm::Handle<edm::PSimHitContainer> SiTIDLowContainer;
00677 iEvent.getByLabel(SiTIDLowSrc_,SiTIDLowContainer);
00678 if (!SiTIDLowContainer.isValid()) {
00679 edm::LogWarning(MsgLoggerCat)
00680 << "Unable to find TrackerHitsTIDLowTof in event!";
00681 return;
00682 }
00683
00684 edm::Handle<edm::PSimHitContainer> SiTIDHighContainer;
00685 iEvent.getByLabel(SiTIDHighSrc_,SiTIDHighContainer);
00686 if (!SiTIDHighContainer.isValid()) {
00687 edm::LogWarning("GlobalHitsProducer_fillTrk")
00688 << "Unable to find TrackerHitsTIDHighTof in event!";
00689 return;
00690 }
00691
00692 edm::Handle<edm::PSimHitContainer> SiTECLowContainer;
00693 iEvent.getByLabel(SiTECLowSrc_,SiTECLowContainer);
00694 if (!SiTECLowContainer.isValid()) {
00695 edm::LogWarning(MsgLoggerCat)
00696 << "Unable to find TrackerHitsTECLowTof in event!";
00697 return;
00698 }
00699
00700 edm::Handle<edm::PSimHitContainer> SiTECHighContainer;
00701 iEvent.getByLabel(SiTECHighSrc_,SiTECHighContainer);
00702 if (!SiTECHighContainer.isValid()) {
00703 edm::LogWarning(MsgLoggerCat)
00704 << "Unable to find TrackerHitsTECHighTof in event!";
00705 return;
00706 }
00707
00708 theSiFwdHits.insert(theSiFwdHits.end(),SiTIDLowContainer->begin(),
00709 SiTIDLowContainer->end());
00710 theSiFwdHits.insert(theSiFwdHits.end(),SiTIDHighContainer->begin(),
00711 SiTIDHighContainer->end());
00712 theSiFwdHits.insert(theSiFwdHits.end(),SiTECLowContainer->begin(),
00713 SiTECLowContainer->end());
00714 theSiFwdHits.insert(theSiFwdHits.end(),SiTECHighContainer->begin(),
00715 SiTECHighContainer->end());
00716
00717
00718 i = 0; j = 0;
00719 for (itHit = theSiFwdHits.begin(); itHit != theSiFwdHits.end(); ++itHit) {
00720
00721 ++i;
00722
00723
00724 DetId theDetUnitId(itHit->detUnitId());
00725 int detector = theDetUnitId.det();
00726 int subdetector = theDetUnitId.subdetId();
00727
00728
00729 if ((detector == dTrk) &&
00730 ((subdetector == sdSiTID) ||
00731 (subdetector == sdSiTEC))) {
00732
00733
00734 const GeomDetUnit *theDet = theTracker.idToDetUnit(theDetUnitId);
00735
00736 if (!theDet) {
00737 edm::LogWarning(MsgLoggerCat)
00738 << "Unable to get GeomDetUnit from SiFwdHits Hit " << i;
00739 return;
00740 }
00741
00742 ++j;
00743
00744
00745 const BoundPlane& bSurface = theDet->surface();
00746
00747
00748 SiFwdToF.push_back(itHit->tof());
00749 SiFwdZ.push_back(bSurface.toGlobal(itHit->localPosition()).z());
00750 SiFwdPhi.push_back(bSurface.toGlobal(itHit->localPosition()).phi());
00751 SiFwdEta.push_back(bSurface.toGlobal(itHit->localPosition()).eta());
00752 } else {
00753 edm::LogWarning(MsgLoggerCat)
00754 << "SiFwd PSimHit " << i
00755 << " is expected to be (det,subdet) = ("
00756 << dTrk << "," << sdSiTOB
00757 << " || " << sdSiTEC << "); value returned is: ("
00758 << detector << "," << subdetector << ")";
00759 continue;
00760 }
00761 }
00762
00763 if (verbosity > 1) {
00764 eventout += "\n Number of Silicon Forward Hits collected:.. ";
00765 eventout += j;
00766 }
00767
00768 if (verbosity > 0)
00769 edm::LogInfo(MsgLoggerCat) << eventout << "\n";
00770
00771 return;
00772 }
00773
00774 void GlobalHitsProducer::storeTrk(PGlobalSimHit& product)
00775 {
00776 std::string MsgLoggerCat = "GlobalHitsProducer_storeTrk";
00777
00778 if (verbosity > 2) {
00779 TString eventout("\n nPxlBrlHits = ");
00780 eventout += PxlBrlToF.size();
00781 for (unsigned int i = 0; i < PxlBrlToF.size(); ++i) {
00782 eventout += "\n (tof,r,phi,eta) = (";
00783 eventout += PxlBrlToF[i];
00784 eventout += ", ";
00785 eventout += PxlBrlR[i];
00786 eventout += ", ";
00787 eventout += PxlBrlPhi[i];
00788 eventout += ", ";
00789 eventout += PxlBrlEta[i];
00790 eventout += ")";
00791 }
00792 eventout += "\n nPxlFwdHits = ";
00793 eventout += PxlFwdToF.size();
00794 for (unsigned int i = 0; i < PxlFwdToF.size(); ++i) {
00795 eventout += "\n (tof,z,phi,eta) = (";
00796 eventout += PxlFwdToF[i];
00797 eventout += ", ";
00798 eventout += PxlFwdZ[i];
00799 eventout += ", ";
00800 eventout += PxlFwdPhi[i];
00801 eventout += ", ";
00802 eventout += PxlFwdEta[i];
00803 eventout += ")";
00804 }
00805 eventout += "\n nSiBrlHits = ";
00806 eventout += SiBrlToF.size();
00807 for (unsigned int i = 0; i < SiBrlToF.size(); ++i) {
00808 eventout += "\n (tof,r,phi,eta) = (";
00809 eventout += SiBrlToF[i];
00810 eventout += ", ";
00811 eventout += SiBrlR[i];
00812 eventout += ", ";
00813 eventout += SiBrlPhi[i];
00814 eventout += ", ";
00815 eventout += SiBrlEta[i];
00816 eventout += ")";
00817 }
00818 eventout += "\n nSiFwdHits = ";
00819 eventout += SiFwdToF.size();
00820 for (unsigned int i = 0; i < SiFwdToF.size(); ++i) {
00821 eventout += "\n (tof,z,phi,eta) = (";
00822 eventout += SiFwdToF[i];
00823 eventout += ", ";
00824 eventout += SiFwdZ[i];
00825 eventout += ", ";
00826 eventout += SiFwdPhi[i];
00827 eventout += ", ";
00828 eventout += SiFwdEta[i];
00829 eventout += ")";
00830 }
00831 edm::LogInfo(MsgLoggerCat) << eventout << "\n";
00832 }
00833
00834 product.putPxlBrlHits(PxlBrlToF,PxlBrlR,PxlBrlPhi,PxlBrlEta);
00835 product.putPxlFwdHits(PxlFwdToF,PxlFwdZ,PxlFwdPhi,PxlFwdEta);
00836 product.putSiBrlHits(SiBrlToF,SiBrlR,SiBrlPhi,SiBrlEta);
00837 product.putSiFwdHits(SiFwdToF,SiFwdZ,SiFwdPhi,SiFwdEta);
00838
00839 return;
00840 }
00841
00842 void GlobalHitsProducer::fillMuon(edm::Event& iEvent,
00843 const edm::EventSetup& iSetup)
00844 {
00845 std::string MsgLoggerCat = "GlobalHitsProducer_fillMuon";
00846
00847 TString eventout;
00848 if (verbosity > 0)
00849 eventout = "\nGathering info:";
00850
00851
00852 edm::PSimHitContainer::const_iterator itHit;
00853
00854
00856
00858
00859 edm::ESHandle<CSCGeometry> theCSCGeometry;
00860 iSetup.get<MuonGeometryRecord>().get(theCSCGeometry);
00861 if (!theCSCGeometry.isValid()) {
00862 edm::LogWarning(MsgLoggerCat)
00863 << "Unable to find MuonGeometryRecord for the CSCGeometry in event!";
00864 return;
00865 }
00866 const CSCGeometry& theCSCMuon(*theCSCGeometry);
00867
00868
00869 edm::Handle<edm::PSimHitContainer> MuonCSCContainer;
00870 iEvent.getByLabel(MuonCscSrc_,MuonCSCContainer);
00871 if (!MuonCSCContainer.isValid()) {
00872 edm::LogWarning(MsgLoggerCat)
00873 << "Unable to find MuonCSCHits in event!";
00874 return;
00875 }
00876
00877
00878 int i = 0, j = 0;
00879 for (itHit = MuonCSCContainer->begin(); itHit != MuonCSCContainer->end();
00880 ++itHit) {
00881
00882 ++i;
00883
00884
00885 DetId theDetUnitId(itHit->detUnitId());
00886 int detector = theDetUnitId.det();
00887 int subdetector = theDetUnitId.subdetId();
00888
00889
00890 if ((detector == dMuon) &&
00891 (subdetector == sdMuonCSC)) {
00892
00893
00894 const GeomDetUnit *theDet = theCSCMuon.idToDetUnit(theDetUnitId);
00895
00896 if (!theDet) {
00897 edm::LogWarning(MsgLoggerCat)
00898 << "Unable to get GeomDetUnit from theCSCMuon for hit " << i;
00899 continue;
00900 }
00901
00902 ++j;
00903
00904
00905 const BoundPlane& bSurface = theDet->surface();
00906
00907
00908 MuonCscToF.push_back(itHit->tof());
00909 MuonCscZ.push_back(bSurface.toGlobal(itHit->localPosition()).z());
00910 MuonCscPhi.push_back(bSurface.toGlobal(itHit->localPosition()).phi());
00911 MuonCscEta.push_back(bSurface.toGlobal(itHit->localPosition()).eta());
00912 } else {
00913 edm::LogWarning(MsgLoggerCat)
00914 << "MuonCsc PSimHit " << i
00915 << " is expected to be (det,subdet) = ("
00916 << dMuon << "," << sdMuonCSC
00917 << "); value returned is: ("
00918 << detector << "," << subdetector << ")";
00919 continue;
00920 }
00921 }
00922
00923 if (verbosity > 1) {
00924 eventout += "\n Number of CSC muon Hits collected:......... ";
00925 eventout += j;
00926 }
00927
00928
00930
00932
00933 edm::ESHandle<DTGeometry> theDTGeometry;
00934 iSetup.get<MuonGeometryRecord>().get(theDTGeometry);
00935 if (!theDTGeometry.isValid()) {
00936 edm::LogWarning(MsgLoggerCat)
00937 << "Unable to find MuonGeometryRecord for the DTGeometry in event!";
00938 return;
00939 }
00940 const DTGeometry& theDTMuon(*theDTGeometry);
00941
00942
00943 edm::Handle<edm::PSimHitContainer> MuonDtContainer;
00944 iEvent.getByLabel(MuonDtSrc_,MuonDtContainer);
00945 if (!MuonDtContainer.isValid()) {
00946 edm::LogWarning(MsgLoggerCat)
00947 << "Unable to find MuonDTHits in event!";
00948 return;
00949 }
00950
00951
00952 i = 0, j = 0;
00953 for (itHit = MuonDtContainer->begin(); itHit != MuonDtContainer->end();
00954 ++itHit) {
00955
00956 ++i;
00957
00958
00959 DetId theDetUnitId(itHit->detUnitId());
00960 int detector = theDetUnitId.det();
00961 int subdetector = theDetUnitId.subdetId();
00962
00963
00964 if ((detector == dMuon) &&
00965 (subdetector == sdMuonDT)) {
00966
00967
00968
00969 DTWireId wireId(itHit->detUnitId());
00970
00971
00972 const DTLayer *theDet = theDTMuon.layer(wireId.layerId());
00973
00974 if (!theDet) {
00975 edm::LogWarning(MsgLoggerCat)
00976 << "Unable to get GeomDetUnit from theDtMuon for hit " << i;
00977 continue;
00978 }
00979
00980 ++j;
00981
00982
00983 const BoundPlane& bSurface = theDet->surface();
00984
00985
00986 MuonDtToF.push_back(itHit->tof());
00987 MuonDtR.push_back(bSurface.toGlobal(itHit->localPosition()).perp());
00988 MuonDtPhi.push_back(bSurface.toGlobal(itHit->localPosition()).phi());
00989 MuonDtEta.push_back(bSurface.toGlobal(itHit->localPosition()).eta());
00990 } else {
00991 edm::LogWarning(MsgLoggerCat)
00992 << "MuonDt PSimHit " << i
00993 << " is expected to be (det,subdet) = ("
00994 << dMuon << "," << sdMuonDT
00995 << "); value returned is: ("
00996 << detector << "," << subdetector << ")";
00997 continue;
00998 }
00999 }
01000
01001 if (verbosity > 1) {
01002 eventout += "\n Number of DT muon Hits collected:.......... ";
01003 eventout += j;
01004 }
01005
01006
01007
01009
01011
01012 edm::ESHandle<RPCGeometry> theRPCGeometry;
01013 iSetup.get<MuonGeometryRecord>().get(theRPCGeometry);
01014 if (!theRPCGeometry.isValid()) {
01015 edm::LogWarning(MsgLoggerCat)
01016 << "Unable to find MuonGeometryRecord for the RPCGeometry in event!";
01017 return;
01018 }
01019 const RPCGeometry& theRPCMuon(*theRPCGeometry);
01020
01021
01022 edm::Handle<edm::PSimHitContainer> MuonRPCContainer;
01023 iEvent.getByLabel(MuonRpcSrc_,MuonRPCContainer);
01024 if (!MuonRPCContainer.isValid()) {
01025 edm::LogWarning(MsgLoggerCat)
01026 << "Unable to find MuonRPCHits in event!";
01027 return;
01028 }
01029
01030
01031 i = 0, j = 0;
01032 int RPCBrl =0, RPCFwd = 0;
01033 for (itHit = MuonRPCContainer->begin(); itHit != MuonRPCContainer->end();
01034 ++itHit) {
01035
01036 ++i;
01037
01038
01039 DetId theDetUnitId(itHit->detUnitId());
01040 int detector = theDetUnitId.det();
01041 int subdetector = theDetUnitId.subdetId();
01042
01043
01044 if ((detector == dMuon) &&
01045 (subdetector == sdMuonRPC)) {
01046
01047
01048 RPCDetId RPCId(itHit->detUnitId());
01049
01050
01051 int region = RPCId.region();
01052
01053
01054 const GeomDetUnit *theDet = theRPCMuon.idToDetUnit(theDetUnitId);
01055
01056 if (!theDet) {
01057 edm::LogWarning(MsgLoggerCat)
01058 << "Unable to get GeomDetUnit from theRPCMuon for hit " << i;
01059 continue;
01060 }
01061
01062 ++j;
01063
01064
01065 const BoundPlane& bSurface = theDet->surface();
01066
01067
01068 if ((region == sdMuonRPCRgnFwdp) || (region == sdMuonRPCRgnFwdn)) {
01069 ++RPCFwd;
01070
01071 MuonRpcFwdToF.push_back(itHit->tof());
01072 MuonRpcFwdZ.push_back(bSurface.toGlobal(itHit->localPosition()).z());
01073 MuonRpcFwdPhi.
01074 push_back(bSurface.toGlobal(itHit->localPosition()).phi());
01075 MuonRpcFwdEta.
01076 push_back(bSurface.toGlobal(itHit->localPosition()).eta());
01077 } else if (region == sdMuonRPCRgnBrl) {
01078 ++RPCBrl;
01079
01080 MuonRpcBrlToF.push_back(itHit->tof());
01081 MuonRpcBrlR.
01082 push_back(bSurface.toGlobal(itHit->localPosition()).perp());
01083 MuonRpcBrlPhi.
01084 push_back(bSurface.toGlobal(itHit->localPosition()).phi());
01085 MuonRpcBrlEta.
01086 push_back(bSurface.toGlobal(itHit->localPosition()).eta());
01087 } else {
01088 edm::LogWarning(MsgLoggerCat)
01089 << "Invalid region for RPC Muon hit" << i;
01090 continue;
01091 }
01092 } else {
01093 edm::LogWarning(MsgLoggerCat)
01094 << "MuonRpc PSimHit " << i
01095 << " is expected to be (det,subdet) = ("
01096 << dMuon << "," << sdMuonRPC
01097 << "); value returned is: ("
01098 << detector << "," << subdetector << ")";
01099 continue;
01100 }
01101 }
01102
01103 if (verbosity > 1) {
01104 eventout += "\n Number of RPC muon Hits collected:......... ";
01105 eventout += j;
01106 eventout += "\n RPC Barrel muon Hits:............ ";
01107 eventout += RPCBrl;
01108 eventout += "\n RPC Forward muon Hits:........... ";
01109 eventout += RPCFwd;
01110 }
01111
01112 if (verbosity > 0)
01113 edm::LogInfo(MsgLoggerCat) << eventout << "\n";
01114
01115 return;
01116 }
01117
01118 void GlobalHitsProducer::storeMuon(PGlobalSimHit& product)
01119 {
01120 std::string MsgLoggerCat = "GlobalHitsProducer_storeMuon";
01121
01122 if (verbosity > 2) {
01123 TString eventout("\n nMuonCSCHits = ");
01124 eventout += MuonCscToF.size();
01125 for (unsigned int i = 0; i < MuonCscToF.size(); ++i) {
01126 eventout += "\n (tof,z,phi,eta) = (";
01127 eventout += MuonCscToF[i];
01128 eventout += ", ";
01129 eventout += MuonCscZ[i];
01130 eventout += ", ";
01131 eventout += MuonCscPhi[i];
01132 eventout += ", ";
01133 eventout += MuonCscEta[i];
01134 eventout += ")";
01135 }
01136 eventout += "\n nMuonDtHits = ";
01137 eventout += MuonDtToF.size();
01138 for (unsigned int i = 0; i < MuonDtToF.size(); ++i) {
01139 eventout += "\n (tof,r,phi,eta) = (";
01140 eventout += MuonDtToF[i];
01141 eventout += ", ";
01142 eventout += MuonDtR[i];
01143 eventout += ", ";
01144 eventout += MuonDtPhi[i];
01145 eventout += ", ";
01146 eventout += MuonDtEta[i];
01147 eventout += ")";
01148 }
01149 eventout += "\n nMuonRpcBrlHits = ";
01150 eventout += MuonRpcBrlToF.size();
01151 for (unsigned int i = 0; i < MuonRpcBrlToF.size(); ++i) {
01152 eventout += "\n (tof,r,phi,eta) = (";
01153 eventout += MuonRpcBrlToF[i];
01154 eventout += ", ";
01155 eventout += MuonRpcBrlR[i];
01156 eventout += ", ";
01157 eventout += MuonRpcBrlPhi[i];
01158 eventout += ", ";
01159 eventout += MuonRpcBrlEta[i];
01160 eventout += ")";
01161 }
01162 eventout += "\n nMuonRpcFwdHits = ";
01163 eventout += MuonRpcFwdToF.size();
01164 for (unsigned int i = 0; i < MuonRpcFwdToF.size(); ++i) {
01165 eventout += "\n (tof,z,phi,eta) = (";
01166 eventout += MuonRpcFwdToF[i];
01167 eventout += ", ";
01168 eventout += MuonRpcFwdZ[i];
01169 eventout += ", ";
01170 eventout += MuonRpcFwdPhi[i];
01171 eventout += ", ";
01172 eventout += MuonRpcFwdEta[i];
01173 eventout += ")";
01174 }
01175 edm::LogInfo(MsgLoggerCat) << eventout << "\n";
01176 }
01177
01178 product.putMuonCscHits(MuonCscToF,MuonCscZ,MuonCscPhi,MuonCscEta);
01179 product.putMuonDtHits(MuonDtToF,MuonDtR,MuonDtPhi,MuonDtEta);
01180 product.putMuonRpcBrlHits(MuonRpcBrlToF,MuonRpcBrlR,MuonRpcBrlPhi,
01181 MuonRpcBrlEta);
01182 product.putMuonRpcFwdHits(MuonRpcFwdToF,MuonRpcFwdZ,MuonRpcFwdPhi,
01183 MuonRpcFwdEta);
01184
01185 return;
01186 }
01187
01188 void GlobalHitsProducer::fillECal(edm::Event& iEvent,
01189 const edm::EventSetup& iSetup)
01190 {
01191 std::string MsgLoggerCat = "GlobalHitsProducer_fillECal";
01192
01193 TString eventout;
01194 if (verbosity > 0)
01195 eventout = "\nGathering info:";
01196
01197
01198 edm::ESHandle<CaloGeometry> theCaloGeometry;
01199 iSetup.get<CaloGeometryRecord>().get(theCaloGeometry);
01200 if (!theCaloGeometry.isValid()) {
01201 edm::LogWarning(MsgLoggerCat)
01202 << "Unable to find CaloGeometryRecord in event!";
01203 return;
01204 }
01205 const CaloGeometry& theCalo(*theCaloGeometry);
01206
01207
01208 edm::PCaloHitContainer::const_iterator itHit;
01209
01211
01213 edm::PCaloHitContainer theECalHits;
01214
01215 edm::Handle<edm::PCaloHitContainer> EBContainer;
01216 iEvent.getByLabel(ECalEBSrc_,EBContainer);
01217 if (!EBContainer.isValid()) {
01218 edm::LogWarning(MsgLoggerCat)
01219 << "Unable to find EcalHitsEB in event!";
01220 return;
01221 }
01222
01223 edm::Handle<edm::PCaloHitContainer> EEContainer;
01224 iEvent.getByLabel(ECalEESrc_,EEContainer);
01225 if (!EEContainer.isValid()) {
01226 edm::LogWarning(MsgLoggerCat)
01227 << "Unable to find EcalHitsEE in event!";
01228 return;
01229 }
01230
01231 theECalHits.insert(theECalHits.end(),EBContainer->begin(),
01232 EBContainer->end());
01233 theECalHits.insert(theECalHits.end(),EEContainer->begin(),
01234 EEContainer->end());
01235
01236
01237 int i = 0, j = 0;
01238 for (itHit = theECalHits.begin(); itHit != theECalHits.end(); ++itHit) {
01239
01240 ++i;
01241
01242
01243 DetId theDetUnitId(itHit->id());
01244 int detector = theDetUnitId.det();
01245 int subdetector = theDetUnitId.subdetId();
01246
01247
01248 if ((detector == dEcal) &&
01249 ((subdetector == sdEcalBrl) ||
01250 (subdetector == sdEcalFwd))) {
01251
01252
01253 const CaloCellGeometry *theDet = theCalo.
01254 getSubdetectorGeometry(theDetUnitId)->getGeometry(theDetUnitId);
01255
01256 if (!theDet) {
01257 edm::LogWarning(MsgLoggerCat)
01258 << "Unable to get CaloCellGeometry from ECalHits for Hit " << i;
01259 continue;
01260 }
01261
01262 ++j;
01263
01264
01265 const GlobalPoint& globalposition = theDet->getPosition();
01266
01267
01268 ECalE.push_back(itHit->energy());
01269 ECalToF.push_back(itHit->time());
01270 ECalPhi.push_back(globalposition.phi());
01271 ECalEta.push_back(globalposition.eta());
01272
01273 } else {
01274 edm::LogWarning(MsgLoggerCat)
01275 << "ECal PCaloHit " << i
01276 << " is expected to be (det,subdet) = ("
01277 << dEcal << "," << sdEcalBrl
01278 << " || " << sdEcalFwd << "); value returned is: ("
01279 << detector << "," << subdetector << ")";
01280 continue;
01281 }
01282 }
01283
01284 if (verbosity > 1) {
01285 eventout += "\n Number of ECal Hits collected:............. ";
01286 eventout += j;
01287 }
01288
01290
01292
01293 edm::Handle<edm::PCaloHitContainer> PreShContainer;
01294 iEvent.getByLabel(ECalESSrc_,PreShContainer);
01295 if (!PreShContainer.isValid()) {
01296 edm::LogWarning(MsgLoggerCat)
01297 << "Unable to find EcalHitsES in event!";
01298 return;
01299 }
01300
01301
01302 i = 0, j = 0;
01303 for (itHit = PreShContainer->begin();
01304 itHit != PreShContainer->end(); ++itHit) {
01305
01306 ++i;
01307
01308
01309 DetId theDetUnitId(itHit->id());
01310 int detector = theDetUnitId.det();
01311 int subdetector = theDetUnitId.subdetId();
01312
01313
01314 if ((detector == dEcal) &&
01315 (subdetector == sdEcalPS)) {
01316
01317
01318 const CaloCellGeometry *theDet = theCalo.
01319 getSubdetectorGeometry(theDetUnitId)->getGeometry(theDetUnitId);
01320
01321 if (!theDet) {
01322 edm::LogWarning(MsgLoggerCat)
01323 << "Unable to get CaloCellGeometry from PreShContainer for Hit "
01324 << i;
01325 continue;
01326 }
01327
01328 ++j;
01329
01330
01331 const GlobalPoint& globalposition = theDet->getPosition();
01332
01333
01334 PreShE.push_back(itHit->energy());
01335 PreShToF.push_back(itHit->time());
01336 PreShPhi.push_back(globalposition.phi());
01337 PreShEta.push_back(globalposition.eta());
01338
01339 } else {
01340 edm::LogWarning(MsgLoggerCat)
01341 << "PreSh PCaloHit " << i
01342 << " is expected to be (det,subdet) = ("
01343 << dEcal << "," << sdEcalPS
01344 << "); value returned is: ("
01345 << detector << "," << subdetector << ")";
01346 continue;
01347 }
01348 }
01349
01350 if (verbosity > 1) {
01351 eventout += "\n Number of PreSh Hits collected:............ ";
01352 eventout += j;
01353 }
01354
01355 if (verbosity > 0)
01356 edm::LogInfo(MsgLoggerCat) << eventout << "\n";
01357
01358 return;
01359 }
01360
01361 void GlobalHitsProducer::storeECal(PGlobalSimHit& product)
01362 {
01363 std::string MsgLoggerCat = "GlobalHitsProducer_storeECal";
01364
01365 if (verbosity > 2) {
01366 TString eventout("\n nECalHits = ");
01367 eventout += ECalE.size();
01368 for (unsigned int i = 0; i < ECalE.size(); ++i) {
01369 eventout += "\n (e,tof,phi,eta) = (";
01370 eventout += ECalE[i];
01371 eventout += ", ";
01372 eventout += ECalToF[i];
01373 eventout += ", ";
01374 eventout += ECalPhi[i];
01375 eventout += ", ";
01376 eventout += ECalEta[i];
01377 eventout += ")";
01378 }
01379 eventout += "\n nPreShHits = ";
01380 eventout += PreShE.size();
01381 for (unsigned int i = 0; i < PreShE.size(); ++i) {
01382 eventout += "\n (e,tof,phi,eta) = (";
01383 eventout += PreShE[i];
01384 eventout += ", ";
01385 eventout += PreShToF[i];
01386 eventout += ", ";
01387 eventout += PreShPhi[i];
01388 eventout += ", ";
01389 eventout += PreShEta[i];
01390 eventout += ")";
01391 }
01392 edm::LogInfo(MsgLoggerCat) << eventout << "\n";
01393 }
01394
01395 product.putECalHits(ECalE,ECalToF,ECalPhi,ECalEta);
01396 product.putPreShHits(PreShE,PreShToF,PreShPhi,PreShEta);
01397
01398 return;
01399 }
01400
01401 void GlobalHitsProducer::fillHCal(edm::Event& iEvent,
01402 const edm::EventSetup& iSetup)
01403 {
01404 std::string MsgLoggerCat = "GlobalHitsProducer_fillHCal";
01405
01406 TString eventout;
01407 if (verbosity > 0)
01408 eventout = "\nGathering info:";
01409
01410
01411 edm::ESHandle<CaloGeometry> theCaloGeometry;
01412 iSetup.get<CaloGeometryRecord>().get(theCaloGeometry);
01413 if (!theCaloGeometry.isValid()) {
01414 edm::LogWarning(MsgLoggerCat)
01415 << "Unable to find CaloGeometryRecord in event!";
01416 return;
01417 }
01418 const CaloGeometry& theCalo(*theCaloGeometry);
01419
01420
01421 edm::PCaloHitContainer::const_iterator itHit;
01422
01424
01426
01427 edm::Handle<edm::PCaloHitContainer> HCalContainer;
01428 iEvent.getByLabel(HCalSrc_,HCalContainer);
01429 if (!HCalContainer.isValid()) {
01430 edm::LogWarning(MsgLoggerCat)
01431 << "Unable to find HCalHits in event!";
01432 return;
01433 }
01434
01435
01436 int i = 0, j = 0;
01437 for (itHit = HCalContainer->begin();
01438 itHit != HCalContainer->end(); ++itHit) {
01439
01440 ++i;
01441
01442
01443 DetId theDetUnitId(itHit->id());
01444 int detector = theDetUnitId.det();
01445 int subdetector = theDetUnitId.subdetId();
01446
01447
01448 if ((detector == dHcal) &&
01449 ((subdetector == sdHcalBrl) ||
01450 (subdetector == sdHcalEC) ||
01451 (subdetector == sdHcalOut) ||
01452 (subdetector == sdHcalFwd))) {
01453
01454
01455 const CaloCellGeometry *theDet = theCalo.
01456 getSubdetectorGeometry(theDetUnitId)->getGeometry(theDetUnitId);
01457
01458 if (!theDet) {
01459 edm::LogWarning(MsgLoggerCat)
01460 << "Unable to get CaloCellGeometry from HCalContainer for Hit " << i;
01461 continue;
01462 }
01463
01464 ++j;
01465
01466
01467 const GlobalPoint& globalposition = theDet->getPosition();
01468
01469
01470 HCalE.push_back(itHit->energy());
01471 HCalToF.push_back(itHit->time());
01472 HCalPhi.push_back(globalposition.phi());
01473 HCalEta.push_back(globalposition.eta());
01474
01475 } else {
01476 edm::LogWarning(MsgLoggerCat)
01477 << "HCal PCaloHit " << i
01478 << " is expected to be (det,subdet) = ("
01479 << dHcal << "," << sdHcalBrl
01480 << " || " << sdHcalEC << " || " << sdHcalOut << " || " << sdHcalFwd
01481 << "); value returned is: ("
01482 << detector << "," << subdetector << ")";
01483 continue;
01484 }
01485 }
01486
01487 if (verbosity > 1) {
01488 eventout += "\n Number of HCal Hits collected:............. ";
01489 eventout += j;
01490 }
01491
01492 if (verbosity > 0)
01493 edm::LogInfo(MsgLoggerCat) << eventout << "\n";
01494
01495 return;
01496 }
01497
01498 void GlobalHitsProducer::storeHCal(PGlobalSimHit& product)
01499 {
01500 std::string MsgLoggerCat = "GlobalHitsProducer_storeHCal";
01501
01502 if (verbosity > 2) {
01503 TString eventout("\n nHCalHits = ");
01504 eventout += HCalE.size();
01505 for (unsigned int i = 0; i < HCalE.size(); ++i) {
01506 eventout += "\n (e,tof,phi,eta) = (";
01507 eventout += HCalE[i];
01508 eventout += ", ";
01509 eventout += HCalToF[i];
01510 eventout += ", ";
01511 eventout += HCalPhi[i];
01512 eventout += ", ";
01513 eventout += HCalEta[i];
01514 eventout += ")";
01515 }
01516 edm::LogInfo(MsgLoggerCat) << eventout << "\n";
01517 }
01518
01519 product.putHCalHits(HCalE,HCalToF,HCalPhi,HCalEta);
01520
01521 return;
01522 }
01523
01524 void GlobalHitsProducer::clear()
01525 {
01526 std::string MsgLoggerCat = "GlobalHitsProducer_clear";
01527
01528 if (verbosity > 0)
01529 edm::LogInfo(MsgLoggerCat)
01530 << "Clearing event holders";
01531
01532
01533 nRawGenPart = 0;
01534 G4VtxX.clear();
01535 G4VtxY.clear();
01536 G4VtxZ.clear();
01537 G4TrkPt.clear();
01538 G4TrkE.clear();
01539
01540
01541
01542 ECalE.clear();
01543 ECalToF.clear();
01544 ECalPhi.clear();
01545 ECalEta.clear();
01546
01547 PreShE.clear();
01548 PreShToF.clear();
01549 PreShPhi.clear();
01550 PreShEta.clear();
01551
01552
01553
01554 HCalE.clear();
01555 HCalToF.clear();
01556 HCalPhi.clear();
01557 HCalEta.clear();
01558
01559
01560
01561 PxlBrlToF.clear();
01562 PxlBrlR.clear();
01563 PxlBrlPhi.clear();
01564 PxlBrlEta.clear();
01565 PxlFwdToF.clear();
01566 PxlFwdZ.clear();
01567 PxlFwdPhi.clear();
01568 PxlFwdEta.clear();
01569
01570 SiBrlToF.clear();
01571 SiBrlR.clear();
01572 SiBrlPhi.clear();
01573 SiBrlEta.clear();
01574 SiFwdToF.clear();
01575 SiFwdZ.clear();
01576 SiFwdPhi.clear();
01577 SiFwdEta.clear();
01578
01579
01580
01581 MuonDtToF.clear();
01582 MuonDtR.clear();
01583 MuonDtPhi.clear();
01584 MuonDtEta.clear();
01585
01586 MuonCscToF.clear();
01587 MuonCscZ.clear();
01588 MuonCscPhi.clear();
01589 MuonCscEta.clear();
01590
01591 MuonRpcBrlToF.clear();
01592 MuonRpcBrlR.clear();
01593 MuonRpcBrlPhi.clear();
01594 MuonRpcBrlEta.clear();
01595 MuonRpcFwdToF.clear();
01596 MuonRpcFwdZ.clear();
01597 MuonRpcFwdPhi.clear();
01598 MuonRpcFwdEta.clear();
01599
01600 return;
01601 }