CMS 3D CMS Logo

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 
00012 // data in edm::event
00013 #include "SimDataFormats/ValidationFormats/interface/PValidationFormats.h"
00014 #include "SimDataFormats/HepMCProduct/interface/HepMCProduct.h"
00015 //#include "SimDataFormats/Vertex/interface/SimVertexContainer.h"
00016 #include "SimDataFormats/Track/interface/SimTrackContainer.h"
00017 #include "SimDataFormats/TrackingHit/interface/PSimHitContainer.h"
00018 #include "SimDataFormats/EncodedEventId/interface/EncodedEventId.h"
00019 #include "SimDataFormats/Track/interface/SimTrack.h"
00020 #include "SimDataFormats/Vertex/interface/SimVertex.h"
00021 #include "DataFormats/Math/interface/LorentzVector.h"
00022 
00023 // helper files
00024 #include <CLHEP/Vector/LorentzVector.h>
00025 #include <CLHEP/Units/SystemOfUnits.h>
00026 
00027 
00028 #include <iostream>
00029 #include "DQMServices/Core/interface/DQMStore.h"
00030 using namespace edm;
00031 using namespace std;
00032 
00033 TrackerHitAnalyzer::TrackerHitAnalyzer(const edm::ParameterSet& ps) {
00034 
00035    fDBE = Service<DQMStore>().operator->();
00036    fOutputFile = ps.getUntrackedParameter<string>("outputFile", "TrackerHitHisto.root");
00037    verbose_ = ps.getUntrackedParameter<bool>("Verbosity",false);
00038    //get Labels to use to extract information
00039    PxlBrlLowSrc_ = ps.getParameter<edm::InputTag>("PxlBrlLowSrc");
00040    PxlBrlHighSrc_ = ps.getParameter<edm::InputTag>("PxlBrlHighSrc");
00041    PxlFwdLowSrc_ = ps.getParameter<edm::InputTag>("PxlFwdLowSrc");
00042    PxlFwdHighSrc_ = ps.getParameter<edm::InputTag>("PxlFwdHighSrc");
00043    
00044    SiTIBLowSrc_ = ps.getParameter<edm::InputTag>("SiTIBLowSrc");
00045    SiTIBHighSrc_ = ps.getParameter<edm::InputTag>("SiTIBHighSrc");
00046    SiTOBLowSrc_ = ps.getParameter<edm::InputTag>("SiTOBLowSrc");
00047    SiTOBHighSrc_ = ps.getParameter<edm::InputTag>("SiTOBHighSrc");
00048    SiTIDLowSrc_ = ps.getParameter<edm::InputTag>("SiTIDLowSrc");
00049    SiTIDHighSrc_ = ps.getParameter<edm::InputTag>("SiTIDHighSrc");
00050    SiTECLowSrc_ = ps.getParameter<edm::InputTag>("SiTECLowSrc");
00051    SiTECHighSrc_ = ps.getParameter<edm::InputTag>("SiTECHighSrc");
00052 
00053 
00055         
00056   Char_t  hname1[50], htitle1[80];
00057   Char_t  hname2[50], htitle2[80];
00058   Char_t  hname3[50], htitle3[80];
00059   Char_t  hname4[50], htitle4[80];
00060   Char_t  hname5[50], htitle5[80];
00061   Char_t  hname6[50], htitle6[80];
00062    
00063   if ( fDBE ) {
00064      if ( verbose_ ) {
00065        fDBE->setVerbose(1);
00066      } else {
00067        fDBE->setVerbose(0);
00068      }
00069   }
00070                                                                                                                                         
00071   if ( fDBE) {
00072     if ( verbose_ ) fDBE->showDirStructure();
00073   } 
00074 
00075   if ( fDBE != NULL ) {
00076 //   fDBE->setCurrentFolder("TrackerHitsV/TrackerHitTask");
00077      
00078      // is there any way to record CPU Info ???
00079      // if so, it can be done once - via beginJob() 
00080  const float E2NEL = 1.; 
00081  
00082  const char *Region[] = {"005","051","115","152","225","253",
00083                        "-050","-105","-151","-215","-252","-325"};  
00084  
00085  int nbin = 10000;   
00086       
00087 // Energy loss histograms
00088    for(int i=0; i<12; i++) {
00089   
00090     sprintf (htitle1,"Energy loss in TIB %s", Region[i]);
00091     sprintf (htitle2,"Energy loss in TOB %s", Region[i]);
00092     sprintf (htitle3,"Energy loss in TID %s", Region[i]);
00093     sprintf (htitle4,"Energy loss in TEC %s", Region[i]);
00094     sprintf (htitle5,"Energy loss in BPIX %s", Region[i]);
00095     sprintf (htitle6,"Energy loss in FPIX %s", Region[i]);
00096     
00097     sprintf (hname1,"Eloss_TIB_%i",i+1);
00098     sprintf (hname2,"Eloss_TOB_%i",i+1);
00099     sprintf (hname3,"Eloss_TID_%i",i+1);
00100     sprintf (hname4,"Eloss_TEC_%i",i+1);
00101     sprintf (hname5,"Eloss_BPIX_%i",i+1);
00102     sprintf (hname6,"Eloss_FPIX_%i",i+1);
00103    
00104     fDBE->setCurrentFolder("TrackerHitsV/TrackerHit/TIBHit");
00105     h1e[i]  = fDBE->book1D (hname1, htitle1, nbin , 0.0 , 0.001*E2NEL);
00106     fDBE->setCurrentFolder("TrackerHitsV/TrackerHit/TOBHit");
00107     h2e[i]  = fDBE->book1D (hname2, htitle2, nbin , 0.0 , 0.001*E2NEL);
00108     fDBE->setCurrentFolder("TrackerHitsV/TrackerHit/TIDHit");
00109     h3e[i]  = fDBE->book1D (hname3, htitle3, nbin , 0.0 , 0.001*E2NEL);
00110     fDBE->setCurrentFolder("TrackerHitsV/TrackerHit/TECHit");
00111     h4e[i]  = fDBE->book1D (hname4, htitle4, nbin , 0.0 , 0.001*E2NEL);
00112     fDBE->setCurrentFolder("TrackerHitsV/TrackerHit/BPIXHit");
00113     h5e[i]  = fDBE->book1D (hname5, htitle5, nbin , 0.0 , 0.001*E2NEL);
00114     fDBE->setCurrentFolder("TrackerHitsV/TrackerHit/FPIXHit");
00115     h6e[i]  = fDBE->book1D (hname6, htitle6, nbin , 0.0 , 0.001*E2NEL);
00116    
00117    }
00118 
00119 // limits
00120 const float high[] = {0.03, 0.03, 0.02, 0.03, 0.03, 0.03};
00121 const float low[] = {-0.03, -0.03, -0.02, -0.03, -0.03, -0.03};
00122    
00123    for(int i=0; i<12; i++) {
00124   
00125     sprintf (htitle1,"Entryx-Exitx in TIB %s", Region[i]);
00126     sprintf (htitle2,"Entryx-Exitx in TOB %s", Region[i]);
00127     sprintf (htitle3,"Entryx-Exitx in TID %s", Region[i]);
00128     sprintf (htitle4,"Entryx-Exitx in TEC %s", Region[i]);
00129     sprintf (htitle5,"Entryx-Exitx in BPIX %s", Region[i]);
00130     sprintf (htitle6,"Entryx-Exitx in FPIX %s", Region[i]);
00131     
00132     sprintf (hname1,"Entryx-Exitx_TIB_%i",i+1);
00133     sprintf (hname2,"Entryx-Exitx_TOB_%i",i+1);
00134     sprintf (hname3,"Entryx-Exitx_TID_%i",i+1);
00135     sprintf (hname4,"Entryx-Exitx_TEC_%i",i+1);
00136     sprintf (hname5,"Entryx-Exitx_BPIX_%i",i+1);
00137     sprintf (hname6,"Entryx-Exitx_FPIX_%i",i+1);
00138    
00139     fDBE->setCurrentFolder("TrackerHitsV/TrackerHit/TIBHit");
00140     h1ex[i]  = fDBE->book1D (hname1, htitle1, nbin , low[0] , high[0]);
00141     fDBE->setCurrentFolder("TrackerHitsV/TrackerHit/TOBHit");
00142     h2ex[i]  = fDBE->book1D (hname2, htitle2, nbin , low[1] , high[1]);
00143     fDBE->setCurrentFolder("TrackerHitsV/TrackerHit/TIDHit");
00144     h3ex[i]  = fDBE->book1D (hname3, htitle3, nbin , low[2] , high[2]);
00145     fDBE->setCurrentFolder("TrackerHitsV/TrackerHit/TECHit");
00146     h4ex[i]  = fDBE->book1D (hname4, htitle4, nbin , low[3] , high[3]);
00147     fDBE->setCurrentFolder("TrackerHitsV/TrackerHit/BPIXHit");
00148     h5ex[i]  = fDBE->book1D (hname5, htitle5, nbin , low[4] , high[4]);
00149     fDBE->setCurrentFolder("TrackerHitsV/TrackerHit/FPIXHit");
00150     h6ex[i]  = fDBE->book1D (hname6, htitle6, nbin , low[5] , high[5]);
00151    
00152    }
00153 
00154    for(int i=0; i<12; i++) {
00155   
00156     sprintf (htitle1,"Entryy-Exity in TIB %s", Region[i]);
00157     sprintf (htitle2,"Entryy-Exity in TOB %s", Region[i]);
00158     sprintf (htitle3,"Entryy-Exity in TID %s", Region[i]);
00159     sprintf (htitle4,"Entryy-Exity in TEC %s", Region[i]);
00160     sprintf (htitle5,"Entryy-Exity in BPIX %s", Region[i]);
00161     sprintf (htitle6,"Entryy-Exity in FPIX %s", Region[i]);
00162     
00163     sprintf (hname1,"Entryy-Exity_TIB_%i",i+1);
00164     sprintf (hname2,"Entryy-Exity_TOB_%i",i+1);
00165     sprintf (hname3,"Entryy-Exity_TID_%i",i+1);
00166     sprintf (hname4,"Entryy-Exity_TEC_%i",i+1);
00167     sprintf (hname5,"Entryy-Exity_BPIX_%i",i+1);
00168     sprintf (hname6,"Entryy-Exity_FPIX_%i",i+1);
00169    
00170     fDBE->setCurrentFolder("TrackerHitsV/TrackerHit/TIBHit");
00171     h1ey[i]  = fDBE->book1D (hname1, htitle1, nbin , low[0] , high[0]);
00172     fDBE->setCurrentFolder("TrackerHitsV/TrackerHit/TOBHit");
00173     h2ey[i]  = fDBE->book1D (hname2, htitle2, nbin , low[1] , high[1]);
00174     fDBE->setCurrentFolder("TrackerHitsV/TrackerHit/TIDHit");
00175     h3ey[i]  = fDBE->book1D (hname3, htitle3, nbin , low[2] , high[2]);
00176     fDBE->setCurrentFolder("TrackerHitsV/TrackerHit/TECHit");
00177     h4ey[i]  = fDBE->book1D (hname4, htitle4, nbin , low[3] , high[3]);
00178     fDBE->setCurrentFolder("TrackerHitsV/TrackerHit/BPIXHit");
00179     h5ey[i]  = fDBE->book1D (hname5, htitle5, nbin , low[4] , high[4]);
00180     fDBE->setCurrentFolder("TrackerHitsV/TrackerHit/FPIXHit");
00181     h6ey[i]  = fDBE->book1D (hname6, htitle6, nbin , low[5] , high[5]);
00182    
00183    }
00184 
00185 const float high1[] = {0.05, 0.06, 0.05, 0.06, 0.05, 0.05};
00186 const float low1[]  = {0.,0.,0.,0.,0.,0.};
00187 
00188   for(int i=0; i<12; i++) {
00189   
00190     sprintf (htitle1,"abs(Entryz-Exitz) in TIB %s", Region[i]);
00191     sprintf (htitle2,"abs(Entryz-Exitz) in TOB %s", Region[i]);
00192     sprintf (htitle3,"abs(Entryz-Exitz) in TID %s", Region[i]);
00193     sprintf (htitle4,"abs(Entryz-Exitz) in TEC %s", Region[i]);
00194     sprintf (htitle5,"abs(Entryz-Exitz) in BPIX %s", Region[i]);
00195     sprintf (htitle6,"abs(Entryz-Exitz) in FPIX %s", Region[i]);
00196     
00197     sprintf (hname1,"Entryz-Exitz_TIB_%i",i+1);
00198     sprintf (hname2,"Entryz-Exitz_TOB_%i",i+1);
00199     sprintf (hname3,"Entryz-Exitz_TID_%i",i+1);
00200     sprintf (hname4,"Entryz-Exitz_TEC_%i",i+1);
00201     sprintf (hname5,"Entryz-Exitz_BPIX_%i",i+1);
00202     sprintf (hname6,"Entryz-Exitz_FPIX_%i",i+1);
00203    
00204     fDBE->setCurrentFolder("TrackerHitsV/TrackerHit/TIBHit");
00205     h1ez[i]  = fDBE->book1D (hname1, htitle1, nbin , low1[0] , high1[0]);
00206     fDBE->setCurrentFolder("TrackerHitsV/TrackerHit/TOBHit");
00207     h2ez[i]  = fDBE->book1D (hname2, htitle2, nbin , low1[1] , high1[1]);
00208     fDBE->setCurrentFolder("TrackerHitsV/TrackerHit/TIDHit");
00209     h3ez[i]  = fDBE->book1D (hname3, htitle3, nbin , low1[2] , high1[2]);
00210     fDBE->setCurrentFolder("TrackerHitsV/TrackerHit/TECHit");
00211     h4ez[i]  = fDBE->book1D (hname4, htitle4, nbin , low1[3] , high1[3]);
00212     fDBE->setCurrentFolder("TrackerHitsV/TrackerHit/BPIXHit");
00213     h5ez[i]  = fDBE->book1D (hname5, htitle5, nbin , low1[4] , high1[4]);
00214     fDBE->setCurrentFolder("TrackerHitsV/TrackerHit/FPIXHit");
00215     h6ez[i]  = fDBE->book1D (hname6, htitle6, nbin , low1[5] , high1[5]);
00216    
00217    }
00218 
00219 
00220 const float high2[] = {3.2, 5.0, 5.5, 6.2, 0.85, 0.5};   
00221 const float low2[] = {-3.2, -5.0, -5.5, -6.2, -0.85, -0.5};   
00222 
00223    for(int i=0; i<12; i++) {
00224   
00225     sprintf (htitle1,"Localx in TIB %s", Region[i]);
00226     sprintf (htitle2,"Localx in TOB %s", Region[i]);
00227     sprintf (htitle3,"Localx in TID %s", Region[i]);
00228     sprintf (htitle4,"Localx in TEC %s", Region[i]);
00229     sprintf (htitle5,"Localx in BPIX %s", Region[i]);
00230     sprintf (htitle6,"Localx in FPIX %s", Region[i]);
00231     
00232     sprintf (hname1,"Localx_TIB_%i",i+1);
00233     sprintf (hname2,"Localx_TOB_%i",i+1);
00234     sprintf (hname3,"Localx_TID_%i",i+1);
00235     sprintf (hname4,"Localx_TEC_%i",i+1);
00236     sprintf (hname5,"Localx_BPIX_%i",i+1);
00237     sprintf (hname6,"Localx_FPIX_%i",i+1);
00238    
00239     fDBE->setCurrentFolder("TrackerHitsV/TrackerHit/TIBHit");
00240     h1lx[i]  = fDBE->book1D (hname1, htitle1, nbin , low2[0] , high2[0]);
00241     fDBE->setCurrentFolder("TrackerHitsV/TrackerHit/TOBHit");
00242     h2lx[i]  = fDBE->book1D (hname2, htitle2, nbin , low2[1] , high2[1]);
00243     fDBE->setCurrentFolder("TrackerHitsV/TrackerHit/TIDHit");
00244     h3lx[i]  = fDBE->book1D (hname3, htitle3, nbin , low2[2] , high2[2]);
00245     fDBE->setCurrentFolder("TrackerHitsV/TrackerHit/TECHit");
00246     h4lx[i]  = fDBE->book1D (hname4, htitle4, nbin , low2[3] , high2[3]);
00247     fDBE->setCurrentFolder("TrackerHitsV/TrackerHit/BPIXHit");
00248     h5lx[i]  = fDBE->book1D (hname5, htitle5, nbin , low2[4] , high2[4]);
00249     fDBE->setCurrentFolder("TrackerHitsV/TrackerHit/FPIXHit");
00250     h6lx[i]  = fDBE->book1D (hname6, htitle6, nbin , low2[5] , high2[5]);
00251    
00252    }
00253 
00254 
00255 const float high3[] = {6.0, 10., 5.6, 10.5, 3.4, 0.52};
00256 const float low3[] = {-6.0, -10., -5.6, -10.5, -3.4, -0.52};
00257 
00258    for(int i=0; i<12; i++) {
00259   
00260     sprintf (htitle1,"Localy in TIB %s", Region[i]);
00261     sprintf (htitle2,"Localy in TOB %s", Region[i]);
00262     sprintf (htitle3,"Localy in TID %s", Region[i]);
00263     sprintf (htitle4,"Localy in TEC %s", Region[i]);
00264     sprintf (htitle5,"Localy in BPIX %s", Region[i]);
00265     sprintf (htitle6,"Localy in FPIX %s", Region[i]);
00266     
00267     sprintf (hname1,"Localy_TIB_%i",i+1);
00268     sprintf (hname2,"Localy_TOB_%i",i+1);
00269     sprintf (hname3,"Localy_TID_%i",i+1);
00270     sprintf (hname4,"Localy_TEC_%i",i+1);
00271     sprintf (hname5,"Localy_BPIX_%i",i+1);
00272     sprintf (hname6,"Localy_FPIX_%i",i+1);
00273    
00274     fDBE->setCurrentFolder("TrackerHitsV/TrackerHit/TIBHit");
00275     h1ly[i]  = fDBE->book1D (hname1, htitle1, nbin , low3[0] , high3[0]);
00276     fDBE->setCurrentFolder("TrackerHitsV/TrackerHit/TOBHit");
00277     h2ly[i]  = fDBE->book1D (hname2, htitle2, nbin , low3[1] , high3[1]);
00278     fDBE->setCurrentFolder("TrackerHitsV/TrackerHit/TIDHit");
00279     h3ly[i]  = fDBE->book1D (hname3, htitle3, nbin , low3[2] , high3[2]);
00280     fDBE->setCurrentFolder("TrackerHitsV/TrackerHit/TECHit");
00281     h4ly[i]  = fDBE->book1D (hname4, htitle4, nbin , low3[3] , high3[3]);
00282     fDBE->setCurrentFolder("TrackerHitsV/TrackerHit/BPIXHit");
00283     h5ly[i]  = fDBE->book1D (hname5, htitle5, nbin , low3[4] , high3[4]);
00284     fDBE->setCurrentFolder("TrackerHitsV/TrackerHit/FPIXHit");
00285     h6ly[i]  = fDBE->book1D (hname6, htitle6, nbin , low3[5] , high3[5]);
00286    
00287    }
00288    
00289   }
00290 }
00291 
00292 TrackerHitAnalyzer::~TrackerHitAnalyzer()
00293 {
00294    // don't try to delete any pointers - they're handled by DQM machinery
00295 }
00296 
00297 void TrackerHitAnalyzer::beginJob(const edm::EventSetup& c){
00298 
00299 }
00300 
00301 void TrackerHitAnalyzer::endJob() 
00302 {
00303 
00304   if ( fOutputFile.size() != 0 && fDBE ) fDBE->save(fOutputFile);
00305 
00306   return ;
00307 
00308 }
00309 
00310 
00311 void TrackerHitAnalyzer::analyze(const edm::Event& e, const edm::EventSetup& c)
00312 {
00313 
00314    LogInfo("EventInfo") << " Run = " << e.id().run() << " Event = " << e.id().event();
00315    
00316   // iterator to access containers
00317   edm::PSimHitContainer::const_iterator itHit;
00319   // get Pixel Barrel information
00321   // extract low container
00322   edm::Handle<edm::PSimHitContainer> PxlBrlLowContainer;
00323   e.getByLabel(PxlBrlLowSrc_,PxlBrlLowContainer);
00324   if (!PxlBrlLowContainer.isValid()) {
00325     edm::LogError("TrackerHitAnalyzer::analyze")
00326       << "Unable to find TrackerHitsPixelBarrelLowTof in event!";
00327     return;
00328   }  
00329   // extract high container
00330   edm::Handle<edm::PSimHitContainer> PxlBrlHighContainer;
00331   e.getByLabel(PxlBrlHighSrc_,PxlBrlHighContainer);
00332   if (!PxlBrlHighContainer.isValid()) {
00333     edm::LogError("TrackerHitAnalyzer::analyze")
00334       << "Unable to find TrackerHitsPixelBarrelHighTof in event!";
00335     return;
00336   }
00338   // get Pixel Forward information
00340   // extract low container
00341   edm::Handle<edm::PSimHitContainer> PxlFwdLowContainer;
00342   e.getByLabel(PxlFwdLowSrc_,PxlFwdLowContainer);
00343   if (!PxlFwdLowContainer.isValid()) {
00344     edm::LogError("TrackerHitAnalyzer::analyze")
00345       << "Unable to find TrackerHitsPixelEndcapLowTof in event!";
00346     return;
00347   }
00348   // extract high container
00349   edm::Handle<edm::PSimHitContainer> PxlFwdHighContainer;
00350   e.getByLabel(PxlFwdHighSrc_,PxlFwdHighContainer);
00351   if (!PxlFwdHighContainer.isValid()) {
00352     edm::LogError("TrackerHitAnalyzer::analyze")
00353       << "Unable to find TrackerHitsPixelEndcapHighTof in event!";
00354     return;
00355   }
00356   
00358   // get Silicon TIB information
00360   // extract TIB low container
00361   edm::Handle<edm::PSimHitContainer> SiTIBLowContainer;
00362 //  iEvent.getByLabel("g4SimHits","TrackerHitsTIBLowTof",SiTIBLowContainer);
00363   e.getByLabel(SiTIBLowSrc_,SiTIBLowContainer);
00364   if (!SiTIBLowContainer.isValid()) {
00365     edm::LogError("TrackerHitProducer::analyze")
00366       << "Unable to find TrackerHitsTIBLowTof in event!";
00367     return;
00368   }
00370   // extract TIB low container
00371   edm::Handle<edm::PSimHitContainer> SiTIBHighContainer;
00372 //  iEvent.getByLabel("g4SimHits","TrackerHitsTIBHighTof",SiTIBHighContainer);
00373   e.getByLabel(SiTIBHighSrc_,SiTIBHighContainer);
00374   if (!SiTIBHighContainer.isValid()) {
00375     edm::LogError("TrackerHitProducer::analyze")
00376       << "Unable to find TrackerHitsTIBHighTof in event!";
00377     return;
00378   }
00380   // get Silicon TOB information
00382   // extract TOB low container
00383   edm::Handle<edm::PSimHitContainer> SiTOBLowContainer;
00384 //  iEvent.getByLabel("g4SimHits","TrackerHitsTOBLowTof",SiTOBLowContainer);
00385   e.getByLabel(SiTOBLowSrc_,SiTOBLowContainer);
00386   if (!SiTOBLowContainer.isValid()) {
00387     edm::LogError("TrackerHitProducer::analyze")
00388       << "Unable to find TrackerHitsTOBLowTof in event!";
00389     return;
00390   }
00392   // extract TOB low container
00393   edm::Handle<edm::PSimHitContainer> SiTOBHighContainer;
00394 //  iEvent.getByLabel("g4SimHits","TrackerHitsTOBHighTof",SiTOBHighContainer);
00395   e.getByLabel(SiTOBHighSrc_,SiTOBHighContainer);
00396   if (!SiTOBHighContainer.isValid()) {
00397     edm::LogError("TrackerHitProducer::analyze")
00398       << "Unable to find TrackerHitsTOBHighTof in event!";
00399     return;
00400   }
00401   
00403   // get Silicon TID information
00405   // extract TID low container
00406   edm::Handle<edm::PSimHitContainer> SiTIDLowContainer;
00407 //  iEvent.getByLabel("g4SimHits","TrackerHitsTIDLowTof",SiTIDLowContainer);
00408   e.getByLabel(SiTIDLowSrc_,SiTIDLowContainer);
00409   if (!SiTIDLowContainer.isValid()) {
00410     edm::LogError("TrackerHitProducer::analyze")
00411       << "Unable to find TrackerHitsTIDLowTof in event!";
00412     return;
00413   }
00415   // extract TID low container
00416   edm::Handle<edm::PSimHitContainer> SiTIDHighContainer;
00417 //  iEvent.getByLabel("g4SimHits","TrackerHitsTIDHighTof",SiTIDHighContainer);
00418   e.getByLabel(SiTIDHighSrc_,SiTIDHighContainer);
00419   if (!SiTIDHighContainer.isValid()) {
00420     edm::LogError("TrackerHitProducer::analyze")
00421       << "Unable to find TrackerHitsTIDHighTof in event!";
00422     return;
00423   }
00425   // get Silicon TEC information
00427   // extract TEC low container
00428   edm::Handle<edm::PSimHitContainer> SiTECLowContainer;
00429 //  iEvent.getByLabel("g4SimHits","TrackerHitsTECLowTof",SiTECLowContainer);
00430   e.getByLabel(SiTECLowSrc_,SiTECLowContainer);
00431   if (!SiTECLowContainer.isValid()) {
00432     edm::LogError("TrackerHitProducer::analyze")
00433       << "Unable to find TrackerHitsTECLowTof in event!";
00434     return;
00435   }
00437   // extract TEC low container
00438   edm ::Handle<edm::PSimHitContainer> SiTECHighContainer;
00439 //  iEvent.getByLabel("g4SimHits","TrackerHitsTECHighTof",SiTECHighContainer);
00440   e.getByLabel(SiTECHighSrc_,SiTECHighContainer);
00441   if (!SiTECHighContainer.isValid()) {
00442     edm::LogError("TrackerHitProducer::analyze")
00443       << "Unable to find TrackerHitsTECHighTof in event!";
00444     return;
00445   }
00446   
00448   // get G4Track information
00450   
00451   edm::Handle<edm::SimTrackContainer> G4TrkContainer;
00452   e.getByType(G4TrkContainer);
00453   if (!G4TrkContainer.isValid()) {
00454     edm::LogError("TrackerHitAnalyzer::analyze")
00455       << "Unable to find SimTrack in event!";
00456     return;
00457   }
00458   int ir = -100;
00459   edm::SimTrackContainer::const_iterator itTrk;
00460   for (itTrk = G4TrkContainer->begin(); itTrk != G4TrkContainer->end(); 
00461        ++itTrk) {
00462 
00463 //    cout << "itTrk = "<< itTrk << endl;
00464     double eta =0, phi =0, p =0;
00465     const HepLorentzVector& G4Trk = HepLorentzVector(itTrk->momentum().x(),
00466                                                      itTrk->momentum().y(),
00467                                                      itTrk->momentum().z(),
00468                                                      itTrk->momentum().e());  
00469     p =sqrt(G4Trk[0]*G4Trk[0]+G4Trk[1]*G4Trk[1]+G4Trk[2]*G4Trk[2]);
00470       if ( p == 0) 
00471           edm::LogError("TrackerHitAnalyzer::analyze") 
00472           << "TrackerTest::INFO: Primary has p = 0 ";
00473       else {
00474           double costheta  = G4Trk[2]/p;
00475           double theta = acos(TMath::Min(TMath::Max(costheta, -1.),1.));
00476           eta = -log(tan(theta/2));          
00477           if ( G4Trk[0] != 0 || G4Trk[1] != 0) phi = atan2(G4Trk[1],G4Trk[0]);
00478           
00479           if (eta>0.0 && eta<=0.5) ir = 0;
00480           if (eta>0.5 && eta<=1.0) ir = 1;
00481           if (eta>1.0 && eta<=1.5) ir = 2;
00482           if (eta>1.5 && eta<=2.0) ir = 3;
00483           if (eta>2.0 && eta<=2.5) ir = 4;
00484           if (eta>2.5) ir = 5;
00485           
00486           if (eta>-0.5 && eta<= 0.0) ir = 6;
00487           if (eta>-1.0 && eta<=-0.5) ir = 7;
00488           if (eta>-1.5 && eta<=-1.0) ir = 8;
00489           if (eta>-2.0 && eta<=-1.5) ir = 9;
00490           if (eta>-2.5 && eta<=-2.0) ir = 10;
00491           if (eta<=-2.5) ir = 11;
00492 //          LogInfo("EventInfo") << " eta = " << eta << " ir = " << ir;
00493 //        cout << " " <<endl;
00494 //          cout << "eta " << eta << " ir = " << ir << endl;                  
00495 //        cout << " " <<endl;
00496       }
00497   }       
00499   // get Pixel information
00501   for (itHit = PxlBrlLowContainer->begin(); itHit != PxlBrlLowContainer->end(); ++itHit) {
00502    h5e[ir]->Fill(itHit->energyLoss());
00503    h5ex[ir]->Fill(itHit->entryPoint().x()-itHit->exitPoint().x());
00504    h5ey[ir]->Fill(itHit->entryPoint().y()-itHit->exitPoint().y());
00505    h5ez[ir]->Fill(std::fabs(itHit->entryPoint().z()-itHit->exitPoint().z()));
00506    h5lx[ir]->Fill(itHit->localPosition().x());
00507    h5ly[ir]->Fill(itHit->localPosition().y());
00508   }
00509   for (itHit = PxlBrlHighContainer->begin(); itHit != PxlBrlHighContainer->end(); ++itHit) {
00510    h5e[ir]->Fill(itHit->energyLoss());
00511    h5ex[ir]->Fill(itHit->entryPoint().x()-itHit->exitPoint().x());
00512    h5ey[ir]->Fill(itHit->entryPoint().y()-itHit->exitPoint().y());
00513    h5ez[ir]->Fill(std::fabs(itHit->entryPoint().z()-itHit->exitPoint().z()));
00514    h5lx[ir]->Fill(itHit->localPosition().x());
00515    h5ly[ir]->Fill(itHit->localPosition().y());
00516   }
00517   for (itHit = PxlFwdLowContainer->begin(); itHit != PxlFwdLowContainer->end(); ++itHit) {
00518    h6e[ir]->Fill(itHit->energyLoss());
00519    h6ex[ir]->Fill(itHit->entryPoint().x()-itHit->exitPoint().x());
00520    h6ey[ir]->Fill(itHit->entryPoint().y()-itHit->exitPoint().y());
00521    h6ez[ir]->Fill(std::fabs(itHit->entryPoint().z()-itHit->exitPoint().z()));
00522    h6lx[ir]->Fill(itHit->localPosition().x());
00523    h6ly[ir]->Fill(itHit->localPosition().y());
00524   }  
00525   for (itHit = PxlFwdHighContainer->begin(); itHit != PxlFwdHighContainer->end(); ++itHit) {
00526    h6e[ir]->Fill(itHit->energyLoss());
00527    h6ex[ir]->Fill(itHit->entryPoint().x()-itHit->exitPoint().x());
00528    h6ey[ir]->Fill(itHit->entryPoint().y()-itHit->exitPoint().y());
00529    h6ez[ir]->Fill(std::fabs(itHit->entryPoint().z()-itHit->exitPoint().z()));
00530    h6lx[ir]->Fill(itHit->localPosition().x());
00531    h6ly[ir]->Fill(itHit->localPosition().y());
00532   }
00534   // get TIB information
00536   for (itHit = SiTIBLowContainer->begin(); itHit != SiTIBLowContainer->end(); ++itHit) {
00537    h1e[ir]->Fill(itHit->energyLoss());
00538    h1ex[ir]->Fill(itHit->entryPoint().x()-itHit->exitPoint().x());
00539    h1ey[ir]->Fill(itHit->entryPoint().y()-itHit->exitPoint().y());
00540    h1ez[ir]->Fill(std::fabs(itHit->entryPoint().z()-itHit->exitPoint().z()));
00541    h1lx[ir]->Fill(itHit->localPosition().x());
00542    h1ly[ir]->Fill(itHit->localPosition().y());
00543   }
00544   for (itHit = SiTIBHighContainer->begin(); itHit != SiTIBHighContainer->end(); ++itHit) {
00545    h1e[ir]->Fill(itHit->energyLoss());
00546    h1ex[ir]->Fill(itHit->entryPoint().x()-itHit->exitPoint().x());
00547    h1ey[ir]->Fill(itHit->entryPoint().y()-itHit->exitPoint().y());
00548    h1ez[ir]->Fill(std::fabs(itHit->entryPoint().z()-itHit->exitPoint().z()));
00549    h1lx[ir]->Fill(itHit->localPosition().x());
00550    h1ly[ir]->Fill(itHit->localPosition().y());
00551   }
00553   // get TOB information
00555   for (itHit = SiTOBLowContainer->begin(); itHit != SiTOBLowContainer->end(); ++itHit) {
00556    h2e[ir]->Fill(itHit->energyLoss());
00557    h2ex[ir]->Fill(itHit->entryPoint().x()-itHit->exitPoint().x());
00558    h2ey[ir]->Fill(itHit->entryPoint().y()-itHit->exitPoint().y());
00559    h2ez[ir]->Fill(std::fabs(itHit->entryPoint().z()-itHit->exitPoint().z()));
00560    h2lx[ir]->Fill(itHit->localPosition().x());
00561    h2ly[ir]->Fill(itHit->localPosition().y());
00562   }  
00563   for (itHit = SiTOBHighContainer->begin(); itHit != SiTOBHighContainer->end(); ++itHit) {
00564    h2e[ir]->Fill(itHit->energyLoss());
00565    h2ex[ir]->Fill(itHit->entryPoint().x()-itHit->exitPoint().x());
00566    h2ey[ir]->Fill(itHit->entryPoint().y()-itHit->exitPoint().y());
00567    h2ez[ir]->Fill(std::fabs(itHit->entryPoint().z()-itHit->exitPoint().z()));
00568    h2lx[ir]->Fill(itHit->localPosition().x());
00569    h2ly[ir]->Fill(itHit->localPosition().y());
00570   }
00572   // get TID information
00574   for (itHit = SiTIDLowContainer->begin(); itHit != SiTIDLowContainer->end(); ++itHit) {
00575    h3e[ir]->Fill(itHit->energyLoss());
00576    h3ex[ir]->Fill(itHit->entryPoint().x()-itHit->exitPoint().x());
00577    h3ey[ir]->Fill(itHit->entryPoint().y()-itHit->exitPoint().y());
00578    h3ez[ir]->Fill(std::fabs(itHit->entryPoint().z()-itHit->exitPoint().z()));
00579    h3lx[ir]->Fill(itHit->localPosition().x());
00580    h3ly[ir]->Fill(itHit->localPosition().y());
00581   }  
00582   for (itHit = SiTIDHighContainer->begin(); itHit != SiTIDHighContainer->end(); ++itHit) {
00583    h3e[ir]->Fill(itHit->energyLoss());
00584    h3ex[ir]->Fill(itHit->entryPoint().x()-itHit->exitPoint().x());
00585    h3ey[ir]->Fill(itHit->entryPoint().y()-itHit->exitPoint().y());
00586    h3ez[ir]->Fill(std::fabs(itHit->entryPoint().z()-itHit->exitPoint().z()));
00587    h3lx[ir]->Fill(itHit->localPosition().x());
00588    h3ly[ir]->Fill(itHit->localPosition().y());
00589   }
00591   // get TEC information
00593   for (itHit = SiTECLowContainer->begin(); itHit != SiTECLowContainer->end(); ++itHit) {
00594    h4e[ir]->Fill(itHit->energyLoss());
00595    h4ex[ir]->Fill(itHit->entryPoint().x()-itHit->exitPoint().x());
00596    h4ey[ir]->Fill(itHit->entryPoint().y()-itHit->exitPoint().y());
00597    h4ez[ir]->Fill(std::fabs(itHit->entryPoint().z()-itHit->exitPoint().z()));
00598    h4lx[ir]->Fill(itHit->localPosition().x());
00599    h4ly[ir]->Fill(itHit->localPosition().y());
00600   }  
00601   for (itHit = SiTECHighContainer->begin(); itHit != SiTECHighContainer->end(); ++itHit) {
00602    h4e[ir]->Fill(itHit->energyLoss());
00603    h4ex[ir]->Fill(itHit->entryPoint().x()-itHit->exitPoint().x());
00604    h4ey[ir]->Fill(itHit->entryPoint().y()-itHit->exitPoint().y());
00605    h4ez[ir]->Fill(std::fabs(itHit->entryPoint().z()-itHit->exitPoint().z()));
00606    h4lx[ir]->Fill(itHit->localPosition().x());
00607    h4ly[ir]->Fill(itHit->localPosition().y());
00608   }
00609   
00610       
00611    return ;
00612    
00613 }
00614 
00615 DEFINE_FWK_MODULE(TrackerHitAnalyzer);
00616 

Generated on Tue Jun 9 17:49:44 2009 for CMSSW by  doxygen 1.5.4