CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
L1TPhase2OuterTrackerTkMET.cc
Go to the documentation of this file.
1 // Package: SiOuterTracker
2 // Class: SiOuterTracker
3 //
4 // Author: Emily MacDonald (emily.kaelyn.macdonald@cern.ch)
5 
6 // system include files
7 #include <memory>
8 #include <vector>
9 #include <numeric>
10 #include <iostream>
11 #include <fstream>
12 #include <string>
13 
14 // user include files
24 
35 
37 
38 // constructors and destructor
40  : conf_(iConfig), m_topoToken(esConsumes()) {
41  topFolderName_ = conf_.getParameter<std::string>("TopFolderName");
43  consumes<std::vector<TTTrack<Ref_Phase2TrackerDigi_> > >(conf_.getParameter<edm::InputTag>("TTTracksTag"));
44  pvToken = consumes<l1t::TkPrimaryVertexCollection>(conf_.getParameter<edm::InputTag>("L1VertexInputTag"));
45 
46  maxZ0 = conf_.getParameter<double>("maxZ0");
47  DeltaZ = conf_.getParameter<double>("DeltaZ");
48  chi2dofMax = conf_.getParameter<double>("chi2dofMax");
49  bendchi2Max = conf_.getParameter<double>("bendchi2Max");
50  minPt = conf_.getParameter<double>("minPt");
51  nStubsmin = iConfig.getParameter<int>("nStubsmin");
52  nStubsPSmin = iConfig.getParameter<int>("nStubsPSmin");
53  maxPt = conf_.getParameter<double>("maxPt");
54  maxEta = conf_.getParameter<double>("maxEta");
55  HighPtTracks = iConfig.getParameter<int>("HighPtTracks");
56 }
57 
59  // do anything here that needs to be done at desctruction time
60  // (e.g. close files, deallocate resources etc.)
61 }
62 
63 // member functions
64 
65 // ------------ method called for each event ------------
67  // L1 Primaries
69  iEvent.getByToken(pvToken, L1VertexHandle);
70 
72  iEvent.getByToken(ttTrackToken_, TTTrackHandle);
73 
74  // for PS stubs
75  // Tracker Topology
76  const TrackerTopology* const tTopo = &iSetup.getData(m_topoToken);
77 
78  // Adding protection
79  if (!TTTrackHandle.isValid()) {
80  edm::LogWarning("L1TPhase2OuterTrackerTkMET") << "cant find tracks" << std::endl;
81  return;
82  }
83  if (!L1VertexHandle.isValid()) {
84  edm::LogWarning("L1TPhase2OuterTrackerTkMET") << "cant find vertex" << std::endl;
85  return;
86  }
87  float sumPx = 0;
88  float sumPy = 0;
89  float etTot = 0;
90  double sumPx_PU = 0;
91  double sumPy_PU = 0;
92  double etTot_PU = 0;
93  int nTracks_counter = 0;
94 
95  float zVTX = L1VertexHandle->begin()->zvertex();
96  unsigned int tkCnt = 0;
97  for (const auto& trackIter : *TTTrackHandle) {
98  edm::Ptr<TTTrack<Ref_Phase2TrackerDigi_> > tempTrackPtr(TTTrackHandle, tkCnt++);
99  float pt = tempTrackPtr->momentum().perp();
100  float phi = tempTrackPtr->momentum().phi();
101  float eta = tempTrackPtr->momentum().eta();
102  std::vector<edm::Ref<edmNew::DetSetVector<TTStub<Ref_Phase2TrackerDigi_> >, TTStub<Ref_Phase2TrackerDigi_> > >
103  theStubs = trackIter.getStubRefs();
104  int nstubs = (int)theStubs.size();
105 
106  float chi2dof = tempTrackPtr->chi2Red();
107  float bendchi2 = tempTrackPtr->stubPtConsistency();
108  float z0 = tempTrackPtr->z0();
109 
110  if (pt < minPt || fabs(z0) > maxZ0 || fabs(eta) > maxEta || chi2dof > chi2dofMax || bendchi2 > bendchi2Max)
111  continue;
112  if (maxPt > 0 && pt > maxPt) {
113  if (HighPtTracks == 0)
114  continue; // ignore these very high PT tracks: truncate
115  if (HighPtTracks == 1)
116  pt = maxPt; // saturate
117  }
118 
119  int nPS = 0.; // number of stubs in PS modules
120  // loop over the stubs
121  for (unsigned int istub = 0; istub < (unsigned int)theStubs.size(); istub++) {
122  DetId detId(theStubs.at(istub)->getDetId());
123  if (detId.det() == DetId::Detector::Tracker) {
124  if ((detId.subdetId() == StripSubdetector::TOB && tTopo->tobLayer(detId) <= 3) ||
125  (detId.subdetId() == StripSubdetector::TID && tTopo->tidRing(detId) <= 9))
126  nPS++;
127  }
128  }
129 
130  if (nstubs < nStubsmin || nPS < nStubsPSmin)
131  continue;
132 
133  // construct deltaZ cut to be based on track eta
134  if (fabs(eta) >= 0 && fabs(eta) < 0.7)
135  DeltaZ = 0.4;
136  else if (fabs(eta) >= 0.7 && fabs(eta) < 1.0)
137  DeltaZ = 0.6;
138  else if (fabs(eta) >= 1.0 && fabs(eta) < 1.2)
139  DeltaZ = 0.76;
140  else if (fabs(eta) >= 1.2 && fabs(eta) < 1.6)
141  DeltaZ = 1.0;
142  else if (fabs(eta) >= 1.6 && fabs(eta) < 2.0)
143  DeltaZ = 1.7;
144  else if (fabs(eta) >= 2.0 && fabs(eta) <= 2.4)
145  DeltaZ = 2.2;
146 
147  if (fabs(z0 - zVTX) <= DeltaZ) {
148  nTracks_counter++;
149  Track_Pt->Fill(pt);
150  Track_NStubs->Fill(nstubs);
151  Track_NPSstubs->Fill(nPS);
152  Track_Eta->Fill(eta);
153  Track_VtxZ->Fill(z0);
154  Track_Chi2Dof->Fill(chi2dof);
155  Track_BendChi2->Fill(bendchi2);
156 
157  sumPx += pt * cos(phi);
158  sumPy += pt * sin(phi);
159  etTot += pt;
160  } else { // PU sums
161  sumPx_PU += pt * cos(phi);
162  sumPy_PU += pt * sin(phi);
163  etTot_PU += pt;
164  }
165  } // end loop over tracks
166 
167  Track_N->Fill(nTracks_counter);
168  float et = sqrt(sumPx * sumPx + sumPy * sumPy);
169  double etmiss_PU = sqrt(sumPx_PU * sumPx_PU + sumPy_PU * sumPy_PU);
170 
171  math::XYZTLorentzVector missingEt(-sumPx, -sumPy, 0, et);
172 
173  TkMET_QualityCuts->Fill(missingEt.Pt());
174  TkMET_PU->Fill(etmiss_PU);
175 
176 } // end of method
177 
178 // ------------ method called once each job just before starting event loop ------------
179 //Creating all histograms for DQM file output
181  edm::Run const& run,
182  edm::EventSetup const& es) {
184  iBooker.setCurrentFolder(topFolderName_ + "/TkMET_Tracks/");
185 
186  // Num of L1Tracks in tkMET selection
187  HistoName = "Track_N";
188  edm::ParameterSet psTrack_N = conf_.getParameter<edm::ParameterSet>("TH1_NTracks");
189  Track_N = iBooker.book1D(HistoName,
190  HistoName,
191  psTrack_N.getParameter<int32_t>("Nbinsx"),
192  psTrack_N.getParameter<double>("xmin"),
193  psTrack_N.getParameter<double>("xmax"));
194  Track_N->setAxisTitle("# L1 Tracks", 1);
195  Track_N->setAxisTitle("# Events", 2);
196 
197  //Pt of the tracks
198  edm::ParameterSet psTrack_Pt = conf_.getParameter<edm::ParameterSet>("TH1_Track_Pt");
199  HistoName = "Track_Pt";
200  Track_Pt = iBooker.book1D(HistoName,
201  HistoName,
202  psTrack_Pt.getParameter<int32_t>("Nbinsx"),
203  psTrack_Pt.getParameter<double>("xmin"),
204  psTrack_Pt.getParameter<double>("xmax"));
205  Track_Pt->setAxisTitle("p_{T} [GeV]", 1);
206  Track_Pt->setAxisTitle("# L1 Tracks", 2);
207 
208  //Eta
209  edm::ParameterSet psTrack_Eta = conf_.getParameter<edm::ParameterSet>("TH1_Track_Eta");
210  HistoName = "Track_Eta";
211  Track_Eta = iBooker.book1D(HistoName,
212  HistoName,
213  psTrack_Eta.getParameter<int32_t>("Nbinsx"),
214  psTrack_Eta.getParameter<double>("xmin"),
215  psTrack_Eta.getParameter<double>("xmax"));
216  Track_Eta->setAxisTitle("#eta", 1);
217  Track_Eta->setAxisTitle("# L1 Tracks", 2);
218 
219  //VtxZ
220  edm::ParameterSet psTrack_VtxZ = conf_.getParameter<edm::ParameterSet>("TH1_Track_VtxZ");
221  HistoName = "Track_VtxZ";
222  Track_VtxZ = iBooker.book1D(HistoName,
223  HistoName,
224  psTrack_VtxZ.getParameter<int32_t>("Nbinsx"),
225  psTrack_VtxZ.getParameter<double>("xmin"),
226  psTrack_VtxZ.getParameter<double>("xmax"));
227  Track_VtxZ->setAxisTitle("L1 Track vertex position z [cm]", 1);
228  Track_VtxZ->setAxisTitle("# L1 Tracks", 2);
229 
230  //chi2dof
231  edm::ParameterSet psTrack_Chi2Dof = conf_.getParameter<edm::ParameterSet>("TH1_Track_Chi2Dof");
232  HistoName = "Track_Chi2Dof";
233  Track_Chi2Dof = iBooker.book1D(HistoName,
234  HistoName,
235  psTrack_Chi2Dof.getParameter<int32_t>("Nbinsx"),
236  psTrack_Chi2Dof.getParameter<double>("xmin"),
237  psTrack_Chi2Dof.getParameter<double>("xmax"));
238  Track_Chi2Dof->setAxisTitle("L1 Track #chi^{2}/D.O.F.", 1);
239  Track_Chi2Dof->setAxisTitle("# L1 Tracks", 2);
240 
241  //bend chi2
242  edm::ParameterSet psTrack_BendChi2 = conf_.getParameter<edm::ParameterSet>("TH1_Track_BendChi2");
243  HistoName = "Track_BendChi2";
244  Track_BendChi2 = iBooker.book1D(HistoName,
245  HistoName,
246  psTrack_BendChi2.getParameter<int32_t>("Nbinsx"),
247  psTrack_BendChi2.getParameter<double>("xmin"),
248  psTrack_BendChi2.getParameter<double>("xmax"));
249  Track_BendChi2->setAxisTitle("L1 Track Bend #chi^{2}", 1);
250  Track_BendChi2->setAxisTitle("# L1 Tracks", 2);
251 
252  //nstubs
253  edm::ParameterSet psTrack_NStubs = conf_.getParameter<edm::ParameterSet>("TH1_Track_NStubs");
254  HistoName = "Track_NStubs";
255  Track_NStubs = iBooker.book1D(HistoName,
256  HistoName,
257  psTrack_NStubs.getParameter<int32_t>("Nbinsx"),
258  psTrack_NStubs.getParameter<double>("xmin"),
259  psTrack_NStubs.getParameter<double>("xmax"));
260  Track_NStubs->setAxisTitle("# L1 Stubs", 1);
261  Track_NStubs->setAxisTitle("# L1 Tracks", 2);
262 
263  //nPSstubs
264  edm::ParameterSet psTrack_NPSstubs = conf_.getParameter<edm::ParameterSet>("TH1_Track_NPSstubs");
265  HistoName = "Track_NPSstubs";
266  Track_NPSstubs = iBooker.book1D(HistoName,
267  HistoName,
268  psTrack_NPSstubs.getParameter<int32_t>("Nbinsx"),
269  psTrack_NPSstubs.getParameter<double>("xmin"),
270  psTrack_NPSstubs.getParameter<double>("xmax"));
271  Track_NPSstubs->setAxisTitle("# PS Stubs", 1);
272  Track_NPSstubs->setAxisTitle("# L1 Tracks", 2);
273 
274  iBooker.setCurrentFolder(topFolderName_ + "/TkMET");
275  //loose tkMET
276  edm::ParameterSet psTrack_TkMET = conf_.getParameter<edm::ParameterSet>("TH1_Track_TkMET");
277  HistoName = "TkMET_QualityCuts";
278  TkMET_QualityCuts = iBooker.book1D(HistoName,
279  HistoName,
280  psTrack_TkMET.getParameter<int32_t>("Nbinsx"),
281  psTrack_TkMET.getParameter<double>("xmin"),
282  psTrack_TkMET.getParameter<double>("xmax"));
283  TkMET_QualityCuts->setAxisTitle("L1 Track MET [GeV]", 1);
284  TkMET_QualityCuts->setAxisTitle("# Events", 2);
285 
286  //tkMET -- PU only
287  HistoName = "TkMET_PU";
288  TkMET_PU = iBooker.book1D(HistoName,
289  HistoName,
290  psTrack_TkMET.getParameter<int32_t>("Nbinsx"),
291  psTrack_TkMET.getParameter<double>("xmin"),
292  psTrack_TkMET.getParameter<double>("xmax"));
293  TkMET_PU->setAxisTitle("L1 Track MET (PU only) [GeV]", 1);
294  TkMET_PU->setAxisTitle("# Events", 2);
295 } //end of method
296 
unsigned int tidRing(const DetId &id) const
virtual void setCurrentFolder(std::string const &fullpath)
Definition: DQMStore.cc:32
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:539
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
Sin< T >::type sin(const T &t)
Definition: Sin.h:22
void Fill(long long x)
bool getData(T &iHolder) const
Definition: EventSetup.h:122
XYZTLorentzVectorD XYZTLorentzVector
Lorentz vector with cylindrical internal representation using pseudorapidity.
Definition: LorentzVector.h:29
edm::EDGetTokenT< std::vector< TTTrack< Ref_Phase2TrackerDigi_ > > > ttTrackToken_
int iEvent
Definition: GenABIO.cc:224
T sqrt(T t)
Definition: SSEVec.h:19
void bookHistograms(DQMStore::IBooker &, edm::Run const &, edm::EventSetup const &) override
Cos< T >::type cos(const T &t)
Definition: Cos.h:22
L1TPhase2OuterTrackerTkMET(const edm::ParameterSet &)
static constexpr auto TOB
bool isValid() const
Definition: HandleBase.h:70
Class to store the L1 Track Trigger stubs.
Definition: TTStub.h:22
edm::EDGetTokenT< l1t::TkPrimaryVertexCollection > pvToken
Definition: DetId.h:17
void analyze(const edm::Event &, const edm::EventSetup &) override
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
std::string HistoName
const edm::ESGetToken< TrackerTopology, TrackerTopologyRcd > m_topoToken
Log< level::Warning, false > LogWarning
MonitorElement * book1D(TString const &name, TString const &title, int const nchX, double const lowX, double const highX, FUNC onbooking=NOOP())
Definition: DQMStore.h:98
static constexpr auto TID
ESGetTokenH3DDVariant esConsumes(std::string const &Reccord, edm::ConsumesCollector &)
Definition: DeDxTools.cc:283
unsigned int tobLayer(const DetId &id) const
Definition: Run.h:45
virtual void setAxisTitle(const std::string &title, int axis=1)
set x-, y- or z-axis title (axis=1, 2, 3 respectively)