CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_4_1_8_patch9/src/Validation/GlobalHits/src/GlobalHitsProdHist.cc

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