Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-03-23 04:29:27

0001 #include "Validation/TrackerHits/interface/TrackerHitAnalyzer.h"
0002 
0003 #include "FWCore/Framework/interface/ESHandle.h"
0004 #include "FWCore/Framework/interface/Event.h"
0005 #include "FWCore/Framework/interface/EventSetup.h"
0006 #include "FWCore/Framework/interface/MakerMacros.h"
0007 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0008 #include "FWCore/ServiceRegistry/interface/Service.h"
0009 
0010 #include "DataFormats/Common/interface/Handle.h"
0011 #include "DataFormats/DetId/interface/DetId.h"
0012 
0013 #include "DQMServices/Core/interface/DQMStore.h"
0014 
0015 // tracker info
0016 #include "DataFormats/SiPixelDetId/interface/PixelSubdetector.h"
0017 #include "DataFormats/SiStripDetId/interface/StripSubdetector.h"
0018 #include "Geometry/CommonDetUnit/interface/GeomDet.h"
0019 #include "Geometry/CommonDetUnit/interface/TrackingGeometry.h"
0020 
0021 // data in edm::event
0022 #include "SimDataFormats/GeneratorProducts/interface/HepMCProduct.h"
0023 #include "SimDataFormats/ValidationFormats/interface/PValidationFormats.h"
0024 //#include "SimDataFormats/Vertex/interface/SimVertexContainer.h"
0025 #include "DataFormats/Math/interface/LorentzVector.h"
0026 #include "SimDataFormats/EncodedEventId/interface/EncodedEventId.h"
0027 #include "SimDataFormats/Vertex/interface/SimVertex.h"
0028 
0029 // helper files
0030 #include "CLHEP/Units/GlobalSystemOfUnits.h"
0031 #include <CLHEP/Vector/LorentzVector.h>
0032 
0033 #include <cstdlib>
0034 #include <map>
0035 #include <memory>
0036 #include <vector>
0037 
0038 TrackerHitAnalyzer::TrackerHitAnalyzer(const edm::ParameterSet &ps)
0039     : tGeomEsToken_(esConsumes()),
0040       verbose_(ps.getUntrackedParameter<bool>("Verbosity", false)),
0041       edmPSimHitContainer_pxlBrlLow_Token_(
0042           consumes<edm::PSimHitContainer>(ps.getParameter<edm::InputTag>("PxlBrlLowSrc"))),
0043       edmPSimHitContainer_pxlBrlHigh_Token_(
0044           consumes<edm::PSimHitContainer>(ps.getParameter<edm::InputTag>("PxlBrlHighSrc"))),
0045       edmPSimHitContainer_pxlFwdLow_Token_(
0046           consumes<edm::PSimHitContainer>(ps.getParameter<edm::InputTag>("PxlFwdLowSrc"))),
0047       edmPSimHitContainer_pxlFwdHigh_Token_(
0048           consumes<edm::PSimHitContainer>(ps.getParameter<edm::InputTag>("PxlFwdHighSrc"))),
0049       edmPSimHitContainer_siTIBLow_Token_(
0050           consumes<edm::PSimHitContainer>(ps.getParameter<edm::InputTag>("SiTIBLowSrc"))),
0051       edmPSimHitContainer_siTIBHigh_Token_(
0052           consumes<edm::PSimHitContainer>(ps.getParameter<edm::InputTag>("SiTIBHighSrc"))),
0053       edmPSimHitContainer_siTOBLow_Token_(
0054           consumes<edm::PSimHitContainer>(ps.getParameter<edm::InputTag>("SiTOBLowSrc"))),
0055       edmPSimHitContainer_siTOBHigh_Token_(
0056           consumes<edm::PSimHitContainer>(ps.getParameter<edm::InputTag>("SiTOBHighSrc"))),
0057       edmPSimHitContainer_siTIDLow_Token_(
0058           consumes<edm::PSimHitContainer>(ps.getParameter<edm::InputTag>("SiTIDLowSrc"))),
0059       edmPSimHitContainer_siTIDHigh_Token_(
0060           consumes<edm::PSimHitContainer>(ps.getParameter<edm::InputTag>("SiTIDHighSrc"))),
0061       edmPSimHitContainer_siTECLow_Token_(
0062           consumes<edm::PSimHitContainer>(ps.getParameter<edm::InputTag>("SiTECLowSrc"))),
0063       edmPSimHitContainer_siTECHigh_Token_(
0064           consumes<edm::PSimHitContainer>(ps.getParameter<edm::InputTag>("SiTECHighSrc"))),
0065       edmSimTrackContainerToken_(consumes<edm::SimTrackContainer>(ps.getParameter<edm::InputTag>("G4TrkSrc"))),
0066       fDBE(nullptr),
0067       conf_(ps),
0068       runStandalone(ps.getParameter<bool>("runStandalone")),
0069       fOutputFile(ps.getUntrackedParameter<std::string>("outputFile", "TrackerHitHisto.root")),
0070       pixelOutput(ps.getParameter<bool>("pixelOutput")) {}
0071 
0072 void TrackerHitAnalyzer::bookHistograms(DQMStore::IBooker &ibooker, const edm::Run &run, const edm::EventSetup &es) {
0073   ////// booking histograms
0074   fDBE = edm::Service<DQMStore>().operator->();
0075 
0076   Char_t hname1[50], htitle1[80];
0077   Char_t hname2[50], htitle2[80];
0078   Char_t hname3[50], htitle3[80];
0079   Char_t hname4[50], htitle4[80];
0080   Char_t hname5[50], htitle5[80];
0081   Char_t hname6[50], htitle6[80];
0082 
0083   if (fDBE != nullptr) {
0084     //   fDBE->setCurrentFolder("TrackerHitsV/TrackerHitTask");
0085 
0086     // is there any way to record CPU Info ???
0087     // if so, it can be done once - via beginJob()
0088     int nbin = 5000;
0089 
0090     ibooker.setCurrentFolder("TrackerHitsV/TrackerHit/");
0091     htofeta = ibooker.book2D("tof_eta", "Time of flight vs eta", nbin, -3.0, 3.0, 200, -100, 100);
0092     htofphi = ibooker.book2D("tof_phi", "Time of flight vs phi", nbin, -180, 180, 200, -100, 100);
0093     htofr = ibooker.book2D("tof_r", "Time of flight vs r", nbin, 0, 300, 200, -100, 100);
0094     htofz = ibooker.book2D("tof_z", "Time of flight vs z", nbin, -280, 280, 200, -100, 100);
0095 
0096     const float E2NEL = 1.;
0097 
0098     const char *Region[] = {"005", "051", "115", "152", "225", "253", "-050", "-105", "-151", "-215", "-252", "-325"};
0099     nbin = 200;
0100 
0101     // Energy loss histograms
0102     for (int i = 0; i < 12; i++) {
0103       sprintf(htitle1, "Energy loss in TIB %s", Region[i]);
0104       sprintf(htitle2, "Energy loss in TOB %s", Region[i]);
0105       sprintf(htitle3, "Energy loss in TID %s", Region[i]);
0106       sprintf(htitle4, "Energy loss in TEC %s", Region[i]);
0107       if (pixelOutput)
0108         sprintf(htitle5, "Energy loss in BPIX %s", Region[i]);
0109       if (pixelOutput)
0110         sprintf(htitle6, "Energy loss in FPIX %s", Region[i]);
0111 
0112       sprintf(hname1, "Eloss_TIB_%i", i + 1);
0113       sprintf(hname2, "Eloss_TOB_%i", i + 1);
0114       sprintf(hname3, "Eloss_TID_%i", i + 1);
0115       sprintf(hname4, "Eloss_TEC_%i", i + 1);
0116       if (pixelOutput)
0117         sprintf(hname5, "Eloss_BPIX_%i", i + 1);
0118       if (pixelOutput)
0119         sprintf(hname6, "Eloss_FPIX_%i", i + 1);
0120 
0121       ibooker.setCurrentFolder("TrackerHitsV/TrackerHit/TIBHit");
0122       h1e[i] = ibooker.book1D(hname1, htitle1, nbin, 0.0, 0.001 * E2NEL);
0123       ibooker.setCurrentFolder("TrackerHitsV/TrackerHit/TOBHit");
0124       h2e[i] = ibooker.book1D(hname2, htitle2, nbin, 0.0, 0.001 * E2NEL);
0125       ibooker.setCurrentFolder("TrackerHitsV/TrackerHit/TIDHit");
0126       h3e[i] = ibooker.book1D(hname3, htitle3, nbin, 0.0, 0.001 * E2NEL);
0127       ibooker.setCurrentFolder("TrackerHitsV/TrackerHit/TECHit");
0128       h4e[i] = ibooker.book1D(hname4, htitle4, nbin, 0.0, 0.001 * E2NEL);
0129       if (pixelOutput) {
0130         ibooker.setCurrentFolder("TrackerHitsV/TrackerHit/BPIXHit");
0131         h5e[i] = ibooker.book1D(hname5, htitle5, nbin, 0.0, 0.001 * E2NEL);
0132         ibooker.setCurrentFolder("TrackerHitsV/TrackerHit/FPIXHit");
0133         h6e[i] = ibooker.book1D(hname6, htitle6, nbin, 0.0, 0.001 * E2NEL);
0134       }
0135     }
0136 
0137     // limits
0138     const float high[] = {0.03, 0.03, 0.02, 0.03, 0.03, 0.03};
0139     const float low[] = {-0.03, -0.03, -0.02, -0.03, -0.03, -0.03};
0140 
0141     for (int i = 0; i < 12; i++) {
0142       sprintf(htitle1, "Entryx-Exitx in TIB %s", Region[i]);
0143       sprintf(htitle2, "Entryx-Exitx in TOB %s", Region[i]);
0144       sprintf(htitle3, "Entryx-Exitx in TID %s", Region[i]);
0145       sprintf(htitle4, "Entryx-Exitx in TEC %s", Region[i]);
0146       if (pixelOutput)
0147         sprintf(htitle5, "Entryx-Exitx in BPIX %s", Region[i]);
0148       if (pixelOutput)
0149         sprintf(htitle6, "Entryx-Exitx in FPIX %s", Region[i]);
0150 
0151       sprintf(hname1, "Entryx-Exitx_TIB_%i", i + 1);
0152       sprintf(hname2, "Entryx-Exitx_TOB_%i", i + 1);
0153       sprintf(hname3, "Entryx-Exitx_TID_%i", i + 1);
0154       sprintf(hname4, "Entryx-Exitx_TEC_%i", i + 1);
0155       if (pixelOutput)
0156         sprintf(hname5, "Entryx-Exitx_BPIX_%i", i + 1);
0157       if (pixelOutput)
0158         sprintf(hname6, "Entryx-Exitx_FPIX_%i", i + 1);
0159 
0160       ibooker.setCurrentFolder("TrackerHitsV/TrackerHit/TIBHit");
0161       h1ex[i] = ibooker.book1D(hname1, htitle1, nbin, low[0], high[0]);
0162       ibooker.setCurrentFolder("TrackerHitsV/TrackerHit/TOBHit");
0163       h2ex[i] = ibooker.book1D(hname2, htitle2, nbin, low[1], high[1]);
0164       ibooker.setCurrentFolder("TrackerHitsV/TrackerHit/TIDHit");
0165       h3ex[i] = ibooker.book1D(hname3, htitle3, nbin, low[2], high[2]);
0166       ibooker.setCurrentFolder("TrackerHitsV/TrackerHit/TECHit");
0167       h4ex[i] = ibooker.book1D(hname4, htitle4, nbin, low[3], high[3]);
0168       if (pixelOutput) {
0169         ibooker.setCurrentFolder("TrackerHitsV/TrackerHit/BPIXHit");
0170         h5ex[i] = ibooker.book1D(hname5, htitle5, nbin, low[4], high[4]);
0171         ibooker.setCurrentFolder("TrackerHitsV/TrackerHit/FPIXHit");
0172         h6ex[i] = ibooker.book1D(hname6, htitle6, nbin, low[5], high[5]);
0173       }
0174     }
0175 
0176     const float high0[] = {0.05, 0.06, 0.03, 0.03, 0.03, 0.03};
0177     const float low0[] = {-0.05, -0.06, -0.03, -0.03, -0.03, -0.03};
0178 
0179     for (int i = 0; i < 12; i++) {
0180       sprintf(htitle1, "Entryy-Exity in TIB %s", Region[i]);
0181       sprintf(htitle2, "Entryy-Exity in TOB %s", Region[i]);
0182       sprintf(htitle3, "Entryy-Exity in TID %s", Region[i]);
0183       sprintf(htitle4, "Entryy-Exity in TEC %s", Region[i]);
0184       if (pixelOutput)
0185         sprintf(htitle5, "Entryy-Exity in BPIX %s", Region[i]);
0186       if (pixelOutput)
0187         sprintf(htitle6, "Entryy-Exity in FPIX %s", Region[i]);
0188 
0189       sprintf(hname1, "Entryy-Exity_TIB_%i", i + 1);
0190       sprintf(hname2, "Entryy-Exity_TOB_%i", i + 1);
0191       sprintf(hname3, "Entryy-Exity_TID_%i", i + 1);
0192       sprintf(hname4, "Entryy-Exity_TEC_%i", i + 1);
0193       if (pixelOutput)
0194         sprintf(hname5, "Entryy-Exity_BPIX_%i", i + 1);
0195       if (pixelOutput)
0196         sprintf(hname6, "Entryy-Exity_FPIX_%i", i + 1);
0197 
0198       ibooker.setCurrentFolder("TrackerHitsV/TrackerHit/TIBHit");
0199       h1ey[i] = ibooker.book1D(hname1, htitle1, nbin, low0[0], high0[0]);
0200       ibooker.setCurrentFolder("TrackerHitsV/TrackerHit/TOBHit");
0201       h2ey[i] = ibooker.book1D(hname2, htitle2, nbin, low0[1], high0[1]);
0202       ibooker.setCurrentFolder("TrackerHitsV/TrackerHit/TIDHit");
0203       h3ey[i] = ibooker.book1D(hname3, htitle3, nbin, low0[2], high0[2]);
0204       ibooker.setCurrentFolder("TrackerHitsV/TrackerHit/TECHit");
0205       h4ey[i] = ibooker.book1D(hname4, htitle4, nbin, low0[3], high0[3]);
0206       if (pixelOutput) {
0207         ibooker.setCurrentFolder("TrackerHitsV/TrackerHit/BPIXHit");
0208         h5ey[i] = ibooker.book1D(hname5, htitle5, nbin, low0[4], high0[4]);
0209         ibooker.setCurrentFolder("TrackerHitsV/TrackerHit/FPIXHit");
0210         h6ey[i] = ibooker.book1D(hname6, htitle6, nbin, low0[5], high0[5]);
0211       }
0212     }
0213 
0214     const float high1[] = {0.05, 0.06, 0.05, 0.06, 0.05, 0.05};
0215     const float low1[] = {0., 0., 0., 0., 0., 0.};
0216 
0217     for (int i = 0; i < 12; i++) {
0218       sprintf(htitle1, "abs(Entryz-Exitz) in TIB %s", Region[i]);
0219       sprintf(htitle2, "abs(Entryz-Exitz) in TOB %s", Region[i]);
0220       sprintf(htitle3, "abs(Entryz-Exitz) in TID %s", Region[i]);
0221       sprintf(htitle4, "abs(Entryz-Exitz) in TEC %s", Region[i]);
0222       if (pixelOutput)
0223         sprintf(htitle5, "abs(Entryz-Exitz) in BPIX %s", Region[i]);
0224       if (pixelOutput)
0225         sprintf(htitle6, "abs(Entryz-Exitz) in FPIX %s", Region[i]);
0226 
0227       sprintf(hname1, "Entryz-Exitz_TIB_%i", i + 1);
0228       sprintf(hname2, "Entryz-Exitz_TOB_%i", i + 1);
0229       sprintf(hname3, "Entryz-Exitz_TID_%i", i + 1);
0230       sprintf(hname4, "Entryz-Exitz_TEC_%i", i + 1);
0231       if (pixelOutput)
0232         sprintf(hname5, "Entryz-Exitz_BPIX_%i", i + 1);
0233       if (pixelOutput)
0234         sprintf(hname6, "Entryz-Exitz_FPIX_%i", i + 1);
0235 
0236       ibooker.setCurrentFolder("TrackerHitsV/TrackerHit/TIBHit");
0237       h1ez[i] = ibooker.book1D(hname1, htitle1, nbin, low1[0], high1[0]);
0238       ibooker.setCurrentFolder("TrackerHitsV/TrackerHit/TOBHit");
0239       h2ez[i] = ibooker.book1D(hname2, htitle2, nbin, low1[1], high1[1]);
0240       ibooker.setCurrentFolder("TrackerHitsV/TrackerHit/TIDHit");
0241       h3ez[i] = ibooker.book1D(hname3, htitle3, nbin, low1[2], high1[2]);
0242       ibooker.setCurrentFolder("TrackerHitsV/TrackerHit/TECHit");
0243       h4ez[i] = ibooker.book1D(hname4, htitle4, nbin, low1[3], high1[3]);
0244       if (pixelOutput) {
0245         ibooker.setCurrentFolder("TrackerHitsV/TrackerHit/BPIXHit");
0246         h5ez[i] = ibooker.book1D(hname5, htitle5, nbin, low1[4], high1[4]);
0247         ibooker.setCurrentFolder("TrackerHitsV/TrackerHit/FPIXHit");
0248         h6ez[i] = ibooker.book1D(hname6, htitle6, nbin, low1[5], high1[5]);
0249       }
0250     }
0251 
0252     const float high2[] = {3.2, 5.0, 5.5, 6.2, 0.85, 0.5};
0253     const float low2[] = {-3.2, -5.0, -5.5, -6.2, -0.85, -0.5};
0254 
0255     for (int i = 0; i < 12; i++) {
0256       sprintf(htitle1, "Localx in TIB %s", Region[i]);
0257       sprintf(htitle2, "Localx in TOB %s", Region[i]);
0258       sprintf(htitle3, "Localx in TID %s", Region[i]);
0259       sprintf(htitle4, "Localx in TEC %s", Region[i]);
0260       if (pixelOutput)
0261         sprintf(htitle5, "Localx in BPIX %s", Region[i]);
0262       if (pixelOutput)
0263         sprintf(htitle6, "Localx in FPIX %s", Region[i]);
0264 
0265       sprintf(hname1, "Localx_TIB_%i", i + 1);
0266       sprintf(hname2, "Localx_TOB_%i", i + 1);
0267       sprintf(hname3, "Localx_TID_%i", i + 1);
0268       sprintf(hname4, "Localx_TEC_%i", i + 1);
0269       if (pixelOutput)
0270         sprintf(hname5, "Localx_BPIX_%i", i + 1);
0271       if (pixelOutput)
0272         sprintf(hname6, "Localx_FPIX_%i", i + 1);
0273 
0274       ibooker.setCurrentFolder("TrackerHitsV/TrackerHit/TIBHit");
0275       h1lx[i] = ibooker.book1D(hname1, htitle1, nbin, low2[0], high2[0]);
0276       ibooker.setCurrentFolder("TrackerHitsV/TrackerHit/TOBHit");
0277       h2lx[i] = ibooker.book1D(hname2, htitle2, nbin, low2[1], high2[1]);
0278       ibooker.setCurrentFolder("TrackerHitsV/TrackerHit/TIDHit");
0279       h3lx[i] = ibooker.book1D(hname3, htitle3, nbin, low2[2], high2[2]);
0280       ibooker.setCurrentFolder("TrackerHitsV/TrackerHit/TECHit");
0281       h4lx[i] = ibooker.book1D(hname4, htitle4, nbin, low2[3], high2[3]);
0282       if (pixelOutput) {
0283         ibooker.setCurrentFolder("TrackerHitsV/TrackerHit/BPIXHit");
0284         h5lx[i] = ibooker.book1D(hname5, htitle5, nbin, low2[4], high2[4]);
0285         ibooker.setCurrentFolder("TrackerHitsV/TrackerHit/FPIXHit");
0286         h6lx[i] = ibooker.book1D(hname6, htitle6, nbin, low2[5], high2[5]);
0287       }
0288     }
0289 
0290     const float high3[] = {6.0, 10., 5.6, 10.5, 3.4, 0.52};
0291     const float low3[] = {-6.0, -10., -5.6, -10.5, -3.4, -0.52};
0292 
0293     for (int i = 0; i < 12; i++) {
0294       sprintf(htitle1, "Localy in TIB %s", Region[i]);
0295       sprintf(htitle2, "Localy in TOB %s", Region[i]);
0296       sprintf(htitle3, "Localy in TID %s", Region[i]);
0297       sprintf(htitle4, "Localy in TEC %s", Region[i]);
0298       if (pixelOutput)
0299         sprintf(htitle5, "Localy in BPIX %s", Region[i]);
0300       if (pixelOutput)
0301         sprintf(htitle6, "Localy in FPIX %s", Region[i]);
0302 
0303       sprintf(hname1, "Localy_TIB_%i", i + 1);
0304       sprintf(hname2, "Localy_TOB_%i", i + 1);
0305       sprintf(hname3, "Localy_TID_%i", i + 1);
0306       sprintf(hname4, "Localy_TEC_%i", i + 1);
0307       if (pixelOutput)
0308         sprintf(hname5, "Localy_BPIX_%i", i + 1);
0309       if (pixelOutput)
0310         sprintf(hname6, "Localy_FPIX_%i", i + 1);
0311 
0312       ibooker.setCurrentFolder("TrackerHitsV/TrackerHit/TIBHit");
0313       h1ly[i] = ibooker.book1D(hname1, htitle1, nbin, low3[0], high3[0]);
0314       ibooker.setCurrentFolder("TrackerHitsV/TrackerHit/TOBHit");
0315       h2ly[i] = ibooker.book1D(hname2, htitle2, nbin, low3[1], high3[1]);
0316       ibooker.setCurrentFolder("TrackerHitsV/TrackerHit/TIDHit");
0317       h3ly[i] = ibooker.book1D(hname3, htitle3, nbin, low3[2], high3[2]);
0318       ibooker.setCurrentFolder("TrackerHitsV/TrackerHit/TECHit");
0319       h4ly[i] = ibooker.book1D(hname4, htitle4, nbin, low3[3], high3[3]);
0320       if (pixelOutput) {
0321         ibooker.setCurrentFolder("TrackerHitsV/TrackerHit/BPIXHit");
0322         h5ly[i] = ibooker.book1D(hname5, htitle5, nbin, low3[4], high3[4]);
0323         ibooker.setCurrentFolder("TrackerHitsV/TrackerHit/FPIXHit");
0324         h6ly[i] = ibooker.book1D(hname6, htitle6, nbin, low3[5], high3[5]);
0325       }
0326     }
0327   }
0328 }
0329 
0330 TrackerHitAnalyzer::~TrackerHitAnalyzer() {
0331   // don't try to delete any pointers - they're handled by DQM machinery
0332 }
0333 
0334 void TrackerHitAnalyzer::analyze(const edm::Event &e, const edm::EventSetup &c) {
0335   edm::LogInfo("EventInfo") << " Run = " << e.id().run() << " Event = " << e.id().event();
0336 
0337   // iterator to access containers
0338   edm::PSimHitContainer::const_iterator itHit;
0339   /////////////////////////////////
0340   // get Pixel Barrel information
0341   ////////////////////////////////
0342   // extract low container
0343   edm::Handle<edm::PSimHitContainer> PxlBrlLowContainer;
0344   e.getByToken(edmPSimHitContainer_pxlBrlLow_Token_, PxlBrlLowContainer);
0345   if (!PxlBrlLowContainer.isValid()) {
0346     edm::LogError("TrackerHitAnalyzer::analyze") << "Unable to find TrackerHitsPixelBarrelLowTof in event!";
0347     return;
0348   }
0349   // extract high container
0350   edm::Handle<edm::PSimHitContainer> PxlBrlHighContainer;
0351   e.getByToken(edmPSimHitContainer_pxlBrlHigh_Token_, PxlBrlHighContainer);
0352   if (!PxlBrlHighContainer.isValid()) {
0353     edm::LogError("TrackerHitAnalyzer::analyze") << "Unable to find TrackerHitsPixelBarrelHighTof in event!";
0354     return;
0355   }
0356   /////////////////////////////////
0357   // get Pixel Forward information
0358   ////////////////////////////////
0359   // extract low container
0360   edm::Handle<edm::PSimHitContainer> PxlFwdLowContainer;
0361   e.getByToken(edmPSimHitContainer_pxlFwdLow_Token_, PxlFwdLowContainer);
0362   if (!PxlFwdLowContainer.isValid()) {
0363     edm::LogError("TrackerHitAnalyzer::analyze") << "Unable to find TrackerHitsPixelEndcapLowTof in event!";
0364     return;
0365   }
0366   // extract high container
0367   edm::Handle<edm::PSimHitContainer> PxlFwdHighContainer;
0368   e.getByToken(edmPSimHitContainer_pxlFwdHigh_Token_, PxlFwdHighContainer);
0369   if (!PxlFwdHighContainer.isValid()) {
0370     edm::LogError("TrackerHitAnalyzer::analyze") << "Unable to find TrackerHitsPixelEndcapHighTof in event!";
0371     return;
0372   }
0373   ///////////////////////////////////
0374   // get Silicon TIB information
0375   //////////////////////////////////
0376   // extract TIB low container
0377   edm::Handle<edm::PSimHitContainer> SiTIBLowContainer;
0378   e.getByToken(edmPSimHitContainer_siTIBLow_Token_, SiTIBLowContainer);
0379   if (!SiTIBLowContainer.isValid()) {
0380     edm::LogError("TrackerHitProducer::analyze") << "Unable to find TrackerHitsTIBLowTof in event!";
0381     return;
0382   }
0383   //////////////////////////////////
0384   // extract TIB high container
0385   edm::Handle<edm::PSimHitContainer> SiTIBHighContainer;
0386   e.getByToken(edmPSimHitContainer_siTIBHigh_Token_, SiTIBHighContainer);
0387   if (!SiTIBHighContainer.isValid()) {
0388     edm::LogError("TrackerHitProducer::analyze") << "Unable to find TrackerHitsTIBHighTof in event!";
0389     return;
0390   }
0391   ///////////////////////////////////
0392   // get Silicon TOB information
0393   //////////////////////////////////
0394   // extract TOB low container
0395   edm::Handle<edm::PSimHitContainer> SiTOBLowContainer;
0396   e.getByToken(edmPSimHitContainer_siTOBLow_Token_, SiTOBLowContainer);
0397   if (!SiTOBLowContainer.isValid()) {
0398     edm::LogError("TrackerHitProducer::analyze") << "Unable to find TrackerHitsTOBLowTof in event!";
0399     return;
0400   }
0401   //////////////////////////////////
0402   // extract TOB high container
0403   edm::Handle<edm::PSimHitContainer> SiTOBHighContainer;
0404   e.getByToken(edmPSimHitContainer_siTOBHigh_Token_, SiTOBHighContainer);
0405   if (!SiTOBHighContainer.isValid()) {
0406     edm::LogError("TrackerHitProducer::analyze") << "Unable to find TrackerHitsTOBHighTof in event!";
0407     return;
0408   }
0409 
0410   ///////////////////////////////////
0411   // get Silicon TID information
0412   //////////////////////////////////
0413   // extract TID low container
0414   edm::Handle<edm::PSimHitContainer> SiTIDLowContainer;
0415   e.getByToken(edmPSimHitContainer_siTIDLow_Token_, SiTIDLowContainer);
0416   if (!SiTIDLowContainer.isValid()) {
0417     edm::LogError("TrackerHitProducer::analyze") << "Unable to find TrackerHitsTIDLowTof in event!";
0418     return;
0419   }
0420   //////////////////////////////////
0421   // extract TID high container
0422   edm::Handle<edm::PSimHitContainer> SiTIDHighContainer;
0423   e.getByToken(edmPSimHitContainer_siTIDHigh_Token_, SiTIDHighContainer);
0424   if (!SiTIDHighContainer.isValid()) {
0425     edm::LogError("TrackerHitProducer::analyze") << "Unable to find TrackerHitsTIDHighTof in event!";
0426     return;
0427   }
0428   ///////////////////////////////////
0429   // get Silicon TEC information
0430   //////////////////////////////////
0431   // extract TEC low container
0432   edm::Handle<edm::PSimHitContainer> SiTECLowContainer;
0433   e.getByToken(edmPSimHitContainer_siTECLow_Token_, SiTECLowContainer);
0434   if (!SiTECLowContainer.isValid()) {
0435     edm::LogError("TrackerHitProducer::analyze") << "Unable to find TrackerHitsTECLowTof in event!";
0436     return;
0437   }
0438   //////////////////////////////////
0439   // extract TEC high container
0440   edm::Handle<edm::PSimHitContainer> SiTECHighContainer;
0441   e.getByToken(edmPSimHitContainer_siTECHigh_Token_, SiTECHighContainer);
0442   if (!SiTECHighContainer.isValid()) {
0443     edm::LogError("TrackerHitProducer::analyze") << "Unable to find TrackerHitsTECHighTof in event!";
0444     return;
0445   }
0446 
0447   ///////////////////////////
0448   // get G4Track information
0449   ///////////////////////////
0450 
0451   edm::Handle<edm::SimTrackContainer> G4TrkContainer;
0452   e.getByToken(edmSimTrackContainerToken_, G4TrkContainer);
0453   if (!G4TrkContainer.isValid()) {
0454     edm::LogError("TrackerHitAnalyzer::analyze") << "Unable to find SimTrack in event!";
0455     return;
0456   }
0457 
0458   // Get geometry information
0459   const auto &tracker = &c.getData(tGeomEsToken_);
0460 
0461   int ir = -100;
0462   edm::SimTrackContainer::const_iterator itTrk;
0463   for (itTrk = G4TrkContainer->begin(); itTrk != G4TrkContainer->end(); ++itTrk) {
0464     //    std::cout << "itTrk = "<< itTrk << std::endl;
0465     double eta = 0, p = 0;
0466     const CLHEP::HepLorentzVector &G4Trk = CLHEP::HepLorentzVector(
0467         itTrk->momentum().x(), itTrk->momentum().y(), itTrk->momentum().z(), itTrk->momentum().e());
0468     p = sqrt(G4Trk[0] * G4Trk[0] + G4Trk[1] * G4Trk[1] + G4Trk[2] * G4Trk[2]);
0469     if (p == 0)
0470       edm::LogError("TrackerHitAnalyzer::analyze") << "TrackerTest::INFO: Primary has p = 0 ";
0471     else {
0472       double costheta = G4Trk[2] / p;
0473       double theta = acos(TMath::Min(TMath::Max(costheta, -1.), 1.));
0474       eta = -log(tan(theta / 2));
0475 
0476       if (eta > 0.0 && eta <= 0.5)
0477         ir = 0;
0478       if (eta > 0.5 && eta <= 1.0)
0479         ir = 1;
0480       if (eta > 1.0 && eta <= 1.5)
0481         ir = 2;
0482       if (eta > 1.5 && eta <= 2.0)
0483         ir = 3;
0484       if (eta > 2.0 && eta <= 2.5)
0485         ir = 4;
0486       if (eta > 2.5)
0487         ir = 5;
0488 
0489       if (eta > -0.5 && eta <= 0.0)
0490         ir = 6;
0491       if (eta > -1.0 && eta <= -0.5)
0492         ir = 7;
0493       if (eta > -1.5 && eta <= -1.0)
0494         ir = 8;
0495       if (eta > -2.0 && eta <= -1.5)
0496         ir = 9;
0497       if (eta > -2.5 && eta <= -2.0)
0498         ir = 10;
0499       if (eta <= -2.5)
0500         ir = 11;
0501       //          edm::LogInfo("EventInfo") << " eta = " << eta << " ir = " <<
0502       //          ir;
0503       //      std::cout << " " << std::endl;
0504       //          std::cout << "eta " << eta << " ir = " << ir << std::endl;
0505       //      std::cout << " " << std::endl;
0506     }
0507   }
0508   ///////////////////////////////
0509   // get Pixel information
0510   ///////////////////////////////
0511   // If Phase 1, do not run - will run in new Phase 1 module
0512 
0513   if (pixelOutput) {
0514     for (itHit = PxlBrlLowContainer->begin(); itHit != PxlBrlLowContainer->end(); ++itHit) {
0515       DetId detid = DetId(itHit->detUnitId());
0516       const GeomDetUnit *det = (const GeomDetUnit *)tracker->idToDetUnit(detid);
0517       GlobalPoint gpos = det->toGlobal(itHit->localPosition());
0518       htofeta->Fill(gpos.eta(), itHit->timeOfFlight());
0519       htofphi->Fill(gpos.phi().degrees(), itHit->timeOfFlight());
0520       htofr->Fill(gpos.mag(), itHit->timeOfFlight());
0521       htofz->Fill(gpos.z(), itHit->timeOfFlight());
0522 
0523       h5e[ir]->Fill(itHit->energyLoss());
0524       h5ex[ir]->Fill(itHit->entryPoint().x() - itHit->exitPoint().x());
0525       h5ey[ir]->Fill(itHit->entryPoint().y() - itHit->exitPoint().y());
0526       h5ez[ir]->Fill(std::fabs(itHit->entryPoint().z() - itHit->exitPoint().z()));
0527       h5lx[ir]->Fill(itHit->localPosition().x());
0528       h5ly[ir]->Fill(itHit->localPosition().y());
0529     }
0530     for (itHit = PxlBrlHighContainer->begin(); itHit != PxlBrlHighContainer->end(); ++itHit) {
0531       DetId detid = DetId(itHit->detUnitId());
0532       const GeomDetUnit *det = (const GeomDetUnit *)tracker->idToDetUnit(detid);
0533       GlobalPoint gpos = det->toGlobal(itHit->localPosition());
0534       htofeta->Fill(gpos.eta(), itHit->timeOfFlight());
0535       htofphi->Fill(gpos.phi().degrees(), itHit->timeOfFlight());
0536       htofr->Fill(gpos.mag(), itHit->timeOfFlight());
0537       htofz->Fill(gpos.z(), itHit->timeOfFlight());
0538 
0539       h5e[ir]->Fill(itHit->energyLoss());
0540       h5ex[ir]->Fill(itHit->entryPoint().x() - itHit->exitPoint().x());
0541       h5ey[ir]->Fill(itHit->entryPoint().y() - itHit->exitPoint().y());
0542       h5ez[ir]->Fill(std::fabs(itHit->entryPoint().z() - itHit->exitPoint().z()));
0543       h5lx[ir]->Fill(itHit->localPosition().x());
0544       h5ly[ir]->Fill(itHit->localPosition().y());
0545     }
0546     for (itHit = PxlFwdLowContainer->begin(); itHit != PxlFwdLowContainer->end(); ++itHit) {
0547       DetId detid = DetId(itHit->detUnitId());
0548       const GeomDetUnit *det = (const GeomDetUnit *)tracker->idToDetUnit(detid);
0549       GlobalPoint gpos = det->toGlobal(itHit->localPosition());
0550       htofeta->Fill(gpos.eta(), itHit->timeOfFlight());
0551       htofphi->Fill(gpos.phi().degrees(), itHit->timeOfFlight());
0552       htofr->Fill(gpos.mag(), itHit->timeOfFlight());
0553       htofz->Fill(gpos.z(), itHit->timeOfFlight());
0554 
0555       h6e[ir]->Fill(itHit->energyLoss());
0556       h6ex[ir]->Fill(itHit->entryPoint().x() - itHit->exitPoint().x());
0557       h6ey[ir]->Fill(itHit->entryPoint().y() - itHit->exitPoint().y());
0558       h6ez[ir]->Fill(std::fabs(itHit->entryPoint().z() - itHit->exitPoint().z()));
0559       h6lx[ir]->Fill(itHit->localPosition().x());
0560       h6ly[ir]->Fill(itHit->localPosition().y());
0561     }
0562     for (itHit = PxlFwdHighContainer->begin(); itHit != PxlFwdHighContainer->end(); ++itHit) {
0563       DetId detid = DetId(itHit->detUnitId());
0564       const GeomDetUnit *det = (const GeomDetUnit *)tracker->idToDetUnit(detid);
0565       GlobalPoint gpos = det->toGlobal(itHit->localPosition());
0566       htofeta->Fill(gpos.eta(), itHit->timeOfFlight());
0567       htofphi->Fill(gpos.phi().degrees(), itHit->timeOfFlight());
0568       htofr->Fill(gpos.mag(), itHit->timeOfFlight());
0569       htofz->Fill(gpos.z(), itHit->timeOfFlight());
0570 
0571       h6e[ir]->Fill(itHit->energyLoss());
0572       h6ex[ir]->Fill(itHit->entryPoint().x() - itHit->exitPoint().x());
0573       h6ey[ir]->Fill(itHit->entryPoint().y() - itHit->exitPoint().y());
0574       h6ez[ir]->Fill(std::fabs(itHit->entryPoint().z() - itHit->exitPoint().z()));
0575       h6lx[ir]->Fill(itHit->localPosition().x());
0576       h6ly[ir]->Fill(itHit->localPosition().y());
0577     }
0578   }
0579   ///////////////////////////////
0580   // get TIB information
0581   ///////////////////////////////
0582   for (itHit = SiTIBLowContainer->begin(); itHit != SiTIBLowContainer->end(); ++itHit) {
0583     DetId detid = DetId(itHit->detUnitId());
0584     const GeomDetUnit *det = (const GeomDetUnit *)tracker->idToDetUnit(detid);
0585     GlobalPoint gpos = det->toGlobal(itHit->localPosition());
0586     htofeta->Fill(gpos.eta(), itHit->timeOfFlight());
0587     htofphi->Fill(gpos.phi().degrees(), itHit->timeOfFlight());
0588     htofr->Fill(gpos.mag(), itHit->timeOfFlight());
0589     htofz->Fill(gpos.z(), itHit->timeOfFlight());
0590 
0591     h1e[ir]->Fill(itHit->energyLoss());
0592     h1ex[ir]->Fill(itHit->entryPoint().x() - itHit->exitPoint().x());
0593     h1ey[ir]->Fill(itHit->entryPoint().y() - itHit->exitPoint().y());
0594     h1ez[ir]->Fill(std::fabs(itHit->entryPoint().z() - itHit->exitPoint().z()));
0595     h1lx[ir]->Fill(itHit->localPosition().x());
0596     h1ly[ir]->Fill(itHit->localPosition().y());
0597   }
0598   for (itHit = SiTIBHighContainer->begin(); itHit != SiTIBHighContainer->end(); ++itHit) {
0599     DetId detid = DetId(itHit->detUnitId());
0600     const GeomDetUnit *det = (const GeomDetUnit *)tracker->idToDetUnit(detid);
0601     GlobalPoint gpos = det->toGlobal(itHit->localPosition());
0602     htofeta->Fill(gpos.eta(), itHit->timeOfFlight());
0603     htofphi->Fill(gpos.phi().degrees(), itHit->timeOfFlight());
0604     htofr->Fill(gpos.mag(), itHit->timeOfFlight());
0605     htofz->Fill(gpos.z(), itHit->timeOfFlight());
0606 
0607     h1e[ir]->Fill(itHit->energyLoss());
0608     h1ex[ir]->Fill(itHit->entryPoint().x() - itHit->exitPoint().x());
0609     h1ey[ir]->Fill(itHit->entryPoint().y() - itHit->exitPoint().y());
0610     h1ez[ir]->Fill(std::fabs(itHit->entryPoint().z() - itHit->exitPoint().z()));
0611     h1lx[ir]->Fill(itHit->localPosition().x());
0612     h1ly[ir]->Fill(itHit->localPosition().y());
0613   }
0614   ///////////////////////////////
0615   // get TOB information
0616   ///////////////////////////////
0617   for (itHit = SiTOBLowContainer->begin(); itHit != SiTOBLowContainer->end(); ++itHit) {
0618     DetId detid = DetId(itHit->detUnitId());
0619     const GeomDetUnit *det = (const GeomDetUnit *)tracker->idToDetUnit(detid);
0620     GlobalPoint gpos = det->toGlobal(itHit->localPosition());
0621     htofeta->Fill(gpos.eta(), itHit->timeOfFlight());
0622     htofphi->Fill(gpos.phi().degrees(), itHit->timeOfFlight());
0623     htofr->Fill(gpos.mag(), itHit->timeOfFlight());
0624     htofz->Fill(gpos.z(), itHit->timeOfFlight());
0625 
0626     h2e[ir]->Fill(itHit->energyLoss());
0627     h2ex[ir]->Fill(itHit->entryPoint().x() - itHit->exitPoint().x());
0628     h2ey[ir]->Fill(itHit->entryPoint().y() - itHit->exitPoint().y());
0629     h2ez[ir]->Fill(std::fabs(itHit->entryPoint().z() - itHit->exitPoint().z()));
0630     h2lx[ir]->Fill(itHit->localPosition().x());
0631     h2ly[ir]->Fill(itHit->localPosition().y());
0632   }
0633   for (itHit = SiTOBHighContainer->begin(); itHit != SiTOBHighContainer->end(); ++itHit) {
0634     DetId detid = DetId(itHit->detUnitId());
0635     const GeomDetUnit *det = (const GeomDetUnit *)tracker->idToDetUnit(detid);
0636     GlobalPoint gpos = det->toGlobal(itHit->localPosition());
0637     htofeta->Fill(gpos.eta(), itHit->timeOfFlight());
0638     htofphi->Fill(gpos.phi().degrees(), itHit->timeOfFlight());
0639     htofr->Fill(gpos.mag(), itHit->timeOfFlight());
0640     htofz->Fill(gpos.z(), itHit->timeOfFlight());
0641 
0642     h2e[ir]->Fill(itHit->energyLoss());
0643     h2ex[ir]->Fill(itHit->entryPoint().x() - itHit->exitPoint().x());
0644     h2ey[ir]->Fill(itHit->entryPoint().y() - itHit->exitPoint().y());
0645     h2ez[ir]->Fill(std::fabs(itHit->entryPoint().z() - itHit->exitPoint().z()));
0646     h2lx[ir]->Fill(itHit->localPosition().x());
0647     h2ly[ir]->Fill(itHit->localPosition().y());
0648   }
0649   ///////////////////////////////
0650   // get TID information
0651   ///////////////////////////////
0652   for (itHit = SiTIDLowContainer->begin(); itHit != SiTIDLowContainer->end(); ++itHit) {
0653     DetId detid = DetId(itHit->detUnitId());
0654     const GeomDetUnit *det = (const GeomDetUnit *)tracker->idToDetUnit(detid);
0655     GlobalPoint gpos = det->toGlobal(itHit->localPosition());
0656     htofeta->Fill(gpos.eta(), itHit->timeOfFlight());
0657     htofphi->Fill(gpos.phi().degrees(), itHit->timeOfFlight());
0658     htofr->Fill(gpos.mag(), itHit->timeOfFlight());
0659     htofz->Fill(gpos.z(), itHit->timeOfFlight());
0660 
0661     h3e[ir]->Fill(itHit->energyLoss());
0662     h3ex[ir]->Fill(itHit->entryPoint().x() - itHit->exitPoint().x());
0663     h3ey[ir]->Fill(itHit->entryPoint().y() - itHit->exitPoint().y());
0664     h3ez[ir]->Fill(std::fabs(itHit->entryPoint().z() - itHit->exitPoint().z()));
0665     h3lx[ir]->Fill(itHit->localPosition().x());
0666     h3ly[ir]->Fill(itHit->localPosition().y());
0667   }
0668   for (itHit = SiTIDHighContainer->begin(); itHit != SiTIDHighContainer->end(); ++itHit) {
0669     DetId detid = DetId(itHit->detUnitId());
0670     const GeomDetUnit *det = (const GeomDetUnit *)tracker->idToDetUnit(detid);
0671     GlobalPoint gpos = det->toGlobal(itHit->localPosition());
0672     htofeta->Fill(gpos.eta(), itHit->timeOfFlight());
0673     htofphi->Fill(gpos.phi().degrees(), itHit->timeOfFlight());
0674     htofr->Fill(gpos.mag(), itHit->timeOfFlight());
0675     htofz->Fill(gpos.z(), itHit->timeOfFlight());
0676 
0677     h3e[ir]->Fill(itHit->energyLoss());
0678     h3ex[ir]->Fill(itHit->entryPoint().x() - itHit->exitPoint().x());
0679     h3ey[ir]->Fill(itHit->entryPoint().y() - itHit->exitPoint().y());
0680     h3ez[ir]->Fill(std::fabs(itHit->entryPoint().z() - itHit->exitPoint().z()));
0681     h3lx[ir]->Fill(itHit->localPosition().x());
0682     h3ly[ir]->Fill(itHit->localPosition().y());
0683   }
0684   ///////////////////////////////
0685   // get TEC information
0686   ///////////////////////////////
0687   for (itHit = SiTECLowContainer->begin(); itHit != SiTECLowContainer->end(); ++itHit) {
0688     DetId detid = DetId(itHit->detUnitId());
0689     const GeomDetUnit *det = (const GeomDetUnit *)tracker->idToDetUnit(detid);
0690     GlobalPoint gpos = det->toGlobal(itHit->localPosition());
0691     htofeta->Fill(gpos.eta(), itHit->timeOfFlight());
0692     htofphi->Fill(gpos.phi().degrees(), itHit->timeOfFlight());
0693     htofr->Fill(gpos.mag(), itHit->timeOfFlight());
0694     htofz->Fill(gpos.z(), itHit->timeOfFlight());
0695 
0696     h4e[ir]->Fill(itHit->energyLoss());
0697     h4ex[ir]->Fill(itHit->entryPoint().x() - itHit->exitPoint().x());
0698     h4ey[ir]->Fill(itHit->entryPoint().y() - itHit->exitPoint().y());
0699     h4ez[ir]->Fill(std::fabs(itHit->entryPoint().z() - itHit->exitPoint().z()));
0700     h4lx[ir]->Fill(itHit->localPosition().x());
0701     h4ly[ir]->Fill(itHit->localPosition().y());
0702   }
0703   for (itHit = SiTECHighContainer->begin(); itHit != SiTECHighContainer->end(); ++itHit) {
0704     DetId detid = DetId(itHit->detUnitId());
0705     const GeomDetUnit *det = (const GeomDetUnit *)tracker->idToDetUnit(detid);
0706     GlobalPoint gpos = det->toGlobal(itHit->localPosition());
0707     htofeta->Fill(gpos.eta(), itHit->timeOfFlight());
0708     htofphi->Fill(gpos.phi().degrees(), itHit->timeOfFlight());
0709     htofr->Fill(gpos.mag(), itHit->timeOfFlight());
0710     htofz->Fill(gpos.z(), itHit->timeOfFlight());
0711 
0712     h4e[ir]->Fill(itHit->energyLoss());
0713     h4ex[ir]->Fill(itHit->entryPoint().x() - itHit->exitPoint().x());
0714     h4ey[ir]->Fill(itHit->entryPoint().y() - itHit->exitPoint().y());
0715     h4ez[ir]->Fill(std::fabs(itHit->entryPoint().z() - itHit->exitPoint().z()));
0716     h4lx[ir]->Fill(itHit->localPosition().x());
0717     h4ly[ir]->Fill(itHit->localPosition().y());
0718   }
0719 
0720   return;
0721 }
0722 
0723 DEFINE_FWK_MODULE(TrackerHitAnalyzer);