Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-05-10 02:21:33

0001 /** \file GlobalHitsAnalyzer.cc
0002  *
0003  *  See header file for description of class
0004  *
0005  *  \author M. Strang SUNY-Buffalo
0006  */
0007 #include "Geometry/Records/interface/CaloGeometryRecord.h"
0008 
0009 #include "DQMServices/Core/interface/DQMStore.h"
0010 #include "Validation/GlobalHits/interface/GlobalHitsAnalyzer.h"
0011 
0012 #include "DataFormats/HcalDetId/interface/HcalDetId.h"
0013 #include "Geometry/HcalCommonData/interface/HcalDDDRecConstants.h"
0014 #include "Geometry/HcalCommonData/interface/HcalHitRelabeller.h"
0015 #include "Geometry/HcalTowerAlgo/interface/HcalGeometry.h"
0016 #include "Geometry/Records/interface/HcalRecNumberingRecord.h"
0017 #include "FWCore/Framework/interface/GetterOfProducts.h"
0018 #include "FWCore/Framework/interface/ProcessMatch.h"
0019 using CLHEP::micrometer;
0020 using CLHEP::millimeter;
0021 
0022 GlobalHitsAnalyzer::GlobalHitsAnalyzer(const edm::ParameterSet &iPSet)
0023     : fName(""),
0024       verbosity(0),
0025       frequency(0),
0026       vtxunit(0),
0027       label(""),
0028       getAllProvenances(false),
0029       printProvenanceInfo(false),
0030       testNumber(false),
0031       G4VtxSrc_Token_(consumes<edm::SimVertexContainer>((iPSet.getParameter<edm::InputTag>("G4VtxSrc")))),
0032       G4TrkSrc_Token_(consumes<edm::SimTrackContainer>(iPSet.getParameter<edm::InputTag>("G4TrkSrc"))),
0033       tGeomToken_(esConsumes()),
0034       cscGeomToken_(esConsumes()),
0035       dtGeomToken_(esConsumes()),
0036       rpcGeomToken_(esConsumes()),
0037       caloGeomToken_(esConsumes()),
0038       hcaldddRecToken_(esConsumes()),
0039       count(0) {
0040   getterOfProducts_ = edm::GetterOfProducts<edm::HepMCProduct>(edm::ProcessMatch("*"), this);
0041   callWhenNewProductsRegistered(getterOfProducts_);
0042 
0043   std::string MsgLoggerCat = "GlobalHitsAnalyzer_GlobalHitsAnalyzer";
0044 
0045   // get information from parameter set
0046   fName = iPSet.getUntrackedParameter<std::string>("Name");
0047   verbosity = iPSet.getUntrackedParameter<int>("Verbosity");
0048   frequency = iPSet.getUntrackedParameter<int>("Frequency");
0049   vtxunit = iPSet.getUntrackedParameter<int>("VtxUnit");
0050   edm::ParameterSet m_Prov = iPSet.getParameter<edm::ParameterSet>("ProvenanceLookup");
0051   getAllProvenances = m_Prov.getUntrackedParameter<bool>("GetAllProvenances");
0052   printProvenanceInfo = m_Prov.getUntrackedParameter<bool>("PrintProvenanceInfo");
0053   testNumber = iPSet.getUntrackedParameter<bool>("testNumber");
0054 
0055   // get Labels to use to extract information
0056   PxlBrlLowSrc_ = iPSet.getParameter<edm::InputTag>("PxlBrlLowSrc");
0057   PxlBrlHighSrc_ = iPSet.getParameter<edm::InputTag>("PxlBrlHighSrc");
0058   PxlFwdLowSrc_ = iPSet.getParameter<edm::InputTag>("PxlFwdLowSrc");
0059   PxlFwdHighSrc_ = iPSet.getParameter<edm::InputTag>("PxlFwdHighSrc");
0060 
0061   SiTIBLowSrc_ = iPSet.getParameter<edm::InputTag>("SiTIBLowSrc");
0062   SiTIBHighSrc_ = iPSet.getParameter<edm::InputTag>("SiTIBHighSrc");
0063   SiTOBLowSrc_ = iPSet.getParameter<edm::InputTag>("SiTOBLowSrc");
0064   SiTOBHighSrc_ = iPSet.getParameter<edm::InputTag>("SiTOBHighSrc");
0065   SiTIDLowSrc_ = iPSet.getParameter<edm::InputTag>("SiTIDLowSrc");
0066   SiTIDHighSrc_ = iPSet.getParameter<edm::InputTag>("SiTIDHighSrc");
0067   SiTECLowSrc_ = iPSet.getParameter<edm::InputTag>("SiTECLowSrc");
0068   SiTECHighSrc_ = iPSet.getParameter<edm::InputTag>("SiTECHighSrc");
0069 
0070   MuonCscSrc_ = iPSet.getParameter<edm::InputTag>("MuonCscSrc");
0071   MuonDtSrc_ = iPSet.getParameter<edm::InputTag>("MuonDtSrc");
0072   MuonRpcSrc_ = iPSet.getParameter<edm::InputTag>("MuonRpcSrc");
0073 
0074   ECalEBSrc_ = iPSet.getParameter<edm::InputTag>("ECalEBSrc");
0075   ECalEESrc_ = iPSet.getParameter<edm::InputTag>("ECalEESrc");
0076   ECalESSrc_ = iPSet.getParameter<edm::InputTag>("ECalESSrc");
0077 
0078   HCalSrc_ = iPSet.getParameter<edm::InputTag>("HCalSrc");
0079 
0080   // fix for consumes
0081   PxlBrlLowSrc_Token_ = consumes<edm::PSimHitContainer>(iPSet.getParameter<edm::InputTag>("PxlBrlLowSrc"));
0082   PxlBrlHighSrc_Token_ = consumes<edm::PSimHitContainer>(iPSet.getParameter<edm::InputTag>("PxlBrlHighSrc"));
0083   PxlFwdLowSrc_Token_ = consumes<edm::PSimHitContainer>(iPSet.getParameter<edm::InputTag>("PxlFwdLowSrc"));
0084   PxlFwdHighSrc_Token_ = consumes<edm::PSimHitContainer>(iPSet.getParameter<edm::InputTag>("PxlFwdHighSrc"));
0085 
0086   SiTIBLowSrc_Token_ = consumes<edm::PSimHitContainer>(iPSet.getParameter<edm::InputTag>("SiTIBLowSrc"));
0087   SiTIBHighSrc_Token_ = consumes<edm::PSimHitContainer>(iPSet.getParameter<edm::InputTag>("SiTIBHighSrc"));
0088   SiTOBLowSrc_Token_ = consumes<edm::PSimHitContainer>(iPSet.getParameter<edm::InputTag>("SiTOBLowSrc"));
0089   SiTOBHighSrc_Token_ = consumes<edm::PSimHitContainer>(iPSet.getParameter<edm::InputTag>("SiTOBHighSrc"));
0090   SiTIDLowSrc_Token_ = consumes<edm::PSimHitContainer>(iPSet.getParameter<edm::InputTag>("SiTIDLowSrc"));
0091   SiTIDHighSrc_Token_ = consumes<edm::PSimHitContainer>(iPSet.getParameter<edm::InputTag>("SiTIDHighSrc"));
0092   SiTECLowSrc_Token_ = consumes<edm::PSimHitContainer>(iPSet.getParameter<edm::InputTag>("SiTECLowSrc"));
0093   SiTECHighSrc_Token_ = consumes<edm::PSimHitContainer>(iPSet.getParameter<edm::InputTag>("SiTECHighSrc"));
0094 
0095   MuonCscSrc_Token_ = consumes<edm::PSimHitContainer>(iPSet.getParameter<edm::InputTag>("MuonCscSrc"));
0096   MuonDtSrc_Token_ = consumes<edm::PSimHitContainer>(iPSet.getParameter<edm::InputTag>("MuonDtSrc"));
0097   MuonRpcSrc_Token_ = consumes<edm::PSimHitContainer>(iPSet.getParameter<edm::InputTag>("MuonRpcSrc"));
0098 
0099   ECalEBSrc_Token_ = consumes<edm::PCaloHitContainer>(iPSet.getParameter<edm::InputTag>("ECalEBSrc"));
0100   ECalEESrc_Token_ = consumes<edm::PCaloHitContainer>(iPSet.getParameter<edm::InputTag>("ECalEESrc"));
0101   ECalESSrc_Token_ = consumes<edm::PCaloHitContainer>(iPSet.getParameter<edm::InputTag>("ECalESSrc"));
0102   HCalSrc_Token_ = consumes<edm::PCaloHitContainer>(iPSet.getParameter<edm::InputTag>("HCalSrc"));
0103 
0104   // determine whether to process subdetector or not
0105   validHepMCevt = iPSet.getUntrackedParameter<bool>("validHepMCevt");
0106   validG4VtxContainer = iPSet.getUntrackedParameter<bool>("validG4VtxContainer");
0107   validG4trkContainer = iPSet.getUntrackedParameter<bool>("validG4trkContainer");
0108   validPxlBrlLow = iPSet.getUntrackedParameter<bool>("validPxlBrlLow", true);
0109   validPxlBrlHigh = iPSet.getUntrackedParameter<bool>("validPxlBrlHigh", true);
0110   validPxlFwdLow = iPSet.getUntrackedParameter<bool>("validPxlFwdLow", true);
0111   validPxlFwdHigh = iPSet.getUntrackedParameter<bool>("validPxlFwdHigh", true);
0112   validSiTIBLow = iPSet.getUntrackedParameter<bool>("validSiTIBLow", true);
0113   validSiTIBHigh = iPSet.getUntrackedParameter<bool>("validSiTIBHigh", true);
0114   validSiTOBLow = iPSet.getUntrackedParameter<bool>("validSiTOBLow", true);
0115   validSiTOBHigh = iPSet.getUntrackedParameter<bool>("validSiTOBHigh", true);
0116   validSiTIDLow = iPSet.getUntrackedParameter<bool>("validSiTIDLow", true);
0117   validSiTIDHigh = iPSet.getUntrackedParameter<bool>("validSiTIDHigh", true);
0118   validSiTECLow = iPSet.getUntrackedParameter<bool>("validSiTECLow", true);
0119   validSiTECHigh = iPSet.getUntrackedParameter<bool>("validSiTECHigh", true);
0120   validMuonCSC = iPSet.getUntrackedParameter<bool>("validMuonCSC", true);
0121   validMuonDt = iPSet.getUntrackedParameter<bool>("validMuonDt", true);
0122   validMuonRPC = iPSet.getUntrackedParameter<bool>("validMuonRPC", true);
0123   validEB = iPSet.getUntrackedParameter<bool>("validEB", true);
0124   validEE = iPSet.getUntrackedParameter<bool>("validEE", true);
0125   validPresh = iPSet.getUntrackedParameter<bool>("validPresh", true);
0126   validHcal = iPSet.getUntrackedParameter<bool>("validHcal", true);
0127 
0128   // use value of first digit to determine default output level (inclusive)
0129   // 0 is none, 1 is basic, 2 is fill output, 3 is gather output
0130   verbosity %= 10;
0131 
0132   // print out Parameter Set information being used
0133   if (verbosity >= 0) {
0134     edm::LogInfo(MsgLoggerCat)
0135         << "\n===============================\n"
0136         << "Initialized as EDAnalyzer with parameter values:\n"
0137         << "    Name                  = " << fName << "\n"
0138         << "    Verbosity             = " << verbosity << "\n"
0139         << "    Frequency             = " << frequency << "\n"
0140         << "    VtxUnit               = " << vtxunit << "\n"
0141         << "    GetProv               = " << getAllProvenances << "\n"
0142         << "    PrintProv             = " << printProvenanceInfo << "\n"
0143         << "    PxlBrlLowSrc          = " << PxlBrlLowSrc_.label() << ":" << PxlBrlLowSrc_.instance() << "\n"
0144         << "    PxlBrlHighSrc         = " << PxlBrlHighSrc_.label() << ":" << PxlBrlHighSrc_.instance() << "\n"
0145         << "    PxlFwdLowSrc          = " << PxlFwdLowSrc_.label() << ":" << PxlBrlLowSrc_.instance() << "\n"
0146         << "    PxlFwdHighSrc         = " << PxlFwdHighSrc_.label() << ":" << PxlBrlHighSrc_.instance() << "\n"
0147         << "    SiTIBLowSrc           = " << SiTIBLowSrc_.label() << ":" << SiTIBLowSrc_.instance() << "\n"
0148         << "    SiTIBHighSrc          = " << SiTIBHighSrc_.label() << ":" << SiTIBHighSrc_.instance() << "\n"
0149         << "    SiTOBLowSrc           = " << SiTOBLowSrc_.label() << ":" << SiTOBLowSrc_.instance() << "\n"
0150         << "    SiTOBHighSrc          = " << SiTOBHighSrc_.label() << ":" << SiTOBHighSrc_.instance() << "\n"
0151         << "    SiTIDLowSrc           = " << SiTIDLowSrc_.label() << ":" << SiTIDLowSrc_.instance() << "\n"
0152         << "    SiTIDHighSrc          = " << SiTIDHighSrc_.label() << ":" << SiTIDHighSrc_.instance() << "\n"
0153         << "    SiTECLowSrc           = " << SiTECLowSrc_.label() << ":" << SiTECLowSrc_.instance() << "\n"
0154         << "    SiTECHighSrc          = " << SiTECHighSrc_.label() << ":" << SiTECHighSrc_.instance() << "\n"
0155         << "    MuonCscSrc            = " << MuonCscSrc_.label() << ":" << MuonCscSrc_.instance() << "\n"
0156         << "    MuonDtSrc             = " << MuonDtSrc_.label() << ":" << MuonDtSrc_.instance() << "\n"
0157         << "    MuonRpcSrc            = " << MuonRpcSrc_.label() << ":" << MuonRpcSrc_.instance() << "\n"
0158         << "    ECalEBSrc             = " << ECalEBSrc_.label() << ":" << ECalEBSrc_.instance() << "\n"
0159         << "    ECalEESrc             = " << ECalEESrc_.label() << ":" << ECalEESrc_.instance() << "\n"
0160         << "    ECalESSrc             = " << ECalESSrc_.label() << ":" << ECalESSrc_.instance() << "\n"
0161         << "    HCalSrc               = " << HCalSrc_.label() << ":" << HCalSrc_.instance() << "\n"
0162         << "\n"
0163         << "    validHepMCevt         = "
0164         << ":" << validHepMCevt << "\n"
0165         << "    validG4VtxContainer   = "
0166         << ":" << validG4VtxContainer << "\n"
0167         << "    validG4trkContainer   = "
0168         << ":" << validG4trkContainer << "\n"
0169         << "    validPxlBrlLow        = "
0170         << ":" << validPxlBrlLow << "\n"
0171         << "    validPxlBrlHigh       = "
0172         << ":" << validPxlBrlHigh << "\n"
0173         << "    validPxlFwdLow        = "
0174         << ":" << validPxlFwdLow << "\n"
0175         << "    validPxlFwdHigh       = "
0176         << ":" << validPxlFwdHigh << "\n"
0177         << "    validSiTIBLow         = "
0178         << ":" << validSiTIBLow << "\n"
0179         << "    validSiTIBHigh        = "
0180         << ":" << validSiTIBHigh << "\n"
0181         << "    validSiTOBLow         = "
0182         << ":" << validSiTOBLow << "\n"
0183         << "    validSiTOBHigh        = "
0184         << ":" << validSiTOBHigh << "\n"
0185         << "    validSiTIDLow         = "
0186         << ":" << validSiTIDLow << "\n"
0187         << "    validSiTIDHigh        = "
0188         << ":" << validSiTIDHigh << "\n"
0189         << "    validSiTECLow         = "
0190         << ":" << validSiTECLow << "\n"
0191         << "    validSiTECHigh        = "
0192         << ":" << validSiTECHigh << "\n"
0193         << "    validMuonCSC          = "
0194         << ":" << validMuonCSC << "\n"
0195         << "    validMuonDt           = "
0196         << ":" << validMuonDt << "\n"
0197         << "    validMuonRPC          = "
0198         << ":" << validMuonRPC << "\n"
0199         << "    validEB               = "
0200         << ":" << validEB << "\n"
0201         << "    validEE               = "
0202         << ":" << validEE << "\n"
0203         << "    validPresh            = "
0204         << ":" << validPresh << "\n"
0205         << "    validHcal             = "
0206         << ":" << validHcal << "\n"
0207         << "===============================\n";
0208   }
0209 
0210   // initialize monitor elements
0211   for (Int_t i = 0; i < 2; ++i) {
0212     meMCRGP[i] = nullptr;
0213     meMCG4Vtx[i] = nullptr;
0214     meGeantVtxX[i] = nullptr;
0215     meGeantVtxY[i] = nullptr;
0216     meGeantVtxZ[i] = nullptr;
0217     meMCG4Trk[i] = nullptr;
0218     meCaloEcal[i] = nullptr;
0219     meCaloEcalE[i] = nullptr;
0220     meCaloEcalToF[i] = nullptr;
0221     meCaloPreSh[i] = nullptr;
0222     meCaloPreShE[i] = nullptr;
0223     meCaloPreShToF[i] = nullptr;
0224     meCaloHcal[i] = nullptr;
0225     meCaloHcalE[i] = nullptr;
0226     meCaloHcalToF[i] = nullptr;
0227     meTrackerPx[i] = nullptr;
0228     meTrackerSi[i] = nullptr;
0229     meMuon[i] = nullptr;
0230     meMuonDtToF[i] = nullptr;
0231     meMuonCscToF[i] = nullptr;
0232     meMuonRpcFToF[i] = nullptr;
0233     meMuonRpcBToF[i] = nullptr;
0234     meGeantVtxRad[i] = nullptr;
0235   }
0236   meGeantTrkPt = nullptr;
0237   meGeantTrkE = nullptr;
0238   meGeantVtxEta = nullptr;
0239   meGeantVtxPhi = nullptr;
0240   meGeantVtxMulti = nullptr;
0241   meCaloEcalPhi = nullptr;
0242   meCaloEcalEta = nullptr;
0243   meCaloPreShPhi = nullptr;
0244   meCaloPreShEta = nullptr;
0245   meCaloHcalPhi = nullptr;
0246   meCaloHcalEta = nullptr;
0247   meTrackerPxPhi = nullptr;
0248   meTrackerPxEta = nullptr;
0249   meTrackerPxBToF = nullptr;
0250   meTrackerPxBR = nullptr;
0251   meTrackerPxFToF = nullptr;
0252   meTrackerPxFZ = nullptr;
0253   meTrackerSiPhi = nullptr;
0254   meTrackerSiEta = nullptr;
0255   meTrackerSiBToF = nullptr;
0256   meTrackerSiBR = nullptr;
0257   meTrackerSiFToF = nullptr;
0258   meTrackerSiFZ = nullptr;
0259   meMuonPhi = nullptr;
0260   meMuonEta = nullptr;
0261   meMuonDtR = nullptr;
0262   meMuonCscZ = nullptr;
0263   meMuonRpcBR = nullptr;
0264   meMuonRpcFZ = nullptr;
0265 }
0266 
0267 GlobalHitsAnalyzer::~GlobalHitsAnalyzer() {}
0268 
0269 void GlobalHitsAnalyzer::bookHistograms(DQMStore::IBooker &iBooker, edm::Run const &run, edm::EventSetup const &es) {
0270   // book histograms
0271   Char_t hname[200];
0272   Char_t htitle[200];
0273 
0274   // MCGeant
0275   iBooker.setCurrentFolder("GlobalHitsV/MCGeant");
0276   sprintf(hname, "hMCRGP1");
0277   sprintf(htitle, "RawGenParticles");
0278   meMCRGP[0] = iBooker.book1D(hname, htitle, 100, 0., 5000.);
0279   sprintf(hname, "hMCRGP2");
0280   meMCRGP[1] = iBooker.book1D(hname, htitle, 100, 0., 500.);
0281   for (Int_t i = 0; i < 2; ++i) {
0282     meMCRGP[i]->setAxisTitle("Number of Raw Generated Particles", 1);
0283     meMCRGP[i]->setAxisTitle("Count", 2);
0284   }
0285 
0286   sprintf(hname, "hMCG4Vtx1");
0287   sprintf(htitle, "G4 Vertices");
0288   meMCG4Vtx[0] = iBooker.book1D(hname, htitle, 150, 0., 15000.);
0289   sprintf(hname, "hMCG4Vtx2");
0290   meMCG4Vtx[1] = iBooker.book1D(hname, htitle, 100, -0.5, 99.5);
0291   for (Int_t i = 0; i < 2; ++i) {
0292     meMCG4Vtx[i]->setAxisTitle("Number of Vertices", 1);
0293     meMCG4Vtx[i]->setAxisTitle("Count", 2);
0294   }
0295 
0296   sprintf(hname, "hMCG4Trk1");
0297   sprintf(htitle, "G4 Tracks");
0298   meMCG4Trk[0] = iBooker.book1D(hname, htitle, 150, 0., 15000.);
0299   sprintf(hname, "hMCG4Trk2");
0300   meMCG4Trk[1] = iBooker.book1D(hname, htitle, 150, -0.5, 99.5);
0301   for (Int_t i = 0; i < 2; ++i) {
0302     meMCG4Trk[i]->setAxisTitle("Number of Tracks", 1);
0303     meMCG4Trk[i]->setAxisTitle("Count", 2);
0304   }
0305 
0306   sprintf(hname, "hGeantVtxX1");
0307   sprintf(htitle, "Geant vertex x/micrometer");
0308   meGeantVtxX[0] = iBooker.book1D(hname, htitle, 100, -8000000., 8000000.);
0309   sprintf(hname, "hGeantVtxX2");
0310   meGeantVtxX[1] = iBooker.book1D(hname, htitle, 100, -50., 50.);
0311   for (Int_t i = 0; i < 2; ++i) {
0312     meGeantVtxX[i]->setAxisTitle("x of Vertex (um)", 1);
0313     meGeantVtxX[i]->setAxisTitle("Count", 2);
0314   }
0315 
0316   sprintf(hname, "hGeantVtxY1");
0317   sprintf(htitle, "Geant vertex y/micrometer");
0318   meGeantVtxY[0] = iBooker.book1D(hname, htitle, 100, -8000000, 8000000.);
0319   sprintf(hname, "hGeantVtxY2");
0320   meGeantVtxY[1] = iBooker.book1D(hname, htitle, 100, -50., 50.);
0321   for (Int_t i = 0; i < 2; ++i) {
0322     meGeantVtxY[i]->setAxisTitle("y of Vertex (um)", 1);
0323     meGeantVtxY[i]->setAxisTitle("Count", 2);
0324   }
0325 
0326   sprintf(hname, "hGeantVtxZ1");
0327   sprintf(htitle, "Geant vertex z/millimeter");
0328   meGeantVtxZ[0] = iBooker.book1D(hname, htitle, 100, -11000., 11000.);
0329   sprintf(hname, "hGeantVtxZ2");
0330   meGeantVtxZ[1] = iBooker.book1D(hname, htitle, 200, -500., 500.);
0331   // meGeantVtxZ[1] = iBooker.book1D(hname,htitle,100,-250.,250.);
0332   for (Int_t i = 0; i < 2; ++i) {
0333     meGeantVtxZ[i]->setAxisTitle("z of Vertex (mm)", 1);
0334     meGeantVtxZ[i]->setAxisTitle("Count", 2);
0335   }
0336 
0337   sprintf(hname, "hGeantTrkPt");
0338   sprintf(htitle, "Log10 Geant track pt/GeV");
0339   meGeantTrkPt = iBooker.book1D(hname, htitle, 80, -4., 4.);
0340   meGeantTrkPt->setAxisTitle("Log10 pT of Track (GeV)", 1);
0341   meGeantTrkPt->setAxisTitle("Count", 2);
0342 
0343   sprintf(hname, "hGeantTrkE");
0344   sprintf(htitle, "Log10 Geant track E/GeV");
0345   meGeantTrkE = iBooker.book1D(hname, htitle, 80, -4., 4.);
0346   meGeantTrkE->setAxisTitle("Log10 E of Track (GeV)", 1);
0347   meGeantTrkE->setAxisTitle("Count", 2);
0348 
0349   sprintf(hname, "hGeantVtxEta");
0350   sprintf(htitle, "Geant vertices eta");
0351   meGeantVtxEta = iBooker.book1D(hname, htitle, 220, -5.5, 5.5);
0352   meGeantVtxEta->setAxisTitle("eta of SimVertex", 1);
0353   meGeantVtxEta->setAxisTitle("Count", 2);
0354 
0355   sprintf(hname, "hGeantVtxPhi");
0356   sprintf(htitle, "Geant vertices phi/rad");
0357   meGeantVtxPhi = iBooker.book1D(hname, htitle, 100, -3.2, 3.2);
0358   meGeantVtxPhi->setAxisTitle("phi of SimVertex (rad)", 1);
0359   meGeantVtxPhi->setAxisTitle("Count", 2);
0360 
0361   sprintf(hname, "hGeantVtxRad1");
0362   sprintf(htitle, "Geant vertices radius/cm");
0363   meGeantVtxRad[0] = iBooker.book1D(hname, htitle, 130, 0., 130.);
0364   sprintf(hname, "hGeantVtxRad2");
0365   meGeantVtxRad[1] = iBooker.book1D(hname, htitle, 100, 0., 1000.);
0366   for (Int_t i = 0; i < 2; ++i) {
0367     meGeantVtxRad[i]->setAxisTitle("radius of SimVertex (cm)", 1);
0368     meGeantVtxRad[i]->setAxisTitle("Count", 2);
0369   }
0370 
0371   sprintf(hname, "hGeantVtxMulti");
0372   sprintf(htitle, "Geant vertices outgoing multiplicity");
0373   meGeantVtxMulti = iBooker.book1D(hname, htitle, 20, 0., 20);
0374   meGeantVtxMulti->setAxisTitle("multiplicity of particles attached to a SimVertex", 1);
0375   meGeantVtxMulti->setAxisTitle("Count", 2);
0376 
0377   // ECal
0378   iBooker.setCurrentFolder("GlobalHitsV/ECals");
0379   sprintf(hname, "hCaloEcal1");
0380   sprintf(htitle, "Ecal hits");
0381   meCaloEcal[0] = iBooker.book1D(hname, htitle, 100, 0., 10000.);
0382   sprintf(hname, "hCaloEcal2");
0383   meCaloEcal[1] = iBooker.book1D(hname, htitle, 100, -0.5, 99.5);
0384 
0385   sprintf(hname, "hCaloEcalE1");
0386   sprintf(htitle, "Ecal hits, energy/GeV");
0387   meCaloEcalE[0] = iBooker.book1D(hname, htitle, 100, 0., 10.);
0388   sprintf(hname, "hCaloEcalE2");
0389   meCaloEcalE[1] = iBooker.book1D(hname, htitle, 100, 0., 0.1);
0390   sprintf(hname, "hCaloEcalToF1");
0391   sprintf(htitle, "Ecal hits, ToF/ns");
0392   meCaloEcalToF[0] = iBooker.book1D(hname, htitle, 100, 0., 1000.);
0393   sprintf(hname, "hCaloEcalToF2");
0394   meCaloEcalToF[1] = iBooker.book1D(hname, htitle, 100, 0., 100.);
0395 
0396   for (Int_t i = 0; i < 2; ++i) {
0397     meCaloEcal[i]->setAxisTitle("Number of Hits", 1);
0398     meCaloEcal[i]->setAxisTitle("Count", 2);
0399     meCaloEcalE[i]->setAxisTitle("Energy of Hits (GeV)", 1);
0400     meCaloEcalE[i]->setAxisTitle("Count", 2);
0401     meCaloEcalToF[i]->setAxisTitle("Time of Flight of Hits (ns)", 1);
0402     meCaloEcalToF[i]->setAxisTitle("Count", 2);
0403   }
0404 
0405   sprintf(hname, "hCaloEcalPhi");
0406   sprintf(htitle, "Ecal hits, phi/rad");
0407   meCaloEcalPhi = iBooker.book1D(hname, htitle, 100, -3.2, 3.2);
0408   meCaloEcalPhi->setAxisTitle("Phi of Hits (rad)", 1);
0409   meCaloEcalPhi->setAxisTitle("Count", 2);
0410 
0411   sprintf(hname, "hCaloEcalEta");
0412   sprintf(htitle, "Ecal hits, eta");
0413   meCaloEcalEta = iBooker.book1D(hname, htitle, 100, -5.5, 5.5);
0414   meCaloEcalEta->setAxisTitle("Eta of Hits", 1);
0415   meCaloEcalEta->setAxisTitle("Count", 2);
0416 
0417   sprintf(hname, "hCaloPreSh1");
0418   sprintf(htitle, "PreSh hits");
0419   meCaloPreSh[0] = iBooker.book1D(hname, htitle, 100, 0., 10000.);
0420   sprintf(hname, "hCaloPreSh2");
0421   meCaloPreSh[1] = iBooker.book1D(hname, htitle, 100, -0.5, 99.5);
0422 
0423   sprintf(hname, "hCaloPreShE1");
0424   sprintf(htitle, "PreSh hits, energy/GeV");
0425   meCaloPreShE[0] = iBooker.book1D(hname, htitle, 100, 0., 10.);
0426   sprintf(hname, "hCaloPreShE2");
0427   meCaloPreShE[1] = iBooker.book1D(hname, htitle, 100, 0., 0.1);
0428 
0429   sprintf(hname, "hCaloPreShToF1");
0430   sprintf(htitle, "PreSh hits, ToF/ns");
0431   meCaloPreShToF[0] = iBooker.book1D(hname, htitle, 100, 0., 1000.);
0432   sprintf(hname, "hCaloPreShToF2");
0433   meCaloPreShToF[1] = iBooker.book1D(hname, htitle, 100, 0., 100.);
0434 
0435   for (Int_t i = 0; i < 2; ++i) {
0436     meCaloPreSh[i]->setAxisTitle("Number of Hits", 1);
0437     meCaloPreSh[i]->setAxisTitle("Count", 2);
0438     meCaloPreShE[i]->setAxisTitle("Energy of Hits (GeV)", 1);
0439     meCaloPreShE[i]->setAxisTitle("Count", 2);
0440     meCaloPreShToF[i]->setAxisTitle("Time of Flight of Hits (ns)", 1);
0441     meCaloPreShToF[i]->setAxisTitle("Count", 2);
0442   }
0443 
0444   sprintf(hname, "hCaloPreShPhi");
0445   sprintf(htitle, "PreSh hits, phi/rad");
0446   meCaloPreShPhi = iBooker.book1D(hname, htitle, 100, -3.2, 3.2);
0447   meCaloPreShPhi->setAxisTitle("Phi of Hits (rad)", 1);
0448   meCaloPreShPhi->setAxisTitle("Count", 2);
0449 
0450   sprintf(hname, "hCaloPreShEta");
0451   sprintf(htitle, "PreSh hits, eta");
0452   meCaloPreShEta = iBooker.book1D(hname, htitle, 100, -5.5, 5.5);
0453   meCaloPreShEta->setAxisTitle("Eta of Hits", 1);
0454   meCaloPreShEta->setAxisTitle("Count", 2);
0455 
0456   // Hcal
0457   iBooker.setCurrentFolder("GlobalHitsV/HCals");
0458   sprintf(hname, "hCaloHcal1");
0459   sprintf(htitle, "Hcal hits");
0460   meCaloHcal[0] = iBooker.book1D(hname, htitle, 100, 0., 10000.);
0461   sprintf(hname, "hCaloHcal2");
0462   meCaloHcal[1] = iBooker.book1D(hname, htitle, 100, -0.5, 99.5);
0463 
0464   sprintf(hname, "hCaloHcalE1");
0465   sprintf(htitle, "Hcal hits, energy/GeV");
0466   meCaloHcalE[0] = iBooker.book1D(hname, htitle, 100, 0., 10.);
0467   sprintf(hname, "hCaloHcalE2");
0468   meCaloHcalE[1] = iBooker.book1D(hname, htitle, 100, 0., 0.1);
0469 
0470   sprintf(hname, "hCaloHcalToF1");
0471   sprintf(htitle, "Hcal hits, ToF/ns");
0472   meCaloHcalToF[0] = iBooker.book1D(hname, htitle, 100, 0., 1000.);
0473   sprintf(hname, "hCaloHcalToF2");
0474   meCaloHcalToF[1] = iBooker.book1D(hname, htitle, 100, 0., 100.);
0475 
0476   for (Int_t i = 0; i < 2; ++i) {
0477     meCaloHcal[i]->setAxisTitle("Number of Hits", 1);
0478     meCaloHcal[i]->setAxisTitle("Count", 2);
0479     meCaloHcalE[i]->setAxisTitle("Energy of Hits (GeV)", 1);
0480     meCaloHcalE[i]->setAxisTitle("Count", 2);
0481     meCaloHcalToF[i]->setAxisTitle("Time of Flight of Hits (ns)", 1);
0482     meCaloHcalToF[i]->setAxisTitle("Count", 2);
0483   }
0484 
0485   sprintf(hname, "hCaloHcalPhi");
0486   sprintf(htitle, "Hcal hits, phi/rad");
0487   meCaloHcalPhi = iBooker.book1D(hname, htitle, 100, -3.2, 3.2);
0488   meCaloHcalPhi->setAxisTitle("Phi of Hits (rad)", 1);
0489   meCaloHcalPhi->setAxisTitle("Count", 2);
0490 
0491   sprintf(hname, "hCaloHcalEta");
0492   sprintf(htitle, "Hcal hits, eta");
0493   meCaloHcalEta = iBooker.book1D(hname, htitle, 100, -5.5, 5.5);
0494   meCaloHcalEta->setAxisTitle("Eta of Hits", 1);
0495   meCaloHcalEta->setAxisTitle("Count", 2);
0496 
0497   // SiPixels
0498   iBooker.setCurrentFolder("GlobalHitsV/SiPixels");
0499   sprintf(hname, "hTrackerPx1");
0500   sprintf(htitle, "Pixel hits");
0501   meTrackerPx[0] = iBooker.book1D(hname, htitle, 100, 0., 10000.);
0502   sprintf(hname, "hTrackerPx2");
0503   meTrackerPx[1] = iBooker.book1D(hname, htitle, 100, -0.5, 99.5);
0504   for (Int_t i = 0; i < 2; ++i) {
0505     meTrackerPx[i]->setAxisTitle("Number of Pixel Hits", 1);
0506     meTrackerPx[i]->setAxisTitle("Count", 2);
0507   }
0508 
0509   sprintf(hname, "hTrackerPxPhi");
0510   sprintf(htitle, "Pixel hits phi/rad");
0511   meTrackerPxPhi = iBooker.book1D(hname, htitle, 100, -3.2, 3.2);
0512   meTrackerPxPhi->setAxisTitle("Phi of Hits (rad)", 1);
0513   meTrackerPxPhi->setAxisTitle("Count", 2);
0514 
0515   sprintf(hname, "hTrackerPxEta");
0516   sprintf(htitle, "Pixel hits eta");
0517   meTrackerPxEta = iBooker.book1D(hname, htitle, 100, -3.5, 3.5);
0518   meTrackerPxEta->setAxisTitle("Eta of Hits", 1);
0519   meTrackerPxEta->setAxisTitle("Count", 2);
0520 
0521   sprintf(hname, "hTrackerPxBToF");
0522   sprintf(htitle, "Pixel barrel hits, ToF/ns");
0523   meTrackerPxBToF = iBooker.book1D(hname, htitle, 100, 0., 40.);
0524   meTrackerPxBToF->setAxisTitle("Time of Flight of Hits (ns)", 1);
0525   meTrackerPxBToF->setAxisTitle("Count", 2);
0526 
0527   sprintf(hname, "hTrackerPxBR");
0528   sprintf(htitle, "Pixel barrel hits, R/cm");
0529   meTrackerPxBR = iBooker.book1D(hname, htitle, 100, 0., 50.);
0530   meTrackerPxBR->setAxisTitle("R of Hits (cm)", 1);
0531   meTrackerPxBR->setAxisTitle("Count", 2);
0532 
0533   sprintf(hname, "hTrackerPxFToF");
0534   sprintf(htitle, "Pixel forward hits, ToF/ns");
0535   meTrackerPxFToF = iBooker.book1D(hname, htitle, 100, 0., 50.);
0536   meTrackerPxFToF->setAxisTitle("Time of Flight of Hits (ns)", 1);
0537   meTrackerPxFToF->setAxisTitle("Count", 2);
0538 
0539   sprintf(hname, "hTrackerPxFZ");
0540   sprintf(htitle, "Pixel forward hits, Z/cm");
0541   meTrackerPxFZ = iBooker.book1D(hname, htitle, 200, -100., 100.);
0542   meTrackerPxFZ->setAxisTitle("Z of Hits (cm)", 1);
0543   meTrackerPxFZ->setAxisTitle("Count", 2);
0544 
0545   // SiStrips
0546   iBooker.setCurrentFolder("GlobalHitsV/SiStrips");
0547   sprintf(hname, "hTrackerSi1");
0548   sprintf(htitle, "Silicon hits");
0549   meTrackerSi[0] = iBooker.book1D(hname, htitle, 100, 0., 10000.);
0550   sprintf(hname, "hTrackerSi2");
0551   meTrackerSi[1] = iBooker.book1D(hname, htitle, 100, -0.5, 99.5);
0552   for (Int_t i = 0; i < 2; ++i) {
0553     meTrackerSi[i]->setAxisTitle("Number of Silicon Hits", 1);
0554     meTrackerSi[i]->setAxisTitle("Count", 2);
0555   }
0556 
0557   sprintf(hname, "hTrackerSiPhi");
0558   sprintf(htitle, "Silicon hits phi/rad");
0559   meTrackerSiPhi = iBooker.book1D(hname, htitle, 100, -3.2, 3.2);
0560   meTrackerSiPhi->setAxisTitle("Phi of Hits (rad)", 1);
0561   meTrackerSiPhi->setAxisTitle("Count", 2);
0562 
0563   sprintf(hname, "hTrackerSiEta");
0564   sprintf(htitle, "Silicon hits eta");
0565   meTrackerSiEta = iBooker.book1D(hname, htitle, 100, -3.5, 3.5);
0566   meTrackerSiEta->setAxisTitle("Eta of Hits", 1);
0567   meTrackerSiEta->setAxisTitle("Count", 2);
0568 
0569   sprintf(hname, "hTrackerSiBToF");
0570   sprintf(htitle, "Silicon barrel hits, ToF/ns");
0571   meTrackerSiBToF = iBooker.book1D(hname, htitle, 100, 0., 50.);
0572   meTrackerSiBToF->setAxisTitle("Time of Flight of Hits (ns)", 1);
0573   meTrackerSiBToF->setAxisTitle("Count", 2);
0574 
0575   sprintf(hname, "hTrackerSiBR");
0576   sprintf(htitle, "Silicon barrel hits, R/cm");
0577   meTrackerSiBR = iBooker.book1D(hname, htitle, 100, 0., 200.);
0578   meTrackerSiBR->setAxisTitle("R of Hits (cm)", 1);
0579   meTrackerSiBR->setAxisTitle("Count", 2);
0580 
0581   sprintf(hname, "hTrackerSiFToF");
0582   sprintf(htitle, "Silicon forward hits, ToF/ns");
0583   meTrackerSiFToF = iBooker.book1D(hname, htitle, 100, 0., 75.);
0584   meTrackerSiFToF->setAxisTitle("Time of Flight of Hits (ns)", 1);
0585   meTrackerSiFToF->setAxisTitle("Count", 2);
0586 
0587   sprintf(hname, "hTrackerSiFZ");
0588   sprintf(htitle, "Silicon forward hits, Z/cm");
0589   meTrackerSiFZ = iBooker.book1D(hname, htitle, 200, -300., 300.);
0590   meTrackerSiFZ->setAxisTitle("Z of Hits (cm)", 1);
0591   meTrackerSiFZ->setAxisTitle("Count", 2);
0592 
0593   // Muon
0594   iBooker.setCurrentFolder("GlobalHitsV/Muons");
0595   sprintf(hname, "hMuon1");
0596   sprintf(htitle, "Muon hits");
0597   meMuon[0] = iBooker.book1D(hname, htitle, 100, 0., 10000.);
0598   sprintf(hname, "hMuon2");
0599   meMuon[1] = iBooker.book1D(hname, htitle, 100, -0.5, 99.5);
0600   for (Int_t i = 0; i < 2; ++i) {
0601     meMuon[i]->setAxisTitle("Number of Muon Hits", 1);
0602     meMuon[i]->setAxisTitle("Count", 2);
0603   }
0604 
0605   sprintf(hname, "hMuonPhi");
0606   sprintf(htitle, "Muon hits phi/rad");
0607   meMuonPhi = iBooker.book1D(hname, htitle, 100, -3.2, 3.2);
0608   meMuonPhi->setAxisTitle("Phi of Hits (rad)", 1);
0609   meMuonPhi->setAxisTitle("Count", 2);
0610 
0611   sprintf(hname, "hMuonEta");
0612   sprintf(htitle, "Muon hits eta");
0613   meMuonEta = iBooker.book1D(hname, htitle, 100, -3.5, 3.5);
0614   meMuonEta->setAxisTitle("Eta of Hits", 1);
0615   meMuonEta->setAxisTitle("Count", 2);
0616 
0617   sprintf(hname, "hMuonCscToF1");
0618   sprintf(htitle, "Muon CSC hits, ToF/ns");
0619   meMuonCscToF[0] = iBooker.book1D(hname, htitle, 100, 0., 250.);
0620   sprintf(hname, "hMuonCscToF2");
0621   meMuonCscToF[1] = iBooker.book1D(hname, htitle, 100, 0., 50.);
0622   for (Int_t i = 0; i < 2; ++i) {
0623     meMuonCscToF[i]->setAxisTitle("Time of Flight of Hits (ns)", 1);
0624     meMuonCscToF[i]->setAxisTitle("Count", 2);
0625   }
0626 
0627   sprintf(hname, "hMuonCscZ");
0628   sprintf(htitle, "Muon CSC hits, Z/cm");
0629   meMuonCscZ = iBooker.book1D(hname, htitle, 200, -1500., 1500.);
0630   meMuonCscZ->setAxisTitle("Z of Hits (cm)", 1);
0631   meMuonCscZ->setAxisTitle("Count", 2);
0632 
0633   sprintf(hname, "hMuonDtToF1");
0634   sprintf(htitle, "Muon DT hits, ToF/ns");
0635   meMuonDtToF[0] = iBooker.book1D(hname, htitle, 100, 0., 250.);
0636   sprintf(hname, "hMuonDtToF2");
0637   meMuonDtToF[1] = iBooker.book1D(hname, htitle, 100, 0., 50.);
0638   for (Int_t i = 0; i < 2; ++i) {
0639     meMuonDtToF[i]->setAxisTitle("Time of Flight of Hits (ns)", 1);
0640     meMuonDtToF[i]->setAxisTitle("Count", 2);
0641   }
0642 
0643   sprintf(hname, "hMuonDtR");
0644   sprintf(htitle, "Muon DT hits, R/cm");
0645   meMuonDtR = iBooker.book1D(hname, htitle, 100, 0., 1500.);
0646   meMuonDtR->setAxisTitle("R of Hits (cm)", 1);
0647   meMuonDtR->setAxisTitle("Count", 2);
0648 
0649   sprintf(hname, "hMuonRpcFToF1");
0650   sprintf(htitle, "Muon RPC forward hits, ToF/ns");
0651   meMuonRpcFToF[0] = iBooker.book1D(hname, htitle, 100, 0., 250.);
0652   sprintf(hname, "hMuonRpcFToF2");
0653   meMuonRpcFToF[1] = iBooker.book1D(hname, htitle, 100, 0., 50.);
0654   for (Int_t i = 0; i < 2; ++i) {
0655     meMuonRpcFToF[i]->setAxisTitle("Time of Flight of Hits (ns)", 1);
0656     meMuonRpcFToF[i]->setAxisTitle("Count", 2);
0657   }
0658   sprintf(hname, "hMuonRpcFZ");
0659   sprintf(htitle, "Muon RPC forward hits, Z/cm");
0660   meMuonRpcFZ = iBooker.book1D(hname, htitle, 201, -1500., 1500.);
0661   meMuonRpcFZ->setAxisTitle("Z of Hits (cm)", 1);
0662   meMuonRpcFZ->setAxisTitle("Count", 2);
0663 
0664   sprintf(hname, "hMuonRpcBToF1");
0665   sprintf(htitle, "Muon RPC barrel hits, ToF/ns");
0666   meMuonRpcBToF[0] = iBooker.book1D(hname, htitle, 100, 0., 250.);
0667   sprintf(hname, "hMuonRpcBToF2");
0668   meMuonRpcBToF[1] = iBooker.book1D(hname, htitle, 100, 0., 50.);
0669   for (Int_t i = 0; i < 2; ++i) {
0670     meMuonRpcBToF[i]->setAxisTitle("Time of Flight of Hits (ns)", 1);
0671     meMuonRpcBToF[i]->setAxisTitle("Count", 2);
0672   }
0673 
0674   sprintf(hname, "hMuonRpcBR");
0675   sprintf(htitle, "Muon RPC barrel hits, R/cm");
0676   meMuonRpcBR = iBooker.book1D(hname, htitle, 100, 0., 1500.);
0677   meMuonRpcBR->setAxisTitle("R of Hits (cm)", 1);
0678   meMuonRpcBR->setAxisTitle("Count", 2);
0679 }
0680 
0681 void GlobalHitsAnalyzer::analyze(const edm::Event &iEvent, const edm::EventSetup &iSetup) {
0682   std::string MsgLoggerCat = "GlobalHitsAnalyzer_analyze";
0683 
0684   // keep track of number of events processed
0685   ++count;
0686 
0687   // get event id information
0688   edm::RunNumber_t nrun = iEvent.id().run();
0689   edm::EventNumber_t nevt = iEvent.id().event();
0690 
0691   if (verbosity > 0) {
0692     edm::LogInfo(MsgLoggerCat) << "Processing run " << nrun << ", event " << nevt << " (" << count << " events total)";
0693   } else if (verbosity == 0) {
0694     if (nevt % frequency == 0 || nevt == 1) {
0695       edm::LogInfo(MsgLoggerCat) << "Processing run " << nrun << ", event " << nevt << " (" << count
0696                                  << " events total)";
0697     }
0698   }
0699 
0700   // look at information available in the event
0701   if (getAllProvenances) {
0702     std::vector<const edm::StableProvenance *> AllProv;
0703     iEvent.getAllStableProvenance(AllProv);
0704 
0705     if (verbosity >= 0)
0706       edm::LogInfo(MsgLoggerCat) << "Number of Provenances = " << AllProv.size();
0707 
0708     if (printProvenanceInfo && (verbosity >= 0)) {
0709       TString eventout("\nProvenance info:\n");
0710 
0711       for (unsigned int i = 0; i < AllProv.size(); ++i) {
0712         eventout += "\n       ******************************";
0713         eventout += "\n       Module       : ";
0714         eventout += AllProv[i]->moduleLabel();
0715         eventout += "\n       ProductID    : ";
0716         eventout += AllProv[i]->productID().id();
0717         eventout += "\n       ClassName    : ";
0718         eventout += AllProv[i]->className();
0719         eventout += "\n       InstanceName : ";
0720         eventout += AllProv[i]->productInstanceName();
0721         eventout += "\n       BranchName   : ";
0722         eventout += AllProv[i]->branchName();
0723       }
0724       eventout += "\n       ******************************\n";
0725       edm::LogInfo(MsgLoggerCat) << eventout << "\n";
0726       printProvenanceInfo = false;
0727     }
0728     getAllProvenances = false;
0729   }
0730 
0731   // call fill functions
0732   // gather G4MC information from event
0733   fillG4MC(iEvent);
0734   // gather Tracker information from event
0735   fillTrk(iEvent, iSetup);
0736   // gather muon information from event
0737   fillMuon(iEvent, iSetup);
0738   // gather Ecal information from event
0739   fillECal(iEvent, iSetup);
0740   // gather Hcal information from event
0741   fillHCal(iEvent, iSetup);
0742 
0743   if (verbosity > 0)
0744     edm::LogInfo(MsgLoggerCat) << "Done gathering data from event.";
0745 
0746   return;
0747 }
0748 
0749 //==================fill and store functions================================
0750 void GlobalHitsAnalyzer::fillG4MC(const edm::Event &iEvent) {
0751   std::string MsgLoggerCat = "GlobalHitsAnalyzer_fillG4MC";
0752 
0753   TString eventout;
0754   if (verbosity > 0)
0755     eventout = "\nGathering info:";
0756 
0757   //////////////////////
0758   // get MC information
0759   /////////////////////
0760   edm::Handle<edm::HepMCProduct> HepMCEvt;
0761   std::vector<edm::Handle<edm::HepMCProduct>> AllHepMCEvt;
0762   getterOfProducts_.fillHandles(iEvent, AllHepMCEvt);
0763   // loop through products and extract VtxSmearing if available. Any of them
0764   // should have the information needed
0765   for (unsigned int i = 0; i < AllHepMCEvt.size(); ++i) {
0766     HepMCEvt = AllHepMCEvt[i];
0767     if ((HepMCEvt.provenance()->branchDescription()).moduleLabel() == "generatorSmeared")
0768       break;
0769   }
0770 
0771   if (!HepMCEvt.isValid()) {
0772     LogDebug(MsgLoggerCat) << "Unable to find HepMCProduct in event!";
0773     validHepMCevt = false;
0774   } else {
0775     eventout += "\n          Using HepMCProduct: ";
0776     eventout += (HepMCEvt.provenance()->branchDescription()).moduleLabel();
0777   }
0778   if (validHepMCevt) {
0779     const HepMC::GenEvent *MCEvt = HepMCEvt->GetEvent();
0780     nRawGenPart = MCEvt->particles_size();
0781 
0782     if (verbosity > 1) {
0783       eventout += "\n          Number of Raw Particles collected:......... ";
0784       eventout += nRawGenPart;
0785     }
0786 
0787     if (meMCRGP[0])
0788       meMCRGP[0]->Fill((float)nRawGenPart);
0789     if (meMCRGP[1])
0790       meMCRGP[1]->Fill((float)nRawGenPart);
0791   }
0792 
0793   ////////////////////////////
0794   // get G4Vertex information
0795   ////////////////////////////
0796   // convert unit stored in SimVertex to mm
0797   float unit = 0.;
0798   if (vtxunit == 0)
0799     unit = 1.;  // already in mm
0800   if (vtxunit == 1)
0801     unit = 10.;  // stored in cm, convert to mm
0802 
0803   edm::Handle<edm::SimVertexContainer> G4VtxContainer;
0804   iEvent.getByToken(G4VtxSrc_Token_, G4VtxContainer);
0805 
0806   // needed here by vertex multiplicity
0807   edm::Handle<edm::SimTrackContainer> G4TrkContainer;
0808   iEvent.getByToken(G4TrkSrc_Token_, G4TrkContainer);
0809 
0810   if (!G4VtxContainer.isValid()) {
0811     LogDebug(MsgLoggerCat) << "Unable to find SimVertex in event!";
0812     validG4VtxContainer = false;
0813   }
0814   if (validG4VtxContainer) {
0815     int i = 0;
0816     edm::SimVertexContainer::const_iterator itVtx;
0817     for (itVtx = G4VtxContainer->begin(); itVtx != G4VtxContainer->end(); ++itVtx) {
0818       ++i;
0819 
0820       const math::XYZTLorentzVector G4Vtx1(
0821           itVtx->position().x(), itVtx->position().y(), itVtx->position().z(), itVtx->position().e());
0822 
0823       double G4Vtx[4];
0824       G4Vtx1.GetCoordinates(G4Vtx);
0825 
0826       if (meGeantVtxX[0])
0827         meGeantVtxX[0]->Fill((G4Vtx[0] * unit) / micrometer);
0828       if (meGeantVtxX[1])
0829         meGeantVtxX[1]->Fill((G4Vtx[0] * unit) / micrometer);
0830 
0831       if (meGeantVtxY[0])
0832         meGeantVtxY[0]->Fill((G4Vtx[1] * unit) / micrometer);
0833       if (meGeantVtxY[1])
0834         meGeantVtxY[1]->Fill((G4Vtx[1] * unit) / micrometer);
0835 
0836       if (meGeantVtxZ[0])
0837         meGeantVtxZ[0]->Fill((G4Vtx[2] * unit) / millimeter);
0838       if (meGeantVtxZ[1])
0839         meGeantVtxZ[1]->Fill((G4Vtx[2] * unit) / millimeter);
0840 
0841       if (meGeantVtxEta)
0842         meGeantVtxEta->Fill(G4Vtx1.eta());
0843       if (meGeantVtxPhi)
0844         meGeantVtxPhi->Fill(G4Vtx1.phi());
0845       if (meGeantVtxRad[0])
0846         meGeantVtxRad[0]->Fill(G4Vtx1.rho());
0847       if (meGeantVtxRad[1])
0848         meGeantVtxRad[1]->Fill(G4Vtx1.rho());
0849 
0850       if (meGeantVtxMulti) {
0851         int multi = 0;
0852         if (G4TrkContainer.isValid()) {
0853           edm::SimTrackContainer::const_iterator itTrk;
0854           for (itTrk = G4TrkContainer->begin(); itTrk != G4TrkContainer->end(); ++itTrk) {
0855             if ((*itTrk).vertIndex() == i) {
0856               multi++;
0857             }
0858           }
0859         }
0860         meGeantVtxMulti->Fill(((double)multi + 0.5));
0861       }
0862     }
0863 
0864     if (verbosity > 1) {
0865       eventout += "\n          Number of G4Vertices collected:............ ";
0866       eventout += i;
0867     }
0868 
0869     if (meMCG4Vtx[0])
0870       meMCG4Vtx[0]->Fill((float)i);
0871     if (meMCG4Vtx[1])
0872       meMCG4Vtx[1]->Fill((float)i);
0873   }
0874 
0875   ///////////////////////////
0876   // get G4Track information
0877   ///////////////////////////
0878   if (!G4TrkContainer.isValid()) {
0879     LogDebug(MsgLoggerCat) << "Unable to find SimTrack in event!";
0880     validG4trkContainer = false;
0881   }
0882   if (validG4trkContainer) {
0883     int i = 0;
0884     edm::SimTrackContainer::const_iterator itTrk;
0885     for (itTrk = G4TrkContainer->begin(); itTrk != G4TrkContainer->end(); ++itTrk) {
0886       ++i;
0887 
0888       const math::XYZTLorentzVector G4Trk1(
0889           itTrk->momentum().x(), itTrk->momentum().y(), itTrk->momentum().z(), itTrk->momentum().e());
0890       double G4Trk[4];
0891       G4Trk1.GetCoordinates(G4Trk);
0892 
0893       if (meGeantTrkPt)
0894         meGeantTrkPt->Fill(std::log10(std::max(sqrt(G4Trk[0] * G4Trk[0] + G4Trk[1] * G4Trk[1]), -9.)));
0895       if (meGeantTrkE)
0896         meGeantTrkE->Fill(std::log10(std::max(G4Trk[3], -9.)));
0897     }
0898 
0899     if (verbosity > 1) {
0900       eventout += "\n          Number of G4Tracks collected:.............. ";
0901       eventout += i;
0902     }
0903 
0904     if (meMCG4Trk[0])
0905       meMCG4Trk[0]->Fill((float)i);
0906     if (meMCG4Trk[1])
0907       meMCG4Trk[1]->Fill((float)i);
0908   }
0909 
0910   if (verbosity > 0)
0911     edm::LogInfo(MsgLoggerCat) << eventout << "\n";
0912 
0913   return;
0914 }
0915 
0916 void GlobalHitsAnalyzer::fillTrk(const edm::Event &iEvent, const edm::EventSetup &iSetup) {
0917   nPxlHits = 0;
0918   std::string MsgLoggerCat = "GlobalHitsAnalyzer_fillTrk";
0919 
0920   TString eventout;
0921   if (verbosity > 0)
0922     eventout = "\nGathering info:";
0923 
0924   // access the tracker geometry
0925   const auto &theTrackerGeometry = iSetup.getHandle(tGeomToken_);
0926   if (!theTrackerGeometry.isValid()) {
0927     edm::LogWarning(MsgLoggerCat) << "Unable to find TrackerDigiGeometryRecord in event!";
0928     return;
0929   }
0930   const TrackerGeometry &theTracker(*theTrackerGeometry);
0931 
0932   // iterator to access containers
0933   edm::PSimHitContainer::const_iterator itHit;
0934 
0935   ///////////////////////////////
0936   // get Pixel Barrel information
0937   ///////////////////////////////
0938   edm::PSimHitContainer thePxlBrlHits;
0939   // extract low container
0940   edm::Handle<edm::PSimHitContainer> PxlBrlLowContainer;
0941   iEvent.getByToken(PxlBrlLowSrc_Token_, PxlBrlLowContainer);
0942   if (!PxlBrlLowContainer.isValid()) {
0943     LogDebug(MsgLoggerCat) << "Unable to find TrackerHitsPixelBarrelLowTof in event!";
0944     validPxlBrlLow = false;
0945   }
0946   // extract high container
0947   edm::Handle<edm::PSimHitContainer> PxlBrlHighContainer;
0948   iEvent.getByToken(PxlBrlHighSrc_Token_, PxlBrlHighContainer);
0949   if (!PxlBrlHighContainer.isValid()) {
0950     LogDebug(MsgLoggerCat) << "Unable to find TrackerHitsPixelBarrelHighTof in event!";
0951     validPxlBrlHigh = false;
0952   }
0953   // place both containers into new container
0954   if (validPxlBrlLow)
0955     thePxlBrlHits.insert(thePxlBrlHits.end(), PxlBrlLowContainer->begin(), PxlBrlLowContainer->end());
0956   if (validPxlBrlHigh)
0957     thePxlBrlHits.insert(thePxlBrlHits.end(), PxlBrlHighContainer->begin(), PxlBrlHighContainer->end());
0958 
0959   // cycle through new container
0960   int i = 0, j = 0;
0961   for (itHit = thePxlBrlHits.begin(); itHit != thePxlBrlHits.end(); ++itHit) {
0962     ++i;
0963 
0964     // create a DetId from the detUnitId
0965     DetId theDetUnitId(itHit->detUnitId());
0966     int detector = theDetUnitId.det();
0967     int subdetector = theDetUnitId.subdetId();
0968 
0969     // check that expected detector is returned
0970     if ((detector == dTrk) && (subdetector == sdPxlBrl)) {
0971       // get the GeomDetUnit from the geometry using theDetUnitID
0972       const GeomDetUnit *theDet = theTracker.idToDetUnit(theDetUnitId);
0973 
0974       if (!theDet) {
0975         edm::LogWarning(MsgLoggerCat) << "Unable to get GeomDetUnit from PxlBrlHits for Hit " << i;
0976         continue;
0977       }
0978 
0979       ++j;
0980 
0981       // get the Surface of the hit (knows how to go from local <-> global)
0982       const BoundPlane &bSurface = theDet->surface();
0983 
0984       if (meTrackerPxBToF)
0985         meTrackerPxBToF->Fill(itHit->tof());
0986       if (meTrackerPxBR)
0987         meTrackerPxBR->Fill(bSurface.toGlobal(itHit->localPosition()).perp());
0988       if (meTrackerPxPhi)
0989         meTrackerPxPhi->Fill(bSurface.toGlobal(itHit->localPosition()).phi());
0990       if (meTrackerPxEta)
0991         meTrackerPxEta->Fill(bSurface.toGlobal(itHit->localPosition()).eta());
0992 
0993     } else {
0994       edm::LogWarning(MsgLoggerCat) << "PxlBrl PSimHit " << i << " is expected to be (det,subdet) = (" << dTrk << ","
0995                                     << sdPxlBrl << "); value returned is: (" << detector << "," << subdetector << ")";
0996       continue;
0997     }  // end detector type check
0998   }    // end loop through PxlBrl Hits
0999 
1000   if (verbosity > 1) {
1001     eventout += "\n          Number of Pixel Barrel Hits collected:..... ";
1002     eventout += j;
1003   }
1004 
1005   nPxlHits += j;
1006 
1007   /////////////////////////////////
1008   // get Pixel Forward information
1009   ////////////////////////////////
1010   edm::PSimHitContainer thePxlFwdHits;
1011   // extract low container
1012   edm::Handle<edm::PSimHitContainer> PxlFwdLowContainer;
1013   iEvent.getByToken(PxlFwdLowSrc_Token_, PxlFwdLowContainer);
1014   if (!PxlFwdLowContainer.isValid()) {
1015     LogDebug(MsgLoggerCat) << "Unable to find TrackerHitsPixelEndcapLowTof in event!";
1016     validPxlFwdLow = false;
1017   }
1018   // extract high container
1019   edm::Handle<edm::PSimHitContainer> PxlFwdHighContainer;
1020   iEvent.getByToken(PxlFwdHighSrc_Token_, PxlFwdHighContainer);
1021   if (!PxlFwdHighContainer.isValid()) {
1022     LogDebug("GlobalHitsAnalyzer_fillTrk") << "Unable to find TrackerHitsPixelEndcapHighTof in event!";
1023     validPxlFwdHigh = false;
1024   }
1025   // place both containers into new container
1026   if (validPxlFwdLow)
1027     thePxlFwdHits.insert(thePxlFwdHits.end(), PxlFwdLowContainer->begin(), PxlFwdLowContainer->end());
1028   if (validPxlFwdHigh)
1029     thePxlFwdHits.insert(thePxlFwdHits.end(), PxlFwdHighContainer->begin(), PxlFwdHighContainer->end());
1030 
1031   // cycle through new container
1032   i = 0;
1033   j = 0;
1034   for (itHit = thePxlFwdHits.begin(); itHit != thePxlFwdHits.end(); ++itHit) {
1035     ++i;
1036 
1037     // create a DetId from the detUnitId
1038     DetId theDetUnitId(itHit->detUnitId());
1039     int detector = theDetUnitId.det();
1040     int subdetector = theDetUnitId.subdetId();
1041 
1042     // check that expected detector is returned
1043     if ((detector == dTrk) && (subdetector == sdPxlFwd)) {
1044       // get the GeomDetUnit from the geometry using theDetUnitID
1045       const GeomDetUnit *theDet = theTracker.idToDetUnit(theDetUnitId);
1046 
1047       if (!theDet) {
1048         edm::LogWarning(MsgLoggerCat) << "Unable to get GeomDetUnit from PxlFwdHits for Hit " << i;
1049         ;
1050         continue;
1051       }
1052 
1053       ++j;
1054 
1055       // get the Surface of the hit (knows how to go from local <-> global)
1056       const BoundPlane &bSurface = theDet->surface();
1057 
1058       if (meTrackerPxFToF)
1059         meTrackerPxFToF->Fill(itHit->tof());
1060       if (meTrackerPxFZ)
1061         meTrackerPxFZ->Fill(bSurface.toGlobal(itHit->localPosition()).z());
1062       if (meTrackerPxPhi)
1063         meTrackerPxPhi->Fill(bSurface.toGlobal(itHit->localPosition()).phi());
1064       if (meTrackerPxEta)
1065         meTrackerPxEta->Fill(bSurface.toGlobal(itHit->localPosition()).eta());
1066 
1067     } else {
1068       edm::LogWarning(MsgLoggerCat) << "PxlFwd PSimHit " << i << " is expected to be (det,subdet) = (" << dTrk << ","
1069                                     << sdPxlFwd << "); value returned is: (" << detector << "," << subdetector << ")";
1070       continue;
1071     }  // end detector type check
1072   }    // end loop through PxlFwd Hits
1073 
1074   if (verbosity > 1) {
1075     eventout += "\n          Number of Pixel Forward Hits collected:.... ";
1076     eventout += j;
1077   }
1078 
1079   nPxlHits += j;
1080 
1081   if (meTrackerPx[0])
1082     meTrackerPx[0]->Fill((float)nPxlHits);
1083   if (meTrackerPx[1])
1084     meTrackerPx[1]->Fill((float)nPxlHits);
1085 
1086   ///////////////////////////////////
1087   // get Silicon Barrel information
1088   //////////////////////////////////
1089   nSiHits = 0;
1090   edm::PSimHitContainer theSiBrlHits;
1091   // extract TIB low container
1092   edm::Handle<edm::PSimHitContainer> SiTIBLowContainer;
1093   iEvent.getByToken(SiTIBLowSrc_Token_, SiTIBLowContainer);
1094   if (!SiTIBLowContainer.isValid()) {
1095     LogDebug(MsgLoggerCat) << "Unable to find TrackerHitsTIBLowTof in event!";
1096     validSiTIBLow = false;
1097   }
1098   // extract TIB high container
1099   edm::Handle<edm::PSimHitContainer> SiTIBHighContainer;
1100   iEvent.getByToken(SiTIBHighSrc_Token_, SiTIBHighContainer);
1101   if (!SiTIBHighContainer.isValid()) {
1102     LogDebug(MsgLoggerCat) << "Unable to find TrackerHitsTIBHighTof in event!";
1103     validSiTIBHigh = false;
1104   }
1105   // extract TOB low container
1106   edm::Handle<edm::PSimHitContainer> SiTOBLowContainer;
1107   iEvent.getByToken(SiTOBLowSrc_Token_, SiTOBLowContainer);
1108   if (!SiTOBLowContainer.isValid()) {
1109     LogDebug(MsgLoggerCat) << "Unable to find TrackerHitsTOBLowTof in event!";
1110     validSiTOBLow = false;
1111   }
1112   // extract TOB high container
1113   edm::Handle<edm::PSimHitContainer> SiTOBHighContainer;
1114   iEvent.getByToken(SiTOBHighSrc_Token_, SiTOBHighContainer);
1115   if (!SiTOBHighContainer.isValid()) {
1116     LogDebug(MsgLoggerCat) << "Unable to find TrackerHitsTOBHighTof in event!";
1117     validSiTOBHigh = false;
1118   }
1119   // place all containers into new container
1120   if (validSiTIBLow)
1121     theSiBrlHits.insert(theSiBrlHits.end(), SiTIBLowContainer->begin(), SiTIBLowContainer->end());
1122   if (validSiTIBHigh)
1123     theSiBrlHits.insert(theSiBrlHits.end(), SiTIBHighContainer->begin(), SiTIBHighContainer->end());
1124   if (validSiTOBLow)
1125     theSiBrlHits.insert(theSiBrlHits.end(), SiTOBLowContainer->begin(), SiTOBLowContainer->end());
1126   if (validSiTOBHigh)
1127     theSiBrlHits.insert(theSiBrlHits.end(), SiTOBHighContainer->begin(), SiTOBHighContainer->end());
1128 
1129   // cycle through new container
1130   i = 0;
1131   j = 0;
1132   for (itHit = theSiBrlHits.begin(); itHit != theSiBrlHits.end(); ++itHit) {
1133     ++i;
1134 
1135     // create a DetId from the detUnitId
1136     DetId theDetUnitId(itHit->detUnitId());
1137     int detector = theDetUnitId.det();
1138     int subdetector = theDetUnitId.subdetId();
1139 
1140     // check that expected detector is returned
1141     if ((detector == dTrk) && ((subdetector == sdSiTIB) || (subdetector == sdSiTOB))) {
1142       // get the GeomDetUnit from the geometry using theDetUnitID
1143       const GeomDetUnit *theDet = theTracker.idToDetUnit(theDetUnitId);
1144 
1145       if (!theDet) {
1146         edm::LogWarning(MsgLoggerCat) << "Unable to get GeomDetUnit from SiBrlHits for Hit " << i;
1147         continue;
1148       }
1149 
1150       ++j;
1151 
1152       // get the Surface of the hit (knows how to go from local <-> global)
1153       const BoundPlane &bSurface = theDet->surface();
1154 
1155       if (meTrackerSiBToF)
1156         meTrackerSiBToF->Fill(itHit->tof());
1157       if (meTrackerSiBR)
1158         meTrackerSiBR->Fill(bSurface.toGlobal(itHit->localPosition()).perp());
1159       if (meTrackerSiPhi)
1160         meTrackerSiPhi->Fill(bSurface.toGlobal(itHit->localPosition()).phi());
1161       if (meTrackerSiEta)
1162         meTrackerSiEta->Fill(bSurface.toGlobal(itHit->localPosition()).eta());
1163 
1164     } else {
1165       edm::LogWarning(MsgLoggerCat) << "SiBrl PSimHit " << i << " is expected to be (det,subdet) = (" << dTrk << ","
1166                                     << sdSiTIB << " || " << sdSiTOB << "); value returned is: (" << detector << ","
1167                                     << subdetector << ")";
1168       continue;
1169     }  // end detector type check
1170   }    // end loop through SiBrl Hits
1171 
1172   if (verbosity > 1) {
1173     eventout += "\n          Number of Silicon Barrel Hits collected:... ";
1174     eventout += j;
1175   }
1176 
1177   nSiHits += j;
1178 
1179   ///////////////////////////////////
1180   // get Silicon Forward information
1181   ///////////////////////////////////
1182   edm::PSimHitContainer theSiFwdHits;
1183   // extract TID low container
1184   edm::Handle<edm::PSimHitContainer> SiTIDLowContainer;
1185   iEvent.getByToken(SiTIDLowSrc_Token_, SiTIDLowContainer);
1186   if (!SiTIDLowContainer.isValid()) {
1187     LogDebug(MsgLoggerCat) << "Unable to find TrackerHitsTIDLowTof in event!";
1188     validSiTIDLow = false;
1189   }
1190   // extract TID high container
1191   edm::Handle<edm::PSimHitContainer> SiTIDHighContainer;
1192   iEvent.getByToken(SiTIDHighSrc_Token_, SiTIDHighContainer);
1193   if (!SiTIDHighContainer.isValid()) {
1194     LogDebug("GlobalHitsAnalyzer_fillTrk") << "Unable to find TrackerHitsTIDHighTof in event!";
1195     validSiTIDHigh = false;
1196   }
1197   // extract TEC low container
1198   edm::Handle<edm::PSimHitContainer> SiTECLowContainer;
1199   iEvent.getByToken(SiTECLowSrc_Token_, SiTECLowContainer);
1200   if (!SiTECLowContainer.isValid()) {
1201     LogDebug(MsgLoggerCat) << "Unable to find TrackerHitsTECLowTof in event!";
1202     validSiTECLow = false;
1203   }
1204   // extract TEC high container
1205   edm::Handle<edm::PSimHitContainer> SiTECHighContainer;
1206   iEvent.getByToken(SiTECHighSrc_Token_, SiTECHighContainer);
1207   if (!SiTECHighContainer.isValid()) {
1208     LogDebug(MsgLoggerCat) << "Unable to find TrackerHitsTECHighTof in event!";
1209     validSiTECHigh = false;
1210   }
1211   // place all containers into new container
1212   if (validSiTIDLow)
1213     theSiFwdHits.insert(theSiFwdHits.end(), SiTIDLowContainer->begin(), SiTIDLowContainer->end());
1214   if (validSiTIDHigh)
1215     theSiFwdHits.insert(theSiFwdHits.end(), SiTIDHighContainer->begin(), SiTIDHighContainer->end());
1216   if (validSiTECLow)
1217     theSiFwdHits.insert(theSiFwdHits.end(), SiTECLowContainer->begin(), SiTECLowContainer->end());
1218   if (validSiTECHigh)
1219     theSiFwdHits.insert(theSiFwdHits.end(), SiTECHighContainer->begin(), SiTECHighContainer->end());
1220 
1221   // cycle through container
1222   i = 0;
1223   j = 0;
1224   for (itHit = theSiFwdHits.begin(); itHit != theSiFwdHits.end(); ++itHit) {
1225     ++i;
1226 
1227     // create a DetId from the detUnitId
1228     DetId theDetUnitId(itHit->detUnitId());
1229     int detector = theDetUnitId.det();
1230     int subdetector = theDetUnitId.subdetId();
1231 
1232     // check that expected detector is returned
1233     if ((detector == dTrk) && ((subdetector == sdSiTID) || (subdetector == sdSiTEC))) {
1234       // get the GeomDetUnit from the geometry using theDetUnitID
1235       const GeomDetUnit *theDet = theTracker.idToDetUnit(theDetUnitId);
1236 
1237       if (!theDet) {
1238         edm::LogWarning(MsgLoggerCat) << "Unable to get GeomDetUnit from SiFwdHits Hit " << i;
1239         return;
1240       }
1241 
1242       ++j;
1243 
1244       // get the Surface of the hit (knows how to go from local <-> global)
1245       const BoundPlane &bSurface = theDet->surface();
1246 
1247       if (meTrackerSiFToF)
1248         meTrackerSiFToF->Fill(itHit->tof());
1249       if (meTrackerSiFZ)
1250         meTrackerSiFZ->Fill(bSurface.toGlobal(itHit->localPosition()).z());
1251       if (meTrackerSiPhi)
1252         meTrackerSiPhi->Fill(bSurface.toGlobal(itHit->localPosition()).phi());
1253       if (meTrackerSiEta)
1254         meTrackerSiEta->Fill(bSurface.toGlobal(itHit->localPosition()).eta());
1255 
1256     } else {
1257       edm::LogWarning(MsgLoggerCat) << "SiFwd PSimHit " << i << " is expected to be (det,subdet) = (" << dTrk << ","
1258                                     << sdSiTOB << " || " << sdSiTEC << "); value returned is: (" << detector << ","
1259                                     << subdetector << ")";
1260       continue;
1261     }  // end check detector type
1262   }    // end loop through SiFwd Hits
1263 
1264   if (verbosity > 1) {
1265     eventout += "\n          Number of Silicon Forward Hits collected:.. ";
1266     eventout += j;
1267   }
1268 
1269   nSiHits += j;
1270 
1271   if (meTrackerSi[0])
1272     meTrackerSi[0]->Fill((float)nSiHits);
1273   if (meTrackerSi[1])
1274     meTrackerSi[1]->Fill((float)nSiHits);
1275 
1276   if (verbosity > 0)
1277     edm::LogInfo(MsgLoggerCat) << eventout << "\n";
1278 
1279   return;
1280 }
1281 
1282 void GlobalHitsAnalyzer::fillMuon(const edm::Event &iEvent, const edm::EventSetup &iSetup) {
1283   nMuonHits = 0;
1284   std::string MsgLoggerCat = "GlobalHitsAnalyzer_fillMuon";
1285 
1286   TString eventout;
1287   if (verbosity > 0)
1288     eventout = "\nGathering info:";
1289 
1290   // iterator to access containers
1291   edm::PSimHitContainer::const_iterator itHit;
1292 
1293   ///////////////////////
1294   // access the CSC Muon
1295   ///////////////////////
1296   // access the CSC Muon geometry
1297   const auto &theCSCGeometry = iSetup.getHandle(cscGeomToken_);
1298   if (!theCSCGeometry.isValid()) {
1299     edm::LogWarning(MsgLoggerCat) << "Unable to find MuonGeometryRecord for the CSCGeometry in event!";
1300     return;
1301   }
1302   const CSCGeometry &theCSCMuon(*theCSCGeometry);
1303 
1304   // get Muon CSC information
1305   edm::Handle<edm::PSimHitContainer> MuonCSCContainer;
1306   iEvent.getByToken(MuonCscSrc_Token_, MuonCSCContainer);
1307   if (!MuonCSCContainer.isValid()) {
1308     LogDebug(MsgLoggerCat) << "Unable to find MuonCSCHits in event!";
1309     validMuonCSC = false;
1310   }
1311 
1312   if (validMuonCSC) {
1313     // cycle through container
1314     int i = 0, j = 0;
1315     for (itHit = MuonCSCContainer->begin(); itHit != MuonCSCContainer->end(); ++itHit) {
1316       ++i;
1317 
1318       // create a DetId from the detUnitId
1319       DetId theDetUnitId(itHit->detUnitId());
1320       int detector = theDetUnitId.det();
1321       int subdetector = theDetUnitId.subdetId();
1322 
1323       // check that expected detector is returned
1324       if ((detector == dMuon) && (subdetector == sdMuonCSC)) {
1325         // get the GeomDetUnit from the geometry using theDetUnitID
1326         const GeomDetUnit *theDet = theCSCMuon.idToDetUnit(theDetUnitId);
1327 
1328         if (!theDet) {
1329           edm::LogWarning(MsgLoggerCat) << "Unable to get GeomDetUnit from theCSCMuon for hit " << i;
1330           continue;
1331         }
1332 
1333         ++j;
1334 
1335         // get the Surface of the hit (knows how to go from local <-> global)
1336         const BoundPlane &bSurface = theDet->surface();
1337 
1338         if (meMuonCscToF[0])
1339           meMuonCscToF[0]->Fill(itHit->tof());
1340         if (meMuonCscToF[1])
1341           meMuonCscToF[1]->Fill(itHit->tof());
1342         if (meMuonCscZ)
1343           meMuonCscZ->Fill(bSurface.toGlobal(itHit->localPosition()).z());
1344         if (meMuonPhi)
1345           meMuonPhi->Fill(bSurface.toGlobal(itHit->localPosition()).phi());
1346         if (meMuonEta)
1347           meMuonEta->Fill(bSurface.toGlobal(itHit->localPosition()).eta());
1348 
1349       } else {
1350         edm::LogWarning(MsgLoggerCat) << "MuonCsc PSimHit " << i << " is expected to be (det,subdet) = (" << dMuon
1351                                       << "," << sdMuonCSC << "); value returned is: (" << detector << "," << subdetector
1352                                       << ")";
1353         continue;
1354       }  // end detector type check
1355     }    // end loop through CSC Hits
1356 
1357     if (verbosity > 1) {
1358       eventout += "\n          Number of CSC muon Hits collected:......... ";
1359       eventout += j;
1360     }
1361 
1362     nMuonHits += j;
1363   }
1364 
1365   /////////////////////
1366   // access the DT Muon
1367   /////////////////////
1368   // access the DT Muon geometry
1369   const auto &theDTGeometry = iSetup.getHandle(dtGeomToken_);
1370   if (!theDTGeometry.isValid()) {
1371     edm::LogWarning(MsgLoggerCat) << "Unable to find MuonGeometryRecord for the DTGeometry in event!";
1372     return;
1373   }
1374   const DTGeometry &theDTMuon(*theDTGeometry);
1375 
1376   // get Muon DT information
1377   edm::Handle<edm::PSimHitContainer> MuonDtContainer;
1378   iEvent.getByToken(MuonDtSrc_Token_, MuonDtContainer);
1379   if (!MuonDtContainer.isValid()) {
1380     LogDebug(MsgLoggerCat) << "Unable to find MuonDTHits in event!";
1381     validMuonDt = false;
1382   }
1383 
1384   if (validMuonDt) {
1385     // cycle through container
1386     int i = 0, j = 0;
1387     for (itHit = MuonDtContainer->begin(); itHit != MuonDtContainer->end(); ++itHit) {
1388       ++i;
1389 
1390       // create a DetId from the detUnitId
1391       DetId theDetUnitId(itHit->detUnitId());
1392       int detector = theDetUnitId.det();
1393       int subdetector = theDetUnitId.subdetId();
1394 
1395       // check that expected detector is returned
1396       if ((detector == dMuon) && (subdetector == sdMuonDT)) {
1397         // CSC uses wires and layers rather than the full detID
1398         // get the wireId
1399         DTWireId wireId(itHit->detUnitId());
1400 
1401         // get the DTLayer from the geometry using the wireID
1402         const DTLayer *theDet = theDTMuon.layer(wireId.layerId());
1403 
1404         if (!theDet) {
1405           edm::LogWarning(MsgLoggerCat) << "Unable to get GeomDetUnit from theDtMuon for hit " << i;
1406           continue;
1407         }
1408 
1409         ++j;
1410 
1411         // get the Surface of the hit (knows how to go from local <-> global)
1412         const BoundPlane &bSurface = theDet->surface();
1413 
1414         if (meMuonDtToF[0])
1415           meMuonDtToF[0]->Fill(itHit->tof());
1416         if (meMuonDtToF[1])
1417           meMuonDtToF[1]->Fill(itHit->tof());
1418         if (meMuonDtR)
1419           meMuonDtR->Fill(bSurface.toGlobal(itHit->localPosition()).perp());
1420         if (meMuonPhi)
1421           meMuonPhi->Fill(bSurface.toGlobal(itHit->localPosition()).phi());
1422         if (meMuonEta)
1423           meMuonEta->Fill(bSurface.toGlobal(itHit->localPosition()).eta());
1424 
1425       } else {
1426         edm::LogWarning(MsgLoggerCat) << "MuonDt PSimHit " << i << " is expected to be (det,subdet) = (" << dMuon << ","
1427                                       << sdMuonDT << "); value returned is: (" << detector << "," << subdetector << ")";
1428         continue;
1429       }  // end detector type check
1430     }    // end loop through DT Hits
1431 
1432     if (verbosity > 1) {
1433       eventout += "\n          Number of DT muon Hits collected:.......... ";
1434       eventout += j;
1435     }
1436 
1437     nMuonHits += j;
1438   }
1439 
1440   // int RPCBrl = 0, RPCFwd = 0;
1441   ///////////////////////
1442   // access the RPC Muon
1443   ///////////////////////
1444   // access the RPC Muon geometry
1445   const auto &theRPCGeometry = iSetup.getHandle(rpcGeomToken_);
1446   if (!theRPCGeometry.isValid()) {
1447     edm::LogWarning(MsgLoggerCat) << "Unable to find MuonGeometryRecord for the RPCGeometry in event!";
1448     return;
1449   }
1450   const RPCGeometry &theRPCMuon(*theRPCGeometry);
1451 
1452   // get Muon RPC information
1453   edm::Handle<edm::PSimHitContainer> MuonRPCContainer;
1454   iEvent.getByToken(MuonRpcSrc_Token_, MuonRPCContainer);
1455   if (!MuonRPCContainer.isValid()) {
1456     LogDebug(MsgLoggerCat) << "Unable to find MuonRPCHits in event!";
1457     validMuonRPC = false;
1458   }
1459 
1460   if (validMuonRPC) {
1461     // cycle through container
1462     int i = 0, j = 0;
1463     int RPCBrl = 0, RPCFwd = 0;
1464     for (itHit = MuonRPCContainer->begin(); itHit != MuonRPCContainer->end(); ++itHit) {
1465       ++i;
1466 
1467       // create a DetID from the detUnitId
1468       DetId theDetUnitId(itHit->detUnitId());
1469       int detector = theDetUnitId.det();
1470       int subdetector = theDetUnitId.subdetId();
1471 
1472       // check that expected detector is returned
1473       if ((detector == dMuon) && (subdetector == sdMuonRPC)) {
1474         // get an RPCDetID from the detUnitID
1475         RPCDetId RPCId(itHit->detUnitId());
1476 
1477         // find the region of the RPC hit
1478         int region = RPCId.region();
1479 
1480         // get the GeomDetUnit from the geometry using the RPCDetId
1481         const GeomDetUnit *theDet = theRPCMuon.idToDetUnit(theDetUnitId);
1482 
1483         if (!theDet) {
1484           edm::LogWarning(MsgLoggerCat) << "Unable to get GeomDetUnit from theRPCMuon for hit " << i;
1485           continue;
1486         }
1487 
1488         ++j;
1489 
1490         // get the Surface of the hit (knows how to go from local <-> global)
1491         const BoundPlane &bSurface = theDet->surface();
1492 
1493         // gather necessary information
1494         if ((region == sdMuonRPCRgnFwdp) || (region == sdMuonRPCRgnFwdn)) {
1495           ++RPCFwd;
1496 
1497           if (meMuonRpcFToF[0])
1498             meMuonRpcFToF[0]->Fill(itHit->tof());
1499           if (meMuonRpcFToF[1])
1500             meMuonRpcFToF[1]->Fill(itHit->tof());
1501           if (meMuonRpcFZ)
1502             meMuonRpcFZ->Fill(bSurface.toGlobal(itHit->localPosition()).z());
1503           if (meMuonPhi)
1504             meMuonPhi->Fill(bSurface.toGlobal(itHit->localPosition()).phi());
1505           if (meMuonEta)
1506             meMuonEta->Fill(bSurface.toGlobal(itHit->localPosition()).eta());
1507 
1508         } else if (region == sdMuonRPCRgnBrl) {
1509           ++RPCBrl;
1510 
1511           if (meMuonRpcBToF[0])
1512             meMuonRpcBToF[0]->Fill(itHit->tof());
1513           if (meMuonRpcBToF[1])
1514             meMuonRpcBToF[1]->Fill(itHit->tof());
1515           if (meMuonRpcBR)
1516             meMuonRpcBR->Fill(bSurface.toGlobal(itHit->localPosition()).perp());
1517           if (meMuonPhi)
1518             meMuonPhi->Fill(bSurface.toGlobal(itHit->localPosition()).phi());
1519           if (meMuonEta)
1520             meMuonEta->Fill(bSurface.toGlobal(itHit->localPosition()).eta());
1521 
1522         } else {
1523           edm::LogWarning(MsgLoggerCat) << "Invalid region for RPC Muon hit" << i;
1524           continue;
1525         }  // end check of region
1526       } else {
1527         edm::LogWarning(MsgLoggerCat) << "MuonRpc PSimHit " << i << " is expected to be (det,subdet) = (" << dMuon
1528                                       << "," << sdMuonRPC << "); value returned is: (" << detector << "," << subdetector
1529                                       << ")";
1530         continue;
1531       }  // end detector type check
1532     }    // end loop through RPC Hits
1533 
1534     if (verbosity > 1) {
1535       eventout += "\n          Number of RPC muon Hits collected:......... ";
1536       eventout += j;
1537       eventout += "\n                    RPC Barrel muon Hits:............ ";
1538       eventout += RPCBrl;
1539       eventout += "\n                    RPC Forward muon Hits:........... ";
1540       eventout += RPCFwd;
1541     }
1542 
1543     nMuonHits += j;
1544   }
1545 
1546   if (meMuon[0])
1547     meMuon[0]->Fill((float)nMuonHits);
1548   if (meMuon[1])
1549     meMuon[1]->Fill((float)nMuonHits);
1550 
1551   if (verbosity > 0)
1552     edm::LogInfo(MsgLoggerCat) << eventout << "\n";
1553 
1554   return;
1555 }
1556 
1557 void GlobalHitsAnalyzer::fillECal(const edm::Event &iEvent, const edm::EventSetup &iSetup) {
1558   std::string MsgLoggerCat = "GlobalHitsAnalyzer_fillECal";
1559 
1560   TString eventout;
1561   if (verbosity > 0)
1562     eventout = "\nGathering info:";
1563 
1564   // access the calorimeter geometry
1565   const auto &theCaloGeometry = iSetup.getHandle(caloGeomToken_);
1566   if (!theCaloGeometry.isValid()) {
1567     edm::LogWarning(MsgLoggerCat) << "Unable to find CaloGeometryRecord in event!";
1568     return;
1569   }
1570   const CaloGeometry &theCalo(*theCaloGeometry);
1571 
1572   // iterator to access containers
1573   edm::PCaloHitContainer::const_iterator itHit;
1574 
1575   ///////////////////////////////
1576   // get  ECal information
1577   ///////////////////////////////
1578   edm::PCaloHitContainer theECalHits;
1579   // extract EB container
1580   edm::Handle<edm::PCaloHitContainer> EBContainer;
1581   iEvent.getByToken(ECalEBSrc_Token_, EBContainer);
1582   if (!EBContainer.isValid()) {
1583     LogDebug(MsgLoggerCat) << "Unable to find EcalHitsEB in event!";
1584     validEB = false;
1585   }
1586   // extract EE container
1587   edm::Handle<edm::PCaloHitContainer> EEContainer;
1588   iEvent.getByToken(ECalEESrc_Token_, EEContainer);
1589   if (!EEContainer.isValid()) {
1590     LogDebug(MsgLoggerCat) << "Unable to find EcalHitsEE in event!";
1591     validEE = false;
1592   }
1593   // place both containers into new container
1594   if (validEB)
1595     theECalHits.insert(theECalHits.end(), EBContainer->begin(), EBContainer->end());
1596   if (validEE)
1597     theECalHits.insert(theECalHits.end(), EEContainer->begin(), EEContainer->end());
1598 
1599   // cycle through new container
1600   int i = 0, j = 0;
1601   for (itHit = theECalHits.begin(); itHit != theECalHits.end(); ++itHit) {
1602     ++i;
1603 
1604     // create a DetId from the detUnitId
1605     DetId theDetUnitId(itHit->id());
1606     int detector = theDetUnitId.det();
1607     int subdetector = theDetUnitId.subdetId();
1608 
1609     // check that expected detector is returned
1610     if ((detector == dEcal) && ((subdetector == sdEcalBrl) || (subdetector == sdEcalFwd))) {
1611       // get the Cell geometry
1612       auto theDet = (theCalo.getSubdetectorGeometry(theDetUnitId))->getGeometry(theDetUnitId);
1613 
1614       if (!theDet) {
1615         edm::LogWarning(MsgLoggerCat) << "Unable to get CaloCellGeometry from ECalHits for Hit " << i;
1616         continue;
1617       }
1618 
1619       ++j;
1620 
1621       // get the global position of the cell
1622       const GlobalPoint &globalposition = theDet->getPosition();
1623 
1624       if (meCaloEcalE[0])
1625         meCaloEcalE[0]->Fill(itHit->energy());
1626       if (meCaloEcalE[1])
1627         meCaloEcalE[1]->Fill(itHit->energy());
1628       if (meCaloEcalToF[0])
1629         meCaloEcalToF[0]->Fill(itHit->time());
1630       if (meCaloEcalToF[1])
1631         meCaloEcalToF[1]->Fill(itHit->time());
1632       if (meCaloEcalPhi)
1633         meCaloEcalPhi->Fill(globalposition.phi());
1634       if (meCaloEcalEta)
1635         meCaloEcalEta->Fill(globalposition.eta());
1636 
1637     } else {
1638       edm::LogWarning(MsgLoggerCat) << "ECal PCaloHit " << i << " is expected to be (det,subdet) = (" << dEcal << ","
1639                                     << sdEcalBrl << " || " << sdEcalFwd << "); value returned is: (" << detector << ","
1640                                     << subdetector << ")";
1641       continue;
1642     }  // end detector type check
1643   }    // end loop through ECal Hits
1644 
1645   if (verbosity > 1) {
1646     eventout += "\n          Number of ECal Hits collected:............. ";
1647     eventout += j;
1648   }
1649 
1650   if (meCaloEcal[0])
1651     meCaloEcal[0]->Fill((float)j);
1652   if (meCaloEcal[1])
1653     meCaloEcal[1]->Fill((float)j);
1654 
1655   ////////////////////////////
1656   // Get Preshower information
1657   ////////////////////////////
1658   // extract PreShower container
1659   edm::Handle<edm::PCaloHitContainer> PreShContainer;
1660   iEvent.getByToken(ECalESSrc_Token_, PreShContainer);
1661   if (!PreShContainer.isValid()) {
1662     LogDebug(MsgLoggerCat) << "Unable to find EcalHitsES in event!";
1663     validPresh = false;
1664   }
1665 
1666   if (validPresh) {
1667     // cycle through container
1668     int i = 0, j = 0;
1669     for (itHit = PreShContainer->begin(); itHit != PreShContainer->end(); ++itHit) {
1670       ++i;
1671 
1672       // create a DetId from the detUnitId
1673       DetId theDetUnitId(itHit->id());
1674       int detector = theDetUnitId.det();
1675       int subdetector = theDetUnitId.subdetId();
1676 
1677       // check that expected detector is returned
1678       if ((detector == dEcal) && (subdetector == sdEcalPS)) {
1679         // get the Cell geometry
1680         auto theDet = (theCalo.getSubdetectorGeometry(theDetUnitId))->getGeometry(theDetUnitId);
1681 
1682         if (!theDet) {
1683           edm::LogWarning(MsgLoggerCat) << "Unable to get CaloCellGeometry from PreShContainer for Hit " << i;
1684           continue;
1685         }
1686 
1687         ++j;
1688 
1689         // get the global position of the cell
1690         const GlobalPoint &globalposition = theDet->getPosition();
1691 
1692         if (meCaloPreShE[0])
1693           meCaloPreShE[0]->Fill(itHit->energy());
1694         if (meCaloPreShE[1])
1695           meCaloPreShE[1]->Fill(itHit->energy());
1696         if (meCaloPreShToF[0])
1697           meCaloPreShToF[0]->Fill(itHit->time());
1698         if (meCaloPreShToF[1])
1699           meCaloPreShToF[1]->Fill(itHit->time());
1700         if (meCaloPreShPhi)
1701           meCaloPreShPhi->Fill(globalposition.phi());
1702         if (meCaloPreShEta)
1703           meCaloPreShEta->Fill(globalposition.eta());
1704 
1705       } else {
1706         edm::LogWarning(MsgLoggerCat) << "PreSh PCaloHit " << i << " is expected to be (det,subdet) = (" << dEcal << ","
1707                                       << sdEcalPS << "); value returned is: (" << detector << "," << subdetector << ")";
1708         continue;
1709       }  // end detector type check
1710     }    // end loop through PreShower Hits
1711 
1712     if (verbosity > 1) {
1713       eventout += "\n          Number of PreSh Hits collected:............ ";
1714       eventout += j;
1715     }
1716 
1717     if (meCaloPreSh[0])
1718       meCaloPreSh[0]->Fill((float)j);
1719     if (meCaloPreSh[1])
1720       meCaloPreSh[1]->Fill((float)j);
1721   }
1722 
1723   if (verbosity > 0)
1724     edm::LogInfo(MsgLoggerCat) << eventout << "\n";
1725 
1726   return;
1727 }
1728 
1729 void GlobalHitsAnalyzer::fillHCal(const edm::Event &iEvent, const edm::EventSetup &iSetup) {
1730   std::string MsgLoggerCat = "GlobalHitsAnalyzer_fillHCal";
1731 
1732   TString eventout;
1733   if (verbosity > 0)
1734     eventout = "\nGathering info:";
1735 
1736   // access the calorimeter geometry
1737   const auto &theCaloGeometry = iSetup.getHandle(caloGeomToken_);
1738   if (!theCaloGeometry.isValid()) {
1739     edm::LogWarning(MsgLoggerCat) << "Unable to find CaloGeometryRecord in event!";
1740     return;
1741   }
1742   const CaloGeometry &theCalo(*theCaloGeometry);
1743 
1744   const HcalDDDRecConstants *hcons = &iSetup.getData(hcaldddRecToken_);
1745 
1746   // iterator to access containers
1747   edm::PCaloHitContainer::const_iterator itHit;
1748 
1749   ///////////////////////////////
1750   // get  HCal information
1751   ///////////////////////////////
1752   // extract HCal container
1753   edm::Handle<edm::PCaloHitContainer> HCalContainer;
1754   iEvent.getByToken(HCalSrc_Token_, HCalContainer);
1755   if (!HCalContainer.isValid()) {
1756     LogDebug(MsgLoggerCat) << "Unable to find HCalHits in event!";
1757     validHcal = false;
1758   }
1759 
1760   if (validHcal) {
1761     // cycle through container
1762     int i = 0, j = 0;
1763     for (itHit = HCalContainer->begin(); itHit != HCalContainer->end(); ++itHit) {
1764       ++i;
1765 
1766       // create a DetId from the detUnitId
1767       DetId theDetUnitId;
1768       unsigned int id_ = itHit->id();
1769       if (testNumber)
1770         theDetUnitId = HcalHitRelabeller::relabel(id_, hcons);
1771       else
1772         theDetUnitId = id_;
1773 
1774       int detector = theDetUnitId.det();
1775       int subdetector = theDetUnitId.subdetId();
1776 
1777       // check that expected detector is returned
1778       if ((detector == dHcal) && ((subdetector == sdHcalBrl) || (subdetector == sdHcalEC) ||
1779                                   (subdetector == sdHcalOut) || (subdetector == sdHcalFwd))) {
1780         // get the Cell geometry
1781         const HcalGeometry *theDet = dynamic_cast<const HcalGeometry *>(theCalo.getSubdetectorGeometry(theDetUnitId));
1782 
1783         if (!theDet) {
1784           edm::LogWarning(MsgLoggerCat) << "Unable to get HcalGeometry from HCalContainer for Hit " << i;
1785           continue;
1786         }
1787 
1788         ++j;
1789 
1790         // get the global position of the cell
1791         const GlobalPoint &globalposition = theDet->getPosition(theDetUnitId);
1792 
1793         if (meCaloHcalE[0])
1794           meCaloHcalE[0]->Fill(itHit->energy());
1795         if (meCaloHcalE[1])
1796           meCaloHcalE[1]->Fill(itHit->energy());
1797         if (meCaloHcalToF[0])
1798           meCaloHcalToF[0]->Fill(itHit->time());
1799         if (meCaloHcalToF[1])
1800           meCaloHcalToF[1]->Fill(itHit->time());
1801         if (meCaloHcalPhi)
1802           meCaloHcalPhi->Fill(globalposition.phi());
1803         if (meCaloHcalEta)
1804           meCaloHcalEta->Fill(globalposition.eta());
1805 
1806       } else {
1807         edm::LogWarning(MsgLoggerCat) << "HCal PCaloHit " << i << " is expected to be (det,subdet) = (" << dHcal << ","
1808                                       << sdHcalBrl << " || " << sdHcalEC << " || " << sdHcalOut << " || " << sdHcalFwd
1809                                       << "); value returned is: (" << detector << "," << subdetector << ")";
1810         continue;
1811       }  // end detector type check
1812     }    // end loop through HCal Hits
1813 
1814     if (verbosity > 1) {
1815       eventout += "\n          Number of HCal Hits collected:............. ";
1816       eventout += j;
1817     }
1818 
1819     if (meCaloHcal[0])
1820       meCaloHcal[0]->Fill((float)j);
1821     if (meCaloHcal[1])
1822       meCaloHcal[1]->Fill((float)j);
1823   }
1824 
1825   if (verbosity > 0)
1826     edm::LogInfo(MsgLoggerCat) << eventout << "\n";
1827 
1828   return;
1829 }