CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_5_3_9_patch3/src/Validation/TrackerHits/src/TrackerHitAnalyzer.cc

Go to the documentation of this file.
00001 #include "Validation/TrackerHits/interface/TrackerHitAnalyzer.h"
00002 
00003 
00004 #include "DataFormats/Common/interface/Handle.h"
00005 
00006 // tracker info
00007 #include "Geometry/Records/interface/TrackerDigiGeometryRecord.h"
00008 #include "Geometry/CommonDetUnit/interface/TrackingGeometry.h"
00009 #include "DataFormats/SiStripDetId/interface/StripSubdetector.h"
00010 #include "DataFormats/SiPixelDetId/interface/PixelSubdetector.h"
00011 #include "Geometry/CommonDetUnit/interface/GeomDetUnit.h"
00012 #include "Geometry/TrackerGeometryBuilder/interface/TrackerGeometry.h"
00013 
00014 // data in edm::event
00015 #include "SimDataFormats/ValidationFormats/interface/PValidationFormats.h"
00016 #include "SimDataFormats/GeneratorProducts/interface/HepMCProduct.h"
00017 //#include "SimDataFormats/Vertex/interface/SimVertexContainer.h"
00018 #include "SimDataFormats/Track/interface/SimTrackContainer.h"
00019 #include "SimDataFormats/TrackingHit/interface/PSimHitContainer.h"
00020 #include "SimDataFormats/EncodedEventId/interface/EncodedEventId.h"
00021 #include "SimDataFormats/Track/interface/SimTrack.h"
00022 #include "SimDataFormats/Vertex/interface/SimVertex.h"
00023 #include "DataFormats/Math/interface/LorentzVector.h"
00024 
00025 // helper files
00026 #include <CLHEP/Vector/LorentzVector.h>
00027 #include "CLHEP/Units/GlobalSystemOfUnits.h"
00028 
00029 
00030 #include <iostream>
00031 #include "DQMServices/Core/interface/DQMStore.h"
00032 using namespace edm;
00033 using namespace std;
00034 
00035 TrackerHitAnalyzer::TrackerHitAnalyzer(const edm::ParameterSet& ps) {
00036 
00037    fDBE = Service<DQMStore>().operator->();
00038    fOutputFile = ps.getUntrackedParameter<string>("outputFile", "TrackerHitHisto.root");
00039    verbose_ = ps.getUntrackedParameter<bool>("Verbosity",false);
00040    //get Labels to use to extract information
00041    PxlBrlLowSrc_ = ps.getParameter<edm::InputTag>("PxlBrlLowSrc");
00042    PxlBrlHighSrc_ = ps.getParameter<edm::InputTag>("PxlBrlHighSrc");
00043    PxlFwdLowSrc_ = ps.getParameter<edm::InputTag>("PxlFwdLowSrc");
00044    PxlFwdHighSrc_ = ps.getParameter<edm::InputTag>("PxlFwdHighSrc");
00045    
00046    SiTIBLowSrc_ = ps.getParameter<edm::InputTag>("SiTIBLowSrc");
00047    SiTIBHighSrc_ = ps.getParameter<edm::InputTag>("SiTIBHighSrc");
00048    SiTOBLowSrc_ = ps.getParameter<edm::InputTag>("SiTOBLowSrc");
00049    SiTOBHighSrc_ = ps.getParameter<edm::InputTag>("SiTOBHighSrc");
00050    SiTIDLowSrc_ = ps.getParameter<edm::InputTag>("SiTIDLowSrc");
00051    SiTIDHighSrc_ = ps.getParameter<edm::InputTag>("SiTIDHighSrc");
00052    SiTECLowSrc_ = ps.getParameter<edm::InputTag>("SiTECLowSrc");
00053    SiTECHighSrc_ = ps.getParameter<edm::InputTag>("SiTECHighSrc");
00054 
00055 
00057         
00058   Char_t  hname1[50], htitle1[80];
00059   Char_t  hname2[50], htitle2[80];
00060   Char_t  hname3[50], htitle3[80];
00061   Char_t  hname4[50], htitle4[80];
00062   Char_t  hname5[50], htitle5[80];
00063   Char_t  hname6[50], htitle6[80];
00064    
00065   if ( fDBE ) {
00066      if ( verbose_ ) {
00067        fDBE->setVerbose(1);
00068      } else {
00069        fDBE->setVerbose(0);
00070      }
00071   }
00072                                                                                                                                         
00073   if ( fDBE) {
00074     if ( verbose_ ) fDBE->showDirStructure();
00075   } 
00076 
00077   if ( fDBE != NULL ) {
00078 //   fDBE->setCurrentFolder("TrackerHitsV/TrackerHitTask");
00079      
00080      // is there any way to record CPU Info ???
00081      // if so, it can be done once - via beginJob() 
00082  int nbin = 5000;   
00083 
00084     fDBE->setCurrentFolder("TrackerHitsV/TrackerHit/");
00085     htofeta  = fDBE->book2D ("tof_eta", "Time of flight vs eta", nbin , -3.0 , 3.0,200,-100,100);
00086     htofphi  = fDBE->book2D("tof_phi", "Time of flight vs phi", nbin,-180,180,200,-100,100);
00087     htofr  = fDBE->book2D("tof_r", "Time of flight vs r", nbin , 0 , 300, 200, -100,100);
00088     htofz  = fDBE->book2D("tof_z", "Time of flight vs z", nbin , -280 , 280, 200, -100,100);
00089 
00090 
00091  const float E2NEL = 1.; 
00092  
00093  const char *Region[] = {"005","051","115","152","225","253",
00094                        "-050","-105","-151","-215","-252","-325"};  
00095   nbin = 10000;   
00096       
00097 // Energy loss histograms
00098    for(int i=0; i<12; i++) {
00099   
00100     sprintf (htitle1,"Energy loss in TIB %s", Region[i]);
00101     sprintf (htitle2,"Energy loss in TOB %s", Region[i]);
00102     sprintf (htitle3,"Energy loss in TID %s", Region[i]);
00103     sprintf (htitle4,"Energy loss in TEC %s", Region[i]);
00104     sprintf (htitle5,"Energy loss in BPIX %s", Region[i]);
00105     sprintf (htitle6,"Energy loss in FPIX %s", Region[i]);
00106     
00107     sprintf (hname1,"Eloss_TIB_%i",i+1);
00108     sprintf (hname2,"Eloss_TOB_%i",i+1);
00109     sprintf (hname3,"Eloss_TID_%i",i+1);
00110     sprintf (hname4,"Eloss_TEC_%i",i+1);
00111     sprintf (hname5,"Eloss_BPIX_%i",i+1);
00112     sprintf (hname6,"Eloss_FPIX_%i",i+1);
00113    
00114     fDBE->setCurrentFolder("TrackerHitsV/TrackerHit/TIBHit");
00115     h1e[i]  = fDBE->book1D (hname1, htitle1, nbin , 0.0 , 0.001*E2NEL);
00116     fDBE->setCurrentFolder("TrackerHitsV/TrackerHit/TOBHit");
00117     h2e[i]  = fDBE->book1D (hname2, htitle2, nbin , 0.0 , 0.001*E2NEL);
00118     fDBE->setCurrentFolder("TrackerHitsV/TrackerHit/TIDHit");
00119     h3e[i]  = fDBE->book1D (hname3, htitle3, nbin , 0.0 , 0.001*E2NEL);
00120     fDBE->setCurrentFolder("TrackerHitsV/TrackerHit/TECHit");
00121     h4e[i]  = fDBE->book1D (hname4, htitle4, nbin , 0.0 , 0.001*E2NEL);
00122     fDBE->setCurrentFolder("TrackerHitsV/TrackerHit/BPIXHit");
00123     h5e[i]  = fDBE->book1D (hname5, htitle5, nbin , 0.0 , 0.001*E2NEL);
00124     fDBE->setCurrentFolder("TrackerHitsV/TrackerHit/FPIXHit");
00125     h6e[i]  = fDBE->book1D (hname6, htitle6, nbin , 0.0 , 0.001*E2NEL);
00126    
00127    }
00128 
00129 // limits
00130 const float high[] = {0.03, 0.03, 0.02, 0.03, 0.03, 0.03};
00131 const float low[] = {-0.03, -0.03, -0.02, -0.03, -0.03, -0.03};
00132    
00133    for(int i=0; i<12; i++) {
00134   
00135     sprintf (htitle1,"Entryx-Exitx in TIB %s", Region[i]);
00136     sprintf (htitle2,"Entryx-Exitx in TOB %s", Region[i]);
00137     sprintf (htitle3,"Entryx-Exitx in TID %s", Region[i]);
00138     sprintf (htitle4,"Entryx-Exitx in TEC %s", Region[i]);
00139     sprintf (htitle5,"Entryx-Exitx in BPIX %s", Region[i]);
00140     sprintf (htitle6,"Entryx-Exitx in FPIX %s", Region[i]);
00141     
00142     sprintf (hname1,"Entryx-Exitx_TIB_%i",i+1);
00143     sprintf (hname2,"Entryx-Exitx_TOB_%i",i+1);
00144     sprintf (hname3,"Entryx-Exitx_TID_%i",i+1);
00145     sprintf (hname4,"Entryx-Exitx_TEC_%i",i+1);
00146     sprintf (hname5,"Entryx-Exitx_BPIX_%i",i+1);
00147     sprintf (hname6,"Entryx-Exitx_FPIX_%i",i+1);
00148    
00149     fDBE->setCurrentFolder("TrackerHitsV/TrackerHit/TIBHit");
00150     h1ex[i]  = fDBE->book1D (hname1, htitle1, nbin , low[0] , high[0]);
00151     fDBE->setCurrentFolder("TrackerHitsV/TrackerHit/TOBHit");
00152     h2ex[i]  = fDBE->book1D (hname2, htitle2, nbin , low[1] , high[1]);
00153     fDBE->setCurrentFolder("TrackerHitsV/TrackerHit/TIDHit");
00154     h3ex[i]  = fDBE->book1D (hname3, htitle3, nbin , low[2] , high[2]);
00155     fDBE->setCurrentFolder("TrackerHitsV/TrackerHit/TECHit");
00156     h4ex[i]  = fDBE->book1D (hname4, htitle4, nbin , low[3] , high[3]);
00157     fDBE->setCurrentFolder("TrackerHitsV/TrackerHit/BPIXHit");
00158     h5ex[i]  = fDBE->book1D (hname5, htitle5, nbin , low[4] , high[4]);
00159     fDBE->setCurrentFolder("TrackerHitsV/TrackerHit/FPIXHit");
00160     h6ex[i]  = fDBE->book1D (hname6, htitle6, nbin , low[5] , high[5]);
00161    
00162    }
00163 
00164 const float high0[] = {0.05, 0.06, 0.03, 0.03, 0.03, 0.03};
00165 const float low0[] = {-0.05, -0.06, -0.03, -0.03, -0.03, -0.03};
00166 
00167    for(int i=0; i<12; i++) {
00168   
00169     sprintf (htitle1,"Entryy-Exity in TIB %s", Region[i]);
00170     sprintf (htitle2,"Entryy-Exity in TOB %s", Region[i]);
00171     sprintf (htitle3,"Entryy-Exity in TID %s", Region[i]);
00172     sprintf (htitle4,"Entryy-Exity in TEC %s", Region[i]);
00173     sprintf (htitle5,"Entryy-Exity in BPIX %s", Region[i]);
00174     sprintf (htitle6,"Entryy-Exity in FPIX %s", Region[i]);
00175     
00176     sprintf (hname1,"Entryy-Exity_TIB_%i",i+1);
00177     sprintf (hname2,"Entryy-Exity_TOB_%i",i+1);
00178     sprintf (hname3,"Entryy-Exity_TID_%i",i+1);
00179     sprintf (hname4,"Entryy-Exity_TEC_%i",i+1);
00180     sprintf (hname5,"Entryy-Exity_BPIX_%i",i+1);
00181     sprintf (hname6,"Entryy-Exity_FPIX_%i",i+1);
00182    
00183     fDBE->setCurrentFolder("TrackerHitsV/TrackerHit/TIBHit");
00184     h1ey[i]  = fDBE->book1D (hname1, htitle1, nbin , low0[0] , high0[0]);
00185     fDBE->setCurrentFolder("TrackerHitsV/TrackerHit/TOBHit");
00186     h2ey[i]  = fDBE->book1D (hname2, htitle2, nbin , low0[1] , high0[1]);
00187     fDBE->setCurrentFolder("TrackerHitsV/TrackerHit/TIDHit");
00188     h3ey[i]  = fDBE->book1D (hname3, htitle3, nbin , low0[2] , high0[2]);
00189     fDBE->setCurrentFolder("TrackerHitsV/TrackerHit/TECHit");
00190     h4ey[i]  = fDBE->book1D (hname4, htitle4, nbin , low0[3] , high0[3]);
00191     fDBE->setCurrentFolder("TrackerHitsV/TrackerHit/BPIXHit");
00192     h5ey[i]  = fDBE->book1D (hname5, htitle5, nbin , low0[4] , high0[4]);
00193     fDBE->setCurrentFolder("TrackerHitsV/TrackerHit/FPIXHit");
00194     h6ey[i]  = fDBE->book1D (hname6, htitle6, nbin , low0[5] , high0[5]);
00195    
00196    }
00197 
00198 const float high1[] = {0.05, 0.06, 0.05, 0.06, 0.05, 0.05};
00199 const float low1[]  = {0.,0.,0.,0.,0.,0.};
00200 
00201   for(int i=0; i<12; i++) {
00202   
00203     sprintf (htitle1,"abs(Entryz-Exitz) in TIB %s", Region[i]);
00204     sprintf (htitle2,"abs(Entryz-Exitz) in TOB %s", Region[i]);
00205     sprintf (htitle3,"abs(Entryz-Exitz) in TID %s", Region[i]);
00206     sprintf (htitle4,"abs(Entryz-Exitz) in TEC %s", Region[i]);
00207     sprintf (htitle5,"abs(Entryz-Exitz) in BPIX %s", Region[i]);
00208     sprintf (htitle6,"abs(Entryz-Exitz) in FPIX %s", Region[i]);
00209     
00210     sprintf (hname1,"Entryz-Exitz_TIB_%i",i+1);
00211     sprintf (hname2,"Entryz-Exitz_TOB_%i",i+1);
00212     sprintf (hname3,"Entryz-Exitz_TID_%i",i+1);
00213     sprintf (hname4,"Entryz-Exitz_TEC_%i",i+1);
00214     sprintf (hname5,"Entryz-Exitz_BPIX_%i",i+1);
00215     sprintf (hname6,"Entryz-Exitz_FPIX_%i",i+1);
00216    
00217     fDBE->setCurrentFolder("TrackerHitsV/TrackerHit/TIBHit");
00218     h1ez[i]  = fDBE->book1D (hname1, htitle1, nbin , low1[0] , high1[0]);
00219     fDBE->setCurrentFolder("TrackerHitsV/TrackerHit/TOBHit");
00220     h2ez[i]  = fDBE->book1D (hname2, htitle2, nbin , low1[1] , high1[1]);
00221     fDBE->setCurrentFolder("TrackerHitsV/TrackerHit/TIDHit");
00222     h3ez[i]  = fDBE->book1D (hname3, htitle3, nbin , low1[2] , high1[2]);
00223     fDBE->setCurrentFolder("TrackerHitsV/TrackerHit/TECHit");
00224     h4ez[i]  = fDBE->book1D (hname4, htitle4, nbin , low1[3] , high1[3]);
00225     fDBE->setCurrentFolder("TrackerHitsV/TrackerHit/BPIXHit");
00226     h5ez[i]  = fDBE->book1D (hname5, htitle5, nbin , low1[4] , high1[4]);
00227     fDBE->setCurrentFolder("TrackerHitsV/TrackerHit/FPIXHit");
00228     h6ez[i]  = fDBE->book1D (hname6, htitle6, nbin , low1[5] , high1[5]);
00229    
00230    }
00231 
00232 
00233 const float high2[] = {3.2, 5.0, 5.5, 6.2, 0.85, 0.5};   
00234 const float low2[] = {-3.2, -5.0, -5.5, -6.2, -0.85, -0.5};   
00235 
00236    for(int i=0; i<12; i++) {
00237   
00238     sprintf (htitle1,"Localx in TIB %s", Region[i]);
00239     sprintf (htitle2,"Localx in TOB %s", Region[i]);
00240     sprintf (htitle3,"Localx in TID %s", Region[i]);
00241     sprintf (htitle4,"Localx in TEC %s", Region[i]);
00242     sprintf (htitle5,"Localx in BPIX %s", Region[i]);
00243     sprintf (htitle6,"Localx in FPIX %s", Region[i]);
00244     
00245     sprintf (hname1,"Localx_TIB_%i",i+1);
00246     sprintf (hname2,"Localx_TOB_%i",i+1);
00247     sprintf (hname3,"Localx_TID_%i",i+1);
00248     sprintf (hname4,"Localx_TEC_%i",i+1);
00249     sprintf (hname5,"Localx_BPIX_%i",i+1);
00250     sprintf (hname6,"Localx_FPIX_%i",i+1);
00251    
00252     fDBE->setCurrentFolder("TrackerHitsV/TrackerHit/TIBHit");
00253     h1lx[i]  = fDBE->book1D (hname1, htitle1, nbin , low2[0] , high2[0]);
00254     fDBE->setCurrentFolder("TrackerHitsV/TrackerHit/TOBHit");
00255     h2lx[i]  = fDBE->book1D (hname2, htitle2, nbin , low2[1] , high2[1]);
00256     fDBE->setCurrentFolder("TrackerHitsV/TrackerHit/TIDHit");
00257     h3lx[i]  = fDBE->book1D (hname3, htitle3, nbin , low2[2] , high2[2]);
00258     fDBE->setCurrentFolder("TrackerHitsV/TrackerHit/TECHit");
00259     h4lx[i]  = fDBE->book1D (hname4, htitle4, nbin , low2[3] , high2[3]);
00260     fDBE->setCurrentFolder("TrackerHitsV/TrackerHit/BPIXHit");
00261     h5lx[i]  = fDBE->book1D (hname5, htitle5, nbin , low2[4] , high2[4]);
00262     fDBE->setCurrentFolder("TrackerHitsV/TrackerHit/FPIXHit");
00263     h6lx[i]  = fDBE->book1D (hname6, htitle6, nbin , low2[5] , high2[5]);
00264    
00265    }
00266 
00267 
00268 const float high3[] = {6.0, 10., 5.6, 10.5, 3.4, 0.52};
00269 const float low3[] = {-6.0, -10., -5.6, -10.5, -3.4, -0.52};
00270 
00271    for(int i=0; i<12; i++) {
00272   
00273     sprintf (htitle1,"Localy in TIB %s", Region[i]);
00274     sprintf (htitle2,"Localy in TOB %s", Region[i]);
00275     sprintf (htitle3,"Localy in TID %s", Region[i]);
00276     sprintf (htitle4,"Localy in TEC %s", Region[i]);
00277     sprintf (htitle5,"Localy in BPIX %s", Region[i]);
00278     sprintf (htitle6,"Localy in FPIX %s", Region[i]);
00279     
00280     sprintf (hname1,"Localy_TIB_%i",i+1);
00281     sprintf (hname2,"Localy_TOB_%i",i+1);
00282     sprintf (hname3,"Localy_TID_%i",i+1);
00283     sprintf (hname4,"Localy_TEC_%i",i+1);
00284     sprintf (hname5,"Localy_BPIX_%i",i+1);
00285     sprintf (hname6,"Localy_FPIX_%i",i+1);
00286    
00287     fDBE->setCurrentFolder("TrackerHitsV/TrackerHit/TIBHit");
00288     h1ly[i]  = fDBE->book1D (hname1, htitle1, nbin , low3[0] , high3[0]);
00289     fDBE->setCurrentFolder("TrackerHitsV/TrackerHit/TOBHit");
00290     h2ly[i]  = fDBE->book1D (hname2, htitle2, nbin , low3[1] , high3[1]);
00291     fDBE->setCurrentFolder("TrackerHitsV/TrackerHit/TIDHit");
00292     h3ly[i]  = fDBE->book1D (hname3, htitle3, nbin , low3[2] , high3[2]);
00293     fDBE->setCurrentFolder("TrackerHitsV/TrackerHit/TECHit");
00294     h4ly[i]  = fDBE->book1D (hname4, htitle4, nbin , low3[3] , high3[3]);
00295     fDBE->setCurrentFolder("TrackerHitsV/TrackerHit/BPIXHit");
00296     h5ly[i]  = fDBE->book1D (hname5, htitle5, nbin , low3[4] , high3[4]);
00297     fDBE->setCurrentFolder("TrackerHitsV/TrackerHit/FPIXHit");
00298     h6ly[i]  = fDBE->book1D (hname6, htitle6, nbin , low3[5] , high3[5]);
00299    
00300    }
00301    
00302    
00303   }
00304 }
00305 
00306 TrackerHitAnalyzer::~TrackerHitAnalyzer()
00307 {
00308    // don't try to delete any pointers - they're handled by DQM machinery
00309 }
00310 
00311 
00312 
00313 void TrackerHitAnalyzer::endJob() 
00314 {
00315   //before check that histos are there....
00316 
00317   // check if ME still there (and not killed by MEtoEDM for memory saving)
00318   if( fDBE )
00319     {
00320       // check existence of first histo in the list
00321       if (! fDBE->get("TrackerHitsV/TrackerHit/tof_eta")) return;
00322     }
00323   else
00324     return;
00325 
00326   fDBE->setCurrentFolder("TrackerHitsV/TrackerHit/");
00327   htofeta_profile  = fDBE->bookProfile ("tof_eta_profile",htofeta->getTH2F()->ProfileX());
00328   htofphi_profile  = fDBE->bookProfile("tof_phi_profile", htofphi->getTH2F()->ProfileX());
00329   htofr_profile  = fDBE->bookProfile("tof_r_profile",htofr->getTH2F()->ProfileX());
00330   htofz_profile  = fDBE->bookProfile("tof_z_profile", htofz->getTH2F()->ProfileX());
00331 
00332 
00333   if ( fOutputFile.size() != 0 && fDBE ) fDBE->save(fOutputFile);
00334 
00335   return ;
00336 
00337 }
00338 
00339 
00340 void TrackerHitAnalyzer::analyze(const edm::Event& e, const edm::EventSetup& c)
00341 {
00342 
00343    LogInfo("EventInfo") << " Run = " << e.id().run() << " Event = " << e.id().event();
00344    
00345   // iterator to access containers
00346   edm::PSimHitContainer::const_iterator itHit;
00348   // get Pixel Barrel information
00350   // extract low container
00351   edm::Handle<edm::PSimHitContainer> PxlBrlLowContainer;
00352   e.getByLabel(PxlBrlLowSrc_,PxlBrlLowContainer);
00353   if (!PxlBrlLowContainer.isValid()) {
00354     edm::LogError("TrackerHitAnalyzer::analyze")
00355       << "Unable to find TrackerHitsPixelBarrelLowTof in event!";
00356     return;
00357   }  
00358   // extract high container
00359   edm::Handle<edm::PSimHitContainer> PxlBrlHighContainer;
00360   e.getByLabel(PxlBrlHighSrc_,PxlBrlHighContainer);
00361   if (!PxlBrlHighContainer.isValid()) {
00362     edm::LogError("TrackerHitAnalyzer::analyze")
00363       << "Unable to find TrackerHitsPixelBarrelHighTof in event!";
00364     return;
00365   }
00367   // get Pixel Forward information
00369   // extract low container
00370   edm::Handle<edm::PSimHitContainer> PxlFwdLowContainer;
00371   e.getByLabel(PxlFwdLowSrc_,PxlFwdLowContainer);
00372   if (!PxlFwdLowContainer.isValid()) {
00373     edm::LogError("TrackerHitAnalyzer::analyze")
00374       << "Unable to find TrackerHitsPixelEndcapLowTof in event!";
00375     return;
00376   }
00377   // extract high container
00378   edm::Handle<edm::PSimHitContainer> PxlFwdHighContainer;
00379   e.getByLabel(PxlFwdHighSrc_,PxlFwdHighContainer);
00380   if (!PxlFwdHighContainer.isValid()) {
00381     edm::LogError("TrackerHitAnalyzer::analyze")
00382       << "Unable to find TrackerHitsPixelEndcapHighTof in event!";
00383     return;
00384   }
00385   
00387   // get Silicon TIB information
00389   // extract TIB low container
00390   edm::Handle<edm::PSimHitContainer> SiTIBLowContainer;
00391 //  iEvent.getByLabel("g4SimHits","TrackerHitsTIBLowTof",SiTIBLowContainer);
00392   e.getByLabel(SiTIBLowSrc_,SiTIBLowContainer);
00393   if (!SiTIBLowContainer.isValid()) {
00394     edm::LogError("TrackerHitProducer::analyze")
00395       << "Unable to find TrackerHitsTIBLowTof in event!";
00396     return;
00397   }
00399   // extract TIB low container
00400   edm::Handle<edm::PSimHitContainer> SiTIBHighContainer;
00401 //  iEvent.getByLabel("g4SimHits","TrackerHitsTIBHighTof",SiTIBHighContainer);
00402   e.getByLabel(SiTIBHighSrc_,SiTIBHighContainer);
00403   if (!SiTIBHighContainer.isValid()) {
00404     edm::LogError("TrackerHitProducer::analyze")
00405       << "Unable to find TrackerHitsTIBHighTof in event!";
00406     return;
00407   }
00409   // get Silicon TOB information
00411   // extract TOB low container
00412   edm::Handle<edm::PSimHitContainer> SiTOBLowContainer;
00413 //  iEvent.getByLabel("g4SimHits","TrackerHitsTOBLowTof",SiTOBLowContainer);
00414   e.getByLabel(SiTOBLowSrc_,SiTOBLowContainer);
00415   if (!SiTOBLowContainer.isValid()) {
00416     edm::LogError("TrackerHitProducer::analyze")
00417       << "Unable to find TrackerHitsTOBLowTof in event!";
00418     return;
00419   }
00421   // extract TOB low container
00422   edm::Handle<edm::PSimHitContainer> SiTOBHighContainer;
00423 //  iEvent.getByLabel("g4SimHits","TrackerHitsTOBHighTof",SiTOBHighContainer);
00424   e.getByLabel(SiTOBHighSrc_,SiTOBHighContainer);
00425   if (!SiTOBHighContainer.isValid()) {
00426     edm::LogError("TrackerHitProducer::analyze")
00427       << "Unable to find TrackerHitsTOBHighTof in event!";
00428     return;
00429   }
00430   
00432   // get Silicon TID information
00434   // extract TID low container
00435   edm::Handle<edm::PSimHitContainer> SiTIDLowContainer;
00436 //  iEvent.getByLabel("g4SimHits","TrackerHitsTIDLowTof",SiTIDLowContainer);
00437   e.getByLabel(SiTIDLowSrc_,SiTIDLowContainer);
00438   if (!SiTIDLowContainer.isValid()) {
00439     edm::LogError("TrackerHitProducer::analyze")
00440       << "Unable to find TrackerHitsTIDLowTof in event!";
00441     return;
00442   }
00444   // extract TID low container
00445   edm::Handle<edm::PSimHitContainer> SiTIDHighContainer;
00446 //  iEvent.getByLabel("g4SimHits","TrackerHitsTIDHighTof",SiTIDHighContainer);
00447   e.getByLabel(SiTIDHighSrc_,SiTIDHighContainer);
00448   if (!SiTIDHighContainer.isValid()) {
00449     edm::LogError("TrackerHitProducer::analyze")
00450       << "Unable to find TrackerHitsTIDHighTof in event!";
00451     return;
00452   }
00454   // get Silicon TEC information
00456   // extract TEC low container
00457   edm::Handle<edm::PSimHitContainer> SiTECLowContainer;
00458 //  iEvent.getByLabel("g4SimHits","TrackerHitsTECLowTof",SiTECLowContainer);
00459   e.getByLabel(SiTECLowSrc_,SiTECLowContainer);
00460   if (!SiTECLowContainer.isValid()) {
00461     edm::LogError("TrackerHitProducer::analyze")
00462       << "Unable to find TrackerHitsTECLowTof in event!";
00463     return;
00464   }
00466   // extract TEC low container
00467   edm ::Handle<edm::PSimHitContainer> SiTECHighContainer;
00468 //  iEvent.getByLabel("g4SimHits","TrackerHitsTECHighTof",SiTECHighContainer);
00469   e.getByLabel(SiTECHighSrc_,SiTECHighContainer);
00470   if (!SiTECHighContainer.isValid()) {
00471     edm::LogError("TrackerHitProducer::analyze")
00472       << "Unable to find TrackerHitsTECHighTof in event!";
00473     return;
00474   }
00475   
00477   // get G4Track information
00479   
00480   edm::Handle<edm::SimTrackContainer> G4TrkContainer;
00481   e.getByType(G4TrkContainer);
00482   if (!G4TrkContainer.isValid()) {
00483     edm::LogError("TrackerHitAnalyzer::analyze")
00484       << "Unable to find SimTrack in event!";
00485     return;
00486   }
00487 
00488   // Get geometry information
00489 
00490   edm::ESHandle<TrackerGeometry> tracker;
00491   c.get<TrackerDigiGeometryRecord>().get( tracker );
00492 
00493 
00494   
00495   int ir = -100;
00496   edm::SimTrackContainer::const_iterator itTrk;
00497   for (itTrk = G4TrkContainer->begin(); itTrk != G4TrkContainer->end(); 
00498        ++itTrk) {
00499 
00500 //    cout << "itTrk = "<< itTrk << endl;
00501     double eta =0, p =0;
00502     const CLHEP::HepLorentzVector& G4Trk = CLHEP::HepLorentzVector(itTrk->momentum().x(),
00503                                                      itTrk->momentum().y(),
00504                                                      itTrk->momentum().z(),
00505                                                      itTrk->momentum().e());  
00506     p =sqrt(G4Trk[0]*G4Trk[0]+G4Trk[1]*G4Trk[1]+G4Trk[2]*G4Trk[2]);
00507       if ( p == 0) 
00508           edm::LogError("TrackerHitAnalyzer::analyze") 
00509           << "TrackerTest::INFO: Primary has p = 0 ";
00510       else {
00511           double costheta  = G4Trk[2]/p;
00512           double theta = acos(TMath::Min(TMath::Max(costheta, -1.),1.));
00513           eta = -log(tan(theta/2));          
00514           
00515           if (eta>0.0 && eta<=0.5) ir = 0;
00516           if (eta>0.5 && eta<=1.0) ir = 1;
00517           if (eta>1.0 && eta<=1.5) ir = 2;
00518           if (eta>1.5 && eta<=2.0) ir = 3;
00519           if (eta>2.0 && eta<=2.5) ir = 4;
00520           if (eta>2.5) ir = 5;
00521           
00522           if (eta>-0.5 && eta<= 0.0) ir = 6;
00523           if (eta>-1.0 && eta<=-0.5) ir = 7;
00524           if (eta>-1.5 && eta<=-1.0) ir = 8;
00525           if (eta>-2.0 && eta<=-1.5) ir = 9;
00526           if (eta>-2.5 && eta<=-2.0) ir = 10;
00527           if (eta<=-2.5) ir = 11;
00528 //          LogInfo("EventInfo") << " eta = " << eta << " ir = " << ir;
00529 //        cout << " " <<endl;
00530 //          cout << "eta " << eta << " ir = " << ir << endl;                  
00531 //        cout << " " <<endl;
00532       }
00533   }       
00535   // get Pixel information
00537   for (itHit = PxlBrlLowContainer->begin(); itHit != PxlBrlLowContainer->end(); ++itHit) {
00538     DetId detid=DetId(itHit->detUnitId());
00539     const GeomDetUnit * det=(const GeomDetUnit*)tracker->idToDetUnit( detid );
00540     GlobalPoint gpos=det->toGlobal(itHit->localPosition());
00541     htofeta->Fill(gpos.eta(), itHit->timeOfFlight());
00542     htofphi->Fill(gpos.phi().degrees(), itHit->timeOfFlight());
00543     htofr->Fill(gpos.mag(), itHit->timeOfFlight());
00544     htofz->Fill(gpos.z(), itHit->timeOfFlight());
00545 
00546     h5e[ir]->Fill(itHit->energyLoss());
00547     h5ex[ir]->Fill(itHit->entryPoint().x()-itHit->exitPoint().x());
00548     h5ey[ir]->Fill(itHit->entryPoint().y()-itHit->exitPoint().y());
00549     h5ez[ir]->Fill(std::fabs(itHit->entryPoint().z()-itHit->exitPoint().z()));
00550     h5lx[ir]->Fill(itHit->localPosition().x());
00551     h5ly[ir]->Fill(itHit->localPosition().y());
00552   }
00553   for (itHit = PxlBrlHighContainer->begin(); itHit != PxlBrlHighContainer->end(); ++itHit) {
00554     DetId detid=DetId(itHit->detUnitId());
00555     const GeomDetUnit * det=(const GeomDetUnit*)tracker->idToDetUnit( detid );
00556     GlobalPoint gpos=det->toGlobal(itHit->localPosition());
00557     htofeta->Fill(gpos.eta(), itHit->timeOfFlight());
00558     htofphi->Fill(gpos.phi().degrees(), itHit->timeOfFlight());
00559     htofr->Fill(gpos.mag(), itHit->timeOfFlight());
00560     htofz->Fill(gpos.z(), itHit->timeOfFlight());
00561 
00562 
00563    h5e[ir]->Fill(itHit->energyLoss());
00564    h5ex[ir]->Fill(itHit->entryPoint().x()-itHit->exitPoint().x());
00565    h5ey[ir]->Fill(itHit->entryPoint().y()-itHit->exitPoint().y());
00566    h5ez[ir]->Fill(std::fabs(itHit->entryPoint().z()-itHit->exitPoint().z()));
00567    h5lx[ir]->Fill(itHit->localPosition().x());
00568    h5ly[ir]->Fill(itHit->localPosition().y());
00569   }
00570   for (itHit = PxlFwdLowContainer->begin(); itHit != PxlFwdLowContainer->end(); ++itHit) {
00571     DetId detid=DetId(itHit->detUnitId());
00572     const GeomDetUnit * det=(const GeomDetUnit*)tracker->idToDetUnit( detid );
00573     GlobalPoint gpos=det->toGlobal(itHit->localPosition());
00574     htofeta->Fill(gpos.eta(), itHit->timeOfFlight());
00575     htofphi->Fill(gpos.phi().degrees(), itHit->timeOfFlight());
00576     htofr->Fill(gpos.mag(), itHit->timeOfFlight());
00577     htofz->Fill(gpos.z(), itHit->timeOfFlight());
00578 
00579 
00580    h6e[ir]->Fill(itHit->energyLoss());
00581    h6ex[ir]->Fill(itHit->entryPoint().x()-itHit->exitPoint().x());
00582    h6ey[ir]->Fill(itHit->entryPoint().y()-itHit->exitPoint().y());
00583    h6ez[ir]->Fill(std::fabs(itHit->entryPoint().z()-itHit->exitPoint().z()));
00584    h6lx[ir]->Fill(itHit->localPosition().x());
00585    h6ly[ir]->Fill(itHit->localPosition().y());
00586   }  
00587   for (itHit = PxlFwdHighContainer->begin(); itHit != PxlFwdHighContainer->end(); ++itHit) {
00588     DetId detid=DetId(itHit->detUnitId());
00589     const GeomDetUnit * det=(const GeomDetUnit*)tracker->idToDetUnit( detid );
00590     GlobalPoint gpos=det->toGlobal(itHit->localPosition());
00591     htofeta->Fill(gpos.eta(), itHit->timeOfFlight());
00592     htofphi->Fill(gpos.phi().degrees(), itHit->timeOfFlight());
00593     htofr->Fill(gpos.mag(), itHit->timeOfFlight());
00594     htofz->Fill(gpos.z(), itHit->timeOfFlight());
00595 
00596 
00597    h6e[ir]->Fill(itHit->energyLoss());
00598    h6ex[ir]->Fill(itHit->entryPoint().x()-itHit->exitPoint().x());
00599    h6ey[ir]->Fill(itHit->entryPoint().y()-itHit->exitPoint().y());
00600    h6ez[ir]->Fill(std::fabs(itHit->entryPoint().z()-itHit->exitPoint().z()));
00601    h6lx[ir]->Fill(itHit->localPosition().x());
00602    h6ly[ir]->Fill(itHit->localPosition().y());
00603   }
00605   // get TIB information
00607   for (itHit = SiTIBLowContainer->begin(); itHit != SiTIBLowContainer->end(); ++itHit) {
00608     DetId detid=DetId(itHit->detUnitId());
00609     const GeomDetUnit * det=(const GeomDetUnit*)tracker->idToDetUnit( detid );
00610     GlobalPoint gpos=det->toGlobal(itHit->localPosition());
00611     htofeta->Fill(gpos.eta(), itHit->timeOfFlight());
00612     htofphi->Fill(gpos.phi().degrees(), itHit->timeOfFlight());
00613     htofr->Fill(gpos.mag(), itHit->timeOfFlight());
00614     htofz->Fill(gpos.z(), itHit->timeOfFlight());
00615 
00616 
00617    h1e[ir]->Fill(itHit->energyLoss());
00618    h1ex[ir]->Fill(itHit->entryPoint().x()-itHit->exitPoint().x());
00619    h1ey[ir]->Fill(itHit->entryPoint().y()-itHit->exitPoint().y());
00620    h1ez[ir]->Fill(std::fabs(itHit->entryPoint().z()-itHit->exitPoint().z()));
00621    h1lx[ir]->Fill(itHit->localPosition().x());
00622    h1ly[ir]->Fill(itHit->localPosition().y());
00623   }
00624   for (itHit = SiTIBHighContainer->begin(); itHit != SiTIBHighContainer->end(); ++itHit) {
00625     DetId detid=DetId(itHit->detUnitId());
00626     const GeomDetUnit * det=(const GeomDetUnit*)tracker->idToDetUnit( detid );
00627     GlobalPoint gpos=det->toGlobal(itHit->localPosition());
00628     htofeta->Fill(gpos.eta(), itHit->timeOfFlight());
00629     htofphi->Fill(gpos.phi().degrees(), itHit->timeOfFlight());
00630     htofr->Fill(gpos.mag(), itHit->timeOfFlight());
00631     htofz->Fill(gpos.z(), itHit->timeOfFlight());
00632 
00633 
00634    h1e[ir]->Fill(itHit->energyLoss());
00635    h1ex[ir]->Fill(itHit->entryPoint().x()-itHit->exitPoint().x());
00636    h1ey[ir]->Fill(itHit->entryPoint().y()-itHit->exitPoint().y());
00637    h1ez[ir]->Fill(std::fabs(itHit->entryPoint().z()-itHit->exitPoint().z()));
00638    h1lx[ir]->Fill(itHit->localPosition().x());
00639    h1ly[ir]->Fill(itHit->localPosition().y());
00640   }
00642   // get TOB information
00644   for (itHit = SiTOBLowContainer->begin(); itHit != SiTOBLowContainer->end(); ++itHit) {
00645     DetId detid=DetId(itHit->detUnitId());
00646     const GeomDetUnit * det=(const GeomDetUnit*)tracker->idToDetUnit( detid );
00647     GlobalPoint gpos=det->toGlobal(itHit->localPosition());
00648     htofeta->Fill(gpos.eta(), itHit->timeOfFlight());
00649     htofphi->Fill(gpos.phi().degrees(), itHit->timeOfFlight());
00650     htofr->Fill(gpos.mag(), itHit->timeOfFlight());
00651     htofz->Fill(gpos.z(), itHit->timeOfFlight());
00652 
00653 
00654    h2e[ir]->Fill(itHit->energyLoss());
00655    h2ex[ir]->Fill(itHit->entryPoint().x()-itHit->exitPoint().x());
00656    h2ey[ir]->Fill(itHit->entryPoint().y()-itHit->exitPoint().y());
00657    h2ez[ir]->Fill(std::fabs(itHit->entryPoint().z()-itHit->exitPoint().z()));
00658    h2lx[ir]->Fill(itHit->localPosition().x());
00659    h2ly[ir]->Fill(itHit->localPosition().y());
00660   }  
00661   for (itHit = SiTOBHighContainer->begin(); itHit != SiTOBHighContainer->end(); ++itHit) {
00662     DetId detid=DetId(itHit->detUnitId());
00663     const GeomDetUnit * det=(const GeomDetUnit*)tracker->idToDetUnit( detid );
00664     GlobalPoint gpos=det->toGlobal(itHit->localPosition());
00665     htofeta->Fill(gpos.eta(), itHit->timeOfFlight());
00666     htofphi->Fill(gpos.phi().degrees(), itHit->timeOfFlight());
00667     htofr->Fill(gpos.mag(), itHit->timeOfFlight());
00668     htofz->Fill(gpos.z(), itHit->timeOfFlight());
00669 
00670    h2e[ir]->Fill(itHit->energyLoss());
00671    h2ex[ir]->Fill(itHit->entryPoint().x()-itHit->exitPoint().x());
00672    h2ey[ir]->Fill(itHit->entryPoint().y()-itHit->exitPoint().y());
00673    h2ez[ir]->Fill(std::fabs(itHit->entryPoint().z()-itHit->exitPoint().z()));
00674    h2lx[ir]->Fill(itHit->localPosition().x());
00675    h2ly[ir]->Fill(itHit->localPosition().y());
00676   }
00678   // get TID information
00680   for (itHit = SiTIDLowContainer->begin(); itHit != SiTIDLowContainer->end(); ++itHit) {
00681     DetId detid=DetId(itHit->detUnitId());
00682     const GeomDetUnit * det=(const GeomDetUnit*)tracker->idToDetUnit( detid );
00683     GlobalPoint gpos=det->toGlobal(itHit->localPosition());
00684     htofeta->Fill(gpos.eta(), itHit->timeOfFlight());
00685     htofphi->Fill(gpos.phi().degrees(), itHit->timeOfFlight());
00686     htofr->Fill(gpos.mag(), itHit->timeOfFlight());
00687     htofz->Fill(gpos.z(), itHit->timeOfFlight());
00688 
00689    h3e[ir]->Fill(itHit->energyLoss());
00690    h3ex[ir]->Fill(itHit->entryPoint().x()-itHit->exitPoint().x());
00691    h3ey[ir]->Fill(itHit->entryPoint().y()-itHit->exitPoint().y());
00692    h3ez[ir]->Fill(std::fabs(itHit->entryPoint().z()-itHit->exitPoint().z()));
00693    h3lx[ir]->Fill(itHit->localPosition().x());
00694    h3ly[ir]->Fill(itHit->localPosition().y());
00695   }  
00696   for (itHit = SiTIDHighContainer->begin(); itHit != SiTIDHighContainer->end(); ++itHit) {
00697     DetId detid=DetId(itHit->detUnitId());
00698     const GeomDetUnit * det=(const GeomDetUnit*)tracker->idToDetUnit( detid );
00699     GlobalPoint gpos=det->toGlobal(itHit->localPosition());
00700     htofeta->Fill(gpos.eta(), itHit->timeOfFlight());
00701     htofphi->Fill(gpos.phi().degrees(), itHit->timeOfFlight());
00702     htofr->Fill(gpos.mag(), itHit->timeOfFlight());
00703     htofz->Fill(gpos.z(), itHit->timeOfFlight());
00704 
00705    h3e[ir]->Fill(itHit->energyLoss());
00706    h3ex[ir]->Fill(itHit->entryPoint().x()-itHit->exitPoint().x());
00707    h3ey[ir]->Fill(itHit->entryPoint().y()-itHit->exitPoint().y());
00708    h3ez[ir]->Fill(std::fabs(itHit->entryPoint().z()-itHit->exitPoint().z()));
00709    h3lx[ir]->Fill(itHit->localPosition().x());
00710    h3ly[ir]->Fill(itHit->localPosition().y());
00711   }
00713   // get TEC information
00715   for (itHit = SiTECLowContainer->begin(); itHit != SiTECLowContainer->end(); ++itHit) {
00716     DetId detid=DetId(itHit->detUnitId());
00717     const GeomDetUnit * det=(const GeomDetUnit*)tracker->idToDetUnit( detid );
00718     GlobalPoint gpos=det->toGlobal(itHit->localPosition());
00719     htofeta->Fill(gpos.eta(), itHit->timeOfFlight());
00720     htofphi->Fill(gpos.phi().degrees(), itHit->timeOfFlight());
00721     htofr->Fill(gpos.mag(), itHit->timeOfFlight());
00722     htofz->Fill(gpos.z(), itHit->timeOfFlight());
00723 
00724    h4e[ir]->Fill(itHit->energyLoss());
00725    h4ex[ir]->Fill(itHit->entryPoint().x()-itHit->exitPoint().x());
00726    h4ey[ir]->Fill(itHit->entryPoint().y()-itHit->exitPoint().y());
00727    h4ez[ir]->Fill(std::fabs(itHit->entryPoint().z()-itHit->exitPoint().z()));
00728    h4lx[ir]->Fill(itHit->localPosition().x());
00729    h4ly[ir]->Fill(itHit->localPosition().y());
00730   }  
00731   for (itHit = SiTECHighContainer->begin(); itHit != SiTECHighContainer->end(); ++itHit) {
00732     DetId detid=DetId(itHit->detUnitId());
00733     const GeomDetUnit * det=(const GeomDetUnit*)tracker->idToDetUnit( detid );
00734     GlobalPoint gpos=det->toGlobal(itHit->localPosition());
00735     htofeta->Fill(gpos.eta(), itHit->timeOfFlight());
00736     htofphi->Fill(gpos.phi().degrees(), itHit->timeOfFlight());
00737     htofr->Fill(gpos.mag(), itHit->timeOfFlight());
00738     htofz->Fill(gpos.z(), itHit->timeOfFlight());
00739 
00740    h4e[ir]->Fill(itHit->energyLoss());
00741    h4ex[ir]->Fill(itHit->entryPoint().x()-itHit->exitPoint().x());
00742    h4ey[ir]->Fill(itHit->entryPoint().y()-itHit->exitPoint().y());
00743    h4ez[ir]->Fill(std::fabs(itHit->entryPoint().z()-itHit->exitPoint().z()));
00744    h4lx[ir]->Fill(itHit->localPosition().x());
00745    h4ly[ir]->Fill(itHit->localPosition().y());
00746   }
00747   
00748       
00749    return ;
00750    
00751 }
00752 
00753 DEFINE_FWK_MODULE(TrackerHitAnalyzer);
00754