CMS 3D CMS Logo

CMSSW_4_4_3_patch1/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, phi =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           if ( G4Trk[0] != 0 || G4Trk[1] != 0) phi = atan2(G4Trk[1],G4Trk[0]);
00515           
00516           if (eta>0.0 && eta<=0.5) ir = 0;
00517           if (eta>0.5 && eta<=1.0) ir = 1;
00518           if (eta>1.0 && eta<=1.5) ir = 2;
00519           if (eta>1.5 && eta<=2.0) ir = 3;
00520           if (eta>2.0 && eta<=2.5) ir = 4;
00521           if (eta>2.5) ir = 5;
00522           
00523           if (eta>-0.5 && eta<= 0.0) ir = 6;
00524           if (eta>-1.0 && eta<=-0.5) ir = 7;
00525           if (eta>-1.5 && eta<=-1.0) ir = 8;
00526           if (eta>-2.0 && eta<=-1.5) ir = 9;
00527           if (eta>-2.5 && eta<=-2.0) ir = 10;
00528           if (eta<=-2.5) ir = 11;
00529 //          LogInfo("EventInfo") << " eta = " << eta << " ir = " << ir;
00530 //        cout << " " <<endl;
00531 //          cout << "eta " << eta << " ir = " << ir << endl;                  
00532 //        cout << " " <<endl;
00533       }
00534   }       
00536   // get Pixel information
00538   for (itHit = PxlBrlLowContainer->begin(); itHit != PxlBrlLowContainer->end(); ++itHit) {
00539     DetId detid=DetId(itHit->detUnitId());
00540     const GeomDetUnit * det=(const GeomDetUnit*)tracker->idToDetUnit( detid );
00541     GlobalPoint gpos=det->toGlobal(itHit->localPosition());
00542     htofeta->Fill(gpos.eta(), itHit->timeOfFlight());
00543     htofphi->Fill(gpos.phi().degrees(), itHit->timeOfFlight());
00544     htofr->Fill(gpos.mag(), itHit->timeOfFlight());
00545     htofz->Fill(gpos.z(), itHit->timeOfFlight());
00546 
00547     h5e[ir]->Fill(itHit->energyLoss());
00548     h5ex[ir]->Fill(itHit->entryPoint().x()-itHit->exitPoint().x());
00549     h5ey[ir]->Fill(itHit->entryPoint().y()-itHit->exitPoint().y());
00550     h5ez[ir]->Fill(std::fabs(itHit->entryPoint().z()-itHit->exitPoint().z()));
00551     h5lx[ir]->Fill(itHit->localPosition().x());
00552     h5ly[ir]->Fill(itHit->localPosition().y());
00553   }
00554   for (itHit = PxlBrlHighContainer->begin(); itHit != PxlBrlHighContainer->end(); ++itHit) {
00555     DetId detid=DetId(itHit->detUnitId());
00556     const GeomDetUnit * det=(const GeomDetUnit*)tracker->idToDetUnit( detid );
00557     GlobalPoint gpos=det->toGlobal(itHit->localPosition());
00558     htofeta->Fill(gpos.eta(), itHit->timeOfFlight());
00559     htofphi->Fill(gpos.phi().degrees(), itHit->timeOfFlight());
00560     htofr->Fill(gpos.mag(), itHit->timeOfFlight());
00561     htofz->Fill(gpos.z(), itHit->timeOfFlight());
00562 
00563 
00564    h5e[ir]->Fill(itHit->energyLoss());
00565    h5ex[ir]->Fill(itHit->entryPoint().x()-itHit->exitPoint().x());
00566    h5ey[ir]->Fill(itHit->entryPoint().y()-itHit->exitPoint().y());
00567    h5ez[ir]->Fill(std::fabs(itHit->entryPoint().z()-itHit->exitPoint().z()));
00568    h5lx[ir]->Fill(itHit->localPosition().x());
00569    h5ly[ir]->Fill(itHit->localPosition().y());
00570   }
00571   for (itHit = PxlFwdLowContainer->begin(); itHit != PxlFwdLowContainer->end(); ++itHit) {
00572     DetId detid=DetId(itHit->detUnitId());
00573     const GeomDetUnit * det=(const GeomDetUnit*)tracker->idToDetUnit( detid );
00574     GlobalPoint gpos=det->toGlobal(itHit->localPosition());
00575     htofeta->Fill(gpos.eta(), itHit->timeOfFlight());
00576     htofphi->Fill(gpos.phi().degrees(), itHit->timeOfFlight());
00577     htofr->Fill(gpos.mag(), itHit->timeOfFlight());
00578     htofz->Fill(gpos.z(), itHit->timeOfFlight());
00579 
00580 
00581    h6e[ir]->Fill(itHit->energyLoss());
00582    h6ex[ir]->Fill(itHit->entryPoint().x()-itHit->exitPoint().x());
00583    h6ey[ir]->Fill(itHit->entryPoint().y()-itHit->exitPoint().y());
00584    h6ez[ir]->Fill(std::fabs(itHit->entryPoint().z()-itHit->exitPoint().z()));
00585    h6lx[ir]->Fill(itHit->localPosition().x());
00586    h6ly[ir]->Fill(itHit->localPosition().y());
00587   }  
00588   for (itHit = PxlFwdHighContainer->begin(); itHit != PxlFwdHighContainer->end(); ++itHit) {
00589     DetId detid=DetId(itHit->detUnitId());
00590     const GeomDetUnit * det=(const GeomDetUnit*)tracker->idToDetUnit( detid );
00591     GlobalPoint gpos=det->toGlobal(itHit->localPosition());
00592     htofeta->Fill(gpos.eta(), itHit->timeOfFlight());
00593     htofphi->Fill(gpos.phi().degrees(), itHit->timeOfFlight());
00594     htofr->Fill(gpos.mag(), itHit->timeOfFlight());
00595     htofz->Fill(gpos.z(), itHit->timeOfFlight());
00596 
00597 
00598    h6e[ir]->Fill(itHit->energyLoss());
00599    h6ex[ir]->Fill(itHit->entryPoint().x()-itHit->exitPoint().x());
00600    h6ey[ir]->Fill(itHit->entryPoint().y()-itHit->exitPoint().y());
00601    h6ez[ir]->Fill(std::fabs(itHit->entryPoint().z()-itHit->exitPoint().z()));
00602    h6lx[ir]->Fill(itHit->localPosition().x());
00603    h6ly[ir]->Fill(itHit->localPosition().y());
00604   }
00606   // get TIB information
00608   for (itHit = SiTIBLowContainer->begin(); itHit != SiTIBLowContainer->end(); ++itHit) {
00609     DetId detid=DetId(itHit->detUnitId());
00610     const GeomDetUnit * det=(const GeomDetUnit*)tracker->idToDetUnit( detid );
00611     GlobalPoint gpos=det->toGlobal(itHit->localPosition());
00612     htofeta->Fill(gpos.eta(), itHit->timeOfFlight());
00613     htofphi->Fill(gpos.phi().degrees(), itHit->timeOfFlight());
00614     htofr->Fill(gpos.mag(), itHit->timeOfFlight());
00615     htofz->Fill(gpos.z(), itHit->timeOfFlight());
00616 
00617 
00618    h1e[ir]->Fill(itHit->energyLoss());
00619    h1ex[ir]->Fill(itHit->entryPoint().x()-itHit->exitPoint().x());
00620    h1ey[ir]->Fill(itHit->entryPoint().y()-itHit->exitPoint().y());
00621    h1ez[ir]->Fill(std::fabs(itHit->entryPoint().z()-itHit->exitPoint().z()));
00622    h1lx[ir]->Fill(itHit->localPosition().x());
00623    h1ly[ir]->Fill(itHit->localPosition().y());
00624   }
00625   for (itHit = SiTIBHighContainer->begin(); itHit != SiTIBHighContainer->end(); ++itHit) {
00626     DetId detid=DetId(itHit->detUnitId());
00627     const GeomDetUnit * det=(const GeomDetUnit*)tracker->idToDetUnit( detid );
00628     GlobalPoint gpos=det->toGlobal(itHit->localPosition());
00629     htofeta->Fill(gpos.eta(), itHit->timeOfFlight());
00630     htofphi->Fill(gpos.phi().degrees(), itHit->timeOfFlight());
00631     htofr->Fill(gpos.mag(), itHit->timeOfFlight());
00632     htofz->Fill(gpos.z(), itHit->timeOfFlight());
00633 
00634 
00635    h1e[ir]->Fill(itHit->energyLoss());
00636    h1ex[ir]->Fill(itHit->entryPoint().x()-itHit->exitPoint().x());
00637    h1ey[ir]->Fill(itHit->entryPoint().y()-itHit->exitPoint().y());
00638    h1ez[ir]->Fill(std::fabs(itHit->entryPoint().z()-itHit->exitPoint().z()));
00639    h1lx[ir]->Fill(itHit->localPosition().x());
00640    h1ly[ir]->Fill(itHit->localPosition().y());
00641   }
00643   // get TOB information
00645   for (itHit = SiTOBLowContainer->begin(); itHit != SiTOBLowContainer->end(); ++itHit) {
00646     DetId detid=DetId(itHit->detUnitId());
00647     const GeomDetUnit * det=(const GeomDetUnit*)tracker->idToDetUnit( detid );
00648     GlobalPoint gpos=det->toGlobal(itHit->localPosition());
00649     htofeta->Fill(gpos.eta(), itHit->timeOfFlight());
00650     htofphi->Fill(gpos.phi().degrees(), itHit->timeOfFlight());
00651     htofr->Fill(gpos.mag(), itHit->timeOfFlight());
00652     htofz->Fill(gpos.z(), itHit->timeOfFlight());
00653 
00654 
00655    h2e[ir]->Fill(itHit->energyLoss());
00656    h2ex[ir]->Fill(itHit->entryPoint().x()-itHit->exitPoint().x());
00657    h2ey[ir]->Fill(itHit->entryPoint().y()-itHit->exitPoint().y());
00658    h2ez[ir]->Fill(std::fabs(itHit->entryPoint().z()-itHit->exitPoint().z()));
00659    h2lx[ir]->Fill(itHit->localPosition().x());
00660    h2ly[ir]->Fill(itHit->localPosition().y());
00661   }  
00662   for (itHit = SiTOBHighContainer->begin(); itHit != SiTOBHighContainer->end(); ++itHit) {
00663     DetId detid=DetId(itHit->detUnitId());
00664     const GeomDetUnit * det=(const GeomDetUnit*)tracker->idToDetUnit( detid );
00665     GlobalPoint gpos=det->toGlobal(itHit->localPosition());
00666     htofeta->Fill(gpos.eta(), itHit->timeOfFlight());
00667     htofphi->Fill(gpos.phi().degrees(), itHit->timeOfFlight());
00668     htofr->Fill(gpos.mag(), itHit->timeOfFlight());
00669     htofz->Fill(gpos.z(), itHit->timeOfFlight());
00670 
00671    h2e[ir]->Fill(itHit->energyLoss());
00672    h2ex[ir]->Fill(itHit->entryPoint().x()-itHit->exitPoint().x());
00673    h2ey[ir]->Fill(itHit->entryPoint().y()-itHit->exitPoint().y());
00674    h2ez[ir]->Fill(std::fabs(itHit->entryPoint().z()-itHit->exitPoint().z()));
00675    h2lx[ir]->Fill(itHit->localPosition().x());
00676    h2ly[ir]->Fill(itHit->localPosition().y());
00677   }
00679   // get TID information
00681   for (itHit = SiTIDLowContainer->begin(); itHit != SiTIDLowContainer->end(); ++itHit) {
00682     DetId detid=DetId(itHit->detUnitId());
00683     const GeomDetUnit * det=(const GeomDetUnit*)tracker->idToDetUnit( detid );
00684     GlobalPoint gpos=det->toGlobal(itHit->localPosition());
00685     htofeta->Fill(gpos.eta(), itHit->timeOfFlight());
00686     htofphi->Fill(gpos.phi().degrees(), itHit->timeOfFlight());
00687     htofr->Fill(gpos.mag(), itHit->timeOfFlight());
00688     htofz->Fill(gpos.z(), itHit->timeOfFlight());
00689 
00690    h3e[ir]->Fill(itHit->energyLoss());
00691    h3ex[ir]->Fill(itHit->entryPoint().x()-itHit->exitPoint().x());
00692    h3ey[ir]->Fill(itHit->entryPoint().y()-itHit->exitPoint().y());
00693    h3ez[ir]->Fill(std::fabs(itHit->entryPoint().z()-itHit->exitPoint().z()));
00694    h3lx[ir]->Fill(itHit->localPosition().x());
00695    h3ly[ir]->Fill(itHit->localPosition().y());
00696   }  
00697   for (itHit = SiTIDHighContainer->begin(); itHit != SiTIDHighContainer->end(); ++itHit) {
00698     DetId detid=DetId(itHit->detUnitId());
00699     const GeomDetUnit * det=(const GeomDetUnit*)tracker->idToDetUnit( detid );
00700     GlobalPoint gpos=det->toGlobal(itHit->localPosition());
00701     htofeta->Fill(gpos.eta(), itHit->timeOfFlight());
00702     htofphi->Fill(gpos.phi().degrees(), itHit->timeOfFlight());
00703     htofr->Fill(gpos.mag(), itHit->timeOfFlight());
00704     htofz->Fill(gpos.z(), itHit->timeOfFlight());
00705 
00706    h3e[ir]->Fill(itHit->energyLoss());
00707    h3ex[ir]->Fill(itHit->entryPoint().x()-itHit->exitPoint().x());
00708    h3ey[ir]->Fill(itHit->entryPoint().y()-itHit->exitPoint().y());
00709    h3ez[ir]->Fill(std::fabs(itHit->entryPoint().z()-itHit->exitPoint().z()));
00710    h3lx[ir]->Fill(itHit->localPosition().x());
00711    h3ly[ir]->Fill(itHit->localPosition().y());
00712   }
00714   // get TEC information
00716   for (itHit = SiTECLowContainer->begin(); itHit != SiTECLowContainer->end(); ++itHit) {
00717     DetId detid=DetId(itHit->detUnitId());
00718     const GeomDetUnit * det=(const GeomDetUnit*)tracker->idToDetUnit( detid );
00719     GlobalPoint gpos=det->toGlobal(itHit->localPosition());
00720     htofeta->Fill(gpos.eta(), itHit->timeOfFlight());
00721     htofphi->Fill(gpos.phi().degrees(), itHit->timeOfFlight());
00722     htofr->Fill(gpos.mag(), itHit->timeOfFlight());
00723     htofz->Fill(gpos.z(), itHit->timeOfFlight());
00724 
00725    h4e[ir]->Fill(itHit->energyLoss());
00726    h4ex[ir]->Fill(itHit->entryPoint().x()-itHit->exitPoint().x());
00727    h4ey[ir]->Fill(itHit->entryPoint().y()-itHit->exitPoint().y());
00728    h4ez[ir]->Fill(std::fabs(itHit->entryPoint().z()-itHit->exitPoint().z()));
00729    h4lx[ir]->Fill(itHit->localPosition().x());
00730    h4ly[ir]->Fill(itHit->localPosition().y());
00731   }  
00732   for (itHit = SiTECHighContainer->begin(); itHit != SiTECHighContainer->end(); ++itHit) {
00733     DetId detid=DetId(itHit->detUnitId());
00734     const GeomDetUnit * det=(const GeomDetUnit*)tracker->idToDetUnit( detid );
00735     GlobalPoint gpos=det->toGlobal(itHit->localPosition());
00736     htofeta->Fill(gpos.eta(), itHit->timeOfFlight());
00737     htofphi->Fill(gpos.phi().degrees(), itHit->timeOfFlight());
00738     htofr->Fill(gpos.mag(), itHit->timeOfFlight());
00739     htofz->Fill(gpos.z(), itHit->timeOfFlight());
00740 
00741    h4e[ir]->Fill(itHit->energyLoss());
00742    h4ex[ir]->Fill(itHit->entryPoint().x()-itHit->exitPoint().x());
00743    h4ey[ir]->Fill(itHit->entryPoint().y()-itHit->exitPoint().y());
00744    h4ez[ir]->Fill(std::fabs(itHit->entryPoint().z()-itHit->exitPoint().z()));
00745    h4lx[ir]->Fill(itHit->localPosition().x());
00746    h4ly[ir]->Fill(itHit->localPosition().y());
00747   }
00748   
00749       
00750    return ;
00751    
00752 }
00753 
00754 DEFINE_FWK_MODULE(TrackerHitAnalyzer);
00755