CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_6_1_2_SLHC2_patch1/src/Validation/GlobalHits/src/GlobalHitsAnalyzer.cc

Go to the documentation of this file.
00001 
00009 #include "Geometry/Records/interface/CaloGeometryRecord.h"
00010 
00011 #include "Validation/GlobalHits/interface/GlobalHitsAnalyzer.h"
00012 #include "DQMServices/Core/interface/DQMStore.h"
00013 
00014 GlobalHitsAnalyzer::GlobalHitsAnalyzer(const edm::ParameterSet& iPSet) :
00015   fName(""), verbosity(0), frequency(0), vtxunit(0), label(""), 
00016   getAllProvenances(false), printProvenanceInfo(false),
00017   G4VtxSrc_(iPSet.getParameter<edm::InputTag>("G4VtxSrc")),
00018   G4TrkSrc_(iPSet.getParameter<edm::InputTag>("G4TrkSrc")),
00019   count(0)
00020 {
00021   std::string MsgLoggerCat = "GlobalHitsAnalyzer_GlobalHitsAnalyzer";
00022 
00023   // get information from parameter set
00024   fName = iPSet.getUntrackedParameter<std::string>("Name");
00025   verbosity = iPSet.getUntrackedParameter<int>("Verbosity");
00026   frequency = iPSet.getUntrackedParameter<int>("Frequency");
00027   vtxunit = iPSet.getUntrackedParameter<int>("VtxUnit");
00028   edm::ParameterSet m_Prov =
00029     iPSet.getParameter<edm::ParameterSet>("ProvenanceLookup");
00030   getAllProvenances = 
00031     m_Prov.getUntrackedParameter<bool>("GetAllProvenances");
00032   printProvenanceInfo = 
00033     m_Prov.getUntrackedParameter<bool>("PrintProvenanceInfo");
00034 
00035   //get Labels to use to extract information
00036   PxlBrlLowSrc_ = iPSet.getParameter<edm::InputTag>("PxlBrlLowSrc");
00037   PxlBrlHighSrc_ = iPSet.getParameter<edm::InputTag>("PxlBrlHighSrc");
00038   PxlFwdLowSrc_ = iPSet.getParameter<edm::InputTag>("PxlFwdLowSrc");
00039   PxlFwdHighSrc_ = iPSet.getParameter<edm::InputTag>("PxlFwdHighSrc");
00040 
00041   SiTIBLowSrc_ = iPSet.getParameter<edm::InputTag>("SiTIBLowSrc");
00042   SiTIBHighSrc_ = iPSet.getParameter<edm::InputTag>("SiTIBHighSrc");
00043   SiTOBLowSrc_ = iPSet.getParameter<edm::InputTag>("SiTOBLowSrc");
00044   SiTOBHighSrc_ = iPSet.getParameter<edm::InputTag>("SiTOBHighSrc");
00045   SiTIDLowSrc_ = iPSet.getParameter<edm::InputTag>("SiTIDLowSrc");
00046   SiTIDHighSrc_ = iPSet.getParameter<edm::InputTag>("SiTIDHighSrc");
00047   SiTECLowSrc_ = iPSet.getParameter<edm::InputTag>("SiTECLowSrc");
00048   SiTECHighSrc_ = iPSet.getParameter<edm::InputTag>("SiTECHighSrc");
00049 
00050   MuonCscSrc_ = iPSet.getParameter<edm::InputTag>("MuonCscSrc");
00051   MuonDtSrc_ = iPSet.getParameter<edm::InputTag>("MuonDtSrc");
00052   MuonRpcSrc_ = iPSet.getParameter<edm::InputTag>("MuonRpcSrc");
00053 
00054   ECalEBSrc_ = iPSet.getParameter<edm::InputTag>("ECalEBSrc");
00055   ECalEESrc_ = iPSet.getParameter<edm::InputTag>("ECalEESrc");
00056   ECalESSrc_ = iPSet.getParameter<edm::InputTag>("ECalESSrc");
00057 
00058   HCalSrc_ = iPSet.getParameter<edm::InputTag>("HCalSrc");
00059 
00060   // determine whether to process subdetector or not
00061   validHepMCevt = iPSet.getUntrackedParameter<bool>("validHepMCevt");
00062   validG4VtxContainer = 
00063     iPSet.getUntrackedParameter<bool>("validG4VtxContainer");
00064   validG4trkContainer = 
00065     iPSet.getUntrackedParameter<bool>("validG4trkContainer");
00066   validPxlBrlLow = iPSet.getUntrackedParameter<bool>("validPxlBrlLow",true);
00067   validPxlBrlHigh = iPSet.getUntrackedParameter<bool>("validPxlBrlHigh",true);
00068   validPxlFwdLow = iPSet.getUntrackedParameter<bool>("validPxlFwdLow",true);
00069   validPxlFwdHigh = iPSet.getUntrackedParameter<bool>("validPxlFwdHigh",true);
00070   validSiTIBLow = iPSet.getUntrackedParameter<bool>("validSiTIBLow",true);
00071   validSiTIBHigh = iPSet.getUntrackedParameter<bool>("validSiTIBHigh",true);
00072   validSiTOBLow = iPSet.getUntrackedParameter<bool>("validSiTOBLow",true);
00073   validSiTOBHigh = iPSet.getUntrackedParameter<bool>("validSiTOBHigh",true);
00074   validSiTIDLow = iPSet.getUntrackedParameter<bool>("validSiTIDLow",true);
00075   validSiTIDHigh = iPSet.getUntrackedParameter<bool>("validSiTIDHigh",true);
00076   validSiTECLow = iPSet.getUntrackedParameter<bool>("validSiTECLow",true);
00077   validSiTECHigh = iPSet.getUntrackedParameter<bool>("validSiTECHigh",true);
00078   validMuonCSC = iPSet.getUntrackedParameter<bool>("validMuonCSC",true);
00079   validMuonDt = iPSet.getUntrackedParameter<bool>("validMuonDt",true);
00080   validMuonRPC = iPSet.getUntrackedParameter<bool>("validMuonRPC",true);
00081   validEB = iPSet.getUntrackedParameter<bool>("validEB",true);
00082   validEE = iPSet.getUntrackedParameter<bool>("validEE",true);
00083   validPresh = iPSet.getUntrackedParameter<bool>("validPresh",true);
00084   validHcal = iPSet.getUntrackedParameter<bool>("validHcal",true);  
00085 
00086   // use value of first digit to determine default output level (inclusive)
00087   // 0 is none, 1 is basic, 2 is fill output, 3 is gather output
00088   verbosity %= 10;
00089 
00090   // print out Parameter Set information being used
00091   if (verbosity >= 0) {
00092     edm::LogInfo(MsgLoggerCat) 
00093       << "\n===============================\n"
00094       << "Initialized as EDAnalyzer with parameter values:\n"
00095       << "    Name                  = " << fName << "\n"
00096       << "    Verbosity             = " << verbosity << "\n"
00097       << "    Frequency             = " << frequency << "\n"
00098       << "    VtxUnit               = " << vtxunit << "\n"
00099       << "    GetProv               = " << getAllProvenances << "\n"
00100       << "    PrintProv             = " << printProvenanceInfo << "\n"
00101       << "    PxlBrlLowSrc          = " << PxlBrlLowSrc_.label() 
00102       << ":" << PxlBrlLowSrc_.instance() << "\n"
00103       << "    PxlBrlHighSrc         = " << PxlBrlHighSrc_.label() 
00104       << ":" << PxlBrlHighSrc_.instance() << "\n"
00105       << "    PxlFwdLowSrc          = " << PxlFwdLowSrc_.label() 
00106       << ":" << PxlBrlLowSrc_.instance() << "\n"
00107       << "    PxlFwdHighSrc         = " << PxlFwdHighSrc_.label() 
00108       << ":" << PxlBrlHighSrc_.instance() << "\n"
00109       << "    SiTIBLowSrc           = " << SiTIBLowSrc_.label() 
00110       << ":" << SiTIBLowSrc_.instance() << "\n"
00111       << "    SiTIBHighSrc          = " << SiTIBHighSrc_.label() 
00112       << ":" << SiTIBHighSrc_.instance() << "\n"
00113       << "    SiTOBLowSrc           = " << SiTOBLowSrc_.label() 
00114       << ":" << SiTOBLowSrc_.instance() << "\n"
00115       << "    SiTOBHighSrc          = " << SiTOBHighSrc_.label() 
00116       << ":" << SiTOBHighSrc_.instance() << "\n"
00117       << "    SiTIDLowSrc           = " << SiTIDLowSrc_.label() 
00118       << ":" << SiTIDLowSrc_.instance() << "\n"
00119       << "    SiTIDHighSrc          = " << SiTIDHighSrc_.label() 
00120       << ":" << SiTIDHighSrc_.instance() << "\n"
00121       << "    SiTECLowSrc           = " << SiTECLowSrc_.label() 
00122       << ":" << SiTECLowSrc_.instance() << "\n"
00123       << "    SiTECHighSrc          = " << SiTECHighSrc_.label() 
00124       << ":" << SiTECHighSrc_.instance() << "\n"
00125       << "    MuonCscSrc            = " << MuonCscSrc_.label() 
00126       << ":" << MuonCscSrc_.instance() << "\n"
00127       << "    MuonDtSrc             = " << MuonDtSrc_.label() 
00128       << ":" << MuonDtSrc_.instance() << "\n"
00129       << "    MuonRpcSrc            = " << MuonRpcSrc_.label() 
00130       << ":" << MuonRpcSrc_.instance() << "\n"
00131       << "    ECalEBSrc             = " << ECalEBSrc_.label() 
00132       << ":" << ECalEBSrc_.instance() << "\n"
00133       << "    ECalEESrc             = " << ECalEESrc_.label() 
00134       << ":" << ECalEESrc_.instance() << "\n"
00135       << "    ECalESSrc             = " << ECalESSrc_.label() 
00136       << ":" << ECalESSrc_.instance() << "\n"
00137       << "    HCalSrc               = " << HCalSrc_.label() 
00138       << ":" << HCalSrc_.instance() << "\n"
00139       << "\n"
00140       << "    validHepMCevt         = "
00141       << ":" <<  validHepMCevt << "\n"
00142       << "    validG4VtxContainer   = "
00143       << ":" <<  validG4VtxContainer << "\n"
00144       << "    validG4trkContainer   = "
00145       << ":" <<  validG4trkContainer << "\n"
00146       << "    validPxlBrlLow        = "
00147       << ":" <<  validPxlBrlLow << "\n"
00148       << "    validPxlBrlHigh       = "
00149       << ":" <<  validPxlBrlHigh << "\n"
00150       << "    validPxlFwdLow        = "
00151       << ":" <<  validPxlFwdLow << "\n"
00152       << "    validPxlFwdHigh       = "
00153       << ":" <<  validPxlFwdHigh << "\n"
00154       << "    validSiTIBLow         = "
00155       << ":" <<  validSiTIBLow << "\n"
00156       << "    validSiTIBHigh        = "
00157       << ":" <<  validSiTIBHigh << "\n"
00158       << "    validSiTOBLow         = "
00159       << ":" <<  validSiTOBLow << "\n"
00160       << "    validSiTOBHigh        = "
00161       << ":" <<  validSiTOBHigh << "\n"
00162       << "    validSiTIDLow         = "
00163       << ":" <<  validSiTIDLow << "\n"
00164       << "    validSiTIDHigh        = "
00165       << ":" <<  validSiTIDHigh << "\n"
00166       << "    validSiTECLow         = "
00167       << ":" <<  validSiTECLow << "\n"
00168       << "    validSiTECHigh        = "
00169       << ":" <<  validSiTECHigh << "\n"
00170       << "    validMuonCSC          = "
00171       << ":" <<  validMuonCSC << "\n"
00172       << "    validMuonDt           = "
00173       << ":" <<  validMuonDt << "\n"
00174       << "    validMuonRPC          = "
00175       << ":" <<  validMuonRPC << "\n"
00176       << "    validEB               = "
00177       << ":" <<  validEB << "\n"
00178       << "    validEE               = "
00179       << ":" <<  validEE << "\n"
00180       << "    validPresh            = "
00181       << ":" <<  validPresh << "\n"
00182       << "    validHcal             = "
00183       << ":" <<  validHcal << "\n"
00184       << "===============================\n";
00185   }
00186 
00187   // get dqm info
00188   dbe = 0;
00189   dbe = edm::Service<DQMStore>().operator->();
00190   if (dbe) {
00191     if (verbosity > 0 ) {
00192       dbe->setVerbose(1);
00193     } else {
00194       dbe->setVerbose(0);
00195     }
00196   }
00197 
00198   if (dbe) {
00199     if (verbosity > 0 ) dbe->showDirStructure();
00200   }
00201 
00202   // initialize monitor elements
00203   for (Int_t i = 0; i < 2; ++i) {
00204     meMCRGP[i] = 0;
00205     meMCG4Vtx[i] = 0;
00206     meGeantVtxX[i] = 0;
00207     meGeantVtxY[i] = 0;
00208     meGeantVtxZ[i] = 0; 
00209     meMCG4Trk[i] = 0;
00210     meCaloEcal[i] = 0;
00211     meCaloEcalE[i] = 0;
00212     meCaloEcalToF[i] = 0;
00213     meCaloPreSh[i] = 0;
00214     meCaloPreShE[i] = 0;
00215     meCaloPreShToF[i] = 0;
00216     meCaloHcal[i] = 0;
00217     meCaloHcalE[i] = 0;
00218     meCaloHcalToF[i] = 0;
00219     meTrackerPx[i] = 0;
00220     meTrackerSi[i] = 0;
00221     meMuon[i] = 0;
00222     meMuonDtToF[i] = 0;
00223     meMuonCscToF[i] = 0;
00224     meMuonRpcFToF[i] = 0;
00225     meMuonRpcBToF[i] = 0;
00226     meGeantVtxRad[i] = 0;
00227   }
00228   meGeantTrkPt = 0;
00229   meGeantTrkE = 0;
00230   meGeantVtxEta = 0;
00231   meGeantVtxPhi = 0;
00232   meGeantVtxMulti = 0;
00233   meCaloEcalPhi = 0;
00234   meCaloEcalEta = 0;
00235   meCaloPreShPhi = 0;
00236   meCaloPreShEta = 0;
00237   meCaloHcalPhi = 0;
00238   meCaloHcalEta = 0;
00239   meTrackerPxPhi = 0;
00240   meTrackerPxEta = 0;
00241   meTrackerPxBToF = 0;
00242   meTrackerPxBR = 0;
00243   meTrackerPxFToF = 0;
00244   meTrackerPxFZ = 0;
00245   meTrackerSiPhi = 0;
00246   meTrackerSiEta = 0;
00247   meTrackerSiBToF = 0;
00248   meTrackerSiBR = 0;
00249   meTrackerSiFToF = 0;
00250   meTrackerSiFZ = 0;
00251   meMuonPhi = 0;
00252   meMuonEta = 0;
00253   meMuonDtR = 0;
00254   meMuonCscZ = 0;
00255   meMuonRpcBR = 0;
00256   meMuonRpcFZ = 0;
00257 
00258   //create histograms
00259   Char_t hname[200];
00260   Char_t htitle[200];
00261   if (dbe) {
00262 
00263     // MCGeant
00264     dbe->setCurrentFolder("GlobalHitsV/MCGeant");
00265     sprintf(hname,"hMCRGP1");
00266     sprintf(htitle,"RawGenParticles");
00267     meMCRGP[0] = dbe->book1D(hname,htitle,100,0.,5000.);
00268     sprintf(hname,"hMCRGP2");
00269     meMCRGP[1] = dbe->book1D(hname,htitle,100,0.,500.);  
00270     for (Int_t i = 0; i < 2; ++i) {
00271       meMCRGP[i]->setAxisTitle("Number of Raw Generated Particles",1);
00272       meMCRGP[i]->setAxisTitle("Count",2);
00273     }
00274 
00275     sprintf(hname,"hMCG4Vtx1");
00276     sprintf(htitle,"G4 Vertices");
00277     meMCG4Vtx[0] = dbe->book1D(hname,htitle,150,0.,15000.);
00278     sprintf(hname,"hMCG4Vtx2");
00279     meMCG4Vtx[1] = dbe->book1D(hname,htitle,100,-0.5,99.5); 
00280     for (Int_t i = 0; i < 2; ++i) {
00281       meMCG4Vtx[i]->setAxisTitle("Number of Vertices",1);
00282       meMCG4Vtx[i]->setAxisTitle("Count",2);
00283     }
00284 
00285     sprintf(hname,"hMCG4Trk1");
00286     sprintf(htitle,"G4 Tracks");
00287     meMCG4Trk[0] = dbe->book1D(hname,htitle,150,0.,15000.);
00288     sprintf(hname,"hMCG4Trk2");
00289     meMCG4Trk[1] = dbe->book1D(hname,htitle,150,-0.5,99.5);    
00290     for (Int_t i = 0; i < 2; ++i) {
00291       meMCG4Trk[i]->setAxisTitle("Number of Tracks",1);
00292       meMCG4Trk[i]->setAxisTitle("Count",2);
00293     }
00294 
00295     sprintf(hname,"hGeantVtxX1");
00296     sprintf(htitle,"Geant vertex x/micrometer");
00297     meGeantVtxX[0] = dbe->book1D(hname,htitle,100,-8000000.,8000000.);
00298     sprintf(hname,"hGeantVtxX2");
00299     meGeantVtxX[1] = dbe->book1D(hname,htitle,100,-50.,50.); 
00300     for (Int_t i = 0; i < 2; ++i) {
00301       meGeantVtxX[i]->setAxisTitle("x of Vertex (um)",1);
00302       meGeantVtxX[i]->setAxisTitle("Count",2);
00303     }
00304 
00305     sprintf(hname,"hGeantVtxY1");
00306     sprintf(htitle,"Geant vertex y/micrometer");
00307     meGeantVtxY[0] = dbe->book1D(hname,htitle,100,-8000000,8000000.);
00308     sprintf(hname,"hGeantVtxY2");
00309     meGeantVtxY[1] = dbe->book1D(hname,htitle,100,-50.,50.); 
00310     for (Int_t i = 0; i < 2; ++i) {
00311       meGeantVtxY[i]->setAxisTitle("y of Vertex (um)",1);
00312       meGeantVtxY[i]->setAxisTitle("Count",2);
00313     }
00314 
00315     sprintf(hname,"hGeantVtxZ1");
00316     sprintf(htitle,"Geant vertex z/millimeter");
00317     meGeantVtxZ[0] = dbe->book1D(hname,htitle,100,-11000.,11000.);
00318     sprintf(hname,"hGeantVtxZ2");
00319     meGeantVtxZ[1] = dbe->book1D(hname,htitle,200,-500.,500.);
00320     //meGeantVtxZ[1] = dbe->book1D(hname,htitle,100,-250.,250.);
00321     for (Int_t i = 0; i < 2; ++i) {
00322       meGeantVtxZ[i]->setAxisTitle("z of Vertex (mm)",1);
00323       meGeantVtxZ[i]->setAxisTitle("Count",2);
00324     }
00325 
00326     sprintf(hname,"hGeantTrkPt");
00327     sprintf(htitle,"Log10 Geant track pt/GeV");
00328     meGeantTrkPt = dbe->book1D(hname,htitle,80,-4.,4.);
00329     meGeantTrkPt->setAxisTitle("Log10 pT of Track (GeV)",1);
00330     meGeantTrkPt->setAxisTitle("Count",2);
00331 
00332     sprintf(hname,"hGeantTrkE");
00333     sprintf(htitle,"Log10 Geant track E/GeV");
00334     meGeantTrkE = dbe->book1D(hname,htitle,80,-4.,4.);
00335     meGeantTrkE->setAxisTitle("Log10 E of Track (GeV)",1);
00336     meGeantTrkE->setAxisTitle("Count",2);
00337 
00338     sprintf(hname,"hGeantVtxEta");
00339     sprintf(htitle,"Geant vertices eta");
00340     meGeantVtxEta = dbe->book1D(hname,htitle,220,-5.5,5.5);
00341     meGeantVtxEta->setAxisTitle("eta of SimVertex",1);
00342     meGeantVtxEta->setAxisTitle("Count",2);
00343 
00344     sprintf(hname,"hGeantVtxPhi");
00345     sprintf(htitle,"Geant vertices phi/rad");
00346     meGeantVtxPhi = dbe->book1D(hname,htitle,100,-3.2,3.2);
00347     meGeantVtxPhi->setAxisTitle("phi of SimVertex (rad)",1);
00348     meGeantVtxPhi->setAxisTitle("Count",2);
00349 
00350     sprintf(hname,"hGeantVtxRad1");
00351     sprintf(htitle,"Geant vertices radius/cm");
00352     meGeantVtxRad[0] = dbe->book1D(hname,htitle,130,0.,130.);
00353     sprintf(hname,"hGeantVtxRad2");
00354     meGeantVtxRad[1] = dbe->book1D(hname,htitle,100,0.,1000.);
00355     for (Int_t i = 0; i < 2; ++i) {
00356       meGeantVtxRad[i]->setAxisTitle("radius of SimVertex (cm)",1);
00357       meGeantVtxRad[i]->setAxisTitle("Count",2);
00358     }
00359 
00360     sprintf(hname,"hGeantVtxMulti");
00361     sprintf(htitle,"Geant vertices outgoing multiplicity");
00362     meGeantVtxMulti = dbe->book1D(hname,htitle,20,0.,20);
00363     meGeantVtxMulti->setAxisTitle("multiplicity of particles attached to a SimVertex",1);
00364     meGeantVtxMulti->setAxisTitle("Count",2);
00365 
00366     // ECal
00367     dbe->setCurrentFolder("GlobalHitsV/ECals");
00368     sprintf(hname,"hCaloEcal1");
00369     sprintf(htitle,"Ecal hits");
00370     meCaloEcal[0] = dbe->book1D(hname,htitle,100,0.,10000.);
00371     sprintf(hname,"hCaloEcal2");
00372     meCaloEcal[1] = dbe->book1D(hname,htitle,100,-0.5,99.5);
00373 
00374     sprintf(hname,"hCaloEcalE1");
00375     sprintf(htitle,"Ecal hits, energy/GeV");
00376     meCaloEcalE[0] = dbe->book1D(hname,htitle,100,0.,10.);
00377     sprintf(hname,"hCaloEcalE2");
00378     meCaloEcalE[1] = dbe->book1D(hname,htitle,100,0.,0.1);
00379     sprintf(hname,"hCaloEcalToF1");
00380     sprintf(htitle,"Ecal hits, ToF/ns");
00381     meCaloEcalToF[0] = dbe->book1D(hname,htitle,100,0.,1000.);
00382     sprintf(hname,"hCaloEcalToF2");
00383     meCaloEcalToF[1] = dbe->book1D(hname,htitle,100,0.,100.);
00384  
00385     for (Int_t i = 0; i < 2; ++i) {
00386       meCaloEcal[i]->setAxisTitle("Number of Hits",1);
00387       meCaloEcal[i]->setAxisTitle("Count",2);
00388       meCaloEcalE[i]->setAxisTitle("Energy of Hits (GeV)",1);
00389       meCaloEcalE[i]->setAxisTitle("Count",2);
00390       meCaloEcalToF[i]->setAxisTitle("Time of Flight of Hits (ns)",1);
00391       meCaloEcalToF[i]->setAxisTitle("Count",2);
00392     }
00393 
00394     sprintf(hname,"hCaloEcalPhi");
00395     sprintf(htitle,"Ecal hits, phi/rad");
00396     meCaloEcalPhi = dbe->book1D(hname,htitle,100,-3.2,3.2);
00397     meCaloEcalPhi->setAxisTitle("Phi of Hits (rad)",1);
00398     meCaloEcalPhi->setAxisTitle("Count",2);
00399 
00400     sprintf(hname,"hCaloEcalEta");
00401     sprintf(htitle,"Ecal hits, eta");
00402     meCaloEcalEta = dbe->book1D(hname,htitle,100,-5.5,5.5);
00403     meCaloEcalEta->setAxisTitle("Eta of Hits",1);
00404     meCaloEcalEta->setAxisTitle("Count",2);
00405 
00406     sprintf(hname,"hCaloPreSh1");
00407     sprintf(htitle,"PreSh hits");
00408     meCaloPreSh[0] = dbe->book1D(hname,htitle,100,0.,10000.);
00409     sprintf(hname,"hCaloPreSh2");
00410     meCaloPreSh[1] = dbe->book1D(hname,htitle,100,-0.5,99.5);
00411 
00412     sprintf(hname,"hCaloPreShE1");
00413     sprintf(htitle,"PreSh hits, energy/GeV");
00414     meCaloPreShE[0] = dbe->book1D(hname,htitle,100,0.,10.);
00415     sprintf(hname,"hCaloPreShE2");
00416     meCaloPreShE[1] = dbe->book1D(hname,htitle,100,0.,0.1);
00417 
00418     sprintf(hname,"hCaloPreShToF1");
00419     sprintf(htitle,"PreSh hits, ToF/ns");
00420     meCaloPreShToF[0] = dbe->book1D(hname,htitle,100,0.,1000.);
00421     sprintf(hname,"hCaloPreShToF2");
00422     meCaloPreShToF[1] = dbe->book1D(hname,htitle,100,0.,100.);
00423 
00424     for (Int_t i = 0; i < 2; ++i) {
00425       meCaloPreSh[i]->setAxisTitle("Number of Hits",1);
00426       meCaloPreSh[i]->setAxisTitle("Count",2);
00427       meCaloPreShE[i]->setAxisTitle("Energy of Hits (GeV)",1);
00428       meCaloPreShE[i]->setAxisTitle("Count",2);
00429       meCaloPreShToF[i]->setAxisTitle("Time of Flight of Hits (ns)",1);
00430       meCaloPreShToF[i]->setAxisTitle("Count",2);
00431     }
00432 
00433     sprintf(hname,"hCaloPreShPhi");
00434     sprintf(htitle,"PreSh hits, phi/rad");
00435     meCaloPreShPhi = dbe->book1D(hname,htitle,100,-3.2,3.2);
00436     meCaloPreShPhi->setAxisTitle("Phi of Hits (rad)",1);
00437     meCaloPreShPhi->setAxisTitle("Count",2);
00438 
00439     sprintf(hname,"hCaloPreShEta");
00440     sprintf(htitle,"PreSh hits, eta");
00441     meCaloPreShEta = dbe->book1D(hname,htitle,100,-5.5,5.5);
00442     meCaloPreShEta->setAxisTitle("Eta of Hits",1);
00443     meCaloPreShEta->setAxisTitle("Count",2);
00444 
00445     // Hcal
00446     dbe->setCurrentFolder("GlobalHitsV/HCals");
00447     sprintf(hname,"hCaloHcal1");
00448     sprintf(htitle,"Hcal hits");
00449     meCaloHcal[0] = dbe->book1D(hname,htitle,100,0.,10000.);
00450     sprintf(hname,"hCaloHcal2");
00451     meCaloHcal[1] = dbe->book1D(hname,htitle,100,-0.5,99.5);
00452 
00453     sprintf(hname,"hCaloHcalE1");
00454     sprintf(htitle,"Hcal hits, energy/GeV");
00455     meCaloHcalE[0] = dbe->book1D(hname,htitle,100,0.,10.);
00456     sprintf(hname,"hCaloHcalE2");
00457     meCaloHcalE[1] = dbe->book1D(hname,htitle,100,0.,0.1);
00458 
00459     sprintf(hname,"hCaloHcalToF1");
00460     sprintf(htitle,"Hcal hits, ToF/ns");
00461     meCaloHcalToF[0] = dbe->book1D(hname,htitle,100,0.,1000.);
00462     sprintf(hname,"hCaloHcalToF2");
00463     meCaloHcalToF[1] = dbe->book1D(hname,htitle,100,0.,100.);
00464 
00465     for (Int_t i = 0; i < 2; ++i) {
00466       meCaloHcal[i]->setAxisTitle("Number of Hits",1);
00467       meCaloHcal[i]->setAxisTitle("Count",2);
00468       meCaloHcalE[i]->setAxisTitle("Energy of Hits (GeV)",1);
00469       meCaloHcalE[i]->setAxisTitle("Count",2);
00470       meCaloHcalToF[i]->setAxisTitle("Time of Flight of Hits (ns)",1);
00471       meCaloHcalToF[i]->setAxisTitle("Count",2);
00472     }
00473 
00474     sprintf(hname,"hCaloHcalPhi");
00475     sprintf(htitle,"Hcal hits, phi/rad");
00476     meCaloHcalPhi = dbe->book1D(hname,htitle,100,-3.2,3.2);
00477     meCaloHcalPhi->setAxisTitle("Phi of Hits (rad)",1);
00478     meCaloHcalPhi->setAxisTitle("Count",2);
00479 
00480     sprintf(hname,"hCaloHcalEta");
00481     sprintf(htitle,"Hcal hits, eta");
00482     meCaloHcalEta = dbe->book1D(hname,htitle,100,-5.5,5.5);
00483     meCaloHcalEta->setAxisTitle("Eta of Hits",1);
00484     meCaloHcalEta->setAxisTitle("Count",2);
00485     
00486     // SiPixels
00487     dbe->setCurrentFolder("GlobalHitsV/SiPixels");
00488     sprintf(hname,"hTrackerPx1");
00489     sprintf(htitle,"Pixel hits");
00490     meTrackerPx[0] = dbe->book1D(hname,htitle,100,0.,10000.);
00491     sprintf(hname,"hTrackerPx2");
00492     meTrackerPx[1] = dbe->book1D(hname,htitle,100,-0.5,99.5);
00493     for (Int_t i = 0; i < 2; ++i) {
00494       meTrackerPx[i]->setAxisTitle("Number of Pixel Hits",1);
00495       meTrackerPx[i]->setAxisTitle("Count",2);
00496     }
00497 
00498     sprintf(hname,"hTrackerPxPhi");
00499     sprintf(htitle,"Pixel hits phi/rad");
00500     meTrackerPxPhi = dbe->book1D(hname,htitle,100,-3.2,3.2);
00501     meTrackerPxPhi->setAxisTitle("Phi of Hits (rad)",1);
00502     meTrackerPxPhi->setAxisTitle("Count",2);
00503 
00504     sprintf(hname,"hTrackerPxEta");
00505     sprintf(htitle,"Pixel hits eta");
00506     meTrackerPxEta = dbe->book1D(hname,htitle,100,-3.5,3.5);
00507     meTrackerPxEta->setAxisTitle("Eta of Hits",1);
00508     meTrackerPxEta->setAxisTitle("Count",2);
00509 
00510     sprintf(hname,"hTrackerPxBToF");
00511     sprintf(htitle,"Pixel barrel hits, ToF/ns");
00512     meTrackerPxBToF = dbe->book1D(hname,htitle,100,0.,40.);
00513     meTrackerPxBToF->setAxisTitle("Time of Flight of Hits (ns)",1);
00514     meTrackerPxBToF->setAxisTitle("Count",2);
00515 
00516     sprintf(hname,"hTrackerPxBR");
00517     sprintf(htitle,"Pixel barrel hits, R/cm");
00518     meTrackerPxBR = dbe->book1D(hname,htitle,100,0.,50.);
00519     meTrackerPxBR->setAxisTitle("R of Hits (cm)",1);
00520     meTrackerPxBR->setAxisTitle("Count",2);
00521 
00522     sprintf(hname,"hTrackerPxFToF");
00523     sprintf(htitle,"Pixel forward hits, ToF/ns");
00524     meTrackerPxFToF = dbe->book1D(hname,htitle,100,0.,50.);
00525     meTrackerPxFToF->setAxisTitle("Time of Flight of Hits (ns)",1);
00526     meTrackerPxFToF->setAxisTitle("Count",2);
00527 
00528     sprintf(hname,"hTrackerPxFZ");
00529     sprintf(htitle,"Pixel forward hits, Z/cm");
00530     meTrackerPxFZ = 
00531       dbe->book1D(hname,htitle,200,-100.,100.);
00532     meTrackerPxFZ->setAxisTitle("Z of Hits (cm)",1);
00533     meTrackerPxFZ->setAxisTitle("Count",2);
00534 
00535     // SiStrips
00536     dbe->setCurrentFolder("GlobalHitsV/SiStrips");
00537     sprintf(hname,"hTrackerSi1");
00538     sprintf(htitle,"Silicon hits");
00539     meTrackerSi[0] = dbe->book1D(hname,htitle,100,0.,10000.);
00540     sprintf(hname,"hTrackerSi2");
00541     meTrackerSi[1] = dbe->book1D(hname,htitle,100,-0.5,99.5);
00542     for (Int_t i = 0; i < 2; ++i) { 
00543       meTrackerSi[i]->setAxisTitle("Number of Silicon Hits",1);
00544       meTrackerSi[i]->setAxisTitle("Count",2);
00545     }
00546 
00547     sprintf(hname,"hTrackerSiPhi");
00548     sprintf(htitle,"Silicon hits phi/rad");
00549     meTrackerSiPhi = dbe->book1D(hname,htitle,100,-3.2,3.2);
00550     meTrackerSiPhi->setAxisTitle("Phi of Hits (rad)",1);
00551     meTrackerSiPhi->setAxisTitle("Count",2);
00552 
00553     sprintf(hname,"hTrackerSiEta");
00554     sprintf(htitle,"Silicon hits eta");
00555     meTrackerSiEta = dbe->book1D(hname,htitle,100,-3.5,3.5);
00556     meTrackerSiEta->setAxisTitle("Eta of Hits",1);
00557     meTrackerSiEta->setAxisTitle("Count",2);
00558 
00559     sprintf(hname,"hTrackerSiBToF");
00560     sprintf(htitle,"Silicon barrel hits, ToF/ns");
00561     meTrackerSiBToF = dbe->book1D(hname,htitle,100,0.,50.);
00562     meTrackerSiBToF->setAxisTitle("Time of Flight of Hits (ns)",1);
00563     meTrackerSiBToF->setAxisTitle("Count",2);
00564 
00565     sprintf(hname,"hTrackerSiBR");
00566     sprintf(htitle,"Silicon barrel hits, R/cm");
00567     meTrackerSiBR = dbe->book1D(hname,htitle,100,0.,200.);
00568     meTrackerSiBR->setAxisTitle("R of Hits (cm)",1);
00569     meTrackerSiBR->setAxisTitle("Count",2);
00570 
00571     sprintf(hname,"hTrackerSiFToF");
00572     sprintf(htitle,"Silicon forward hits, ToF/ns");
00573     meTrackerSiFToF = dbe->book1D(hname,htitle,100,0.,75.);
00574     meTrackerSiFToF->setAxisTitle("Time of Flight of Hits (ns)",1);
00575     meTrackerSiFToF->setAxisTitle("Count",2);
00576 
00577     sprintf(hname,"hTrackerSiFZ");
00578     sprintf(htitle,"Silicon forward hits, Z/cm");
00579     meTrackerSiFZ = dbe->book1D(hname,htitle,200,-300.,300.);
00580     meTrackerSiFZ->setAxisTitle("Z of Hits (cm)",1);
00581     meTrackerSiFZ->setAxisTitle("Count",2);
00582 
00583     // Muon
00584     dbe->setCurrentFolder("GlobalHitsV/Muons");
00585     sprintf(hname,"hMuon1");
00586     sprintf(htitle,"Muon hits");
00587     meMuon[0] = dbe->book1D(hname,htitle,100,0.,10000.);
00588     sprintf(hname,"hMuon2");
00589     meMuon[1] = dbe->book1D(hname,htitle,100,-0.5,99.5);
00590     for (Int_t i = 0; i < 2; ++i) { 
00591       meMuon[i]->setAxisTitle("Number of Muon Hits",1);
00592       meMuon[i]->setAxisTitle("Count",2);
00593     }  
00594 
00595     sprintf(hname,"hMuonPhi");
00596     sprintf(htitle,"Muon hits phi/rad");
00597     meMuonPhi = dbe->book1D(hname,htitle,100,-3.2,3.2);
00598     meMuonPhi->setAxisTitle("Phi of Hits (rad)",1);
00599     meMuonPhi->setAxisTitle("Count",2);
00600 
00601     sprintf(hname,"hMuonEta");
00602     sprintf(htitle,"Muon hits eta");
00603     meMuonEta = dbe->book1D(hname,htitle,100,-3.5,3.5);
00604     meMuonEta->setAxisTitle("Eta of Hits",1);
00605     meMuonEta->setAxisTitle("Count",2);
00606 
00607     sprintf(hname,"hMuonCscToF1");
00608     sprintf(htitle,"Muon CSC hits, ToF/ns");
00609     meMuonCscToF[0] = dbe->book1D(hname,htitle,100,0.,250.);
00610     sprintf(hname,"hMuonCscToF2");
00611     meMuonCscToF[1] = dbe->book1D(hname,htitle,100,0.,50.);
00612     for (Int_t i = 0; i < 2; ++i) {   
00613       meMuonCscToF[i]->setAxisTitle("Time of Flight of Hits (ns)",1);
00614       meMuonCscToF[i]->setAxisTitle("Count",2);
00615     }  
00616 
00617     sprintf(hname,"hMuonCscZ");
00618     sprintf(htitle,"Muon CSC hits, Z/cm");
00619     meMuonCscZ = dbe->book1D(hname,htitle,200,-1500.,1500.);
00620     meMuonCscZ->setAxisTitle("Z of Hits (cm)",1);
00621     meMuonCscZ->setAxisTitle("Count",2);
00622 
00623     sprintf(hname,"hMuonDtToF1");
00624     sprintf(htitle,"Muon DT hits, ToF/ns");
00625     meMuonDtToF[0] = dbe->book1D(hname,htitle,100,0.,250.);
00626     sprintf(hname,"hMuonDtToF2");
00627     meMuonDtToF[1] = dbe->book1D(hname,htitle,100,0.,50.);
00628     for (Int_t i = 0; i < 2; ++i) {   
00629       meMuonDtToF[i]->setAxisTitle("Time of Flight of Hits (ns)",1);
00630       meMuonDtToF[i]->setAxisTitle("Count",2);
00631     } 
00632 
00633     sprintf(hname,"hMuonDtR");
00634     sprintf(htitle,"Muon DT hits, R/cm");
00635     meMuonDtR = dbe->book1D(hname,htitle,100,0.,1500.); 
00636     meMuonDtR->setAxisTitle("R of Hits (cm)",1);
00637     meMuonDtR->setAxisTitle("Count",2);
00638 
00639     sprintf(hname,"hMuonRpcFToF1");
00640     sprintf(htitle,"Muon RPC forward hits, ToF/ns");
00641     meMuonRpcFToF[0] = dbe->book1D(hname,htitle,100,0.,250.);
00642     sprintf(hname,"hMuonRpcFToF2");
00643     meMuonRpcFToF[1] = dbe->book1D(hname,htitle,100,0.,50.);
00644     for (Int_t i = 0; i < 2; ++i) {   
00645       meMuonRpcFToF[i]->setAxisTitle("Time of Flight of Hits (ns)",1);
00646       meMuonRpcFToF[i]->setAxisTitle("Count",2);
00647     }  
00648     sprintf(hname,"hMuonRpcFZ");
00649     sprintf(htitle,"Muon RPC forward hits, Z/cm");
00650     meMuonRpcFZ = dbe->book1D(hname,htitle,201,-1500.,1500.);
00651     meMuonRpcFZ->setAxisTitle("Z of Hits (cm)",1);
00652     meMuonRpcFZ->setAxisTitle("Count",2);
00653 
00654     sprintf(hname,"hMuonRpcBToF1");
00655     sprintf(htitle,"Muon RPC barrel hits, ToF/ns");
00656     meMuonRpcBToF[0] = dbe->book1D(hname,htitle,100,0.,250.);
00657     sprintf(hname,"hMuonRpcBToF2");
00658     meMuonRpcBToF[1] = dbe->book1D(hname,htitle,100,0.,50.);
00659     for (Int_t i = 0; i < 2; ++i) {   
00660       meMuonRpcBToF[i]->setAxisTitle("Time of Flight of Hits (ns)",1);
00661       meMuonRpcBToF[i]->setAxisTitle("Count",2);
00662     }
00663 
00664     sprintf(hname,"hMuonRpcBR");
00665     sprintf(htitle,"Muon RPC barrel hits, R/cm");
00666     meMuonRpcBR = dbe->book1D(hname,htitle,100,0.,1500.);
00667     meMuonRpcBR->setAxisTitle("R of Hits (cm)",1);
00668     meMuonRpcBR->setAxisTitle("Count",2); 
00669   }
00670 }
00671 
00672 GlobalHitsAnalyzer::~GlobalHitsAnalyzer() {}
00673 
00674 void GlobalHitsAnalyzer::beginJob( void )
00675 {
00676   return;
00677 }
00678 
00679 void GlobalHitsAnalyzer::endJob()
00680 {
00681   std::string MsgLoggerCat = "GlobalHitsAnalyzer_endJob";
00682   if (verbosity >= 0)
00683     edm::LogInfo(MsgLoggerCat) 
00684       << "Terminating having processed " << count << " events.";
00685   return;
00686 }
00687 
00688 void GlobalHitsAnalyzer::analyze(const edm::Event& iEvent, 
00689                                  const edm::EventSetup& iSetup)
00690 {
00691   std::string MsgLoggerCat = "GlobalHitsAnalyzer_analyze";
00692 
00693   // keep track of number of events processed
00694   ++count;
00695 
00696   // get event id information
00697   int nrun = iEvent.id().run();
00698   int nevt = iEvent.id().event();
00699 
00700   if (verbosity > 0) {
00701     edm::LogInfo(MsgLoggerCat)
00702       << "Processing run " << nrun << ", event " << nevt
00703       << " (" << count << " events total)";
00704   } else if (verbosity == 0) {
00705     if (nevt%frequency == 0 || nevt == 1) {
00706       edm::LogInfo(MsgLoggerCat)
00707         << "Processing run " << nrun << ", event " << nevt
00708         << " (" << count << " events total)";
00709     }
00710   }
00711 
00712   // look at information available in the event
00713   if (getAllProvenances) {
00714 
00715     std::vector<const edm::Provenance*> AllProv;
00716     iEvent.getAllProvenance(AllProv);
00717 
00718     if (verbosity >= 0)
00719       edm::LogInfo(MsgLoggerCat)
00720         << "Number of Provenances = " << AllProv.size();
00721 
00722     if (printProvenanceInfo && (verbosity >= 0)) {
00723       TString eventout("\nProvenance info:\n");      
00724 
00725       for (unsigned int i = 0; i < AllProv.size(); ++i) {
00726         eventout += "\n       ******************************";
00727         eventout += "\n       Module       : ";
00728         eventout += AllProv[i]->moduleLabel();
00729         eventout += "\n       ProductID    : ";
00730         eventout += AllProv[i]->productID().id();
00731         eventout += "\n       ClassName    : ";
00732         eventout += AllProv[i]->className();
00733         eventout += "\n       InstanceName : ";
00734         eventout += AllProv[i]->productInstanceName();
00735         eventout += "\n       BranchName   : ";
00736         eventout += AllProv[i]->branchName();
00737       }
00738       eventout += "\n       ******************************\n";
00739       edm::LogInfo(MsgLoggerCat) << eventout << "\n";
00740       printProvenanceInfo = false;
00741     }
00742     getAllProvenances = false;
00743   }
00744 
00745   // call fill functions
00746   //gather G4MC information from event
00747   fillG4MC(iEvent);
00748   // gather Tracker information from event
00749   fillTrk(iEvent,iSetup);
00750   // gather muon information from event
00751   fillMuon(iEvent, iSetup);
00752   // gather Ecal information from event
00753   fillECal(iEvent, iSetup);
00754   // gather Hcal information from event
00755   fillHCal(iEvent, iSetup);
00756 
00757   if (verbosity > 0)
00758     edm::LogInfo (MsgLoggerCat)
00759       << "Done gathering data from event.";
00760 
00761   return;
00762 }
00763 
00764 //==================fill and store functions================================
00765 void GlobalHitsAnalyzer::fillG4MC(const edm::Event& iEvent)
00766 {
00767 
00768   std::string MsgLoggerCat = "GlobalHitsAnalyzer_fillG4MC";
00769  
00770   TString eventout;
00771   if (verbosity > 0)
00772     eventout = "\nGathering info:";
00773 
00775   // get MC information
00777   edm::Handle<edm::HepMCProduct> HepMCEvt;
00778   std::vector<edm::Handle<edm::HepMCProduct> > AllHepMCEvt;
00779   iEvent.getManyByType(AllHepMCEvt);
00780 
00781   // loop through products and extract VtxSmearing if available. Any of them
00782   // should have the information needed
00783   for (unsigned int i = 0; i < AllHepMCEvt.size(); ++i) {
00784     HepMCEvt = AllHepMCEvt[i];
00785     if ((HepMCEvt.provenance()->product()).moduleLabel() == "VtxSmeared")
00786       break;
00787   }
00788 
00789   if (!HepMCEvt.isValid()) {
00790     LogDebug(MsgLoggerCat)
00791       << "Unable to find HepMCProduct in event!";
00792     validHepMCevt = false;
00793   } else {
00794     eventout += "\n          Using HepMCProduct: ";
00795     eventout += (HepMCEvt.provenance()->product()).moduleLabel();
00796   }
00797   if (validHepMCevt) {
00798     const HepMC::GenEvent* MCEvt = HepMCEvt->GetEvent();
00799     nRawGenPart = MCEvt->particles_size();
00800     
00801     
00802     if (verbosity > 1) {
00803       eventout += "\n          Number of Raw Particles collected:......... ";
00804       eventout += nRawGenPart;
00805     }      
00806     
00807     if (meMCRGP[0]) meMCRGP[0]->Fill((float)nRawGenPart);
00808     if (meMCRGP[1]) meMCRGP[1]->Fill((float)nRawGenPart);  
00809   }
00810   
00811   
00813   // get G4Vertex information
00815   // convert unit stored in SimVertex to mm
00816   float unit = 0.;
00817   if (vtxunit == 0) unit = 1.;  // already in mm
00818   if (vtxunit == 1) unit = 10.; // stored in cm, convert to mm
00819 
00820   edm::Handle<edm::SimVertexContainer> G4VtxContainer;
00821   iEvent.getByLabel(G4VtxSrc_, G4VtxContainer);
00822 
00823   // needed here by vertex multiplicity
00824   edm::Handle<edm::SimTrackContainer> G4TrkContainer;
00825   iEvent.getByLabel(G4TrkSrc_, G4TrkContainer);
00826 
00827 
00828   if (!G4VtxContainer.isValid()) {
00829     LogDebug(MsgLoggerCat)
00830       << "Unable to find SimVertex in event!";
00831     validG4VtxContainer = false;
00832   }
00833   if (validG4VtxContainer) {
00834     int i = 0;
00835     edm::SimVertexContainer::const_iterator itVtx;
00836     for (itVtx = G4VtxContainer->begin(); itVtx != G4VtxContainer->end(); 
00837          ++itVtx) {
00838       
00839       ++i;
00840       
00841       const math::XYZTLorentzVector G4Vtx1(itVtx->position().x(),
00842                                            itVtx->position().y(),
00843                                            itVtx->position().z(),
00844                                            itVtx->position().e());
00845       
00846       double G4Vtx[4];
00847       G4Vtx1.GetCoordinates(G4Vtx);
00848       
00849       if (meGeantVtxX[0]) meGeantVtxX[0]->Fill((G4Vtx[0]*unit)/micrometer);
00850       if (meGeantVtxX[1]) meGeantVtxX[1]->Fill((G4Vtx[0]*unit)/micrometer);
00851       
00852       if (meGeantVtxY[0]) meGeantVtxY[0]->Fill((G4Vtx[1]*unit)/micrometer);
00853       if (meGeantVtxY[1]) meGeantVtxY[1]->Fill((G4Vtx[1]*unit)/micrometer);
00854       
00855       if (meGeantVtxZ[0]) meGeantVtxZ[0]->Fill((G4Vtx[2]*unit)/millimeter);
00856       if (meGeantVtxZ[1]) meGeantVtxZ[1]->Fill((G4Vtx[2]*unit)/millimeter); 
00857 
00858       if (meGeantVtxEta) meGeantVtxEta->Fill(G4Vtx1.eta());
00859       if (meGeantVtxPhi) meGeantVtxPhi->Fill(G4Vtx1.phi());
00860       if (meGeantVtxRad[0]) meGeantVtxRad[0]->Fill(G4Vtx1.rho());
00861       if (meGeantVtxRad[1]) meGeantVtxRad[1]->Fill(G4Vtx1.rho());
00862 
00863       if (meGeantVtxMulti) { 
00864         int multi = 0;
00865         if ( G4TrkContainer.isValid() ) {
00866           edm::SimTrackContainer::const_iterator itTrk;
00867           for (itTrk = G4TrkContainer->begin(); itTrk != G4TrkContainer->end(); 
00868                ++itTrk) {
00869             if ( (*itTrk).vertIndex() == i ) { multi++; }
00870           }
00871         }
00872         meGeantVtxMulti->Fill(((double)multi+0.5));
00873     }
00874       
00875     }
00876     
00877     if (verbosity > 1) {
00878       eventout += "\n          Number of G4Vertices collected:............ ";
00879       eventout += i;
00880     }  
00881     
00882     if (meMCG4Vtx[0]) meMCG4Vtx[0]->Fill((float)i);
00883     if (meMCG4Vtx[1]) meMCG4Vtx[1]->Fill((float)i);  
00884 
00885   }
00886 
00888   // get G4Track information
00890   if (!G4TrkContainer.isValid()) {
00891     LogDebug(MsgLoggerCat)
00892       << "Unable to find SimTrack in event!";
00893     validG4trkContainer = false;
00894   }
00895   if (validG4trkContainer) {
00896     int i = 0;
00897     edm::SimTrackContainer::const_iterator itTrk;
00898     for (itTrk = G4TrkContainer->begin(); itTrk != G4TrkContainer->end(); 
00899          ++itTrk) {
00900       
00901       ++i;
00902       
00903       const math::XYZTLorentzVector G4Trk1(itTrk->momentum().x(),
00904                                            itTrk->momentum().y(),
00905                                            itTrk->momentum().z(),
00906                                            itTrk->momentum().e());
00907       double G4Trk[4];
00908       G4Trk1.GetCoordinates(G4Trk);
00909       
00910       if (meGeantTrkPt) meGeantTrkPt->
00911                           Fill(std::log10(std::max(sqrt(G4Trk[0]*G4Trk[0]+G4Trk[1]*G4Trk[1]),-9.)));
00912       if (meGeantTrkE) meGeantTrkE->Fill(std::log10(std::max(G4Trk[3],-9.)));
00913     } 
00914     
00915     if (verbosity > 1) {
00916       eventout += "\n          Number of G4Tracks collected:.............. ";
00917       eventout += i;
00918     }  
00919     
00920     if (meMCG4Trk[0]) meMCG4Trk[0]->Fill((float)i);
00921     if (meMCG4Trk[1]) meMCG4Trk[1]->Fill((float)i); 
00922   }
00923 
00924   if (verbosity > 0)
00925     edm::LogInfo(MsgLoggerCat) << eventout << "\n";
00926     
00927   return;
00928 }
00929 
00930 void GlobalHitsAnalyzer::fillTrk(const edm::Event& iEvent, 
00931                                  const edm::EventSetup& iSetup)
00932 {
00933 
00934   nPxlHits = 0;
00935   std::string MsgLoggerCat = "GlobalHitsAnalyzer_fillTrk";
00936 
00937   TString eventout;
00938   if (verbosity > 0)
00939     eventout = "\nGathering info:";  
00940   
00941   // access the tracker geometry
00942   edm::ESHandle<TrackerGeometry> theTrackerGeometry;
00943   iSetup.get<TrackerDigiGeometryRecord>().get(theTrackerGeometry);
00944   if (!theTrackerGeometry.isValid()) {
00945     edm::LogWarning(MsgLoggerCat)
00946       << "Unable to find TrackerDigiGeometryRecord in event!";
00947     return;
00948   }
00949   const TrackerGeometry& theTracker(*theTrackerGeometry);
00950     
00951   // iterator to access containers
00952   edm::PSimHitContainer::const_iterator itHit;
00953 
00955   // get Pixel Barrel information
00957   edm::PSimHitContainer thePxlBrlHits;
00958   // extract low container
00959   edm::Handle<edm::PSimHitContainer> PxlBrlLowContainer;
00960   iEvent.getByLabel(PxlBrlLowSrc_,PxlBrlLowContainer);
00961   if (!PxlBrlLowContainer.isValid()) {
00962     LogDebug(MsgLoggerCat)
00963       << "Unable to find TrackerHitsPixelBarrelLowTof in event!";
00964     validPxlBrlLow = false;
00965   }
00966   // extract high container
00967   edm::Handle<edm::PSimHitContainer> PxlBrlHighContainer;
00968   iEvent.getByLabel(PxlBrlHighSrc_,PxlBrlHighContainer);
00969   if (!PxlBrlHighContainer.isValid()) {
00970     LogDebug(MsgLoggerCat)
00971       << "Unable to find TrackerHitsPixelBarrelHighTof in event!";
00972     validPxlBrlHigh = false;
00973   }
00974   // place both containers into new container
00975   if (validPxlBrlLow) 
00976     thePxlBrlHits.insert(thePxlBrlHits.end(),PxlBrlLowContainer->begin(),
00977                          PxlBrlLowContainer->end());
00978   if(validPxlBrlHigh)
00979     thePxlBrlHits.insert(thePxlBrlHits.end(),PxlBrlHighContainer->begin(),
00980                          PxlBrlHighContainer->end());
00981 
00982   // cycle through new container
00983   int i = 0, j = 0;
00984   for (itHit = thePxlBrlHits.begin(); itHit != thePxlBrlHits.end(); ++itHit) {
00985     
00986     ++i;
00987     
00988     // create a DetId from the detUnitId
00989     DetId theDetUnitId(itHit->detUnitId());
00990     int detector = theDetUnitId.det();
00991     int subdetector = theDetUnitId.subdetId();
00992     
00993     // check that expected detector is returned
00994     if ((detector == dTrk) && (subdetector == sdPxlBrl)) {
00995       
00996       // get the GeomDetUnit from the geometry using theDetUnitID
00997       const GeomDetUnit *theDet = theTracker.idToDetUnit(theDetUnitId);
00998       
00999       if (!theDet) {
01000         edm::LogWarning(MsgLoggerCat)
01001           << "Unable to get GeomDetUnit from PxlBrlHits for Hit " << i;
01002         continue;
01003       }
01004       
01005       ++j;
01006       
01007       // get the Surface of the hit (knows how to go from local <-> global)
01008       const BoundPlane& bSurface = theDet->surface();
01009       
01010       if(meTrackerPxBToF) meTrackerPxBToF->Fill(itHit->tof());
01011       if(meTrackerPxBR) 
01012         meTrackerPxBR->Fill(bSurface.toGlobal(itHit->localPosition()).perp());
01013       if(meTrackerPxPhi) 
01014         meTrackerPxPhi->Fill(bSurface.toGlobal(itHit->localPosition()).phi());
01015       if(meTrackerPxEta) 
01016         meTrackerPxEta->Fill(bSurface.toGlobal(itHit->localPosition()).eta());
01017       
01018     } else {
01019       edm::LogWarning(MsgLoggerCat)
01020         << "PxlBrl PSimHit " << i 
01021         << " is expected to be (det,subdet) = (" 
01022         << dTrk << "," << sdPxlBrl
01023         << "); value returned is: ("
01024         << detector << "," << subdetector << ")";
01025       continue;
01026     } // end detector type check
01027   } // end loop through PxlBrl Hits
01028   
01029   if (verbosity > 1) {
01030     eventout += "\n          Number of Pixel Barrel Hits collected:..... ";
01031     eventout += j;
01032   }  
01033   
01034   nPxlHits += j;
01035   
01037   // get Pixel Forward information
01039   edm::PSimHitContainer thePxlFwdHits;
01040   // extract low container
01041   edm::Handle<edm::PSimHitContainer> PxlFwdLowContainer;
01042   iEvent.getByLabel(PxlFwdLowSrc_,PxlFwdLowContainer);
01043   if (!PxlFwdLowContainer.isValid()) {
01044     LogDebug(MsgLoggerCat)
01045       << "Unable to find TrackerHitsPixelEndcapLowTof in event!";
01046     validPxlFwdLow = false;
01047   }
01048   // extract high container
01049   edm::Handle<edm::PSimHitContainer> PxlFwdHighContainer;
01050   iEvent.getByLabel(PxlFwdHighSrc_,PxlFwdHighContainer);
01051   if (!PxlFwdHighContainer.isValid()) {
01052     LogDebug("GlobalHitsAnalyzer_fillTrk")
01053       << "Unable to find TrackerHitsPixelEndcapHighTof in event!";
01054     validPxlFwdHigh = false;
01055   }
01056   // place both containers into new container
01057   if (validPxlFwdLow)
01058     thePxlFwdHits.insert(thePxlFwdHits.end(),PxlFwdLowContainer->begin(),
01059                          PxlFwdLowContainer->end());
01060   if (validPxlFwdHigh)
01061     thePxlFwdHits.insert(thePxlFwdHits.end(),PxlFwdHighContainer->begin(),
01062                          PxlFwdHighContainer->end());
01063 
01064   // cycle through new container
01065   i = 0; j = 0;
01066   for (itHit = thePxlFwdHits.begin(); itHit != thePxlFwdHits.end(); ++itHit) {
01067 
01068     ++i;
01069 
01070     // create a DetId from the detUnitId
01071     DetId theDetUnitId(itHit->detUnitId());
01072     int detector = theDetUnitId.det();
01073     int subdetector = theDetUnitId.subdetId();
01074 
01075     // check that expected detector is returned
01076     if ((detector == dTrk) && (subdetector == sdPxlFwd)) {
01077 
01078       // get the GeomDetUnit from the geometry using theDetUnitID
01079       const GeomDetUnit *theDet = theTracker.idToDetUnit(theDetUnitId);
01080 
01081       if (!theDet) {
01082         edm::LogWarning(MsgLoggerCat)
01083           << "Unable to get GeomDetUnit from PxlFwdHits for Hit " << i;;
01084         continue;
01085       }
01086 
01087       ++j;
01088 
01089       // get the Surface of the hit (knows how to go from local <-> global)
01090       const BoundPlane& bSurface = theDet->surface();
01091 
01092       if(meTrackerPxFToF) meTrackerPxFToF->Fill(itHit->tof());
01093       if(meTrackerPxFZ) 
01094         meTrackerPxFZ->Fill(bSurface.toGlobal(itHit->localPosition()).z());
01095       if(meTrackerPxPhi) 
01096         meTrackerPxPhi->Fill(bSurface.toGlobal(itHit->localPosition()).phi());
01097       if(meTrackerPxEta) 
01098         meTrackerPxEta->Fill(bSurface.toGlobal(itHit->localPosition()).eta());
01099 
01100     } else {
01101       edm::LogWarning(MsgLoggerCat)
01102         << "PxlFwd PSimHit " << i 
01103         << " is expected to be (det,subdet) = (" 
01104         << dTrk << "," << sdPxlFwd
01105         << "); value returned is: ("
01106         << detector << "," << subdetector << ")";
01107       continue;
01108     } // end detector type check
01109   } // end loop through PxlFwd Hits
01110 
01111   if (verbosity > 1) {
01112     eventout += "\n          Number of Pixel Forward Hits collected:.... ";
01113     eventout += j;
01114   }  
01115 
01116   nPxlHits += j;
01117 
01118   if (meTrackerPx[0]) meTrackerPx[0]->Fill((float)nPxlHits);
01119   if (meTrackerPx[1]) meTrackerPx[1]->Fill((float)nPxlHits); 
01120 
01122   // get Silicon Barrel information
01124   nSiHits = 0;
01125   edm::PSimHitContainer theSiBrlHits;
01126   // extract TIB low container
01127   edm::Handle<edm::PSimHitContainer> SiTIBLowContainer;
01128   iEvent.getByLabel(SiTIBLowSrc_,SiTIBLowContainer);
01129   if (!SiTIBLowContainer.isValid()) {
01130     LogDebug(MsgLoggerCat)
01131       << "Unable to find TrackerHitsTIBLowTof in event!";
01132     validSiTIBLow = false;
01133   }
01134   // extract TIB high container
01135   edm::Handle<edm::PSimHitContainer> SiTIBHighContainer;
01136   iEvent.getByLabel(SiTIBHighSrc_,SiTIBHighContainer);
01137   if (!SiTIBHighContainer.isValid()) {
01138     LogDebug(MsgLoggerCat)
01139       << "Unable to find TrackerHitsTIBHighTof in event!";
01140     validSiTIBHigh = false;
01141   }
01142   // extract TOB low container
01143   edm::Handle<edm::PSimHitContainer> SiTOBLowContainer;
01144   iEvent.getByLabel(SiTOBLowSrc_,SiTOBLowContainer);
01145   if (!SiTOBLowContainer.isValid()) {
01146     LogDebug(MsgLoggerCat)
01147       << "Unable to find TrackerHitsTOBLowTof in event!";
01148     validSiTOBLow = false;
01149   }
01150   // extract TOB high container
01151   edm::Handle<edm::PSimHitContainer> SiTOBHighContainer;
01152   iEvent.getByLabel(SiTOBHighSrc_,SiTOBHighContainer);
01153   if (!SiTOBHighContainer.isValid()) {
01154     LogDebug(MsgLoggerCat)
01155       << "Unable to find TrackerHitsTOBHighTof in event!";
01156     validSiTOBHigh = false;
01157   }
01158   // place all containers into new container
01159   if (validSiTIBLow)
01160     theSiBrlHits.insert(theSiBrlHits.end(),SiTIBLowContainer->begin(),
01161                         SiTIBLowContainer->end());
01162   if (validSiTIBHigh)
01163     theSiBrlHits.insert(theSiBrlHits.end(),SiTIBHighContainer->begin(),
01164                         SiTIBHighContainer->end());
01165   if (validSiTOBLow)
01166     theSiBrlHits.insert(theSiBrlHits.end(),SiTOBLowContainer->begin(),
01167                         SiTOBLowContainer->end());
01168   if (validSiTOBHigh)
01169     theSiBrlHits.insert(theSiBrlHits.end(),SiTOBHighContainer->begin(),
01170                         SiTOBHighContainer->end());
01171 
01172   // cycle through new container
01173   i = 0; j = 0;
01174   for (itHit = theSiBrlHits.begin(); itHit != theSiBrlHits.end(); ++itHit) {
01175 
01176     ++i;
01177 
01178     // create a DetId from the detUnitId
01179     DetId theDetUnitId(itHit->detUnitId());
01180     int detector = theDetUnitId.det();
01181     int subdetector = theDetUnitId.subdetId();
01182 
01183     // check that expected detector is returned
01184     if ((detector == dTrk) && 
01185         ((subdetector == sdSiTIB) ||
01186          (subdetector == sdSiTOB))) {
01187 
01188       // get the GeomDetUnit from the geometry using theDetUnitID
01189       const GeomDetUnit *theDet = theTracker.idToDetUnit(theDetUnitId);
01190 
01191       if (!theDet) {
01192         edm::LogWarning(MsgLoggerCat)
01193           << "Unable to get GeomDetUnit from SiBrlHits for Hit " << i;
01194         continue;
01195       }
01196 
01197       ++j;
01198 
01199       // get the Surface of the hit (knows how to go from local <-> global)
01200       const BoundPlane& bSurface = theDet->surface();
01201 
01202       if(meTrackerSiBToF) meTrackerSiBToF->Fill(itHit->tof());
01203       if(meTrackerSiBR) 
01204         meTrackerSiBR->Fill(bSurface.toGlobal(itHit->localPosition()).perp());
01205       if(meTrackerSiPhi) 
01206         meTrackerSiPhi->Fill(bSurface.toGlobal(itHit->localPosition()).phi());
01207       if(meTrackerSiEta) 
01208         meTrackerSiEta->Fill(bSurface.toGlobal(itHit->localPosition()).eta());
01209 
01210     } else {
01211       edm::LogWarning(MsgLoggerCat)
01212         << "SiBrl PSimHit " << i 
01213         << " is expected to be (det,subdet) = (" 
01214         << dTrk << "," << sdSiTIB
01215         << " || " << sdSiTOB << "); value returned is: ("
01216         << detector << "," << subdetector << ")";
01217       continue;
01218     } // end detector type check
01219   } // end loop through SiBrl Hits
01220 
01221   if (verbosity > 1) {
01222     eventout += "\n          Number of Silicon Barrel Hits collected:... ";
01223     eventout += j;
01224   }  
01225 
01226   nSiHits += j;
01227 
01229   // get Silicon Forward information
01231   edm::PSimHitContainer theSiFwdHits;
01232   // extract TID low container
01233   edm::Handle<edm::PSimHitContainer> SiTIDLowContainer;
01234   iEvent.getByLabel(SiTIDLowSrc_,SiTIDLowContainer);
01235   if (!SiTIDLowContainer.isValid()) {
01236     LogDebug(MsgLoggerCat)
01237       << "Unable to find TrackerHitsTIDLowTof in event!";
01238     validSiTIDLow = false;
01239   }
01240   // extract TID high container
01241   edm::Handle<edm::PSimHitContainer> SiTIDHighContainer;
01242   iEvent.getByLabel(SiTIDHighSrc_,SiTIDHighContainer);
01243   if (!SiTIDHighContainer.isValid()) {
01244     LogDebug("GlobalHitsAnalyzer_fillTrk")
01245       << "Unable to find TrackerHitsTIDHighTof in event!";
01246     validSiTIDHigh = false;
01247   }
01248   // extract TEC low container
01249   edm::Handle<edm::PSimHitContainer> SiTECLowContainer;
01250   iEvent.getByLabel(SiTECLowSrc_,SiTECLowContainer);
01251   if (!SiTECLowContainer.isValid()) {
01252     LogDebug(MsgLoggerCat)
01253       << "Unable to find TrackerHitsTECLowTof in event!";
01254     validSiTECLow = false;
01255   }
01256   // extract TEC high container
01257   edm::Handle<edm::PSimHitContainer> SiTECHighContainer;
01258   iEvent.getByLabel(SiTECHighSrc_,SiTECHighContainer);
01259   if (!SiTECHighContainer.isValid()) {
01260     LogDebug(MsgLoggerCat)
01261       << "Unable to find TrackerHitsTECHighTof in event!";
01262     validSiTECHigh = false;
01263   }
01264   // place all containers into new container
01265   if (validSiTIDLow)
01266     theSiFwdHits.insert(theSiFwdHits.end(),SiTIDLowContainer->begin(),
01267                         SiTIDLowContainer->end());
01268   if (validSiTIDHigh)
01269     theSiFwdHits.insert(theSiFwdHits.end(),SiTIDHighContainer->begin(),
01270                         SiTIDHighContainer->end());
01271   if (validSiTECLow)
01272     theSiFwdHits.insert(theSiFwdHits.end(),SiTECLowContainer->begin(),
01273                         SiTECLowContainer->end());
01274   if (validSiTECHigh)
01275     theSiFwdHits.insert(theSiFwdHits.end(),SiTECHighContainer->begin(),
01276                         SiTECHighContainer->end());
01277 
01278   // cycle through container
01279   i = 0; j = 0;
01280   for (itHit = theSiFwdHits.begin(); itHit != theSiFwdHits.end(); ++itHit) {
01281 
01282     ++i;
01283 
01284     // create a DetId from the detUnitId
01285     DetId theDetUnitId(itHit->detUnitId());
01286     int detector = theDetUnitId.det();
01287     int subdetector = theDetUnitId.subdetId();
01288 
01289     // check that expected detector is returned 
01290     if ((detector == dTrk) && 
01291         ((subdetector == sdSiTID) ||
01292          (subdetector == sdSiTEC))) {
01293       
01294       // get the GeomDetUnit from the geometry using theDetUnitID
01295       const GeomDetUnit *theDet = theTracker.idToDetUnit(theDetUnitId);
01296       
01297       if (!theDet) {
01298         edm::LogWarning(MsgLoggerCat)
01299           << "Unable to get GeomDetUnit from SiFwdHits Hit " << i;
01300         return;
01301       }
01302       
01303       ++j;
01304 
01305       // get the Surface of the hit (knows how to go from local <-> global)
01306       const BoundPlane& bSurface = theDet->surface();
01307       
01308       if(meTrackerSiFToF) meTrackerSiFToF->Fill(itHit->tof());
01309       if(meTrackerSiFZ) 
01310         meTrackerSiFZ->Fill(bSurface.toGlobal(itHit->localPosition()).z());
01311       if(meTrackerSiPhi) 
01312         meTrackerSiPhi->Fill(bSurface.toGlobal(itHit->localPosition()).phi());
01313       if(meTrackerSiEta) 
01314         meTrackerSiEta->Fill(bSurface.toGlobal(itHit->localPosition()).eta());
01315 
01316     } else {
01317       edm::LogWarning(MsgLoggerCat)
01318         << "SiFwd PSimHit " << i 
01319         << " is expected to be (det,subdet) = (" 
01320         << dTrk << "," << sdSiTOB
01321         << " || " << sdSiTEC << "); value returned is: ("
01322         << detector << "," << subdetector << ")";
01323       continue;
01324     } // end check detector type
01325   } // end loop through SiFwd Hits
01326 
01327   if (verbosity > 1) {
01328     eventout += "\n          Number of Silicon Forward Hits collected:.. ";
01329     eventout += j;
01330   }  
01331 
01332   nSiHits +=j;
01333 
01334   if (meTrackerSi[0]) meTrackerSi[0]->Fill((float)nSiHits);
01335   if (meTrackerSi[1]) meTrackerSi[1]->Fill((float)nSiHits); 
01336 
01337   if (verbosity > 0)
01338     edm::LogInfo(MsgLoggerCat) << eventout << "\n";
01339 
01340   return;
01341 }
01342 
01343 void GlobalHitsAnalyzer::fillMuon(const edm::Event& iEvent, 
01344                                   const edm::EventSetup& iSetup)
01345 {
01346   nMuonHits = 0;
01347   std::string MsgLoggerCat = "GlobalHitsAnalyzer_fillMuon";
01348 
01349   TString eventout;
01350   if (verbosity > 0)
01351     eventout = "\nGathering info:";  
01352 
01353   // iterator to access containers
01354   edm::PSimHitContainer::const_iterator itHit;
01355 
01357   // access the CSC Muon
01359   // access the CSC Muon geometry
01360   edm::ESHandle<CSCGeometry> theCSCGeometry;
01361   iSetup.get<MuonGeometryRecord>().get(theCSCGeometry);
01362   if (!theCSCGeometry.isValid()) {
01363     edm::LogWarning(MsgLoggerCat)
01364       << "Unable to find MuonGeometryRecord for the CSCGeometry in event!";
01365     return;
01366   }
01367   const CSCGeometry& theCSCMuon(*theCSCGeometry);
01368 
01369   // get Muon CSC information
01370   edm::Handle<edm::PSimHitContainer> MuonCSCContainer;
01371   iEvent.getByLabel(MuonCscSrc_,MuonCSCContainer);
01372   if (!MuonCSCContainer.isValid()) {
01373     LogDebug(MsgLoggerCat)
01374       << "Unable to find MuonCSCHits in event!";
01375     validMuonCSC = false;
01376   }
01377 
01378   if (validMuonCSC) {
01379     // cycle through container
01380     int i = 0, j = 0;
01381     for (itHit = MuonCSCContainer->begin(); itHit != MuonCSCContainer->end(); 
01382          ++itHit) {
01383       
01384       ++i;
01385       
01386       // create a DetId from the detUnitId
01387       DetId theDetUnitId(itHit->detUnitId());
01388       int detector = theDetUnitId.det();
01389       int subdetector = theDetUnitId.subdetId();
01390       
01391       // check that expected detector is returned
01392       if ((detector == dMuon) && 
01393           (subdetector == sdMuonCSC)) {
01394         
01395         // get the GeomDetUnit from the geometry using theDetUnitID
01396         const GeomDetUnit *theDet = theCSCMuon.idToDetUnit(theDetUnitId);
01397         
01398         if (!theDet) {
01399           edm::LogWarning(MsgLoggerCat)
01400             << "Unable to get GeomDetUnit from theCSCMuon for hit " << i;
01401           continue;
01402         }
01403         
01404         ++j;
01405         
01406         // get the Surface of the hit (knows how to go from local <-> global)
01407         const BoundPlane& bSurface = theDet->surface();
01408         
01409         if (meMuonCscToF[0]) meMuonCscToF[0]->Fill(itHit->tof());
01410         if (meMuonCscToF[1]) meMuonCscToF[1]->Fill(itHit->tof());
01411         if (meMuonCscZ) 
01412           meMuonCscZ->Fill(bSurface.toGlobal(itHit->localPosition()).z());
01413         if (meMuonPhi)
01414           meMuonPhi->Fill(bSurface.toGlobal(itHit->localPosition()).phi());
01415         if (meMuonEta)
01416           meMuonEta->Fill(bSurface.toGlobal(itHit->localPosition()).eta());
01417         
01418       } else {
01419         edm::LogWarning(MsgLoggerCat)
01420           << "MuonCsc PSimHit " << i 
01421           << " is expected to be (det,subdet) = (" 
01422           << dMuon << "," << sdMuonCSC
01423           << "); value returned is: ("
01424           << detector << "," << subdetector << ")";
01425         continue;
01426       } // end detector type check
01427     } // end loop through CSC Hits
01428     
01429     if (verbosity > 1) {
01430       eventout += "\n          Number of CSC muon Hits collected:......... ";
01431       eventout += j;
01432     }  
01433 
01434     nMuonHits += j;
01435   }
01436 
01438   // access the DT Muon
01440   // access the DT Muon geometry
01441   edm::ESHandle<DTGeometry> theDTGeometry;
01442   iSetup.get<MuonGeometryRecord>().get(theDTGeometry);
01443   if (!theDTGeometry.isValid()) {
01444     edm::LogWarning(MsgLoggerCat)
01445       << "Unable to find MuonGeometryRecord for the DTGeometry in event!";
01446     return;
01447   }
01448   const DTGeometry& theDTMuon(*theDTGeometry);
01449 
01450   // get Muon DT information
01451   edm::Handle<edm::PSimHitContainer> MuonDtContainer;
01452   iEvent.getByLabel(MuonDtSrc_,MuonDtContainer);
01453   if (!MuonDtContainer.isValid()) {
01454     LogDebug(MsgLoggerCat)
01455       << "Unable to find MuonDTHits in event!";
01456     validMuonDt = false;
01457   }
01458 
01459   if (validMuonDt) {
01460     // cycle through container
01461     int i = 0, j = 0;
01462     for (itHit = MuonDtContainer->begin(); itHit != MuonDtContainer->end(); 
01463          ++itHit) {
01464       
01465       ++i;
01466       
01467       // create a DetId from the detUnitId
01468       DetId theDetUnitId(itHit->detUnitId());
01469       int detector = theDetUnitId.det();
01470       int subdetector = theDetUnitId.subdetId();
01471       
01472       // check that expected detector is returned
01473       if ((detector == dMuon) && 
01474           (subdetector == sdMuonDT)) {
01475         
01476         // CSC uses wires and layers rather than the full detID
01477         // get the wireId
01478         DTWireId wireId(itHit->detUnitId());
01479         
01480         // get the DTLayer from the geometry using the wireID
01481         const DTLayer *theDet = theDTMuon.layer(wireId.layerId());
01482         
01483         if (!theDet) {
01484           edm::LogWarning(MsgLoggerCat)
01485             << "Unable to get GeomDetUnit from theDtMuon for hit " << i;
01486           continue;
01487         }
01488         
01489         ++j;
01490         
01491         // get the Surface of the hit (knows how to go from local <-> global)
01492         const BoundPlane& bSurface = theDet->surface();
01493         
01494         if (meMuonDtToF[0]) meMuonDtToF[0]->Fill(itHit->tof());
01495         if (meMuonDtToF[1]) meMuonDtToF[1]->Fill(itHit->tof());
01496         if (meMuonDtR) 
01497           meMuonDtR->Fill(bSurface.toGlobal(itHit->localPosition()).perp());
01498         if (meMuonPhi)
01499           meMuonPhi->Fill(bSurface.toGlobal(itHit->localPosition()).phi());
01500         if (meMuonEta)
01501           meMuonEta->Fill(bSurface.toGlobal(itHit->localPosition()).eta());
01502         
01503       } else {
01504         edm::LogWarning(MsgLoggerCat)
01505           << "MuonDt PSimHit " << i 
01506           << " is expected to be (det,subdet) = (" 
01507           << dMuon << "," << sdMuonDT
01508           << "); value returned is: ("
01509           << detector << "," << subdetector << ")";
01510         continue;
01511       } // end detector type check
01512     } // end loop through DT Hits
01513     
01514     if (verbosity > 1) {
01515       eventout += "\n          Number of DT muon Hits collected:.......... ";
01516       eventout += j;
01517     } 
01518     
01519     nMuonHits += j;
01520   }
01521 
01522   //int RPCBrl = 0, RPCFwd = 0;
01524   // access the RPC Muon
01526   // access the RPC Muon geometry
01527   edm::ESHandle<RPCGeometry> theRPCGeometry;
01528   iSetup.get<MuonGeometryRecord>().get(theRPCGeometry);
01529   if (!theRPCGeometry.isValid()) {
01530     edm::LogWarning(MsgLoggerCat)
01531       << "Unable to find MuonGeometryRecord for the RPCGeometry in event!";
01532     return;
01533   }
01534   const RPCGeometry& theRPCMuon(*theRPCGeometry);
01535 
01536   // get Muon RPC information
01537   edm::Handle<edm::PSimHitContainer> MuonRPCContainer;
01538   iEvent.getByLabel(MuonRpcSrc_,MuonRPCContainer);
01539   if (!MuonRPCContainer.isValid()) {
01540     LogDebug(MsgLoggerCat)
01541       << "Unable to find MuonRPCHits in event!";
01542     validMuonRPC = false;
01543   }
01544 
01545   if (validMuonRPC) {
01546     // cycle through container
01547     int i = 0, j = 0;
01548     int RPCBrl =0, RPCFwd = 0;
01549     for (itHit = MuonRPCContainer->begin(); itHit != MuonRPCContainer->end(); 
01550          ++itHit) {
01551       
01552       ++i;
01553       
01554       // create a DetID from the detUnitId
01555       DetId theDetUnitId(itHit->detUnitId());
01556       int detector = theDetUnitId.det();
01557       int subdetector = theDetUnitId.subdetId();
01558       
01559       // check that expected detector is returned
01560       if ((detector == dMuon) && 
01561           (subdetector == sdMuonRPC)) {
01562         
01563         // get an RPCDetID from the detUnitID
01564         RPCDetId RPCId(itHit->detUnitId());      
01565         
01566         // find the region of the RPC hit
01567         int region = RPCId.region();
01568         
01569         // get the GeomDetUnit from the geometry using the RPCDetId
01570         const GeomDetUnit *theDet = theRPCMuon.idToDetUnit(theDetUnitId);
01571         
01572         if (!theDet) {
01573           edm::LogWarning(MsgLoggerCat)
01574             << "Unable to get GeomDetUnit from theRPCMuon for hit " << i;
01575           continue;
01576         }
01577         
01578         ++j;
01579         
01580         // get the Surface of the hit (knows how to go from local <-> global)
01581         const BoundPlane& bSurface = theDet->surface();
01582         
01583         // gather necessary information
01584         if ((region == sdMuonRPCRgnFwdp) || (region == sdMuonRPCRgnFwdn)) {
01585           ++RPCFwd;
01586           
01587           if (meMuonRpcFToF[0]) meMuonRpcFToF[0]->Fill(itHit->tof());
01588           if (meMuonRpcFToF[1]) meMuonRpcFToF[1]->Fill(itHit->tof());
01589           if (meMuonRpcFZ) 
01590             meMuonRpcFZ->Fill(bSurface.toGlobal(itHit->localPosition()).z());
01591           if (meMuonPhi)
01592             meMuonPhi->Fill(bSurface.toGlobal(itHit->localPosition()).phi());
01593           if (meMuonEta)
01594             meMuonEta->Fill(bSurface.toGlobal(itHit->localPosition()).eta());
01595           
01596         } else if (region == sdMuonRPCRgnBrl) {
01597           ++RPCBrl;
01598           
01599           if (meMuonRpcBToF[0]) meMuonRpcBToF[0]->Fill(itHit->tof());
01600           if (meMuonRpcBToF[1]) meMuonRpcBToF[1]->Fill(itHit->tof());
01601           if (meMuonRpcBR) 
01602             meMuonRpcBR->Fill(bSurface.toGlobal(itHit->
01603                                                 localPosition()).perp());
01604           if (meMuonPhi)
01605             meMuonPhi->Fill(bSurface.toGlobal(itHit->localPosition()).phi());
01606           if (meMuonEta)
01607             meMuonEta->Fill(bSurface.toGlobal(itHit->localPosition()).eta());
01608           
01609         } else {
01610           edm::LogWarning(MsgLoggerCat)
01611             << "Invalid region for RPC Muon hit" << i;
01612           continue;
01613         } // end check of region
01614       } else {
01615         edm::LogWarning(MsgLoggerCat)
01616           << "MuonRpc PSimHit " << i 
01617           << " is expected to be (det,subdet) = (" 
01618         << dMuon << "," << sdMuonRPC
01619           << "); value returned is: ("
01620           << detector << "," << subdetector << ")";
01621         continue;
01622       } // end detector type check
01623     } // end loop through RPC Hits
01624     
01625     if (verbosity > 1) {
01626       eventout += "\n          Number of RPC muon Hits collected:......... ";
01627       eventout += j;
01628       eventout += "\n                    RPC Barrel muon Hits:............ ";
01629       eventout += RPCBrl;
01630       eventout += "\n                    RPC Forward muon Hits:........... ";
01631       eventout += RPCFwd;    
01632     }  
01633     
01634     nMuonHits += j;
01635   }
01636 
01637   if (meMuon[0]) meMuon[0]->Fill((float)nMuonHits);
01638   if (meMuon[1]) meMuon[1]->Fill((float)nMuonHits); 
01639   
01640   if (verbosity > 0)
01641     edm::LogInfo(MsgLoggerCat) << eventout << "\n";
01642   
01643   return;
01644 }
01645 
01646 void GlobalHitsAnalyzer::fillECal(const edm::Event& iEvent, 
01647                                   const edm::EventSetup& iSetup)
01648 {
01649   std::string MsgLoggerCat = "GlobalHitsAnalyzer_fillECal";
01650 
01651   TString eventout;
01652   if (verbosity > 0)
01653     eventout = "\nGathering info:";  
01654   
01655   // access the calorimeter geometry
01656   edm::ESHandle<CaloGeometry> theCaloGeometry;
01657   iSetup.get<CaloGeometryRecord>().get(theCaloGeometry);
01658   if (!theCaloGeometry.isValid()) {
01659     edm::LogWarning(MsgLoggerCat)
01660       << "Unable to find CaloGeometryRecord in event!";
01661     return;
01662   }
01663   const CaloGeometry& theCalo(*theCaloGeometry);
01664     
01665   // iterator to access containers
01666   edm::PCaloHitContainer::const_iterator itHit;
01667 
01669   // get  ECal information
01671   edm::PCaloHitContainer theECalHits;
01672   // extract EB container
01673   edm::Handle<edm::PCaloHitContainer> EBContainer;
01674   iEvent.getByLabel(ECalEBSrc_,EBContainer);                         
01675   if (!EBContainer.isValid()) {
01676     LogDebug(MsgLoggerCat)
01677       << "Unable to find EcalHitsEB in event!";
01678     validEB = false;
01679   }
01680   // extract EE container
01681   edm::Handle<edm::PCaloHitContainer> EEContainer;
01682   iEvent.getByLabel(ECalEESrc_,EEContainer);
01683   if (!EEContainer.isValid()) {
01684     LogDebug(MsgLoggerCat)
01685       << "Unable to find EcalHitsEE in event!";
01686     validEE = false;
01687   }
01688   // place both containers into new container
01689   if (validEB)
01690     theECalHits.insert(theECalHits.end(),EBContainer->begin(),
01691                        EBContainer->end());
01692   if (validEE)
01693     theECalHits.insert(theECalHits.end(),EEContainer->begin(),
01694                        EEContainer->end());
01695 
01696   // cycle through new container
01697   int i = 0, j = 0;
01698   for (itHit = theECalHits.begin(); itHit != theECalHits.end(); ++itHit) {
01699 
01700     ++i;
01701 
01702     // create a DetId from the detUnitId
01703     DetId theDetUnitId(itHit->id());
01704     int detector = theDetUnitId.det();
01705     int subdetector = theDetUnitId.subdetId();
01706 
01707     // check that expected detector is returned
01708     if ((detector == dEcal) && 
01709         ((subdetector == sdEcalBrl) ||
01710          (subdetector == sdEcalFwd))) {
01711 
01712       // get the Cell geometry
01713       const CaloCellGeometry *theDet = theCalo.
01714         getSubdetectorGeometry(theDetUnitId)->getGeometry(theDetUnitId);
01715 
01716       if (!theDet) {
01717         edm::LogWarning(MsgLoggerCat)
01718           << "Unable to get CaloCellGeometry from ECalHits for Hit " << i;
01719         continue;
01720       }
01721 
01722       ++j;
01723 
01724       // get the global position of the cell
01725       const GlobalPoint& globalposition = theDet->getPosition();
01726 
01727       if (meCaloEcalE[0]) meCaloEcalE[0]->Fill(itHit->energy());
01728       if (meCaloEcalE[1]) meCaloEcalE[1]->Fill(itHit->energy());
01729       if (meCaloEcalToF[0]) meCaloEcalToF[0]->Fill(itHit->time());
01730       if (meCaloEcalToF[1]) meCaloEcalToF[1]->Fill(itHit->time());
01731       if (meCaloEcalPhi) meCaloEcalPhi->Fill(globalposition.phi());
01732       if (meCaloEcalEta) meCaloEcalEta->Fill(globalposition.eta());
01733 
01734     } else {
01735       edm::LogWarning(MsgLoggerCat)
01736         << "ECal PCaloHit " << i 
01737         << " is expected to be (det,subdet) = (" 
01738         << dEcal << "," << sdEcalBrl
01739         << " || " << sdEcalFwd << "); value returned is: ("
01740         << detector << "," << subdetector << ")";
01741       continue;
01742     } // end detector type check
01743   } // end loop through ECal Hits
01744 
01745   if (verbosity > 1) {
01746     eventout += "\n          Number of ECal Hits collected:............. ";
01747     eventout += j;
01748   }  
01749 
01750   if (meCaloEcal[0]) meCaloEcal[0]->Fill((float)j);
01751   if (meCaloEcal[1]) meCaloEcal[1]->Fill((float)j); 
01752 
01754   // Get Preshower information
01756   // extract PreShower container
01757   edm::Handle<edm::PCaloHitContainer> PreShContainer;
01758   iEvent.getByLabel(ECalESSrc_,PreShContainer);
01759   if (!PreShContainer.isValid()) {
01760     LogDebug(MsgLoggerCat)
01761       << "Unable to find EcalHitsES in event!";
01762     validPresh = false;
01763   }
01764 
01765   if (validPresh) {
01766     // cycle through container
01767     int i = 0, j = 0;
01768     for (itHit = PreShContainer->begin(); 
01769          itHit != PreShContainer->end(); ++itHit) {
01770       
01771       ++i;
01772       
01773       // create a DetId from the detUnitId
01774       DetId theDetUnitId(itHit->id());
01775       int detector = theDetUnitId.det();
01776       int subdetector = theDetUnitId.subdetId();
01777       
01778       // check that expected detector is returned
01779       if ((detector == dEcal) && 
01780           (subdetector == sdEcalPS)) {
01781         
01782         // get the Cell geometry
01783         const CaloCellGeometry *theDet = theCalo.
01784           getSubdetectorGeometry(theDetUnitId)->getGeometry(theDetUnitId);
01785         
01786         if (!theDet) {
01787           edm::LogWarning(MsgLoggerCat)
01788             << "Unable to get CaloCellGeometry from PreShContainer for Hit " 
01789             << i;
01790           continue;
01791         }
01792         
01793         ++j;
01794         
01795         // get the global position of the cell
01796         const GlobalPoint& globalposition = theDet->getPosition();
01797         
01798         if (meCaloPreShE[0]) meCaloPreShE[0]->Fill(itHit->energy());
01799         if (meCaloPreShE[1]) meCaloPreShE[1]->Fill(itHit->energy());
01800         if (meCaloPreShToF[0]) meCaloPreShToF[0]->Fill(itHit->time());
01801         if (meCaloPreShToF[1]) meCaloPreShToF[1]->Fill(itHit->time());
01802         if (meCaloPreShPhi) meCaloPreShPhi->Fill(globalposition.phi());
01803         if (meCaloPreShEta) meCaloPreShEta->Fill(globalposition.eta());
01804         
01805       } else {
01806         edm::LogWarning(MsgLoggerCat)
01807           << "PreSh PCaloHit " << i 
01808           << " is expected to be (det,subdet) = (" 
01809           << dEcal << "," << sdEcalPS
01810           << "); value returned is: ("
01811           << detector << "," << subdetector << ")";
01812         continue;
01813       } // end detector type check
01814     } // end loop through PreShower Hits
01815     
01816     if (verbosity > 1) {
01817       eventout += "\n          Number of PreSh Hits collected:............ ";
01818       eventout += j;
01819     }  
01820     
01821     if (meCaloPreSh[0]) meCaloPreSh[0]->Fill((float)j);
01822     if (meCaloPreSh[1]) meCaloPreSh[1]->Fill((float)j); 
01823   }
01824   
01825   if (verbosity > 0)
01826     edm::LogInfo(MsgLoggerCat) << eventout << "\n";
01827   
01828   return;
01829 }
01830 
01831 void GlobalHitsAnalyzer::fillHCal(const edm::Event& iEvent, 
01832                                   const edm::EventSetup& iSetup)
01833 {
01834   std::string MsgLoggerCat = "GlobalHitsAnalyzer_fillHCal";
01835 
01836   TString eventout;
01837   if (verbosity > 0)
01838     eventout = "\nGathering info:";  
01839   
01840   // access the calorimeter geometry
01841   edm::ESHandle<CaloGeometry> theCaloGeometry;
01842   iSetup.get<CaloGeometryRecord>().get(theCaloGeometry);
01843   if (!theCaloGeometry.isValid()) {
01844     edm::LogWarning(MsgLoggerCat)
01845       << "Unable to find CaloGeometryRecord in event!";
01846     return;
01847   }
01848   const CaloGeometry& theCalo(*theCaloGeometry);
01849     
01850   // iterator to access containers
01851   edm::PCaloHitContainer::const_iterator itHit;
01852 
01854   // get  HCal information
01856   // extract HCal container
01857   edm::Handle<edm::PCaloHitContainer> HCalContainer;
01858   iEvent.getByLabel(HCalSrc_,HCalContainer);
01859   if (!HCalContainer.isValid()) {
01860     LogDebug(MsgLoggerCat)
01861       << "Unable to find HCalHits in event!";
01862     validHcal = false;
01863   }
01864 
01865   if (validHcal) {
01866     // cycle through container
01867     int i = 0, j = 0;
01868     for (itHit = HCalContainer->begin(); 
01869          itHit != HCalContainer->end(); ++itHit) {
01870       
01871       ++i;
01872       
01873       // create a DetId from the detUnitId
01874       DetId theDetUnitId(itHit->id());
01875       int detector = theDetUnitId.det();
01876       int subdetector = theDetUnitId.subdetId();
01877       
01878       // check that expected detector is returned
01879       if ((detector == dHcal) && 
01880           ((subdetector == sdHcalBrl) ||
01881            (subdetector == sdHcalEC) ||
01882            (subdetector == sdHcalOut) ||
01883            (subdetector == sdHcalFwd))) {
01884         
01885         // get the Cell geometry
01886         const CaloCellGeometry *theDet = theCalo.
01887           getSubdetectorGeometry(theDetUnitId)->getGeometry(theDetUnitId);
01888         
01889         if (!theDet) {
01890           edm::LogWarning(MsgLoggerCat)
01891             << "Unable to get CaloCellGeometry from HCalContainer for Hit " 
01892             << i;
01893           continue;
01894         }
01895         
01896         ++j;
01897         
01898         // get the global position of the cell
01899         const GlobalPoint& globalposition = theDet->getPosition();
01900         
01901         if (meCaloHcalE[0]) meCaloHcalE[0]->Fill(itHit->energy());
01902         if (meCaloHcalE[1]) meCaloHcalE[1]->Fill(itHit->energy());
01903         if (meCaloHcalToF[0]) meCaloHcalToF[0]->Fill(itHit->time());
01904         if (meCaloHcalToF[1]) meCaloHcalToF[1]->Fill(itHit->time());
01905         if (meCaloHcalPhi) meCaloHcalPhi->Fill(globalposition.phi());
01906         if (meCaloHcalEta) meCaloHcalEta->Fill(globalposition.eta());
01907         
01908       } else {
01909         edm::LogWarning(MsgLoggerCat)
01910           << "HCal PCaloHit " << i 
01911           << " is expected to be (det,subdet) = (" 
01912           << dHcal << "," << sdHcalBrl
01913           << " || " << sdHcalEC << " || " << sdHcalOut << " || " << sdHcalFwd
01914           << "); value returned is: ("
01915           << detector << "," << subdetector << ")";
01916         continue;
01917       } // end detector type check
01918     } // end loop through HCal Hits
01919     
01920     if (verbosity > 1) {
01921       eventout += "\n          Number of HCal Hits collected:............. ";
01922       eventout += j;
01923     }  
01924     
01925     if (meCaloHcal[0]) meCaloHcal[0]->Fill((float)j);
01926     if (meCaloHcal[1]) meCaloHcal[1]->Fill((float)j); 
01927   }
01928 
01929   if (verbosity > 0)
01930     edm::LogInfo(MsgLoggerCat) << eventout << "\n";
01931   
01932   return;
01933 }