CMS 3D CMS Logo

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