Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2022-08-26 00:19:08

0001 // Package:    SiOuterTracker
0002 // Class:      SiOuterTracker
0003 //
0004 // Author: Emily MacDonald (emily.kaelyn.macdonald@cern.ch)
0005 
0006 // system include files
0007 #include <memory>
0008 #include <vector>
0009 #include <numeric>
0010 #include <iostream>
0011 #include <fstream>
0012 #include <string>
0013 
0014 // user include files
0015 #include "DataFormats/Common/interface/DetSetVector.h"
0016 #include "DataFormats/Common/interface/DetSetVectorNew.h"
0017 #include "DataFormats/Common/interface/Ptr.h"
0018 #include "DataFormats/Common/interface/Ref.h"
0019 #include "DataFormats/L1TrackTrigger/interface/TTCluster.h"
0020 #include "DataFormats/L1TrackTrigger/interface/TTStub.h"
0021 #include "DataFormats/L1TrackTrigger/interface/TTTrack.h"
0022 #include "DataFormats/SiStripDetId/interface/StripSubdetector.h"
0023 #include "DataFormats/TrackerCommon/interface/TrackerTopology.h"
0024 
0025 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0026 #include "Geometry/Records/interface/TrackerDigiGeometryRecord.h"
0027 #include "Geometry/CommonDetUnit/interface/GeomDet.h"
0028 #include "Geometry/TrackerGeometryBuilder/interface/TrackerGeometry.h"
0029 #include "Geometry/TrackerGeometryBuilder/interface/StripGeomDetUnit.h"
0030 #include "SimDataFormats/TrackingAnalysis/interface/TrackingParticle.h"
0031 #include "SimTracker/TrackTriggerAssociation/interface/TTStubAssociationMap.h"
0032 #include "SimTracker/TrackTriggerAssociation/interface/TTTrackAssociationMap.h"
0033 #include "SimTracker/TrackTriggerAssociation/interface/TTClusterAssociationMap.h"
0034 
0035 #include "DQMOffline/L1Trigger/interface/L1TPhase2OuterTrackerTkMET.h"
0036 
0037 // constructors and destructor
0038 L1TPhase2OuterTrackerTkMET::L1TPhase2OuterTrackerTkMET(const edm::ParameterSet& iConfig)
0039     : conf_(iConfig), m_topoToken(esConsumes()) {
0040   topFolderName_ = conf_.getParameter<std::string>("TopFolderName");
0041   ttTrackToken_ =
0042       consumes<std::vector<TTTrack<Ref_Phase2TrackerDigi_> > >(conf_.getParameter<edm::InputTag>("TTTracksTag"));
0043   pvToken = consumes<l1t::VertexWordCollection>(conf_.getParameter<edm::InputTag>("L1VertexInputTag"));
0044 
0045   maxZ0 = conf_.getParameter<double>("maxZ0");
0046   DeltaZ = conf_.getParameter<double>("DeltaZ");
0047   chi2dofMax = conf_.getParameter<double>("chi2dofMax");
0048   bendchi2Max = conf_.getParameter<double>("bendchi2Max");
0049   minPt = conf_.getParameter<double>("minPt");
0050   nStubsmin = iConfig.getParameter<int>("nStubsmin");
0051   nStubsPSmin = iConfig.getParameter<int>("nStubsPSmin");
0052   maxPt = conf_.getParameter<double>("maxPt");
0053   maxEta = conf_.getParameter<double>("maxEta");
0054   HighPtTracks = iConfig.getParameter<int>("HighPtTracks");
0055 }
0056 
0057 L1TPhase2OuterTrackerTkMET::~L1TPhase2OuterTrackerTkMET() {
0058   // do anything here that needs to be done at desctruction time
0059   // (e.g. close files, deallocate resources etc.)
0060 }
0061 
0062 // member functions
0063 
0064 // ------------ method called for each event  ------------
0065 void L1TPhase2OuterTrackerTkMET::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup) {
0066   // L1 Primaries
0067   edm::Handle<l1t::VertexWordCollection> L1VertexHandle;
0068   iEvent.getByToken(pvToken, L1VertexHandle);
0069 
0070   edm::Handle<std::vector<TTTrack<Ref_Phase2TrackerDigi_> > > TTTrackHandle;
0071   iEvent.getByToken(ttTrackToken_, TTTrackHandle);
0072 
0073   // for PS stubs
0074   // Tracker Topology
0075   const TrackerTopology* const tTopo = &iSetup.getData(m_topoToken);
0076 
0077   // Adding protection
0078   if (!TTTrackHandle.isValid()) {
0079     edm::LogWarning("L1TPhase2OuterTrackerTkMET") << "cant find tracks" << std::endl;
0080     return;
0081   }
0082   if (!L1VertexHandle.isValid()) {
0083     edm::LogWarning("L1TPhase2OuterTrackerTkMET") << "cant find vertex" << std::endl;
0084     return;
0085   }
0086   float sumPx = 0;
0087   float sumPy = 0;
0088   float etTot = 0;
0089   double sumPx_PU = 0;
0090   double sumPy_PU = 0;
0091   double etTot_PU = 0;
0092   int nTracks_counter = 0;
0093 
0094   float zVTX = L1VertexHandle->begin()->z0();
0095   unsigned int tkCnt = 0;
0096   for (const auto& trackIter : *TTTrackHandle) {
0097     edm::Ptr<TTTrack<Ref_Phase2TrackerDigi_> > tempTrackPtr(TTTrackHandle, tkCnt++);  /// Make the pointer
0098     float pt = tempTrackPtr->momentum().perp();
0099     float phi = tempTrackPtr->momentum().phi();
0100     float eta = tempTrackPtr->momentum().eta();
0101     std::vector<edm::Ref<edmNew::DetSetVector<TTStub<Ref_Phase2TrackerDigi_> >, TTStub<Ref_Phase2TrackerDigi_> > >
0102         theStubs = trackIter.getStubRefs();
0103     int nstubs = (int)theStubs.size();
0104 
0105     float chi2dof = tempTrackPtr->chi2Red();
0106     float bendchi2 = tempTrackPtr->stubPtConsistency();
0107     float z0 = tempTrackPtr->z0();
0108 
0109     if (pt < minPt || fabs(z0) > maxZ0 || fabs(eta) > maxEta || chi2dof > chi2dofMax || bendchi2 > bendchi2Max)
0110       continue;
0111     if (maxPt > 0 && pt > maxPt) {
0112       if (HighPtTracks == 0)
0113         continue;  // ignore these very high PT tracks: truncate
0114       if (HighPtTracks == 1)
0115         pt = maxPt;  // saturate
0116     }
0117 
0118     int nPS = 0.;  // number of stubs in PS modules
0119     // loop over the stubs
0120     for (unsigned int istub = 0; istub < (unsigned int)theStubs.size(); istub++) {
0121       DetId detId(theStubs.at(istub)->getDetId());
0122       if (detId.det() == DetId::Detector::Tracker) {
0123         if ((detId.subdetId() == StripSubdetector::TOB && tTopo->tobLayer(detId) <= 3) ||
0124             (detId.subdetId() == StripSubdetector::TID && tTopo->tidRing(detId) <= 9))
0125           nPS++;
0126       }
0127     }
0128 
0129     if (nstubs < nStubsmin || nPS < nStubsPSmin)
0130       continue;
0131 
0132     // construct deltaZ cut to be based on track eta
0133     if (fabs(eta) >= 0 && fabs(eta) < 0.7)
0134       DeltaZ = 0.4;
0135     else if (fabs(eta) >= 0.7 && fabs(eta) < 1.0)
0136       DeltaZ = 0.6;
0137     else if (fabs(eta) >= 1.0 && fabs(eta) < 1.2)
0138       DeltaZ = 0.76;
0139     else if (fabs(eta) >= 1.2 && fabs(eta) < 1.6)
0140       DeltaZ = 1.0;
0141     else if (fabs(eta) >= 1.6 && fabs(eta) < 2.0)
0142       DeltaZ = 1.7;
0143     else if (fabs(eta) >= 2.0 && fabs(eta) <= 2.4)
0144       DeltaZ = 2.2;
0145 
0146     if (fabs(z0 - zVTX) <= DeltaZ) {
0147       nTracks_counter++;
0148       Track_Pt->Fill(pt);
0149       Track_NStubs->Fill(nstubs);
0150       Track_NPSstubs->Fill(nPS);
0151       Track_Eta->Fill(eta);
0152       Track_VtxZ->Fill(z0);
0153       Track_Chi2Dof->Fill(chi2dof);
0154       Track_BendChi2->Fill(bendchi2);
0155 
0156       sumPx += pt * cos(phi);
0157       sumPy += pt * sin(phi);
0158       etTot += pt;
0159     } else {  // PU sums
0160       sumPx_PU += pt * cos(phi);
0161       sumPy_PU += pt * sin(phi);
0162       etTot_PU += pt;
0163     }
0164   }  // end loop over tracks
0165 
0166   Track_N->Fill(nTracks_counter);
0167   float et = sqrt(sumPx * sumPx + sumPy * sumPy);
0168   double etmiss_PU = sqrt(sumPx_PU * sumPx_PU + sumPy_PU * sumPy_PU);
0169 
0170   math::XYZTLorentzVector missingEt(-sumPx, -sumPy, 0, et);
0171 
0172   TkMET_QualityCuts->Fill(missingEt.Pt());
0173   TkMET_PU->Fill(etmiss_PU);
0174 
0175 }  // end of method
0176 
0177 // ------------ method called once each job just before starting event loop  ------------
0178 //Creating all histograms for DQM file output
0179 void L1TPhase2OuterTrackerTkMET::bookHistograms(DQMStore::IBooker& iBooker,
0180                                                 edm::Run const& run,
0181                                                 edm::EventSetup const& es) {
0182   std::string HistoName;
0183   iBooker.setCurrentFolder(topFolderName_ + "/TkMET_Tracks/");
0184 
0185   // Num of L1Tracks in tkMET selection
0186   HistoName = "Track_N";
0187   edm::ParameterSet psTrack_N = conf_.getParameter<edm::ParameterSet>("TH1_NTracks");
0188   Track_N = iBooker.book1D(HistoName,
0189                            HistoName,
0190                            psTrack_N.getParameter<int32_t>("Nbinsx"),
0191                            psTrack_N.getParameter<double>("xmin"),
0192                            psTrack_N.getParameter<double>("xmax"));
0193   Track_N->setAxisTitle("# L1 Tracks", 1);
0194   Track_N->setAxisTitle("# Events", 2);
0195 
0196   //Pt of the tracks
0197   edm::ParameterSet psTrack_Pt = conf_.getParameter<edm::ParameterSet>("TH1_Track_Pt");
0198   HistoName = "Track_Pt";
0199   Track_Pt = iBooker.book1D(HistoName,
0200                             HistoName,
0201                             psTrack_Pt.getParameter<int32_t>("Nbinsx"),
0202                             psTrack_Pt.getParameter<double>("xmin"),
0203                             psTrack_Pt.getParameter<double>("xmax"));
0204   Track_Pt->setAxisTitle("p_{T} [GeV]", 1);
0205   Track_Pt->setAxisTitle("# L1 Tracks", 2);
0206 
0207   //Eta
0208   edm::ParameterSet psTrack_Eta = conf_.getParameter<edm::ParameterSet>("TH1_Track_Eta");
0209   HistoName = "Track_Eta";
0210   Track_Eta = iBooker.book1D(HistoName,
0211                              HistoName,
0212                              psTrack_Eta.getParameter<int32_t>("Nbinsx"),
0213                              psTrack_Eta.getParameter<double>("xmin"),
0214                              psTrack_Eta.getParameter<double>("xmax"));
0215   Track_Eta->setAxisTitle("#eta", 1);
0216   Track_Eta->setAxisTitle("# L1 Tracks", 2);
0217 
0218   //VtxZ
0219   edm::ParameterSet psTrack_VtxZ = conf_.getParameter<edm::ParameterSet>("TH1_Track_VtxZ");
0220   HistoName = "Track_VtxZ";
0221   Track_VtxZ = iBooker.book1D(HistoName,
0222                               HistoName,
0223                               psTrack_VtxZ.getParameter<int32_t>("Nbinsx"),
0224                               psTrack_VtxZ.getParameter<double>("xmin"),
0225                               psTrack_VtxZ.getParameter<double>("xmax"));
0226   Track_VtxZ->setAxisTitle("L1 Track vertex position z [cm]", 1);
0227   Track_VtxZ->setAxisTitle("# L1 Tracks", 2);
0228 
0229   //chi2dof
0230   edm::ParameterSet psTrack_Chi2Dof = conf_.getParameter<edm::ParameterSet>("TH1_Track_Chi2Dof");
0231   HistoName = "Track_Chi2Dof";
0232   Track_Chi2Dof = iBooker.book1D(HistoName,
0233                                  HistoName,
0234                                  psTrack_Chi2Dof.getParameter<int32_t>("Nbinsx"),
0235                                  psTrack_Chi2Dof.getParameter<double>("xmin"),
0236                                  psTrack_Chi2Dof.getParameter<double>("xmax"));
0237   Track_Chi2Dof->setAxisTitle("L1 Track #chi^{2}/D.O.F.", 1);
0238   Track_Chi2Dof->setAxisTitle("# L1 Tracks", 2);
0239 
0240   //bend chi2
0241   edm::ParameterSet psTrack_BendChi2 = conf_.getParameter<edm::ParameterSet>("TH1_Track_BendChi2");
0242   HistoName = "Track_BendChi2";
0243   Track_BendChi2 = iBooker.book1D(HistoName,
0244                                   HistoName,
0245                                   psTrack_BendChi2.getParameter<int32_t>("Nbinsx"),
0246                                   psTrack_BendChi2.getParameter<double>("xmin"),
0247                                   psTrack_BendChi2.getParameter<double>("xmax"));
0248   Track_BendChi2->setAxisTitle("L1 Track Bend #chi^{2}", 1);
0249   Track_BendChi2->setAxisTitle("# L1 Tracks", 2);
0250 
0251   //nstubs
0252   edm::ParameterSet psTrack_NStubs = conf_.getParameter<edm::ParameterSet>("TH1_Track_NStubs");
0253   HistoName = "Track_NStubs";
0254   Track_NStubs = iBooker.book1D(HistoName,
0255                                 HistoName,
0256                                 psTrack_NStubs.getParameter<int32_t>("Nbinsx"),
0257                                 psTrack_NStubs.getParameter<double>("xmin"),
0258                                 psTrack_NStubs.getParameter<double>("xmax"));
0259   Track_NStubs->setAxisTitle("# L1 Stubs", 1);
0260   Track_NStubs->setAxisTitle("# L1 Tracks", 2);
0261 
0262   //nPSstubs
0263   edm::ParameterSet psTrack_NPSstubs = conf_.getParameter<edm::ParameterSet>("TH1_Track_NPSstubs");
0264   HistoName = "Track_NPSstubs";
0265   Track_NPSstubs = iBooker.book1D(HistoName,
0266                                   HistoName,
0267                                   psTrack_NPSstubs.getParameter<int32_t>("Nbinsx"),
0268                                   psTrack_NPSstubs.getParameter<double>("xmin"),
0269                                   psTrack_NPSstubs.getParameter<double>("xmax"));
0270   Track_NPSstubs->setAxisTitle("# PS Stubs", 1);
0271   Track_NPSstubs->setAxisTitle("# L1 Tracks", 2);
0272 
0273   iBooker.setCurrentFolder(topFolderName_ + "/TkMET");
0274   //loose tkMET
0275   edm::ParameterSet psTrack_TkMET = conf_.getParameter<edm::ParameterSet>("TH1_Track_TkMET");
0276   HistoName = "TkMET_QualityCuts";
0277   TkMET_QualityCuts = iBooker.book1D(HistoName,
0278                                      HistoName,
0279                                      psTrack_TkMET.getParameter<int32_t>("Nbinsx"),
0280                                      psTrack_TkMET.getParameter<double>("xmin"),
0281                                      psTrack_TkMET.getParameter<double>("xmax"));
0282   TkMET_QualityCuts->setAxisTitle("L1 Track MET [GeV]", 1);
0283   TkMET_QualityCuts->setAxisTitle("# Events", 2);
0284 
0285   //tkMET -- PU only
0286   HistoName = "TkMET_PU";
0287   TkMET_PU = iBooker.book1D(HistoName,
0288                             HistoName,
0289                             psTrack_TkMET.getParameter<int32_t>("Nbinsx"),
0290                             psTrack_TkMET.getParameter<double>("xmin"),
0291                             psTrack_TkMET.getParameter<double>("xmax"));
0292   TkMET_PU->setAxisTitle("L1 Track MET (PU only) [GeV]", 1);
0293   TkMET_PU->setAxisTitle("# Events", 2);
0294 }  //end of method
0295 
0296 DEFINE_FWK_MODULE(L1TPhase2OuterTrackerTkMET);