CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
L1TrackObjectNtupleMaker.cc
Go to the documentation of this file.
1 // //
3 // Analyzer for making mini-ntuple for L1 track performance plots //
4 // //
6 
8 // FRAMEWORK HEADERS
19 
21 // DATA FORMATS HEADERS
24 
37 
40 
42 // DETECTOR GEOMETRY HEADERS
50 
55 
57 // PHYSICS TOOLS
59 
60 //My additions
69 
71 // ROOT HEADERS
72 #include <TROOT.h>
73 #include <TCanvas.h>
74 #include <TTree.h>
75 #include <TFile.h>
76 #include <TF1.h>
77 #include <TH2F.h>
78 #include <TH1F.h>
79 #include <TLorentzVector.h>
80 
82 // STD HEADERS
83 #include <memory>
84 #include <string>
85 #include <iostream>
86 
88 // NAMESPACES
89 using namespace std;
90 using namespace edm;
91 
93 // //
94 // CLASS DEFINITION //
95 // //
97 
99 public:
100  // Constructor/destructor
102  ~L1TrackObjectNtupleMaker() override;
103 
104  // Mandatory methods
105  void beginJob();
106  void endJob();
107  void analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup) override;
108 
109 protected:
110 private:
111  //-----------------------------------------------------------------------------------------------
112  // Containers of parameters passed by python configuration file
114 
115  int MyProcess; // 11/13/211 for single electrons/muons/pions, 6/15 for pions from ttbar/taus, 1 for inclusive
116  bool DebugMode; // lots of debug printout statements
117  bool SaveAllTracks; // store in ntuples not only truth-matched tracks but ALL tracks
118  bool SaveStubs; // option to save also stubs in the ntuples (makes them large...)
119  string Displaced; // "Prompt", "Displaced", "Both"
120  int TP_minNStub; // require TPs to have >= minNStub (defining efficiency denominator) (==0 means to only require >= 1 cluster)
121  int TP_minNStubLayer; // require TPs to have stubs in >= minNStubLayer layers/disks (defining efficiency denominator)
122  double TP_minPt; // save TPs with pt > minPt
123  double TP_maxEta; // save TPs with |eta| < maxEta
124  double TP_maxZ0; // save TPs with |z0| < maxZ0
125  int L1Tk_minNStub; // require L1 tracks to have >= minNStub (this is mostly for tracklet purposes)
126  bool TrackingInJets; // do tracking in jets?
129 
130  edm::InputTag L1TrackInputTag; // L1 track collection
131  edm::InputTag MCTruthTrackInputTag; // MC truth collection
132  edm::InputTag L1TrackExtendedInputTag; // L1 track collection
142 
147 
152 
157 
162 
165 
169 
178 
181 
182  //-----------------------------------------------------------------------------------------------
183  // tree & branches for mini-ntuple
184 
185  bool available_; // ROOT file for histograms is open.
186 
187  TTree* eventTree;
188 
189  // primary vertex
190  // std::vector<float>* m_pv_L1recotruesumpt;
191  // std::vector<float>* m_pv_L1recosumpt;
192  std::vector<float>* m_pv_L1reco;
193  // std::vector<float>* m_pv_L1TP;
194  // std::vector<float>* m_pv_L1TPsumpt;
195  std::vector<float>* m_pv_MC;
196  // std::vector<float>* m_pv_MCChgSumpT;
197  std::vector<int>* m_MC_lep;
198 
199  // all L1 tracks (prompt)
200  std::vector<float>* m_trk_pt;
201  std::vector<float>* m_trk_eta;
202  std::vector<float>* m_trk_phi;
203  std::vector<float>* m_trk_d0; // (filled if nFitPar==5, else 999)
204  std::vector<float>* m_trk_z0;
205  std::vector<float>* m_trk_chi2;
206  std::vector<float>* m_trk_chi2dof;
207  std::vector<float>* m_trk_chi2rphi;
208  std::vector<float>* m_trk_chi2rz;
209  std::vector<float>* m_trk_bendchi2;
210  std::vector<int>* m_trk_nstub;
211  std::vector<int>* m_trk_lhits;
212  std::vector<int>* m_trk_dhits;
213  std::vector<int>* m_trk_seed;
214  std::vector<int>* m_trk_hitpattern;
215  std::vector<unsigned int>* m_trk_phiSector;
216  std::vector<int>* m_trk_genuine;
217  std::vector<int>* m_trk_loose;
218  std::vector<int>* m_trk_unknown;
219  std::vector<int>* m_trk_combinatoric;
220  std::vector<int>* m_trk_fake; //0 fake, 1 track from primary interaction, 2 secondary track
221  std::vector<int>* m_trk_matchtp_pdgid;
222  std::vector<float>* m_trk_matchtp_pt;
223  std::vector<float>* m_trk_matchtp_eta;
224  std::vector<float>* m_trk_matchtp_phi;
225  std::vector<float>* m_trk_matchtp_z0;
226  std::vector<float>* m_trk_matchtp_dxy;
227 
228  // all L1 tracks (extended)
229  std::vector<float>* m_trkExt_pt;
230  std::vector<float>* m_trkExt_eta;
231  std::vector<float>* m_trkExt_phi;
232  std::vector<float>* m_trkExt_d0; // (filled if nFitPar==5, else 999)
233  std::vector<float>* m_trkExt_z0;
234  std::vector<float>* m_trkExt_chi2;
235  std::vector<float>* m_trkExt_chi2dof;
236  std::vector<float>* m_trkExt_chi2rphi;
237  std::vector<float>* m_trkExt_chi2rz;
238  std::vector<float>* m_trkExt_bendchi2;
239  std::vector<int>* m_trkExt_nstub;
240  std::vector<int>* m_trkExt_lhits;
241  std::vector<int>* m_trkExt_dhits;
242  std::vector<int>* m_trkExt_seed;
243  std::vector<int>* m_trkExt_hitpattern;
244  std::vector<unsigned int>* m_trkExt_phiSector;
245  std::vector<int>* m_trkExt_genuine;
246  std::vector<int>* m_trkExt_loose;
247  std::vector<int>* m_trkExt_unknown;
248  std::vector<int>* m_trkExt_combinatoric;
249  std::vector<int>* m_trkExt_fake; //0 fake, 1 track from primary interaction, 2 secondary track
250  std::vector<int>* m_trkExt_matchtp_pdgid;
251  std::vector<float>* m_trkExt_matchtp_pt;
252  std::vector<float>* m_trkExt_matchtp_eta;
253  std::vector<float>* m_trkExt_matchtp_phi;
254  std::vector<float>* m_trkExt_matchtp_z0;
255  std::vector<float>* m_trkExt_matchtp_dxy;
256 
257  // all tracking particles
258  std::vector<float>* m_tp_pt;
259  std::vector<float>* m_tp_eta;
260  std::vector<float>* m_tp_phi;
261  std::vector<float>* m_tp_dxy;
262  std::vector<float>* m_tp_d0;
263  std::vector<float>* m_tp_z0;
264  std::vector<float>* m_tp_d0_prod;
265  std::vector<float>* m_tp_z0_prod;
266  std::vector<int>* m_tp_pdgid;
267  std::vector<int>* m_tp_nmatch;
268  std::vector<int>* m_tp_nstub;
269  std::vector<int>* m_tp_eventid;
270  std::vector<int>* m_tp_charge;
271 
272  // *L1 track* properties if m_tp_nmatch > 0 (prompt)
273  std::vector<float>* m_matchtrk_pt;
274  std::vector<float>* m_matchtrk_eta;
275  std::vector<float>* m_matchtrk_phi;
276  std::vector<float>* m_matchtrk_d0; //this variable is only filled if nFitPar==5
277  std::vector<float>* m_matchtrk_z0;
278  std::vector<float>* m_matchtrk_chi2;
279  std::vector<float>* m_matchtrk_chi2dof;
280  std::vector<float>* m_matchtrk_chi2rphi;
281  std::vector<float>* m_matchtrk_chi2rz;
282  std::vector<float>* m_matchtrk_bendchi2;
283  std::vector<int>* m_matchtrk_nstub;
284  std::vector<int>* m_matchtrk_lhits;
285  std::vector<int>* m_matchtrk_dhits;
286  std::vector<int>* m_matchtrk_seed;
287  std::vector<int>* m_matchtrk_hitpattern;
288 
289  // *L1 track* properties if m_tp_nmatch > 0 (extended)
290  std::vector<float>* m_matchtrkExt_pt;
291  std::vector<float>* m_matchtrkExt_eta;
292  std::vector<float>* m_matchtrkExt_phi;
293  std::vector<float>* m_matchtrkExt_d0; //this variable is only filled if nFitPar==5
294  std::vector<float>* m_matchtrkExt_z0;
295  std::vector<float>* m_matchtrkExt_chi2;
296  std::vector<float>* m_matchtrkExt_chi2dof;
297  std::vector<float>* m_matchtrkExt_chi2rphi;
298  std::vector<float>* m_matchtrkExt_chi2rz;
299  std::vector<float>* m_matchtrkExt_bendchi2;
300  std::vector<int>* m_matchtrkExt_nstub;
301  std::vector<int>* m_matchtrkExt_lhits;
302  std::vector<int>* m_matchtrkExt_dhits;
303  std::vector<int>* m_matchtrkExt_seed;
304  std::vector<int>* m_matchtrkExt_hitpattern;
305 
306  // ALL stubs
307  std::vector<float>* m_allstub_x;
308  std::vector<float>* m_allstub_y;
309  std::vector<float>* m_allstub_z;
310  std::vector<int>* m_allstub_isBarrel; // stub is in barrel (1) or in disk (0)
311  std::vector<int>* m_allstub_layer;
312  std::vector<int>* m_allstub_isPSmodule;
313  std::vector<float>* m_allstub_trigDisplace;
314  std::vector<float>* m_allstub_trigOffset;
315  std::vector<float>* m_allstub_trigPos;
316  std::vector<float>* m_allstub_trigBend;
317 
318  // stub associated with tracking particle ?
319  std::vector<int>* m_allstub_matchTP_pdgid; // -999 if not matched
320  std::vector<float>* m_allstub_matchTP_pt; // -999 if not matched
321  std::vector<float>* m_allstub_matchTP_eta; // -999 if not matched
322  std::vector<float>* m_allstub_matchTP_phi; // -999 if not matched
323  std::vector<int>* m_allstub_genuine;
324 
325  // // track jet variables (for each gen jet, store the sum of pt of TPs / tracks inside jet cone)
326  // std::vector<float>* m_jet_eta;
327  // std::vector<float>* m_jet_phi;
328  // std::vector<float>* m_jet_pt;
329  // std::vector<float>* m_jet_tp_sumpt;
330  // std::vector<float>* m_jet_trk_sumpt;
331  // std::vector<float>* m_jet_matchtrk_sumpt;
332 
333  float trueMET = 0;
334  float trkMET = 0;
335  float trkMHT = 0;
336  float trkHT = 0;
337 
338  float trkMETExt = 0;
339  float trkMHTExt = 0;
340  float trkHTExt = 0;
341 
342  std::vector<float>* m_2ltrkjet_vz;
343  std::vector<float>* m_2ltrkjet_p;
344  std::vector<float>* m_2ltrkjet_phi;
345  std::vector<float>* m_2ltrkjet_eta;
346  std::vector<float>* m_2ltrkjet_pt;
347  std::vector<int>* m_2ltrkjet_ntracks;
348  std::vector<int>* m_2ltrkjet_nDisplaced;
349  std::vector<int>* m_2ltrkjet_nTight;
350  std::vector<int>* m_2ltrkjet_nTightDisplaced;
351  std::vector<int>* m_2ltrkjet_ntdtrk;
352 
353  std::vector<float>* m_trkjet_vz;
354  std::vector<float>* m_trkjet_p;
355  std::vector<float>* m_trkjet_phi;
356  std::vector<float>* m_trkjet_eta;
357  std::vector<float>* m_trkjet_pt;
358  std::vector<int>* m_trkjet_ntracks;
359  std::vector<float>* m_trkjet_tp_sumpt;
360  std::vector<float>* m_trkjet_truetp_sumpt;
361 
362  std::vector<float>* m_2ltrkjetExt_vz;
363  std::vector<float>* m_2ltrkjetExt_p;
364  std::vector<float>* m_2ltrkjetExt_phi;
365  std::vector<float>* m_2ltrkjetExt_eta;
366  std::vector<float>* m_2ltrkjetExt_pt;
367  std::vector<int>* m_2ltrkjetExt_ntracks;
368  std::vector<int>* m_2ltrkjetExt_nDisplaced;
369  std::vector<int>* m_2ltrkjetExt_nTight;
370  std::vector<int>* m_2ltrkjetExt_nTightDisplaced;
371  std::vector<int>* m_2ltrkjetExt_ntdtrk;
372 
373  std::vector<float>* m_trkjetExt_vz;
374  std::vector<float>* m_trkjetExt_p;
375  std::vector<float>* m_trkjetExt_phi;
376  std::vector<float>* m_trkjetExt_eta;
377  std::vector<float>* m_trkjetExt_pt;
378  std::vector<int>* m_trkjetExt_ntracks;
379  std::vector<float>* m_trkjetExt_tp_sumpt;
380  std::vector<float>* m_trkjetExt_truetp_sumpt;
381 };
382 
384 // //
385 // CLASS IMPLEMENTATION //
386 // //
388 
390 // CONSTRUCTOR
392  MyProcess = iConfig.getParameter<int>("MyProcess");
393  DebugMode = iConfig.getParameter<bool>("DebugMode");
394  SaveAllTracks = iConfig.getParameter<bool>("SaveAllTracks");
395  SaveStubs = iConfig.getParameter<bool>("SaveStubs");
396  Displaced = iConfig.getParameter<string>("Displaced");
397  TP_minNStub = iConfig.getParameter<int>("TP_minNStub");
398  TP_minNStubLayer = iConfig.getParameter<int>("TP_minNStubLayer");
399  TP_minPt = iConfig.getParameter<double>("TP_minPt");
400  TP_maxEta = iConfig.getParameter<double>("TP_maxEta");
401  TP_maxZ0 = iConfig.getParameter<double>("TP_maxZ0");
402  L1Tk_minNStub = iConfig.getParameter<int>("L1Tk_minNStub");
403 
404  TrackingInJets = iConfig.getParameter<bool>("TrackingInJets");
405  SaveTrackJets = iConfig.getParameter<bool>("SaveTrackJets");
406  SaveTrackMET = iConfig.getParameter<bool>("SaveTrackMET");
407 
408  L1StubInputTag = iConfig.getParameter<edm::InputTag>("L1StubInputTag");
409  MCTruthClusterInputTag = iConfig.getParameter<edm::InputTag>("MCTruthClusterInputTag");
410  MCTruthStubInputTag = iConfig.getParameter<edm::InputTag>("MCTruthStubInputTag");
411  TrackingParticleInputTag = iConfig.getParameter<edm::InputTag>("TrackingParticleInputTag");
412  TrackingVertexInputTag = iConfig.getParameter<edm::InputTag>("TrackingVertexInputTag");
413  GenJetInputTag = iConfig.getParameter<edm::InputTag>("GenJetInputTag");
414  RecoVertexInputTag = iConfig.getParameter<InputTag>("RecoVertexInputTag");
415  GenParticleInputTag = iConfig.getParameter<InputTag>("GenParticleInputTag");
416 
417  if (Displaced == "Prompt" || Displaced == "Both") {
418  L1TrackInputTag = iConfig.getParameter<edm::InputTag>("L1TrackInputTag");
419  MCTruthTrackInputTag = iConfig.getParameter<edm::InputTag>("MCTruthTrackInputTag");
420  TrackFastJetsInputTag = iConfig.getParameter<InputTag>("TrackFastJetsInputTag");
421  TrackJetsInputTag = iConfig.getParameter<InputTag>("TrackJetsInputTag");
422  TrackMETInputTag = iConfig.getParameter<InputTag>("TrackMETInputTag");
423  TrackMHTInputTag = iConfig.getParameter<InputTag>("TrackMHTInputTag");
424 
425  ttTrackToken_ = consumes<std::vector<TTTrack<Ref_Phase2TrackerDigi_> > >(L1TrackInputTag);
426  ttTrackMCTruthToken_ = consumes<TTTrackAssociationMap<Ref_Phase2TrackerDigi_> >(MCTruthTrackInputTag);
427  TrackFastJetsToken_ = consumes<std::vector<l1t::TkJet> >(TrackFastJetsInputTag);
428  TrackJetsToken_ = consumes<l1t::TkJetCollection>(TrackJetsInputTag);
429  TrackMETToken_ = consumes<std::vector<l1t::TkEtMiss> >(TrackMETInputTag);
430  TrackMHTToken_ = consumes<l1t::TkHTMissCollection>(TrackMHTInputTag);
431  }
432 
433  if (Displaced == "Displaced" || Displaced == "Both") {
434  L1TrackExtendedInputTag = iConfig.getParameter<edm::InputTag>("L1TrackExtendedInputTag");
435  MCTruthTrackExtendedInputTag = iConfig.getParameter<edm::InputTag>("MCTruthTrackExtendedInputTag");
436  TrackFastJetsExtendedInputTag = iConfig.getParameter<InputTag>("TrackFastJetsExtendedInputTag");
437  TrackJetsExtendedInputTag = iConfig.getParameter<InputTag>("TrackJetsExtendedInputTag");
438  TrackMETExtendedInputTag = iConfig.getParameter<InputTag>("TrackMETExtendedInputTag");
439  TrackMHTExtendedInputTag = iConfig.getParameter<InputTag>("TrackMHTExtendedInputTag");
440 
441  ttTrackExtendedToken_ = consumes<std::vector<TTTrack<Ref_Phase2TrackerDigi_> > >(L1TrackExtendedInputTag);
443  consumes<TTTrackAssociationMap<Ref_Phase2TrackerDigi_> >(MCTruthTrackExtendedInputTag);
444  TrackFastJetsExtendedToken_ = consumes<std::vector<l1t::TkJet> >(TrackFastJetsExtendedInputTag);
445  TrackJetsExtendedToken_ = consumes<l1t::TkJetCollection>(TrackJetsExtendedInputTag);
446  TrackMETExtendedToken_ = consumes<std::vector<l1t::TkEtMiss> >(TrackMETExtendedInputTag);
447  TrackMHTExtendedToken_ = consumes<l1t::TkHTMissCollection>(TrackMHTExtendedInputTag);
448  }
449 
450  ttStubToken_ = consumes<edmNew::DetSetVector<TTStub<Ref_Phase2TrackerDigi_> > >(L1StubInputTag);
451  ttClusterMCTruthToken_ = consumes<TTClusterAssociationMap<Ref_Phase2TrackerDigi_> >(MCTruthClusterInputTag);
452  ttStubMCTruthToken_ = consumes<TTStubAssociationMap<Ref_Phase2TrackerDigi_> >(MCTruthStubInputTag);
453  TrackingParticleToken_ = consumes<std::vector<TrackingParticle> >(TrackingParticleInputTag);
454  TrackingVertexToken_ = consumes<std::vector<TrackingVertex> >(TrackingVertexInputTag);
455  GenJetToken_ = consumes<std::vector<reco::GenJet> >(GenJetInputTag);
456  GenParticleToken_ = consumes<std::vector<reco::GenParticle> >(GenParticleInputTag);
457  L1VertexToken_ = consumes<l1t::TkPrimaryVertexCollection>(RecoVertexInputTag);
458 
459  tTopoToken_ = esConsumes<TrackerTopology, TrackerTopologyRcd>(edm::ESInputTag("", ""));
460  tGeomToken_ = esConsumes<TrackerGeometry, TrackerDigiGeometryRecord>(edm::ESInputTag("", ""));
461 }
462 
464 // DESTRUCTOR
466 
468 // END JOB
470  // things to be done at the exit of the event Loop
471  // edm::LogVerbatim("Tracklet") << "L1TrackObjectNtupleMaker::endJob";
472 }
473 
475 // BEGIN JOB
477  // things to be done before entering the event Loop
478  // edm::LogVerbatim("Tracklet") << "L1TrackObjectNtupleMaker::beginJob";
479 
480  //-----------------------------------------------------------------------------------------------
481  // book histograms / make ntuple
483  available_ = fs.isAvailable();
484  if (not available_)
485  return; // No ROOT file open.
486 
487  // initilize
488  m_trk_pt = new std::vector<float>;
489  m_trk_eta = new std::vector<float>;
490  m_trk_phi = new std::vector<float>;
491  m_trk_z0 = new std::vector<float>;
492  m_trk_d0 = new std::vector<float>;
493  m_trk_chi2 = new std::vector<float>;
494  m_trk_chi2dof = new std::vector<float>;
495  m_trk_chi2rphi = new std::vector<float>;
496  m_trk_chi2rz = new std::vector<float>;
497  m_trk_bendchi2 = new std::vector<float>;
498  m_trk_nstub = new std::vector<int>;
499  m_trk_lhits = new std::vector<int>;
500  m_trk_dhits = new std::vector<int>;
501  m_trk_seed = new std::vector<int>;
502  m_trk_hitpattern = new std::vector<int>;
503  m_trk_phiSector = new std::vector<unsigned int>;
504  m_trk_genuine = new std::vector<int>;
505  m_trk_loose = new std::vector<int>;
506  m_trk_unknown = new std::vector<int>;
507  m_trk_combinatoric = new std::vector<int>;
508  m_trk_fake = new std::vector<int>;
509  m_trk_matchtp_pdgid = new std::vector<int>;
510  m_trk_matchtp_pt = new std::vector<float>;
511  m_trk_matchtp_eta = new std::vector<float>;
512  m_trk_matchtp_phi = new std::vector<float>;
513  m_trk_matchtp_z0 = new std::vector<float>;
514  m_trk_matchtp_dxy = new std::vector<float>;
515 
516  m_trkExt_pt = new std::vector<float>;
517  m_trkExt_eta = new std::vector<float>;
518  m_trkExt_phi = new std::vector<float>;
519  m_trkExt_z0 = new std::vector<float>;
520  m_trkExt_d0 = new std::vector<float>;
521  m_trkExt_chi2 = new std::vector<float>;
522  m_trkExt_chi2dof = new std::vector<float>;
523  m_trkExt_chi2rphi = new std::vector<float>;
524  m_trkExt_chi2rz = new std::vector<float>;
525  m_trkExt_bendchi2 = new std::vector<float>;
526  m_trkExt_nstub = new std::vector<int>;
527  m_trkExt_lhits = new std::vector<int>;
528  m_trkExt_dhits = new std::vector<int>;
529  m_trkExt_seed = new std::vector<int>;
530  m_trkExt_hitpattern = new std::vector<int>;
531  m_trkExt_phiSector = new std::vector<unsigned int>;
532  m_trkExt_genuine = new std::vector<int>;
533  m_trkExt_loose = new std::vector<int>;
534  m_trkExt_unknown = new std::vector<int>;
535  m_trkExt_combinatoric = new std::vector<int>;
536  m_trkExt_fake = new std::vector<int>;
537  m_trkExt_matchtp_pdgid = new std::vector<int>;
538  m_trkExt_matchtp_pt = new std::vector<float>;
539  m_trkExt_matchtp_eta = new std::vector<float>;
540  m_trkExt_matchtp_phi = new std::vector<float>;
541  m_trkExt_matchtp_z0 = new std::vector<float>;
542  m_trkExt_matchtp_dxy = new std::vector<float>;
543 
544  m_tp_pt = new std::vector<float>;
545  m_tp_eta = new std::vector<float>;
546  m_tp_phi = new std::vector<float>;
547  m_tp_dxy = new std::vector<float>;
548  m_tp_d0 = new std::vector<float>;
549  m_tp_z0 = new std::vector<float>;
550  m_tp_d0_prod = new std::vector<float>;
551  m_tp_z0_prod = new std::vector<float>;
552  m_tp_pdgid = new std::vector<int>;
553  m_tp_nmatch = new std::vector<int>;
554  m_tp_nstub = new std::vector<int>;
555  m_tp_eventid = new std::vector<int>;
556  m_tp_charge = new std::vector<int>;
557 
558  m_matchtrk_pt = new std::vector<float>;
559  m_matchtrk_eta = new std::vector<float>;
560  m_matchtrk_phi = new std::vector<float>;
561  m_matchtrk_z0 = new std::vector<float>;
562  m_matchtrk_d0 = new std::vector<float>;
563  m_matchtrk_chi2 = new std::vector<float>;
564  m_matchtrk_chi2dof = new std::vector<float>;
565  m_matchtrk_chi2rphi = new std::vector<float>;
566  m_matchtrk_chi2rz = new std::vector<float>;
567  m_matchtrk_bendchi2 = new std::vector<float>;
568  m_matchtrk_nstub = new std::vector<int>;
569  m_matchtrk_dhits = new std::vector<int>;
570  m_matchtrk_lhits = new std::vector<int>;
571  m_matchtrk_seed = new std::vector<int>;
572  m_matchtrk_hitpattern = new std::vector<int>;
573 
574  m_matchtrkExt_pt = new std::vector<float>;
575  m_matchtrkExt_eta = new std::vector<float>;
576  m_matchtrkExt_phi = new std::vector<float>;
577  m_matchtrkExt_z0 = new std::vector<float>;
578  m_matchtrkExt_d0 = new std::vector<float>;
579  m_matchtrkExt_chi2 = new std::vector<float>;
580  m_matchtrkExt_chi2dof = new std::vector<float>;
581  m_matchtrkExt_chi2rphi = new std::vector<float>;
582  m_matchtrkExt_chi2rz = new std::vector<float>;
583  m_matchtrkExt_bendchi2 = new std::vector<float>;
584  m_matchtrkExt_nstub = new std::vector<int>;
585  m_matchtrkExt_dhits = new std::vector<int>;
586  m_matchtrkExt_lhits = new std::vector<int>;
587  m_matchtrkExt_seed = new std::vector<int>;
588  m_matchtrkExt_hitpattern = new std::vector<int>;
589 
590  m_allstub_x = new std::vector<float>;
591  m_allstub_y = new std::vector<float>;
592  m_allstub_z = new std::vector<float>;
593  m_allstub_isBarrel = new std::vector<int>;
594  m_allstub_layer = new std::vector<int>;
595  m_allstub_isPSmodule = new std::vector<int>;
596  m_allstub_trigDisplace = new std::vector<float>;
597  m_allstub_trigOffset = new std::vector<float>;
598  m_allstub_trigPos = new std::vector<float>;
599  m_allstub_trigBend = new std::vector<float>;
600  m_allstub_matchTP_pdgid = new std::vector<int>;
601  m_allstub_matchTP_pt = new std::vector<float>;
602  m_allstub_matchTP_eta = new std::vector<float>;
603  m_allstub_matchTP_phi = new std::vector<float>;
604  m_allstub_genuine = new std::vector<int>;
605 
606  // m_jet_eta = new std::vector<float>;
607  // m_jet_phi = new std::vector<float>;
608  // m_jet_pt = new std::vector<float>;
609  // m_jet_tp_sumpt = new std::vector<float>;
610  // m_jet_trk_sumpt = new std::vector<float>;
611  // m_jet_matchtrk_sumpt = new std::vector<float>;
612 
613  // m_pv_L1recotruesumpt = new std::vector<float>;
614  // m_pv_L1recosumpt = new std::vector<float>;
615  m_pv_L1reco = new std::vector<float>;
616  // m_pv_L1TP = new std::vector<float>;
617  // m_pv_L1TPsumpt = new std::vector<float>;
618  m_pv_MC = new std::vector<float>;
619  // m_pv_MCChgSumpT = new std::vector<float>;
620  m_MC_lep = new std::vector<int>;
621 
622  m_2ltrkjet_eta = new std::vector<float>;
623  m_2ltrkjet_vz = new std::vector<float>;
624  m_2ltrkjet_phi = new std::vector<float>;
625  m_2ltrkjet_p = new std::vector<float>;
626  m_2ltrkjet_pt = new std::vector<float>;
627  m_2ltrkjet_ntracks = new std::vector<int>;
628  m_2ltrkjet_nDisplaced = new std::vector<int>;
629  m_2ltrkjet_nTight = new std::vector<int>;
630  m_2ltrkjet_nTightDisplaced = new std::vector<int>;
631  m_2ltrkjet_ntdtrk = new std::vector<int>;
632 
633  m_trkjet_eta = new std::vector<float>;
634  m_trkjet_vz = new std::vector<float>;
635  m_trkjet_phi = new std::vector<float>;
636  m_trkjet_p = new std::vector<float>;
637  m_trkjet_pt = new std::vector<float>;
638  m_trkjet_ntracks = new std::vector<int>;
639  m_trkjet_tp_sumpt = new std::vector<float>;
640  m_trkjet_truetp_sumpt = new std::vector<float>;
641 
642  m_2ltrkjetExt_eta = new std::vector<float>;
643  m_2ltrkjetExt_vz = new std::vector<float>;
644  m_2ltrkjetExt_phi = new std::vector<float>;
645  m_2ltrkjetExt_p = new std::vector<float>;
646  m_2ltrkjetExt_pt = new std::vector<float>;
647  m_2ltrkjetExt_ntracks = new std::vector<int>;
648  m_2ltrkjetExt_nDisplaced = new std::vector<int>;
649  m_2ltrkjetExt_nTight = new std::vector<int>;
650  m_2ltrkjetExt_nTightDisplaced = new std::vector<int>;
651  m_2ltrkjetExt_ntdtrk = new std::vector<int>;
652 
653  m_trkjetExt_eta = new std::vector<float>;
654  m_trkjetExt_vz = new std::vector<float>;
655  m_trkjetExt_phi = new std::vector<float>;
656  m_trkjetExt_p = new std::vector<float>;
657  m_trkjetExt_pt = new std::vector<float>;
658  m_trkjetExt_ntracks = new std::vector<int>;
659  m_trkjetExt_tp_sumpt = new std::vector<float>;
660  m_trkjetExt_truetp_sumpt = new std::vector<float>;
661 
662  // ntuple
663  eventTree = fs->make<TTree>("eventTree", "Event tree");
664 
665  if (SaveAllTracks && (Displaced == "Prompt" || Displaced == "Both")) {
666  eventTree->Branch("trk_pt", &m_trk_pt);
667  eventTree->Branch("trk_eta", &m_trk_eta);
668  eventTree->Branch("trk_phi", &m_trk_phi);
669  eventTree->Branch("trk_d0", &m_trk_d0);
670  eventTree->Branch("trk_z0", &m_trk_z0);
671  eventTree->Branch("trk_chi2", &m_trk_chi2);
672  eventTree->Branch("trk_chi2dof", &m_trk_chi2dof);
673  eventTree->Branch("trk_chi2rphi", &m_trk_chi2rphi);
674  eventTree->Branch("trk_chi2rz", &m_trk_chi2rz);
675  eventTree->Branch("trk_bendchi2", &m_trk_bendchi2);
676  eventTree->Branch("trk_nstub", &m_trk_nstub);
677  eventTree->Branch("trk_lhits", &m_trk_lhits);
678  eventTree->Branch("trk_dhits", &m_trk_dhits);
679  eventTree->Branch("trk_seed", &m_trk_seed);
680  eventTree->Branch("trk_hitpattern", &m_trk_hitpattern);
681  eventTree->Branch("trk_phiSector", &m_trk_phiSector);
682  eventTree->Branch("trk_genuine", &m_trk_genuine);
683  eventTree->Branch("trk_loose", &m_trk_loose);
684  eventTree->Branch("trk_unknown", &m_trk_unknown);
685  eventTree->Branch("trk_combinatoric", &m_trk_combinatoric);
686  eventTree->Branch("trk_fake", &m_trk_fake);
687  eventTree->Branch("trk_matchtp_pdgid", &m_trk_matchtp_pdgid);
688  eventTree->Branch("trk_matchtp_pt", &m_trk_matchtp_pt);
689  eventTree->Branch("trk_matchtp_eta", &m_trk_matchtp_eta);
690  eventTree->Branch("trk_matchtp_phi", &m_trk_matchtp_phi);
691  eventTree->Branch("trk_matchtp_z0", &m_trk_matchtp_z0);
692  eventTree->Branch("trk_matchtp_dxy", &m_trk_matchtp_dxy);
693  // if (TrackingInJets) {
694  // eventTree->Branch("trk_injet", &m_trk_injet);
695  // eventTree->Branch("trk_injet_highpt", &m_trk_injet_highpt);
696  // eventTree->Branch("trk_injet_vhighpt", &m_trk_injet_vhighpt);
697  // }
698  }
699 
700  if (SaveAllTracks && (Displaced == "Displaced" || Displaced == "Both")) {
701  eventTree->Branch("trkExt_pt", &m_trkExt_pt);
702  eventTree->Branch("trkExt_eta", &m_trkExt_eta);
703  eventTree->Branch("trkExt_phi", &m_trkExt_phi);
704  eventTree->Branch("trkExt_d0", &m_trkExt_d0);
705  eventTree->Branch("trkExt_z0", &m_trkExt_z0);
706  eventTree->Branch("trkExt_chi2", &m_trkExt_chi2);
707  eventTree->Branch("trkExt_chi2dof", &m_trkExt_chi2dof);
708  eventTree->Branch("trkExt_chi2rphi", &m_trkExt_chi2rphi);
709  eventTree->Branch("trkExt_chi2rz", &m_trkExt_chi2rz);
710  eventTree->Branch("trkExt_bendchi2", &m_trkExt_bendchi2);
711  eventTree->Branch("trkExt_nstub", &m_trkExt_nstub);
712  eventTree->Branch("trkExt_lhits", &m_trkExt_lhits);
713  eventTree->Branch("trkExt_dhits", &m_trkExt_dhits);
714  eventTree->Branch("trkExt_seed", &m_trkExt_seed);
715  eventTree->Branch("trkExt_hitpattern", &m_trkExt_hitpattern);
716  eventTree->Branch("trkExt_phiSector", &m_trkExt_phiSector);
717  eventTree->Branch("trkExt_genuine", &m_trkExt_genuine);
718  eventTree->Branch("trkExt_loose", &m_trkExt_loose);
719  eventTree->Branch("trkExt_unknown", &m_trkExt_unknown);
720  eventTree->Branch("trkExt_combinatoric", &m_trkExt_combinatoric);
721  eventTree->Branch("trkExt_fake", &m_trkExt_fake);
722  eventTree->Branch("trkExt_matchtp_pdgid", &m_trkExt_matchtp_pdgid);
723  eventTree->Branch("trkExt_matchtp_pt", &m_trkExt_matchtp_pt);
724  eventTree->Branch("trkExt_matchtp_eta", &m_trkExt_matchtp_eta);
725  eventTree->Branch("trkExt_matchtp_phi", &m_trkExt_matchtp_phi);
726  eventTree->Branch("trkExt_matchtp_z0", &m_trkExt_matchtp_z0);
727  eventTree->Branch("trkExt_matchtp_dxy", &m_trkExt_matchtp_dxy);
728  // if (TrackingInJets) {
729  // eventTree->Branch("trk_injet", &m_trk_injet);
730  // eventTree->Branch("trk_injet_highpt", &m_trk_injet_highpt);
731  // eventTree->Branch("trk_injet_vhighpt", &m_trk_injet_vhighpt);
732  // }
733  }
734  eventTree->Branch("tp_pt", &m_tp_pt);
735  eventTree->Branch("tp_eta", &m_tp_eta);
736  eventTree->Branch("tp_phi", &m_tp_phi);
737  eventTree->Branch("tp_dxy", &m_tp_dxy);
738  eventTree->Branch("tp_d0", &m_tp_d0);
739  eventTree->Branch("tp_z0", &m_tp_z0);
740  eventTree->Branch("tp_d0_prod", &m_tp_d0_prod);
741  eventTree->Branch("tp_z0_prod", &m_tp_z0_prod);
742  eventTree->Branch("tp_pdgid", &m_tp_pdgid);
743  eventTree->Branch("tp_nmatch", &m_tp_nmatch);
744  eventTree->Branch("tp_nstub", &m_tp_nstub);
745  eventTree->Branch("tp_eventid", &m_tp_eventid);
746  eventTree->Branch("tp_charge", &m_tp_charge);
747  // if (TrackingInJets) {
748  // eventTree->Branch("tp_injet", &m_tp_injet);
749  // eventTree->Branch("tp_injet_highpt", &m_tp_injet_highpt);
750  // eventTree->Branch("tp_injet_vhighpt", &m_tp_injet_vhighpt);
751  // }
752 
753  if (Displaced == "Prompt" || Displaced == "Both") {
754  eventTree->Branch("matchtrk_pt", &m_matchtrk_pt);
755  eventTree->Branch("matchtrk_eta", &m_matchtrk_eta);
756  eventTree->Branch("matchtrk_phi", &m_matchtrk_phi);
757  eventTree->Branch("matchtrk_z0", &m_matchtrk_z0);
758  eventTree->Branch("matchtrk_d0", &m_matchtrk_d0);
759  eventTree->Branch("matchtrk_chi2", &m_matchtrk_chi2);
760  eventTree->Branch("matchtrk_chi2dof", &m_matchtrk_chi2dof);
761  eventTree->Branch("matchtrk_chi2rphi", &m_matchtrk_chi2rphi);
762  eventTree->Branch("matchtrk_chi2rz", &m_matchtrk_chi2rz);
763  eventTree->Branch("matchtrk_bendchi2", &m_matchtrk_bendchi2);
764  eventTree->Branch("matchtrk_nstub", &m_matchtrk_nstub);
765  eventTree->Branch("matchtrk_lhits", &m_matchtrk_lhits);
766  eventTree->Branch("matchtrk_dhits", &m_matchtrk_dhits);
767  eventTree->Branch("matchtrk_seed", &m_matchtrk_seed);
768  eventTree->Branch("matchtrk_hitpattern", &m_matchtrk_hitpattern);
769  // if (TrackingInJets) {
770  // eventTree->Branch("matchtrk_injet", &m_matchtrk_injet);
771  // eventTree->Branch("matchtrk_injet_highpt", &m_matchtrk_injet_highpt);
772  // eventTree->Branch("matchtrk_injet_vhighpt", &m_matchtrk_injet_vhighpt);
773  // }
774  }
775 
776  if (Displaced == "Displaced" || Displaced == "Both") {
777  eventTree->Branch("matchtrkExt_pt", &m_matchtrkExt_pt);
778  eventTree->Branch("matchtrkExt_eta", &m_matchtrkExt_eta);
779  eventTree->Branch("matchtrkExt_phi", &m_matchtrkExt_phi);
780  eventTree->Branch("matchtrkExt_z0", &m_matchtrkExt_z0);
781  eventTree->Branch("matchtrkExt_d0", &m_matchtrkExt_d0);
782  eventTree->Branch("matchtrkExt_chi2", &m_matchtrkExt_chi2);
783  eventTree->Branch("matchtrkExt_chi2dof", &m_matchtrkExt_chi2dof);
784  eventTree->Branch("matchtrkExt_chi2rphi", &m_matchtrkExt_chi2rphi);
785  eventTree->Branch("matchtrkExt_chi2rz", &m_matchtrkExt_chi2rz);
786  eventTree->Branch("matchtrkExt_bendchi2", &m_matchtrkExt_bendchi2);
787  eventTree->Branch("matchtrkExt_nstub", &m_matchtrkExt_nstub);
788  eventTree->Branch("matchtrkExt_lhits", &m_matchtrkExt_lhits);
789  eventTree->Branch("matchtrkExt_dhits", &m_matchtrkExt_dhits);
790  eventTree->Branch("matchtrkExt_seed", &m_matchtrkExt_seed);
791  eventTree->Branch("matchtrkExt_hitpattern", &m_matchtrkExt_hitpattern);
792  // if (TrackingInJets) {
793  // eventTree->Branch("matchtrk_injet", &m_matchtrk_injet);
794  // eventTree->Branch("matchtrk_injet_highpt", &m_matchtrk_injet_highpt);
795  // eventTree->Branch("matchtrk_injet_vhighpt", &m_matchtrk_injet_vhighpt);
796  // }
797  }
798 
799  if (SaveStubs) {
800  eventTree->Branch("allstub_x", &m_allstub_x);
801  eventTree->Branch("allstub_y", &m_allstub_y);
802  eventTree->Branch("allstub_z", &m_allstub_z);
803  eventTree->Branch("allstub_isBarrel", &m_allstub_isBarrel);
804  eventTree->Branch("allstub_layer", &m_allstub_layer);
805  eventTree->Branch("allstub_isPSmodule", &m_allstub_isPSmodule);
806  eventTree->Branch("allstub_trigDisplace", &m_allstub_trigDisplace);
807  eventTree->Branch("allstub_trigOffset", &m_allstub_trigOffset);
808  eventTree->Branch("allstub_trigPos", &m_allstub_trigPos);
809  eventTree->Branch("allstub_trigBend", &m_allstub_trigBend);
810  eventTree->Branch("allstub_matchTP_pdgid", &m_allstub_matchTP_pdgid);
811  eventTree->Branch("allstub_matchTP_pt", &m_allstub_matchTP_pt);
812  eventTree->Branch("allstub_matchTP_eta", &m_allstub_matchTP_eta);
813  eventTree->Branch("allstub_matchTP_phi", &m_allstub_matchTP_phi);
814  eventTree->Branch("allstub_genuine", &m_allstub_genuine);
815  }
816 
817  if (SaveTrackJets) {
818  // eventTree->Branch("pv_L1recotruesumpt", &m_pv_L1recotruesumpt);
819  // eventTree->Branch("pv_L1recosumpt", &m_pv_L1recosumpt);
820  eventTree->Branch("pv_L1reco", &m_pv_L1reco);
821  // eventTree->Branch("pv_L1TP", &m_pv_L1TP);
822  // eventTree->Branch("pv_L1TPsumpt", &m_pv_L1TPsumpt);
823  eventTree->Branch("MC_lep", &m_MC_lep);
824  // eventTree->Branch("pv_MCChgSumpT", &m_pv_MCChgSumpT);
825  eventTree->Branch("pv_MC", &m_pv_MC);
826 
827  if (Displaced == "Prompt" || Displaced == "Both") {
828  eventTree->Branch("2ltrkjet_eta", &m_2ltrkjet_eta);
829  eventTree->Branch("2ltrkjet_vz", &m_2ltrkjet_vz);
830  eventTree->Branch("2ltrkjet_p", &m_2ltrkjet_p);
831  eventTree->Branch("2ltrkjet_pt", &m_2ltrkjet_pt);
832  eventTree->Branch("2ltrkjet_phi", &m_2ltrkjet_phi);
833  eventTree->Branch("2ltrkjet_ntracks", &m_2ltrkjet_ntracks);
834  eventTree->Branch("2ltrkjet_nDisplaced", &m_2ltrkjet_nDisplaced);
835  eventTree->Branch("2ltrkjet_nTight", &m_2ltrkjet_nTight);
836  eventTree->Branch("2ltrkjet_nTightDisplaced", &m_2ltrkjet_nTightDisplaced);
837  eventTree->Branch("trkjet_eta", &m_trkjet_eta);
838  eventTree->Branch("trkjet_vz", &m_trkjet_vz);
839  eventTree->Branch("trkjet_p", &m_trkjet_p);
840  eventTree->Branch("trkjet_pt", &m_trkjet_pt);
841  eventTree->Branch("trkjet_phi", &m_trkjet_phi);
842  eventTree->Branch("trkjet_ntracks", &m_trkjet_ntracks);
843  eventTree->Branch("trkjet_truetp_sumpt", m_trkjet_truetp_sumpt);
844  }
845  if (Displaced == "Displaced" || Displaced == "Both") {
846  eventTree->Branch("2ltrkjetExt_eta", &m_2ltrkjetExt_eta);
847  eventTree->Branch("2ltrkjetExt_vz", &m_2ltrkjetExt_vz);
848  eventTree->Branch("2ltrkjetExt_p", &m_2ltrkjetExt_p);
849  eventTree->Branch("2ltrkjetExt_pt", &m_2ltrkjetExt_pt);
850  eventTree->Branch("2ltrkjetExt_phi", &m_2ltrkjetExt_phi);
851  eventTree->Branch("2ltrkjetExt_ntracks", &m_2ltrkjetExt_ntracks);
852  eventTree->Branch("2ltrkjetExt_nDisplaced", &m_2ltrkjetExt_nDisplaced);
853  eventTree->Branch("2ltrkjetExt_nTight", &m_2ltrkjetExt_nTight);
854  eventTree->Branch("2ltrkjetExt_nTightDisplaced", &m_2ltrkjetExt_nTightDisplaced);
855  eventTree->Branch("trkjetExt_eta", &m_trkjetExt_eta);
856  eventTree->Branch("trkjetExt_vz", &m_trkjetExt_vz);
857  eventTree->Branch("trkjetExt_p", &m_trkjetExt_p);
858  eventTree->Branch("trkjetExt_pt", &m_trkjetExt_pt);
859  eventTree->Branch("trkjetExt_phi", &m_trkjetExt_phi);
860  eventTree->Branch("trkjetExt_ntracks", &m_trkjetExt_ntracks);
861  eventTree->Branch("trkjetExt_truetp_sumpt", m_trkjetExt_truetp_sumpt);
862  }
863  }
864 
865  if (SaveTrackMET) {
866  eventTree->Branch("trueMET", &trueMET, "trueMET/F");
867 
868  if (Displaced == "Prompt" || Displaced == "Both") {
869  eventTree->Branch("trkMET", &trkMET, "trkMET/F");
870  eventTree->Branch("trkMHT", &trkMHT, "trkMHT/F");
871  eventTree->Branch("trkHT", &trkHT, "trkHT/F");
872  }
873  if (Displaced == "Displaced" || Displaced == "Both") {
874  eventTree->Branch("trkMETExt", &trkMETExt, "trkMETExt/F");
875  eventTree->Branch("trkMHTExt", &trkMHTExt, "trkMHTExt/F");
876  eventTree->Branch("trkHTExt", &trkHTExt, "trkHTExt/F");
877  }
878  }
879 }
880 
882 // ANALYZE
884  if (not available_)
885  return; // No ROOT file open.
886 
887  if (!(MyProcess == 13 || MyProcess == 11 || MyProcess == 211 || MyProcess == 6 || MyProcess == 15 ||
888  MyProcess == 1)) {
889  edm::LogVerbatim("Tracklet") << "The specified MyProcess is invalid! Exiting...";
890  return;
891  }
892 
893  // clear variables
894  if (SaveAllTracks && (Displaced == "Prompt" || Displaced == "Both")) {
895  m_trk_pt->clear();
896  m_trk_eta->clear();
897  m_trk_phi->clear();
898  m_trk_d0->clear();
899  m_trk_z0->clear();
900  m_trk_chi2->clear();
901  m_trk_chi2dof->clear();
902  m_trk_chi2rphi->clear();
903  m_trk_chi2rz->clear();
904  m_trk_bendchi2->clear();
905  m_trk_nstub->clear();
906  m_trk_lhits->clear();
907  m_trk_dhits->clear();
908  m_trk_seed->clear();
909  m_trk_hitpattern->clear();
910  m_trk_phiSector->clear();
911  m_trk_genuine->clear();
912  m_trk_loose->clear();
913  m_trk_unknown->clear();
914  m_trk_combinatoric->clear();
915  m_trk_fake->clear();
916  m_trk_matchtp_pdgid->clear();
917  m_trk_matchtp_pt->clear();
918  m_trk_matchtp_eta->clear();
919  m_trk_matchtp_phi->clear();
920  m_trk_matchtp_z0->clear();
921  m_trk_matchtp_dxy->clear();
922  }
923  if (SaveAllTracks && (Displaced == "Displaced" || Displaced == "Both")) {
924  m_trkExt_pt->clear();
925  m_trkExt_eta->clear();
926  m_trkExt_phi->clear();
927  m_trkExt_d0->clear();
928  m_trkExt_z0->clear();
929  m_trkExt_chi2->clear();
930  m_trkExt_chi2dof->clear();
931  m_trkExt_chi2rphi->clear();
932  m_trkExt_chi2rz->clear();
933  m_trkExt_bendchi2->clear();
934  m_trkExt_nstub->clear();
935  m_trkExt_lhits->clear();
936  m_trkExt_dhits->clear();
937  m_trkExt_seed->clear();
938  m_trkExt_hitpattern->clear();
939  m_trkExt_phiSector->clear();
940  m_trkExt_genuine->clear();
941  m_trkExt_loose->clear();
942  m_trkExt_unknown->clear();
943  m_trkExt_combinatoric->clear();
944  m_trkExt_fake->clear();
945  m_trkExt_matchtp_pdgid->clear();
946  m_trkExt_matchtp_pt->clear();
947  m_trkExt_matchtp_eta->clear();
948  m_trkExt_matchtp_phi->clear();
949  m_trkExt_matchtp_z0->clear();
950  m_trkExt_matchtp_dxy->clear();
951  }
952  m_tp_pt->clear();
953  m_tp_eta->clear();
954  m_tp_phi->clear();
955  m_tp_dxy->clear();
956  m_tp_d0->clear();
957  m_tp_z0->clear();
958  m_tp_d0_prod->clear();
959  m_tp_z0_prod->clear();
960  m_tp_pdgid->clear();
961  m_tp_nmatch->clear();
962  m_tp_nstub->clear();
963  m_tp_eventid->clear();
964  m_tp_charge->clear();
965 
966  if (Displaced == "Prompt" || Displaced == "Both") {
967  m_matchtrk_pt->clear();
968  m_matchtrk_eta->clear();
969  m_matchtrk_phi->clear();
970  m_matchtrk_z0->clear();
971  m_matchtrk_d0->clear();
972  m_matchtrk_chi2->clear();
973  m_matchtrk_chi2dof->clear();
974  m_matchtrk_chi2rphi->clear();
975  m_matchtrk_chi2rz->clear();
976  m_matchtrk_bendchi2->clear();
977  m_matchtrk_nstub->clear();
978  m_matchtrk_lhits->clear();
979  m_matchtrk_dhits->clear();
980  m_matchtrk_seed->clear();
981  m_matchtrk_hitpattern->clear();
982  }
983 
984  if (Displaced == "Displaced" || Displaced == "Both") {
985  m_matchtrkExt_pt->clear();
986  m_matchtrkExt_eta->clear();
987  m_matchtrkExt_phi->clear();
988  m_matchtrkExt_z0->clear();
989  m_matchtrkExt_d0->clear();
990  m_matchtrkExt_chi2->clear();
991  m_matchtrkExt_chi2dof->clear();
992  m_matchtrkExt_chi2rphi->clear();
993  m_matchtrkExt_chi2rz->clear();
994  m_matchtrkExt_bendchi2->clear();
995  m_matchtrkExt_nstub->clear();
996  m_matchtrkExt_lhits->clear();
997  m_matchtrkExt_dhits->clear();
998  m_matchtrkExt_seed->clear();
999  m_matchtrkExt_hitpattern->clear();
1000  }
1001 
1002  if (SaveStubs) {
1003  m_allstub_x->clear();
1004  m_allstub_y->clear();
1005  m_allstub_z->clear();
1006  m_allstub_isBarrel->clear();
1007  m_allstub_layer->clear();
1008  m_allstub_isPSmodule->clear();
1009  m_allstub_trigDisplace->clear();
1010  m_allstub_trigOffset->clear();
1011  m_allstub_trigPos->clear();
1012  m_allstub_trigBend->clear();
1013  m_allstub_matchTP_pdgid->clear();
1014  m_allstub_matchTP_pt->clear();
1015  m_allstub_matchTP_eta->clear();
1016  m_allstub_matchTP_phi->clear();
1017  m_allstub_genuine->clear();
1018  }
1019 
1020  // m_jet_eta->clear();
1021  // m_jet_phi->clear();
1022  // m_jet_pt->clear();
1023  // m_jet_tp_sumpt->clear();
1024  // m_jet_trk_sumpt->clear();
1025  // m_jet_matchtrk_sumpt->clear();
1026 
1027  if (SaveTrackJets) {
1028  if (Displaced == "Prompt" || Displaced == "Both") {
1029  m_2ltrkjet_eta->clear();
1030  m_2ltrkjet_pt->clear();
1031  m_2ltrkjet_vz->clear();
1032  m_2ltrkjet_phi->clear();
1033  m_2ltrkjet_p->clear();
1034  m_2ltrkjet_ntracks->clear();
1035  m_2ltrkjet_nDisplaced->clear();
1036  m_2ltrkjet_nTight->clear();
1037  m_2ltrkjet_nTightDisplaced->clear();
1038  m_2ltrkjet_ntdtrk->clear();
1039  m_trkjet_eta->clear();
1040  m_trkjet_pt->clear();
1041  m_trkjet_vz->clear();
1042  m_trkjet_phi->clear();
1043  m_trkjet_p->clear();
1044  m_trkjet_ntracks->clear();
1045  m_trkjet_truetp_sumpt->clear();
1046  m_trkjet_tp_sumpt->clear();
1047  }
1048  if (Displaced == "Displaced" || Displaced == "Both") {
1049  m_2ltrkjetExt_eta->clear();
1050  m_2ltrkjetExt_pt->clear();
1051  m_2ltrkjetExt_vz->clear();
1052  m_2ltrkjetExt_phi->clear();
1053  m_2ltrkjetExt_p->clear();
1054  m_2ltrkjetExt_ntracks->clear();
1055  m_2ltrkjetExt_nDisplaced->clear();
1056  m_2ltrkjetExt_nTight->clear();
1058  m_2ltrkjetExt_ntdtrk->clear();
1059  m_trkjetExt_eta->clear();
1060  m_trkjetExt_pt->clear();
1061  m_trkjetExt_vz->clear();
1062  m_trkjetExt_phi->clear();
1063  m_trkjetExt_p->clear();
1064  m_trkjetExt_ntracks->clear();
1065  m_trkjetExt_truetp_sumpt->clear();
1066  m_trkjetExt_tp_sumpt->clear();
1067  }
1068 
1069  // m_pv_L1recotruesumpt->clear();
1070  // m_pv_L1recosumpt->clear();
1071  m_pv_L1reco->clear();
1072  // m_pv_L1TPsumpt->clear();
1073  // m_pv_L1TP->clear();
1074  m_pv_MC->clear();
1075  m_MC_lep->clear();
1076  // m_pv_MCChgSumpT->clear();
1077  }
1078 
1079  // -----------------------------------------------------------------------------------------------
1080  // retrieve various containers
1081  // -----------------------------------------------------------------------------------------------
1082 
1083  // L1 stubs
1085  if (SaveStubs)
1086  iEvent.getByToken(ttStubToken_, TTStubHandle);
1087 
1088  // MC truth association maps
1090  iEvent.getByToken(ttClusterMCTruthToken_, MCTruthTTClusterHandle);
1092  iEvent.getByToken(ttStubMCTruthToken_, MCTruthTTStubHandle);
1093 
1094  // tracking particles
1095  edm::Handle<std::vector<TrackingParticle> > TrackingParticleHandle;
1096  edm::Handle<std::vector<TrackingVertex> > TrackingVertexHandle;
1097  iEvent.getByToken(TrackingParticleToken_, TrackingParticleHandle);
1098  iEvent.getByToken(TrackingVertexToken_, TrackingVertexHandle);
1099 
1100  // -----------------------------------------------------------------------------------------------
1101  // more for TTStubs
1102  const TrackerTopology& tTopo = iSetup.getData(tTopoToken_);
1103  const TrackerGeometry& tGeom = iSetup.getData(tGeomToken_);
1104 
1105  /*edm::ESHandle<TrackerGeometry> geometryHandle;
1106  iSetup.get<TrackerDigiGeometryRecord>().get(geometryHandle);
1107 
1108  edm::ESHandle<TrackerTopology> tTopoHandle;
1109  iSetup.get<TrackerTopologyRcd>().get(tTopoHandle);
1110 
1111  edm::ESHandle<TrackerGeometry> tGeomHandle;
1112  iSetup.get<TrackerDigiGeometryRecord>().get(tGeomHandle);
1113 
1114  const TrackerTopology* const tTopo = tTopoHandle.product();
1115  const TrackerGeometry* const theTrackerGeom = tGeomHandle.product();*/
1116 
1117  //Gen particles
1118  edm::Handle<std::vector<reco::GenParticle> > GenParticleHandle;
1119  iEvent.getByToken(GenParticleToken_, GenParticleHandle);
1120 
1121  //Vertex
1122  edm::Handle<l1t::TkPrimaryVertexCollection> L1TkPrimaryVertexHandle;
1123  iEvent.getByToken(L1VertexToken_, L1TkPrimaryVertexHandle);
1124 
1125  // Track jets
1126  edm::Handle<std::vector<l1t::TkJet> > TrackFastJetsHandle;
1127  edm::Handle<std::vector<l1t::TkJet> > TrackFastJetsExtendedHandle;
1128  edm::Handle<l1t::TkJetCollection> TrackJetsHandle;
1129  edm::Handle<l1t::TkJetCollection> TrackJetsExtendedHandle;
1130  std::vector<l1t::TkJet>::const_iterator jetIter;
1131 
1132  // Track MET
1134  edm::Handle<std::vector<l1t::TkEtMiss> > L1TkMETExtendedHandle;
1136  edm::Handle<std::vector<l1t::TkHTMiss> > L1TkMHTExtendedHandle;
1137 
1138  // L1 tracks
1142  edm::Handle<TTTrackAssociationMap<Ref_Phase2TrackerDigi_> > MCTruthTTTrackExtendedHandle;
1143  std::vector<TTTrack<Ref_Phase2TrackerDigi_> >::const_iterator iterL1Track;
1144 
1145  if (Displaced == "Prompt" || Displaced == "Both") {
1146  iEvent.getByToken(TrackFastJetsToken_, TrackFastJetsHandle);
1147  iEvent.getByToken(TrackJetsToken_, TrackJetsHandle);
1148  iEvent.getByToken(TrackMETToken_, L1TkMETHandle);
1149  iEvent.getByToken(TrackMHTToken_, L1TkMHTHandle);
1150  iEvent.getByToken(ttTrackToken_, TTTrackHandle);
1151  iEvent.getByToken(ttTrackMCTruthToken_, MCTruthTTTrackHandle);
1152  }
1153  if (Displaced == "Displaced" || Displaced == "Both") {
1154  iEvent.getByToken(TrackFastJetsExtendedToken_, TrackFastJetsExtendedHandle);
1155  iEvent.getByToken(TrackJetsExtendedToken_, TrackJetsExtendedHandle);
1156  iEvent.getByToken(TrackMETExtendedToken_, L1TkMETExtendedHandle);
1157  iEvent.getByToken(TrackMHTExtendedToken_, L1TkMHTExtendedHandle);
1158  iEvent.getByToken(ttTrackExtendedToken_, TTTrackExtendedHandle);
1159  iEvent.getByToken(ttTrackMCTruthExtendedToken_, MCTruthTTTrackExtendedHandle);
1160  }
1161 
1162  //Loop over gen particles
1163  if (GenParticleHandle.isValid()) {
1164  vector<reco::GenParticle>::const_iterator genpartIter;
1165 
1166  float zvtx_gen = -999;
1167  for (genpartIter = GenParticleHandle->begin(); genpartIter != GenParticleHandle->end(); ++genpartIter) {
1168  int status = genpartIter->status();
1169  if (status != 1)
1170  continue;
1171  zvtx_gen = genpartIter->vz();
1172  }
1173  m_pv_MC->push_back(zvtx_gen);
1174 
1175  float trueMETx = 0;
1176  float trueMETy = 0;
1177  trueMET = 0;
1178  for (size_t i = 0; i < GenParticleHandle->size(); ++i) {
1179  const reco::GenParticle& p = (*GenParticleHandle)[i];
1180  int id = p.pdgId();
1181  bool isNeutrino = false;
1182  if ((fabs(id) == 12 || fabs(id) == 14 || fabs(id) == 16))
1183  isNeutrino = true;
1184  if ((isNeutrino || id == 1000022) && p.status() == 1) {
1185  trueMETx += p.pt() * cos(p.phi());
1186  trueMETy += p.pt() * sin(p.phi());
1187  }
1188  }
1189  trueMET = sqrt(trueMETx * trueMETx + trueMETy * trueMETy);
1190  } else {
1191  edm::LogWarning("DataNotFound") << "\nWarning: GenParticleHandle not found in the event" << std::endl;
1192  }
1193 
1194  // ----------------------------------------------------------------------------------------------
1195  // loop over L1 stubs
1196  // ----------------------------------------------------------------------------------------------
1197  if (SaveStubs) {
1198  for (auto gd = tGeom.dets().begin(); gd != tGeom.dets().end(); gd++) {
1199  DetId detid = (*gd)->geographicalId();
1200  if (detid.subdetId() != StripSubdetector::TOB && detid.subdetId() != StripSubdetector::TID)
1201  continue;
1202  if (!tTopo.isLower(detid))
1203  continue; // loop on the stacks: choose the lower arbitrarily
1204  DetId stackDetid = tTopo.stack(detid); // Stub module detid
1205 
1206  if (TTStubHandle->find(stackDetid) == TTStubHandle->end())
1207  continue;
1208 
1209  // Get the DetSets of the Clusters
1210  edmNew::DetSet<TTStub<Ref_Phase2TrackerDigi_> > stubs = (*TTStubHandle)[stackDetid];
1211  const GeomDetUnit* det0 = tGeom.idToDetUnit(detid);
1212  const auto* theGeomDet = dynamic_cast<const PixelGeomDetUnit*>(det0);
1213  const PixelTopology* topol = dynamic_cast<const PixelTopology*>(&(theGeomDet->specificTopology()));
1214 
1215  // loop over stubs
1216  for (auto stubIter = stubs.begin(); stubIter != stubs.end(); ++stubIter) {
1218  edmNew::makeRefTo(TTStubHandle, stubIter);
1219 
1220  int isBarrel = 0;
1221  int layer = -999999;
1222  if (detid.subdetId() == StripSubdetector::TOB) {
1223  isBarrel = 1;
1224  layer = static_cast<int>(tTopo.layer(detid));
1225  } else if (detid.subdetId() == StripSubdetector::TID) {
1226  isBarrel = 0;
1227  layer = static_cast<int>(tTopo.layer(detid));
1228  } else {
1229  edm::LogVerbatim("Tracklet") << "WARNING -- neither TOB or TID stub, shouldn't happen...";
1230  layer = -1;
1231  }
1232 
1233  int isPSmodule = 0;
1234  if (topol->nrows() == 960)
1235  isPSmodule = 1;
1236 
1237  MeasurementPoint coords = tempStubPtr->clusterRef(0)->findAverageLocalCoordinatesCentered();
1238  LocalPoint clustlp = topol->localPosition(coords);
1239  GlobalPoint posStub = theGeomDet->surface().toGlobal(clustlp);
1240 
1241  double tmp_stub_x = posStub.x();
1242  double tmp_stub_y = posStub.y();
1243  double tmp_stub_z = posStub.z();
1244 
1245  float trigDisplace = tempStubPtr->rawBend();
1246  float trigOffset = tempStubPtr->bendOffset();
1247  float trigPos = tempStubPtr->innerClusterPosition();
1248  float trigBend = tempStubPtr->bendFE();
1249 
1250  m_allstub_x->push_back(tmp_stub_x);
1251  m_allstub_y->push_back(tmp_stub_y);
1252  m_allstub_z->push_back(tmp_stub_z);
1253  m_allstub_isBarrel->push_back(isBarrel);
1254  m_allstub_layer->push_back(layer);
1255  m_allstub_isPSmodule->push_back(isPSmodule);
1256  m_allstub_trigDisplace->push_back(trigDisplace);
1257  m_allstub_trigOffset->push_back(trigOffset);
1258  m_allstub_trigPos->push_back(trigPos);
1259  m_allstub_trigBend->push_back(trigBend);
1260 
1261  // matched to tracking particle?
1262  edm::Ptr<TrackingParticle> my_tp = MCTruthTTStubHandle->findTrackingParticlePtr(tempStubPtr);
1263 
1264  int myTP_pdgid = -999;
1265  float myTP_pt = -999;
1266  float myTP_eta = -999;
1267  float myTP_phi = -999;
1268 
1269  if (my_tp.isNull() == false) {
1270  int tmp_eventid = my_tp->eventId().event();
1271  if (tmp_eventid > 0)
1272  continue; // this means stub from pileup track
1273  myTP_pdgid = my_tp->pdgId();
1274  myTP_pt = my_tp->p4().pt();
1275  myTP_eta = my_tp->p4().eta();
1276  myTP_phi = my_tp->p4().phi();
1277  }
1278  int tmp_stub_genuine = 0;
1279  if (MCTruthTTStubHandle->isGenuine(tempStubPtr))
1280  tmp_stub_genuine = 1;
1281 
1282  m_allstub_matchTP_pdgid->push_back(myTP_pdgid);
1283  m_allstub_matchTP_pt->push_back(myTP_pt);
1284  m_allstub_matchTP_eta->push_back(myTP_eta);
1285  m_allstub_matchTP_phi->push_back(myTP_phi);
1286  m_allstub_genuine->push_back(tmp_stub_genuine);
1287  }
1288  }
1289  }
1290 
1291  // ----------------------------------------------------------------------------------------------
1292  // loop over (prompt) L1 tracks
1293  // ----------------------------------------------------------------------------------------------
1294  if (SaveAllTracks && (Displaced == "Prompt" || Displaced == "Both")) {
1295  if (DebugMode) {
1296  edm::LogVerbatim("Tracklet") << "\n Loop over L1 tracks!";
1297  edm::LogVerbatim("Tracklet") << "\n Looking at " << Displaced << " tracks!";
1298  }
1299 
1300  int this_l1track = 0;
1301  for (iterL1Track = TTTrackHandle->begin(); iterL1Track != TTTrackHandle->end(); iterL1Track++) {
1302  edm::Ptr<TTTrack<Ref_Phase2TrackerDigi_> > l1track_ptr(TTTrackHandle, this_l1track);
1303  this_l1track++;
1304 
1305  float tmp_trk_pt = iterL1Track->momentum().perp();
1306  float tmp_trk_eta = iterL1Track->momentum().eta();
1307  float tmp_trk_phi = iterL1Track->momentum().phi();
1308  float tmp_trk_z0 = iterL1Track->z0(); //cm
1309  int tmp_trk_nFitPars = iterL1Track->nFitPars(); //4 or 5
1310 
1311  float tmp_trk_d0 = -999;
1312  if (tmp_trk_nFitPars == 5) {
1313  float tmp_trk_x0 = iterL1Track->POCA().x();
1314  float tmp_trk_y0 = iterL1Track->POCA().y();
1315  tmp_trk_d0 = -tmp_trk_x0 * sin(tmp_trk_phi) + tmp_trk_y0 * cos(tmp_trk_phi);
1316  // tmp_trk_d0 = iterL1Track->d0();
1317  }
1318 
1319  float tmp_trk_chi2 = iterL1Track->chi2();
1320  float tmp_trk_chi2dof = iterL1Track->chi2Red();
1321  float tmp_trk_chi2rphi = iterL1Track->chi2XY();
1322  float tmp_trk_chi2rz = iterL1Track->chi2Z();
1323  float tmp_trk_bendchi2 = iterL1Track->stubPtConsistency();
1324 
1325  std::vector<edm::Ref<edmNew::DetSetVector<TTStub<Ref_Phase2TrackerDigi_> >, TTStub<Ref_Phase2TrackerDigi_> > >
1326  stubRefs = iterL1Track->getStubRefs();
1327  int tmp_trk_nstub = (int)stubRefs.size();
1328  int tmp_trk_seed = 0;
1329  tmp_trk_seed = (int)iterL1Track->trackSeedType();
1330  int tmp_trk_hitpattern = 0;
1331  tmp_trk_hitpattern = (int)iterL1Track->hitPattern();
1332  unsigned int tmp_trk_phiSector = iterL1Track->phiSector();
1333 
1334  // ----------------------------------------------------------------------------------------------
1335  // loop over stubs on tracks
1336  int tmp_trk_dhits = 0;
1337  int tmp_trk_lhits = 0;
1338  if (true) {
1339  // loop over stubs
1340  for (int is = 0; is < tmp_trk_nstub; is++) {
1341  //detID of stub
1342  DetId detIdStub = tGeom.idToDet((stubRefs.at(is)->clusterRef(0))->getDetId())->geographicalId();
1343  MeasurementPoint coords = stubRefs.at(is)->clusterRef(0)->findAverageLocalCoordinatesCentered();
1344  const GeomDet* theGeomDet = tGeom.idToDet(detIdStub);
1345  Global3DPoint posStub = theGeomDet->surface().toGlobal(theGeomDet->topology().localPosition(coords));
1346 
1347  double x = posStub.x();
1348  double y = posStub.y();
1349  double z = posStub.z();
1350 
1351  int layer = -999999;
1352  if (detIdStub.subdetId() == StripSubdetector::TOB) {
1353  layer = static_cast<int>(tTopo.layer(detIdStub));
1354  if (DebugMode)
1355  edm::LogVerbatim("Tracklet")
1356  << " stub in layer " << layer << " at position x y z = " << x << " " << y << " " << z;
1357  tmp_trk_lhits += pow(10, layer - 1);
1358  } else if (detIdStub.subdetId() == StripSubdetector::TID) {
1359  layer = static_cast<int>(tTopo.layer(detIdStub));
1360  if (DebugMode)
1361  edm::LogVerbatim("Tracklet")
1362  << " stub in disk " << layer << " at position x y z = " << x << " " << y << " " << z;
1363  tmp_trk_dhits += pow(10, layer - 1);
1364  }
1365  } //end loop over stubs
1366  }
1367  // ----------------------------------------------------------------------------------------------
1368 
1369  int tmp_trk_genuine = 0;
1370  int tmp_trk_loose = 0;
1371  int tmp_trk_unknown = 0;
1372  int tmp_trk_combinatoric = 0;
1373  if (MCTruthTTTrackHandle->isLooselyGenuine(l1track_ptr))
1374  tmp_trk_loose = 1;
1375  if (MCTruthTTTrackHandle->isGenuine(l1track_ptr))
1376  tmp_trk_genuine = 1;
1377  if (MCTruthTTTrackHandle->isUnknown(l1track_ptr))
1378  tmp_trk_unknown = 1;
1379  if (MCTruthTTTrackHandle->isCombinatoric(l1track_ptr))
1380  tmp_trk_combinatoric = 1;
1381 
1382  if (DebugMode) {
1383  edm::LogVerbatim("Tracklet") << "L1 track,"
1384  << " pt: " << tmp_trk_pt << " eta: " << tmp_trk_eta << " phi: " << tmp_trk_phi
1385  << " z0: " << tmp_trk_z0 << " chi2: " << tmp_trk_chi2
1386  << " chi2rphi: " << tmp_trk_chi2rphi << " chi2rz: " << tmp_trk_chi2rz
1387  << " nstub: " << tmp_trk_nstub;
1388  if (tmp_trk_genuine)
1389  edm::LogVerbatim("Tracklet") << " (is genuine)";
1390  if (tmp_trk_unknown)
1391  edm::LogVerbatim("Tracklet") << " (is unknown)";
1392  if (tmp_trk_combinatoric)
1393  edm::LogVerbatim("Tracklet") << " (is combinatoric)";
1394  }
1395 
1396  m_trk_pt->push_back(tmp_trk_pt);
1397  m_trk_eta->push_back(tmp_trk_eta);
1398  m_trk_phi->push_back(tmp_trk_phi);
1399  m_trk_z0->push_back(tmp_trk_z0);
1400  if (tmp_trk_nFitPars == 5)
1401  m_trk_d0->push_back(tmp_trk_d0);
1402  else
1403  m_trk_d0->push_back(999.);
1404  m_trk_chi2->push_back(tmp_trk_chi2);
1405  m_trk_chi2dof->push_back(tmp_trk_chi2dof);
1406  m_trk_chi2rphi->push_back(tmp_trk_chi2rphi);
1407  m_trk_chi2rz->push_back(tmp_trk_chi2rz);
1408  m_trk_bendchi2->push_back(tmp_trk_bendchi2);
1409  m_trk_nstub->push_back(tmp_trk_nstub);
1410  m_trk_dhits->push_back(tmp_trk_dhits);
1411  m_trk_lhits->push_back(tmp_trk_lhits);
1412  m_trk_seed->push_back(tmp_trk_seed);
1413  m_trk_hitpattern->push_back(tmp_trk_hitpattern);
1414  m_trk_phiSector->push_back(tmp_trk_phiSector);
1415  m_trk_genuine->push_back(tmp_trk_genuine);
1416  m_trk_loose->push_back(tmp_trk_loose);
1417  m_trk_unknown->push_back(tmp_trk_unknown);
1418  m_trk_combinatoric->push_back(tmp_trk_combinatoric);
1419 
1420  // ----------------------------------------------------------------------------------------------
1421  // for studying the fake rate
1422  // ----------------------------------------------------------------------------------------------
1423  edm::Ptr<TrackingParticle> my_tp = MCTruthTTTrackHandle->findTrackingParticlePtr(l1track_ptr);
1424 
1425  int myFake = 0;
1426  int myTP_pdgid = -999;
1427  float myTP_pt = -999;
1428  float myTP_eta = -999;
1429  float myTP_phi = -999;
1430  float myTP_z0 = -999;
1431  float myTP_dxy = -999;
1432 
1433  if (my_tp.isNull())
1434  myFake = 0;
1435  else {
1436  int tmp_eventid = my_tp->eventId().event();
1437  if (tmp_eventid > 0)
1438  myFake = 2;
1439  else
1440  myFake = 1;
1441 
1442  myTP_pdgid = my_tp->pdgId();
1443  myTP_pt = my_tp->p4().pt();
1444  myTP_eta = my_tp->p4().eta();
1445  myTP_phi = my_tp->p4().phi();
1446  myTP_z0 = my_tp->vertex().z();
1447 
1448  float myTP_x0 = my_tp->vertex().x();
1449  float myTP_y0 = my_tp->vertex().y();
1450  myTP_dxy = sqrt(myTP_x0 * myTP_x0 + myTP_y0 * myTP_y0);
1451 
1452  if (DebugMode) {
1453  edm::LogVerbatim("Tracklet") << "TP matched to track has pt = " << my_tp->p4().pt()
1454  << " eta = " << my_tp->momentum().eta() << " phi = " << my_tp->momentum().phi()
1455  << " z0 = " << my_tp->vertex().z() << " pdgid = " << my_tp->pdgId()
1456  << " dxy = " << myTP_dxy;
1457  }
1458  }
1459 
1460  m_trk_fake->push_back(myFake);
1461  m_trk_matchtp_pdgid->push_back(myTP_pdgid);
1462  m_trk_matchtp_pt->push_back(myTP_pt);
1463  m_trk_matchtp_eta->push_back(myTP_eta);
1464  m_trk_matchtp_phi->push_back(myTP_phi);
1465  m_trk_matchtp_z0->push_back(myTP_z0);
1466  m_trk_matchtp_dxy->push_back(myTP_dxy);
1467  } //end track loop
1468  } //end if SaveAllTracks
1469 
1470  // ----------------------------------------------------------------------------------------------
1471  // loop over (extended) L1 tracks
1472  // ----------------------------------------------------------------------------------------------
1473  if (SaveAllTracks && (Displaced == "Displaced" || Displaced == "Both")) {
1474  if (DebugMode) {
1475  edm::LogVerbatim("Tracklet") << "\n Loop over L1 tracks!";
1476  edm::LogVerbatim("Tracklet") << "\n Looking at " << Displaced << " tracks!";
1477  }
1478 
1479  int this_l1track = 0;
1480  for (iterL1Track = TTTrackExtendedHandle->begin(); iterL1Track != TTTrackExtendedHandle->end(); iterL1Track++) {
1481  edm::Ptr<TTTrack<Ref_Phase2TrackerDigi_> > l1track_ptr(TTTrackExtendedHandle, this_l1track);
1482  this_l1track++;
1483 
1484  float tmp_trk_pt = iterL1Track->momentum().perp();
1485  float tmp_trk_eta = iterL1Track->momentum().eta();
1486  float tmp_trk_phi = iterL1Track->momentum().phi();
1487  float tmp_trk_z0 = iterL1Track->z0(); //cm
1488  int tmp_trk_nFitPars = iterL1Track->nFitPars(); //4 or 5
1489 
1490  float tmp_trk_d0 = -999;
1491  if (tmp_trk_nFitPars == 5) {
1492  float tmp_trk_x0 = iterL1Track->POCA().x();
1493  float tmp_trk_y0 = iterL1Track->POCA().y();
1494  tmp_trk_d0 = -tmp_trk_x0 * sin(tmp_trk_phi) + tmp_trk_y0 * cos(tmp_trk_phi);
1495  // tmp_trk_d0 = iterL1Track->d0();
1496  }
1497 
1498  float tmp_trk_chi2 = iterL1Track->chi2();
1499  float tmp_trk_chi2dof = iterL1Track->chi2Red();
1500  float tmp_trk_chi2rphi = iterL1Track->chi2XY();
1501  float tmp_trk_chi2rz = iterL1Track->chi2Z();
1502  float tmp_trk_bendchi2 = iterL1Track->stubPtConsistency();
1503 
1504  std::vector<edm::Ref<edmNew::DetSetVector<TTStub<Ref_Phase2TrackerDigi_> >, TTStub<Ref_Phase2TrackerDigi_> > >
1505  stubRefs = iterL1Track->getStubRefs();
1506  int tmp_trk_nstub = (int)stubRefs.size();
1507  int tmp_trk_seed = 0;
1508  tmp_trk_seed = (int)iterL1Track->trackSeedType();
1509  int tmp_trk_hitpattern = 0;
1510  tmp_trk_hitpattern = (int)iterL1Track->hitPattern();
1511  unsigned int tmp_trk_phiSector = iterL1Track->phiSector();
1512 
1513  // ----------------------------------------------------------------------------------------------
1514  // loop over stubs on tracks
1515  int tmp_trk_dhits = 0;
1516  int tmp_trk_lhits = 0;
1517  if (true) {
1518  // loop over stubs
1519  for (int is = 0; is < tmp_trk_nstub; is++) {
1520  //detID of stub
1521  DetId detIdStub = tGeom.idToDet((stubRefs.at(is)->clusterRef(0))->getDetId())->geographicalId();
1522  MeasurementPoint coords = stubRefs.at(is)->clusterRef(0)->findAverageLocalCoordinatesCentered();
1523  const GeomDet* theGeomDet = tGeom.idToDet(detIdStub);
1524  Global3DPoint posStub = theGeomDet->surface().toGlobal(theGeomDet->topology().localPosition(coords));
1525 
1526  double x = posStub.x();
1527  double y = posStub.y();
1528  double z = posStub.z();
1529 
1530  int layer = -999999;
1531  if (detIdStub.subdetId() == StripSubdetector::TOB) {
1532  layer = static_cast<int>(tTopo.layer(detIdStub));
1533  if (DebugMode)
1534  edm::LogVerbatim("Tracklet")
1535  << " stub in layer " << layer << " at position x y z = " << x << " " << y << " " << z;
1536  tmp_trk_lhits += pow(10, layer - 1);
1537  } else if (detIdStub.subdetId() == StripSubdetector::TID) {
1538  layer = static_cast<int>(tTopo.layer(detIdStub));
1539  if (DebugMode)
1540  edm::LogVerbatim("Tracklet")
1541  << " stub in disk " << layer << " at position x y z = " << x << " " << y << " " << z;
1542  tmp_trk_dhits += pow(10, layer - 1);
1543  }
1544  } //end loop over stubs
1545  }
1546  // ----------------------------------------------------------------------------------------------
1547 
1548  int tmp_trk_genuine = 0;
1549  int tmp_trk_loose = 0;
1550  int tmp_trk_unknown = 0;
1551  int tmp_trk_combinatoric = 0;
1552  if (MCTruthTTTrackExtendedHandle->isLooselyGenuine(l1track_ptr))
1553  tmp_trk_loose = 1;
1554  if (MCTruthTTTrackExtendedHandle->isGenuine(l1track_ptr))
1555  tmp_trk_genuine = 1;
1556  if (MCTruthTTTrackExtendedHandle->isUnknown(l1track_ptr))
1557  tmp_trk_unknown = 1;
1558  if (MCTruthTTTrackExtendedHandle->isCombinatoric(l1track_ptr))
1559  tmp_trk_combinatoric = 1;
1560 
1561  if (DebugMode) {
1562  edm::LogVerbatim("Tracklet") << "L1 track,"
1563  << " pt: " << tmp_trk_pt << " eta: " << tmp_trk_eta << " phi: " << tmp_trk_phi
1564  << " z0: " << tmp_trk_z0 << " chi2: " << tmp_trk_chi2
1565  << " chi2rphi: " << tmp_trk_chi2rphi << " chi2rz: " << tmp_trk_chi2rz
1566  << " nstub: " << tmp_trk_nstub;
1567  if (tmp_trk_genuine)
1568  edm::LogVerbatim("Tracklet") << " (is genuine)";
1569  if (tmp_trk_unknown)
1570  edm::LogVerbatim("Tracklet") << " (is unknown)";
1571  if (tmp_trk_combinatoric)
1572  edm::LogVerbatim("Tracklet") << " (is combinatoric)";
1573  }
1574 
1575  m_trkExt_pt->push_back(tmp_trk_pt);
1576  m_trkExt_eta->push_back(tmp_trk_eta);
1577  m_trkExt_phi->push_back(tmp_trk_phi);
1578  m_trkExt_z0->push_back(tmp_trk_z0);
1579  if (tmp_trk_nFitPars == 5)
1580  m_trkExt_d0->push_back(tmp_trk_d0);
1581  else
1582  m_trkExt_d0->push_back(999.);
1583  m_trkExt_chi2->push_back(tmp_trk_chi2);
1584  m_trkExt_chi2dof->push_back(tmp_trk_chi2dof);
1585  m_trkExt_chi2rphi->push_back(tmp_trk_chi2rphi);
1586  m_trkExt_chi2rz->push_back(tmp_trk_chi2rz);
1587  m_trkExt_bendchi2->push_back(tmp_trk_bendchi2);
1588  m_trkExt_nstub->push_back(tmp_trk_nstub);
1589  m_trkExt_dhits->push_back(tmp_trk_dhits);
1590  m_trkExt_lhits->push_back(tmp_trk_lhits);
1591  m_trkExt_seed->push_back(tmp_trk_seed);
1592  m_trkExt_hitpattern->push_back(tmp_trk_hitpattern);
1593  m_trkExt_phiSector->push_back(tmp_trk_phiSector);
1594  m_trkExt_genuine->push_back(tmp_trk_genuine);
1595  m_trkExt_loose->push_back(tmp_trk_loose);
1596  m_trkExt_unknown->push_back(tmp_trk_unknown);
1597  m_trkExt_combinatoric->push_back(tmp_trk_combinatoric);
1598 
1599  // ----------------------------------------------------------------------------------------------
1600  // for studying the fake rate
1601  // ----------------------------------------------------------------------------------------------
1602  edm::Ptr<TrackingParticle> my_tp = MCTruthTTTrackExtendedHandle->findTrackingParticlePtr(l1track_ptr);
1603 
1604  int myFake = 0;
1605  int myTP_pdgid = -999;
1606  float myTP_pt = -999;
1607  float myTP_eta = -999;
1608  float myTP_phi = -999;
1609  float myTP_z0 = -999;
1610  float myTP_dxy = -999;
1611 
1612  if (my_tp.isNull())
1613  myFake = 0;
1614  else {
1615  int tmp_eventid = my_tp->eventId().event();
1616  if (tmp_eventid > 0)
1617  myFake = 2;
1618  else
1619  myFake = 1;
1620 
1621  myTP_pdgid = my_tp->pdgId();
1622  myTP_pt = my_tp->p4().pt();
1623  myTP_eta = my_tp->p4().eta();
1624  myTP_phi = my_tp->p4().phi();
1625  myTP_z0 = my_tp->vertex().z();
1626 
1627  float myTP_x0 = my_tp->vertex().x();
1628  float myTP_y0 = my_tp->vertex().y();
1629  myTP_dxy = sqrt(myTP_x0 * myTP_x0 + myTP_y0 * myTP_y0);
1630 
1631  if (DebugMode) {
1632  edm::LogVerbatim("Tracklet") << "TP matched to track has pt = " << my_tp->p4().pt()
1633  << " eta = " << my_tp->momentum().eta() << " phi = " << my_tp->momentum().phi()
1634  << " z0 = " << my_tp->vertex().z() << " pdgid = " << my_tp->pdgId()
1635  << " dxy = " << myTP_dxy;
1636  }
1637  }
1638 
1639  m_trkExt_fake->push_back(myFake);
1640  m_trkExt_matchtp_pdgid->push_back(myTP_pdgid);
1641  m_trkExt_matchtp_pt->push_back(myTP_pt);
1642  m_trkExt_matchtp_eta->push_back(myTP_eta);
1643  m_trkExt_matchtp_phi->push_back(myTP_phi);
1644  m_trkExt_matchtp_z0->push_back(myTP_z0);
1645  m_trkExt_matchtp_dxy->push_back(myTP_dxy);
1646  } //end track loop
1647  } //end if SaveAllTracks (displaced)
1648 
1649  // ----------------------------------------------------------------------------------------------
1650  // loop over tracking particles
1651  // ----------------------------------------------------------------------------------------------
1652  if (DebugMode)
1653  edm::LogVerbatim("Tracklet") << "\n Loop over tracking particles!";
1654 
1655  int this_tp = 0;
1656  std::vector<TrackingParticle>::const_iterator iterTP;
1657  for (iterTP = TrackingParticleHandle->begin(); iterTP != TrackingParticleHandle->end(); ++iterTP) {
1658  edm::Ptr<TrackingParticle> tp_ptr(TrackingParticleHandle, this_tp);
1659  this_tp++;
1660 
1661  int tmp_eventid = iterTP->eventId().event();
1662  if (MyProcess != 1 && tmp_eventid > 0)
1663  continue; //only care about tracking particles from the primary interaction (except for MyProcess==1, i.e. looking at all TPs)
1664 
1665  float tmp_tp_pt = iterTP->pt();
1666  float tmp_tp_eta = iterTP->eta();
1667  float tmp_tp_phi = iterTP->phi();
1668  float tmp_tp_vz = iterTP->vz();
1669  float tmp_tp_vx = iterTP->vx();
1670  float tmp_tp_vy = iterTP->vy();
1671  int tmp_tp_pdgid = iterTP->pdgId();
1672  float tmp_tp_z0_prod = tmp_tp_vz;
1673  float tmp_tp_d0_prod = tmp_tp_vx * sin(tmp_tp_phi) - tmp_tp_vy * cos(tmp_tp_phi);
1674 
1675  if (MyProcess == 13 && abs(tmp_tp_pdgid) != 13)
1676  continue;
1677  if (MyProcess == 11 && abs(tmp_tp_pdgid) != 11)
1678  continue;
1679  if ((MyProcess == 6 || MyProcess == 15 || MyProcess == 211) && abs(tmp_tp_pdgid) != 211)
1680  continue;
1681 
1682  if (tmp_tp_pt < TP_minPt)
1683  continue;
1684  if (std::abs(tmp_tp_eta) > TP_maxEta)
1685  continue;
1686 
1687  // ----------------------------------------------------------------------------------------------
1688  // get d0/z0 propagated back to the IP
1689 
1690  float tmp_tp_t = tan(2.0 * atan(1.0) - 2.0 * atan(exp(-tmp_tp_eta)));
1691  float delx = -tmp_tp_vx;
1692  float dely = -tmp_tp_vy;
1693 
1694  float A = 0.01 * 0.5696;
1695  float Kmagnitude = A / tmp_tp_pt;
1696  float tmp_tp_charge = tp_ptr->charge();
1697  float K = Kmagnitude * tmp_tp_charge;
1698  float d = 0;
1699  float tmp_tp_x0p = delx - (d + 1. / (2. * K) * sin(tmp_tp_phi));
1700  float tmp_tp_y0p = dely + (d + 1. / (2. * K) * cos(tmp_tp_phi));
1701  float tmp_tp_rp = sqrt(tmp_tp_x0p * tmp_tp_x0p + tmp_tp_y0p * tmp_tp_y0p);
1702  float tmp_tp_d0 = tmp_tp_charge * tmp_tp_rp - (1. / (2. * K));
1703  tmp_tp_d0 = tmp_tp_d0 * (-1); //fix d0 sign
1704  const double pi = 4.0 * atan(1.0);
1705  float delphi = tmp_tp_phi - atan2(-K * tmp_tp_x0p, K * tmp_tp_y0p);
1706  if (delphi < -pi)
1707  delphi += 2.0 * pi;
1708  if (delphi > pi)
1709  delphi -= 2.0 * pi;
1710  float tmp_tp_z0 = tmp_tp_vz + tmp_tp_t * delphi / (2.0 * K);
1711  // ----------------------------------------------------------------------------------------------
1712 
1713  if (std::abs(tmp_tp_z0) > TP_maxZ0)
1714  continue;
1715 
1716  // for pions in ttbar, only consider TPs coming from near the IP!
1717  float dxy = sqrt(tmp_tp_vx * tmp_tp_vx + tmp_tp_vy * tmp_tp_vy);
1718  float tmp_tp_dxy = dxy;
1719  if (MyProcess == 6 && (dxy > 1.0))
1720  continue;
1721 
1722  if (DebugMode && (Displaced == "Prompt" || Displaced == "Both"))
1723  edm::LogVerbatim("Tracklet") << "Tracking particle, pt: " << tmp_tp_pt << " eta: " << tmp_tp_eta
1724  << " phi: " << tmp_tp_phi << " z0: " << tmp_tp_z0 << " d0: " << tmp_tp_d0
1725  << " z_prod: " << tmp_tp_z0_prod << " d_prod: " << tmp_tp_d0_prod
1726  << " pdgid: " << tmp_tp_pdgid << " eventID: " << iterTP->eventId().event()
1727  << " ttclusters " << MCTruthTTClusterHandle->findTTClusterRefs(tp_ptr).size()
1728  << " ttstubs " << MCTruthTTStubHandle->findTTStubRefs(tp_ptr).size() << " tttracks "
1729  << MCTruthTTTrackHandle->findTTTrackPtrs(tp_ptr).size();
1730 
1731  // ----------------------------------------------------------------------------------------------
1732  // only consider TPs associated with >= 1 cluster, or >= X stubs, or have stubs in >= X layers (configurable options)
1733  if (MCTruthTTClusterHandle->findTTClusterRefs(tp_ptr).empty()) {
1734  if (DebugMode)
1735  edm::LogVerbatim("Tracklet") << "No matching TTClusters for TP, continuing...";
1736  continue;
1737  }
1738 
1739  std::vector<edm::Ref<edmNew::DetSetVector<TTStub<Ref_Phase2TrackerDigi_> >, TTStub<Ref_Phase2TrackerDigi_> > >
1740  theStubRefs = MCTruthTTStubHandle->findTTStubRefs(tp_ptr);
1741  int nStubTP = (int)theStubRefs.size();
1742 
1743  // how many layers/disks have stubs?
1744  int hasStubInLayer[11] = {0};
1745  for (auto& theStubRef : theStubRefs) {
1746  DetId detid(theStubRef->getDetId());
1747 
1748  int layer = -1;
1749  if (detid.subdetId() == StripSubdetector::TOB) {
1750  layer = static_cast<int>(tTopo.layer(detid)) - 1; //fill in array as entries 0-5
1751  } else if (detid.subdetId() == StripSubdetector::TID) {
1752  layer = static_cast<int>(tTopo.layer(detid)) + 5; //fill in array as entries 6-10
1753  }
1754 
1755  //treat genuine stubs separately (==2 is genuine, ==1 is not)
1756  if (MCTruthTTStubHandle->findTrackingParticlePtr(theStubRef).isNull() && hasStubInLayer[layer] < 2)
1757  hasStubInLayer[layer] = 1;
1758  else
1759  hasStubInLayer[layer] = 2;
1760  }
1761 
1762  int nStubLayerTP = 0;
1763  int nStubLayerTP_g = 0;
1764  for (int isum : hasStubInLayer) {
1765  if (isum >= 1)
1766  nStubLayerTP += 1;
1767  if (isum == 2)
1768  nStubLayerTP_g += 1;
1769  }
1770 
1771  if (DebugMode)
1772  edm::LogVerbatim("Tracklet") << "TP is associated with " << nStubTP << " stubs, and has stubs in " << nStubLayerTP
1773  << " different layers/disks, and has GENUINE stubs in " << nStubLayerTP_g
1774  << " layers ";
1775 
1776  if (TP_minNStub > 0) {
1777  if (DebugMode)
1778  edm::LogVerbatim("Tracklet") << "Only consider TPs with >= " << TP_minNStub << " stubs";
1779  if (nStubTP < TP_minNStub) {
1780  if (DebugMode)
1781  edm::LogVerbatim("Tracklet") << "TP fails minimum nbr stubs requirement! Continuing...";
1782  continue;
1783  }
1784  }
1785  if (TP_minNStubLayer > 0) {
1786  if (DebugMode)
1787  edm::LogVerbatim("Tracklet") << "Only consider TPs with stubs in >= " << TP_minNStubLayer << " layers/disks";
1788  if (nStubLayerTP < TP_minNStubLayer) {
1789  if (DebugMode)
1790  edm::LogVerbatim("Tracklet") << "TP fails stubs in minimum nbr of layers/disks requirement! Continuing...";
1791  continue;
1792  }
1793  }
1794 
1795  m_tp_pt->push_back(tmp_tp_pt);
1796  m_tp_eta->push_back(tmp_tp_eta);
1797  m_tp_phi->push_back(tmp_tp_phi);
1798  m_tp_dxy->push_back(tmp_tp_dxy);
1799  m_tp_z0->push_back(tmp_tp_z0);
1800  m_tp_d0->push_back(tmp_tp_d0);
1801  m_tp_z0_prod->push_back(tmp_tp_z0_prod);
1802  m_tp_d0_prod->push_back(tmp_tp_d0_prod);
1803  m_tp_pdgid->push_back(tmp_tp_pdgid);
1804  m_tp_nstub->push_back(nStubTP);
1805  m_tp_eventid->push_back(tmp_eventid);
1806  m_tp_charge->push_back(tmp_tp_charge);
1807 
1808  // ----------------------------------------------------------------------------------------------
1809  // look for L1 tracks (prompt) matched to the tracking particle
1810  if (Displaced == "Prompt" || Displaced == "Both") {
1811  std::vector<edm::Ptr<TTTrack<Ref_Phase2TrackerDigi_> > > matchedTracks =
1812  MCTruthTTTrackHandle->findTTTrackPtrs(tp_ptr);
1813 
1814  int nMatch = 0;
1815  int i_track = -1;
1816  float i_chi2dof = 99999;
1817 
1818  if (!matchedTracks.empty()) {
1819  if (DebugMode && (matchedTracks.size() > 1))
1820  edm::LogVerbatim("Tracklet") << "TrackingParticle has more than one matched L1 track!";
1821 
1822  // ----------------------------------------------------------------------------------------------
1823  // loop over matched L1 tracks
1824  // here, "match" means tracks that can be associated to a TrackingParticle with at least one hit of at least one of its clusters
1825  // https://twiki.cern.ch/twiki/bin/viewauth/CMS/SLHCTrackerTriggerSWTools#MC_truth_for_TTTrack
1826 
1827  for (int it = 0; it < (int)matchedTracks.size(); it++) {
1828  bool tmp_trk_genuine = false;
1829  bool tmp_trk_loosegenuine = false;
1830  if (MCTruthTTTrackHandle->isGenuine(matchedTracks.at(it)))
1831  tmp_trk_genuine = true;
1832  if (MCTruthTTTrackHandle->isLooselyGenuine(matchedTracks.at(it)))
1833  tmp_trk_loosegenuine = true;
1834  if (!tmp_trk_loosegenuine)
1835  continue;
1836 
1837  if (DebugMode) {
1838  if (MCTruthTTTrackHandle->findTrackingParticlePtr(matchedTracks.at(it)).isNull()) {
1839  edm::LogVerbatim("Tracklet") << "track matched to TP is NOT uniquely matched to a TP";
1840  } else {
1841  edm::Ptr<TrackingParticle> my_tp = MCTruthTTTrackHandle->findTrackingParticlePtr(matchedTracks.at(it));
1842  edm::LogVerbatim("Tracklet") << "TP matched to track matched to TP ... tp pt = " << my_tp->p4().pt()
1843  << " eta = " << my_tp->momentum().eta()
1844  << " phi = " << my_tp->momentum().phi() << " z0 = " << my_tp->vertex().z();
1845  }
1846  edm::LogVerbatim("Tracklet") << " ... matched L1 track has pt = "
1847  << matchedTracks.at(it)->momentum().perp()
1848  << " eta = " << matchedTracks.at(it)->momentum().eta()
1849  << " phi = " << matchedTracks.at(it)->momentum().phi()
1850  << " chi2 = " << matchedTracks.at(it)->chi2()
1851  << " consistency = " << matchedTracks.at(it)->stubPtConsistency()
1852  << " z0 = " << matchedTracks.at(it)->z0()
1853  << " nstub = " << matchedTracks.at(it)->getStubRefs().size();
1854  if (tmp_trk_genuine)
1855  edm::LogVerbatim("Tracklet") << " (genuine!) ";
1856  if (tmp_trk_loosegenuine)
1857  edm::LogVerbatim("Tracklet") << " (loose genuine!) ";
1858  }
1859 
1860  std::vector<edm::Ref<edmNew::DetSetVector<TTStub<Ref_Phase2TrackerDigi_> >, TTStub<Ref_Phase2TrackerDigi_> > >
1861  stubRefs = matchedTracks.at(it)->getStubRefs();
1862  int tmp_trk_nstub = stubRefs.size();
1863 
1864  if (tmp_trk_nstub < L1Tk_minNStub)
1865  continue;
1866 
1867  float dmatch_pt = 999;
1868  float dmatch_eta = 999;
1869  float dmatch_phi = 999;
1870  int match_id = 999;
1871 
1872  edm::Ptr<TrackingParticle> my_tp = MCTruthTTTrackHandle->findTrackingParticlePtr(matchedTracks.at(it));
1873  dmatch_pt = std::abs(my_tp->p4().pt() - tmp_tp_pt);
1874  dmatch_eta = std::abs(my_tp->p4().eta() - tmp_tp_eta);
1875  dmatch_phi = std::abs(my_tp->p4().phi() - tmp_tp_phi);
1876  match_id = my_tp->pdgId();
1877  float tmp_trk_chi2dof = matchedTracks.at(it)->chi2Red();
1878 
1879  // ensure that track is uniquely matched to the TP we are looking at!
1880  if (dmatch_pt < 0.1 && dmatch_eta < 0.1 && dmatch_phi < 0.1 && tmp_tp_pdgid == match_id && tmp_trk_genuine) {
1881  nMatch++;
1882  if (i_track < 0 || tmp_trk_chi2dof < i_chi2dof) {
1883  i_track = it;
1884  i_chi2dof = tmp_trk_chi2dof;
1885  }
1886  }
1887 
1888  } // end loop over matched L1 tracks
1889  } // end has at least 1 matched L1 track
1890  // ----------------------------------------------------------------------------------------------
1891 
1892  float tmp_matchtrk_pt = -999;
1893  float tmp_matchtrk_eta = -999;
1894  float tmp_matchtrk_phi = -999;
1895  float tmp_matchtrk_z0 = -999;
1896  float tmp_matchtrk_d0 = -999;
1897  float tmp_matchtrk_chi2 = -999;
1898  float tmp_matchtrk_chi2dof = -999;
1899  float tmp_matchtrk_chi2rphi = -999;
1900  float tmp_matchtrk_chi2rz = -999;
1901  float tmp_matchtrk_bendchi2 = -999;
1902  int tmp_matchtrk_nstub = -999;
1903  int tmp_matchtrk_dhits = -999;
1904  int tmp_matchtrk_lhits = -999;
1905  int tmp_matchtrk_seed = -999;
1906  int tmp_matchtrk_hitpattern = -999;
1907  int tmp_matchtrk_nFitPars = -999;
1908 
1909  if (nMatch > 1 && DebugMode)
1910  edm::LogVerbatim("Tracklet") << "WARNING *** 2 or more matches to genuine L1 tracks ***";
1911 
1912  if (nMatch > 0) {
1913  tmp_matchtrk_pt = matchedTracks.at(i_track)->momentum().perp();
1914  tmp_matchtrk_eta = matchedTracks.at(i_track)->momentum().eta();
1915  tmp_matchtrk_phi = matchedTracks.at(i_track)->momentum().phi();
1916  tmp_matchtrk_z0 = matchedTracks.at(i_track)->z0();
1917  tmp_matchtrk_nFitPars = matchedTracks.at(i_track)->nFitPars();
1918 
1919  if (tmp_matchtrk_nFitPars == 5) {
1920  float tmp_matchtrk_x0 = matchedTracks.at(i_track)->POCA().x();
1921  float tmp_matchtrk_y0 = matchedTracks.at(i_track)->POCA().y();
1922  tmp_matchtrk_d0 = -tmp_matchtrk_x0 * sin(tmp_matchtrk_phi) + tmp_matchtrk_y0 * cos(tmp_matchtrk_phi);
1923  // tmp_matchtrk_d0 = matchedTracks.at(i_track)->d0();
1924  }
1925 
1926  tmp_matchtrk_chi2 = matchedTracks.at(i_track)->chi2();
1927  tmp_matchtrk_chi2dof = matchedTracks.at(i_track)->chi2Red();
1928  tmp_matchtrk_chi2rphi = matchedTracks.at(i_track)->chi2XY();
1929  tmp_matchtrk_chi2rz = matchedTracks.at(i_track)->chi2Z();
1930  tmp_matchtrk_bendchi2 = matchedTracks.at(i_track)->stubPtConsistency();
1931  tmp_matchtrk_nstub = (int)matchedTracks.at(i_track)->getStubRefs().size();
1932  tmp_matchtrk_seed = (int)matchedTracks.at(i_track)->trackSeedType();
1933  tmp_matchtrk_hitpattern = (int)matchedTracks.at(i_track)->hitPattern();
1934 
1935  // ------------------------------------------------------------------------------------------
1936  tmp_matchtrk_dhits = 0;
1937  tmp_matchtrk_lhits = 0;
1938 
1939  std::vector<edm::Ref<edmNew::DetSetVector<TTStub<Ref_Phase2TrackerDigi_> >, TTStub<Ref_Phase2TrackerDigi_> > >
1940  stubRefs = matchedTracks.at(i_track)->getStubRefs();
1941  int tmp_nstub = stubRefs.size();
1942 
1943  for (int is = 0; is < tmp_nstub; is++) {
1944  DetId detIdStub = tGeom.idToDet((stubRefs.at(is)->clusterRef(0))->getDetId())->geographicalId();
1945  int layer = -999999;
1946  if (detIdStub.subdetId() == StripSubdetector::TOB) {
1947  layer = static_cast<int>(tTopo.layer(detIdStub));
1948  tmp_matchtrk_lhits += pow(10, layer - 1);
1949  } else if (detIdStub.subdetId() == StripSubdetector::TID) {
1950  layer = static_cast<int>(tTopo.layer(detIdStub));
1951  tmp_matchtrk_dhits += pow(10, layer - 1);
1952  }
1953  }
1954  }
1955 
1956  m_tp_nmatch->push_back(nMatch);
1957 
1958  m_matchtrk_pt->push_back(tmp_matchtrk_pt);
1959  m_matchtrk_eta->push_back(tmp_matchtrk_eta);
1960  m_matchtrk_phi->push_back(tmp_matchtrk_phi);
1961  m_matchtrk_z0->push_back(tmp_matchtrk_z0);
1962  m_matchtrk_d0->push_back(tmp_matchtrk_d0);
1963  m_matchtrk_chi2->push_back(tmp_matchtrk_chi2);
1964  m_matchtrk_chi2dof->push_back(tmp_matchtrk_chi2dof);
1965  m_matchtrk_chi2rphi->push_back(tmp_matchtrk_chi2rphi);
1966  m_matchtrk_chi2rz->push_back(tmp_matchtrk_chi2rz);
1967  m_matchtrk_bendchi2->push_back(tmp_matchtrk_bendchi2);
1968  m_matchtrk_nstub->push_back(tmp_matchtrk_nstub);
1969  m_matchtrk_dhits->push_back(tmp_matchtrk_dhits);
1970  m_matchtrk_lhits->push_back(tmp_matchtrk_lhits);
1971  m_matchtrk_seed->push_back(tmp_matchtrk_seed);
1972  m_matchtrk_hitpattern->push_back(tmp_matchtrk_hitpattern);
1973  }
1974 
1975  // ----------------------------------------------------------------------------------------------
1976  // look for L1 tracks (extended) matched to the tracking particle
1977  if (Displaced == "Displaced" || Displaced == "Both") {
1978  std::vector<edm::Ptr<TTTrack<Ref_Phase2TrackerDigi_> > > matchedTracks =
1979  MCTruthTTTrackExtendedHandle->findTTTrackPtrs(tp_ptr);
1980 
1981  int nMatch = 0;
1982  int i_track = -1;
1983  float i_chi2dof = 99999;
1984 
1985  if (!matchedTracks.empty()) {
1986  if (DebugMode && (matchedTracks.size() > 1))
1987  edm::LogVerbatim("Tracklet") << "TrackingParticle has more than one matched L1 track!";
1988 
1989  // ----------------------------------------------------------------------------------------------
1990  // loop over matched L1 tracks
1991  // here, "match" means tracks that can be associated to a TrackingParticle with at least one hit of at least one of its clusters
1992  // https://twiki.cern.ch/twiki/bin/viewauth/CMS/SLHCTrackerTriggerSWTools#MC_truth_for_TTTrack
1993 
1994  for (int it = 0; it < (int)matchedTracks.size(); it++) {
1995  bool tmp_trk_genuine = false;
1996  bool tmp_trk_loosegenuine = false;
1997  if (MCTruthTTTrackExtendedHandle->isGenuine(matchedTracks.at(it)))
1998  tmp_trk_genuine = true;
1999  if (MCTruthTTTrackExtendedHandle->isLooselyGenuine(matchedTracks.at(it)))
2000  tmp_trk_loosegenuine = true;
2001  if (!tmp_trk_loosegenuine)
2002  continue;
2003 
2004  if (DebugMode) {
2005  if (MCTruthTTTrackExtendedHandle->findTrackingParticlePtr(matchedTracks.at(it)).isNull()) {
2006  edm::LogVerbatim("Tracklet") << "track matched to TP is NOT uniquely matched to a TP";
2007  } else {
2009  MCTruthTTTrackExtendedHandle->findTrackingParticlePtr(matchedTracks.at(it));
2010  edm::LogVerbatim("Tracklet") << "TP matched to track matched to TP ... tp pt = " << my_tp->p4().pt()
2011  << " eta = " << my_tp->momentum().eta()
2012  << " phi = " << my_tp->momentum().phi() << " z0 = " << my_tp->vertex().z();
2013  }
2014  edm::LogVerbatim("Tracklet") << " ... matched L1 track has pt = "
2015  << matchedTracks.at(it)->momentum().perp()
2016  << " eta = " << matchedTracks.at(it)->momentum().eta()
2017  << " phi = " << matchedTracks.at(it)->momentum().phi()
2018  << " chi2 = " << matchedTracks.at(it)->chi2()
2019  << " consistency = " << matchedTracks.at(it)->stubPtConsistency()
2020  << " z0 = " << matchedTracks.at(it)->z0()
2021  << " nstub = " << matchedTracks.at(it)->getStubRefs().size();
2022  if (tmp_trk_genuine)
2023  edm::LogVerbatim("Tracklet") << " (genuine!) ";
2024  if (tmp_trk_loosegenuine)
2025  edm::LogVerbatim("Tracklet") << " (loose genuine!) ";
2026  }
2027 
2028  std::vector<edm::Ref<edmNew::DetSetVector<TTStub<Ref_Phase2TrackerDigi_> >, TTStub<Ref_Phase2TrackerDigi_> > >
2029  stubRefs = matchedTracks.at(it)->getStubRefs();
2030  int tmp_trk_nstub = stubRefs.size();
2031 
2032  if (tmp_trk_nstub < L1Tk_minNStub)
2033  continue;
2034 
2035  float dmatch_pt = 999;
2036  float dmatch_eta = 999;
2037  float dmatch_phi = 999;
2038  int match_id = 999;
2039 
2041  MCTruthTTTrackExtendedHandle->findTrackingParticlePtr(matchedTracks.at(it));
2042  dmatch_pt = std::abs(my_tp->p4().pt() - tmp_tp_pt);
2043  dmatch_eta = std::abs(my_tp->p4().eta() - tmp_tp_eta);
2044  dmatch_phi = std::abs(my_tp->p4().phi() - tmp_tp_phi);
2045  match_id = my_tp->pdgId();
2046  float tmp_trk_chi2dof = matchedTracks.at(it)->chi2Red();
2047 
2048  // ensure that track is uniquely matched to the TP we are looking at!
2049  if (dmatch_pt < 0.1 && dmatch_eta < 0.1 && dmatch_phi < 0.1 && tmp_tp_pdgid == match_id && tmp_trk_genuine) {
2050  nMatch++;
2051  if (i_track < 0 || tmp_trk_chi2dof < i_chi2dof) {
2052  i_track = it;
2053  i_chi2dof = tmp_trk_chi2dof;
2054  }
2055  }
2056 
2057  } // end loop over matched L1 tracks
2058  } // end has at least 1 matched L1 track
2059  // ----------------------------------------------------------------------------------------------
2060 
2061  float tmp_matchtrkExt_pt = -999;
2062  float tmp_matchtrkExt_eta = -999;
2063  float tmp_matchtrkExt_phi = -999;
2064  float tmp_matchtrkExt_z0 = -999;
2065  float tmp_matchtrkExt_d0 = -999;
2066  float tmp_matchtrkExt_chi2 = -999;
2067  float tmp_matchtrkExt_chi2dof = -999;
2068  float tmp_matchtrkExt_chi2rphi = -999;
2069  float tmp_matchtrkExt_chi2rz = -999;
2070  float tmp_matchtrkExt_bendchi2 = -999;
2071  int tmp_matchtrkExt_nstub = -999;
2072  int tmp_matchtrkExt_dhits = -999;
2073  int tmp_matchtrkExt_lhits = -999;
2074  int tmp_matchtrkExt_seed = -999;
2075  int tmp_matchtrkExt_hitpattern = -999;
2076  int tmp_matchtrkExt_nFitPars = -999;
2077 
2078  if (nMatch > 1 && DebugMode)
2079  edm::LogVerbatim("Tracklet") << "WARNING *** 2 or more matches to genuine L1 tracks ***";
2080 
2081  if (nMatch > 0) {
2082  tmp_matchtrkExt_pt = matchedTracks.at(i_track)->momentum().perp();
2083  tmp_matchtrkExt_eta = matchedTracks.at(i_track)->momentum().eta();
2084  tmp_matchtrkExt_phi = matchedTracks.at(i_track)->momentum().phi();
2085  tmp_matchtrkExt_z0 = matchedTracks.at(i_track)->z0();
2086  tmp_matchtrkExt_nFitPars = matchedTracks.at(i_track)->nFitPars();
2087 
2088  if (tmp_matchtrkExt_nFitPars == 5) {
2089  float tmp_matchtrkExt_x0 = matchedTracks.at(i_track)->POCA().x();
2090  float tmp_matchtrkExt_y0 = matchedTracks.at(i_track)->POCA().y();
2091  tmp_matchtrkExt_d0 =
2092  -tmp_matchtrkExt_x0 * sin(tmp_matchtrkExt_phi) + tmp_matchtrkExt_y0 * cos(tmp_matchtrkExt_phi);
2093  // tmp_matchtrkExt_d0 = matchedTracks.at(i_track)->d0();
2094  }
2095 
2096  tmp_matchtrkExt_chi2 = matchedTracks.at(i_track)->chi2();
2097  tmp_matchtrkExt_chi2dof = matchedTracks.at(i_track)->chi2Red();
2098  tmp_matchtrkExt_chi2rphi = matchedTracks.at(i_track)->chi2XY();
2099  tmp_matchtrkExt_chi2rz = matchedTracks.at(i_track)->chi2Z();
2100  tmp_matchtrkExt_bendchi2 = matchedTracks.at(i_track)->stubPtConsistency();
2101  tmp_matchtrkExt_nstub = (int)matchedTracks.at(i_track)->getStubRefs().size();
2102  tmp_matchtrkExt_seed = (int)matchedTracks.at(i_track)->trackSeedType();
2103  tmp_matchtrkExt_hitpattern = (int)matchedTracks.at(i_track)->hitPattern();
2104 
2105  // ------------------------------------------------------------------------------------------
2106  tmp_matchtrkExt_dhits = 0;
2107  tmp_matchtrkExt_lhits = 0;
2108 
2109  std::vector<edm::Ref<edmNew::DetSetVector<TTStub<Ref_Phase2TrackerDigi_> >, TTStub<Ref_Phase2TrackerDigi_> > >
2110  stubRefs = matchedTracks.at(i_track)->getStubRefs();
2111  int tmp_nstub = stubRefs.size();
2112 
2113  for (int is = 0; is < tmp_nstub; is++) {
2114  DetId detIdStub = tGeom.idToDet((stubRefs.at(is)->clusterRef(0))->getDetId())->geographicalId();
2115  int layer = -999999;
2116  if (detIdStub.subdetId() == StripSubdetector::TOB) {
2117  layer = static_cast<int>(tTopo.layer(detIdStub));
2118  tmp_matchtrkExt_lhits += pow(10, layer - 1);
2119  } else if (detIdStub.subdetId() == StripSubdetector::TID) {
2120  layer = static_cast<int>(tTopo.layer(detIdStub));
2121  tmp_matchtrkExt_dhits += pow(10, layer - 1);
2122  }
2123  }
2124  }
2125 
2126  // m_tp_nmatch->push_back(nMatch); //modify to be matches for ext
2127  m_matchtrkExt_pt->push_back(tmp_matchtrkExt_pt);
2128  m_matchtrkExt_eta->push_back(tmp_matchtrkExt_eta);
2129  m_matchtrkExt_phi->push_back(tmp_matchtrkExt_phi);
2130  m_matchtrkExt_z0->push_back(tmp_matchtrkExt_z0);
2131  m_matchtrkExt_d0->push_back(tmp_matchtrkExt_d0);
2132  m_matchtrkExt_chi2->push_back(tmp_matchtrkExt_chi2);
2133  m_matchtrkExt_chi2dof->push_back(tmp_matchtrkExt_chi2dof);
2134  m_matchtrkExt_chi2rphi->push_back(tmp_matchtrkExt_chi2rphi);
2135  m_matchtrkExt_chi2rz->push_back(tmp_matchtrkExt_chi2rz);
2136  m_matchtrkExt_bendchi2->push_back(tmp_matchtrkExt_bendchi2);
2137  m_matchtrkExt_nstub->push_back(tmp_matchtrkExt_nstub);
2138  m_matchtrkExt_dhits->push_back(tmp_matchtrkExt_dhits);
2139  m_matchtrkExt_lhits->push_back(tmp_matchtrkExt_lhits);
2140  m_matchtrkExt_seed->push_back(tmp_matchtrkExt_seed);
2141  m_matchtrkExt_hitpattern->push_back(tmp_matchtrkExt_hitpattern);
2142  }
2143 
2144  } //end loop tracking particles
2145 
2146  if (SaveTrackMET) {
2147  if (Displaced == "Prompt" || Displaced == "Both") {
2148  if (L1TkMETHandle.isValid()) {
2149  trkMET = L1TkMETHandle->begin()->etMiss();
2150  } else {
2151  edm::LogWarning("DataNotFound") << "\nWarning: tkMET handle not found in the event" << std::endl;
2152  }
2153 
2154  if (L1TkMHTHandle.isValid()) {
2155  trkMHT = L1TkMHTHandle->begin()->EtMiss();
2156  trkHT = L1TkMHTHandle->begin()->etTotal();
2157  } else {
2158  edm::LogWarning("DataNotFound") << "\nWarning: tkMHT handle not found in the event" << std::endl;
2159  }
2160  } //end prompt-track quantities
2161 
2162  if (Displaced == "Displaced" || Displaced == "Both") {
2163  if (L1TkMETExtendedHandle.isValid()) {
2164  trkMETExt = L1TkMETExtendedHandle->begin()->etMiss();
2165  } else {
2166  edm::LogWarning("DataNotFound") << "\nWarning: tkMETExtended handle not found in the event" << std::endl;
2167  }
2168 
2169  if (L1TkMHTExtendedHandle.isValid()) {
2170  trkMHTExt = L1TkMHTExtendedHandle->begin()->EtMiss();
2171  trkHTExt = L1TkMHTExtendedHandle->begin()->etTotal();
2172  } else {
2173  edm::LogWarning("DataNotFound") << "\nWarning: tkMHTExtended handle not found in the event" << std::endl;
2174  }
2175  } //end displaced-track quantities
2176  }
2177 
2178  if (SaveTrackJets) {
2179  if (TrackFastJetsHandle.isValid() && (Displaced == "Prompt" || Displaced == "Both")) {
2180  for (jetIter = TrackFastJetsHandle->begin(); jetIter != TrackFastJetsHandle->end(); ++jetIter) {
2181  m_trkjet_vz->push_back(jetIter->jetVtx());
2182  m_trkjet_ntracks->push_back(jetIter->trkPtrs().size());
2183  m_trkjet_phi->push_back(jetIter->phi());
2184  m_trkjet_eta->push_back(jetIter->eta());
2185  m_trkjet_pt->push_back(jetIter->pt());
2186  m_trkjet_p->push_back(jetIter->p());
2187  }
2188  }
2189  if (TrackFastJetsExtendedHandle.isValid() && (Displaced == "Displaced" || Displaced == "Both")) {
2190  for (jetIter = TrackFastJetsExtendedHandle->begin(); jetIter != TrackFastJetsExtendedHandle->end(); ++jetIter) {
2191  m_trkjetExt_vz->push_back(jetIter->jetVtx());
2192  m_trkjetExt_ntracks->push_back(jetIter->trkPtrs().size());
2193  m_trkjetExt_phi->push_back(jetIter->phi());
2194  m_trkjetExt_eta->push_back(jetIter->eta());
2195  m_trkjetExt_pt->push_back(jetIter->pt());
2196  m_trkjetExt_p->push_back(jetIter->p());
2197  }
2198  }
2199  if (!TrackJetsHandle.isValid() && (Displaced == "Prompt" || Displaced == "Both")) {
2200  edm::LogWarning("DataNotFound") << "\nWarning: TrackJetsHandle not found in the event" << std::endl;
2201  }
2202  if (!TrackJetsExtendedHandle.isValid() && (Displaced == "Displaced" || Displaced == "Both")) {
2203  edm::LogWarning("DataNotFound") << "\nWarning: TrackJetsExtendedHandle not found in the event" << std::endl;
2204  }
2205  if (TrackJetsHandle.isValid() && (Displaced == "Prompt" || Displaced == "Both")) {
2206  for (jetIter = TrackJetsHandle->begin(); jetIter != TrackJetsHandle->end(); ++jetIter) {
2207  m_2ltrkjet_vz->push_back(jetIter->jetVtx());
2208  m_2ltrkjet_ntracks->push_back(jetIter->ntracks());
2209  m_2ltrkjet_phi->push_back(jetIter->phi());
2210  m_2ltrkjet_eta->push_back(jetIter->eta());
2211  m_2ltrkjet_pt->push_back(jetIter->pt());
2212  m_2ltrkjet_p->push_back(jetIter->p());
2213  m_2ltrkjet_nDisplaced->push_back(jetIter->nDisptracks());
2214  m_2ltrkjet_nTight->push_back(jetIter->nTighttracks());
2215  m_2ltrkjet_nTightDisplaced->push_back(jetIter->nTightDisptracks());
2216  }
2217  }
2218 
2219  if (TrackJetsExtendedHandle.isValid() && (Displaced == "Displaced" || Displaced == "Both")) {
2220  for (jetIter = TrackJetsExtendedHandle->begin(); jetIter != TrackJetsExtendedHandle->end(); ++jetIter) {
2221  m_2ltrkjetExt_vz->push_back(jetIter->jetVtx());
2222  m_2ltrkjetExt_ntracks->push_back(jetIter->ntracks());
2223  m_2ltrkjetExt_phi->push_back(jetIter->phi());
2224  m_2ltrkjetExt_eta->push_back(jetIter->eta());
2225  m_2ltrkjetExt_pt->push_back(jetIter->pt());
2226  m_2ltrkjetExt_p->push_back(jetIter->p());
2227  m_2ltrkjetExt_nDisplaced->push_back(jetIter->nDisptracks());
2228  m_2ltrkjetExt_nTight->push_back(jetIter->nTighttracks());
2229  m_2ltrkjetExt_nTightDisplaced->push_back(jetIter->nTightDisptracks());
2230  }
2231  }
2232 
2233  if (L1TkPrimaryVertexHandle.isValid()) {
2234  m_pv_L1reco->push_back(L1TkPrimaryVertexHandle->begin()->zvertex());
2235  } else {
2236  edm::LogWarning("DataNotFound") << "\nWarning: L1TkPrimaryVertexHandle not found in the event" << std::endl;
2237  }
2238  } // end track jets
2239 
2240  eventTree->Fill();
2241 } // end of analyze()
2242 
2244 // DEFINE THIS AS A PLUG-IN
std::vector< float > * m_matchtrkExt_eta
std::vector< float > * m_matchtrkExt_d0
std::vector< float > * m_trkjetExt_tp_sumpt
Log< level::Info, true > LogVerbatim
GlobalPoint toGlobal(const Point2DBase< Scalar, LocalTag > lp) const
Definition: Surface.h:79
std::vector< float > * m_trkExt_matchtp_phi
edm::EDGetTokenT< TTTrackAssociationMap< Ref_Phase2TrackerDigi_ > > ttTrackMCTruthToken_
std::vector< float > * m_2ltrkjet_phi
edm::Ref< typename HandleT::element_type, typename HandleT::element_type::value_type::value_type > makeRefTo(const HandleT &iHandle, typename HandleT::element_type::value_type::const_iterator itIter)
edm::ESGetToken< TrackerTopology, TrackerTopologyRcd > tTopoToken_
std::vector< float > * m_trk_chi2rphi
std::vector< float > * m_trkjet_p
std::vector< int > * m_2ltrkjetExt_ntracks
std::vector< float > * m_matchtrkExt_bendchi2
std::vector< int > * m_matchtrk_dhits
std::vector< int > * m_2ltrkjetExt_nTightDisplaced
std::vector< float > * m_matchtrkExt_z0
std::vector< float > * m_trk_phi
std::vector< int > * m_trkExt_matchtp_pdgid
std::vector< float > * m_matchtrk_chi2dof
std::vector< int > * m_trkExt_unknown
const TrackerGeomDet * idToDetUnit(DetId) const override
Return the pointer to the GeomDetUnit corresponding to a given DetId.
double pt() const final
transverse momentum
virtual LocalPoint localPosition(const MeasurementPoint &) const =0
std::vector< int > * m_matchtrkExt_seed
std::vector< float > * m_allstub_trigOffset
std::vector< float > * m_trk_matchtp_dxy
std::vector< float > * m_trkjet_truetp_sumpt
edm::ESGetToken< TrackerGeometry, TrackerDigiGeometryRecord > tGeomToken_
std::vector< float > * m_2ltrkjetExt_pt
L1TrackObjectNtupleMaker(const edm::ParameterSet &iConfig)
std::vector< float > * m_trkExt_chi2
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:539
std::vector< float > * m_trkjetExt_truetp_sumpt
virtual const Topology & topology() const
Definition: GeomDet.cc:67
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
std::vector< float > * m_matchtrk_z0
std::vector< float > * m_trk_matchtp_phi
Sin< T >::type sin(const T &t)
Definition: Sin.h:22
edm::EDGetTokenT< l1t::TkHTMissCollection > TrackMHTExtendedToken_
std::vector< float > * m_trkjet_pt
std::vector< int > * m_2ltrkjet_nTightDisplaced
edm::EDGetTokenT< std::vector< TrackingParticle > > TrackingParticleToken_
T y() const
Definition: PV3DBase.h:60
list status
Definition: mps_update.py:107
virtual int nrows() const =0
std::vector< float > * m_allstub_matchTP_pt
edm::EDGetTokenT< l1t::TkJetCollection > TrackJetsToken_
int status() const final
status word
std::vector< int > * m_trkjet_ntracks
T * make(const Args &...args) const
make new ROOT object
Definition: TFileService.h:64
const DetContainer & dets() const override
Returm a vector of all GeomDet (including all GeomDetUnits)
Exp< T >::type exp(const T &t)
Definition: Exp.h:22
double isum
std::vector< float > * m_2ltrkjetExt_eta
edm::EDGetTokenT< std::vector< TTTrack< Ref_Phase2TrackerDigi_ > > > ttTrackExtendedToken_
std::vector< float > * m_trkExt_d0
void analyze(const edm::Event &iEvent, const edm::EventSetup &iSetup) override
std::vector< float > * m_matchtrkExt_chi2
const Plane & surface() const
The nominal surface of the GeomDet.
Definition: GeomDet.h:37
std::vector< unsigned int > * m_trk_phiSector
example_stream void analyze(const edm::Event &, const edm::EventSetup &) override
std::vector< int > * m_allstub_matchTP_pdgid
std::vector< float > * m_trk_chi2
std::vector< float > * m_matchtrkExt_pt
std::vector< float > * m_trk_chi2rz
void beginJob()
Definition: Breakpoints.cc:14
std::vector< float > * m_allstub_trigDisplace
constexpr std::array< uint8_t, layerIndexSize > layer
edm::EDGetTokenT< std::vector< l1t::TkEtMiss > > TrackMETToken_
const Double_t pi
std::vector< float > * m_trkExt_eta
int pdgId() const final
PDG identifier.
bool isLower(const DetId &id) const
bool getData(T &iHolder) const
Definition: EventSetup.h:128
tuple d
Definition: ztail.py:151
std::vector< float > * m_trkjet_tp_sumpt
std::vector< float > * m_trkjetExt_p
std::vector< float > * m_allstub_matchTP_phi
std::vector< float > * m_2ltrkjet_p
std::vector< float > * m_matchtrkExt_chi2dof
edm::EDGetTokenT< std::vector< l1t::TkJet > > TrackFastJetsExtendedToken_
std::vector< int > * m_2ltrkjet_ntdtrk
std::vector< float > * m_matchtrk_eta
int iEvent
Definition: GenABIO.cc:224
bool isNeutrino(const Candidate &part)
Definition: pdgIdUtils.h:17
std::vector< int > * m_2ltrkjetExt_ntdtrk
std::vector< int > * m_trk_hitpattern
std::vector< int > * m_allstub_genuine
std::vector< int > * m_trkExt_hitpattern
std::vector< float > * m_tp_z0_prod
std::vector< float > * m_trkExt_chi2rz
T sqrt(T t)
Definition: SSEVec.h:19
std::vector< float > * m_trk_matchtp_z0
T z() const
Definition: PV3DBase.h:61
std::vector< float > * m_2ltrkjetExt_p
Cos< T >::type cos(const T &t)
Definition: Cos.h:22
edm::EDGetTokenT< std::vector< TTTrack< Ref_Phase2TrackerDigi_ > > > ttTrackToken_
bool isNull() const
Checks for null.
Definition: Ptr.h:142
bool isAvailable() const
Definition: Service.h:40
constexpr int subdetId() const
get the contents of the subdetector field (not cast into any detector&#39;s numbering enum) ...
Definition: DetId.h:48
std::vector< float > * m_trkjet_phi
std::vector< float > * m_trkjetExt_vz
Tan< T >::type tan(const T &t)
Definition: Tan.h:22
std::vector< float > * m_trk_bendchi2
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
edm::EDGetTokenT< edmNew::DetSetVector< TTStub< Ref_Phase2TrackerDigi_ > > > ttStubToken_
edm::EDGetTokenT< TTClusterAssociationMap< Ref_Phase2TrackerDigi_ > > ttClusterMCTruthToken_
std::vector< float > * m_allstub_x
std::vector< int > * m_2ltrkjet_ntracks
std::vector< float > * m_allstub_trigBend
std::vector< float > * m_trkjetExt_phi
std::vector< unsigned int > * m_trkExt_phiSector
std::vector< float > * m_trkExt_phi
std::vector< float > * m_trk_matchtp_eta
std::vector< float > * m_2ltrkjetExt_phi
std::vector< float > * m_trkExt_matchtp_eta
std::vector< int > * m_matchtrkExt_lhits
std::vector< float > * m_pv_L1reco
std::vector< float > * m_trkExt_matchtp_dxy
static constexpr auto TOB
std::vector< float > * m_matchtrk_chi2rz
bool isValid() const
Definition: HandleBase.h:70
Class to store the L1 Track Trigger stubs.
Definition: TTStub.h:22
std::vector< float > * m_allstub_z
edm::EDGetTokenT< l1t::TkPrimaryVertexCollection > L1VertexToken_
std::vector< float > * m_trk_chi2dof
const TrackerGeomDet * idToDet(DetId) const override
std::vector< float > * m_2ltrkjetExt_vz
std::vector< int > * m_trkjetExt_ntracks
std::vector< float > * m_trkjet_eta
std::vector< int > * m_allstub_isBarrel
std::vector< float > * m_trkExt_matchtp_pt
std::vector< float > * m_matchtrk_bendchi2
std::vector< float > * m_trkExt_matchtp_z0
std::vector< int > * m_allstub_isPSmodule
Definition: DetId.h:17
std::vector< float > * m_trkExt_chi2dof
std::vector< float > * m_matchtrk_phi
edm::EDGetTokenT< std::vector< reco::GenJet > > GenJetToken_
std::vector< float > * m_tp_d0_prod
std::vector< float > * m_allstub_matchTP_eta
std::vector< int > * m_2ltrkjetExt_nDisplaced
std::vector< int > * m_trk_matchtp_pdgid
edm::EDGetTokenT< TTStubAssociationMap< Ref_Phase2TrackerDigi_ > > ttStubMCTruthToken_
uint32_t stack(const DetId &id) const
std::vector< int > * m_2ltrkjet_nDisplaced
std::vector< int > * m_trkExt_combinatoric
std::vector< float > * m_matchtrkExt_phi
std::vector< float > * m_trkjetExt_eta
edm::EDGetTokenT< edmNew::DetSetVector< TTCluster< Ref_Phase2TrackerDigi_ > > > ttClusterToken_
std::vector< int > * m_matchtrk_hitpattern
edm::EDGetTokenT< std::vector< l1t::TkEtMiss > > TrackMETExtendedToken_
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
std::vector< float > * m_matchtrk_chi2rphi
std::vector< int > * m_trkExt_genuine
std::vector< float > * m_allstub_trigPos
std::vector< float > * m_trk_eta
std::vector< int > * m_matchtrkExt_dhits
unsigned int layer(const DetId &id) const
std::vector< float > * m_2ltrkjet_pt
std::vector< float > * m_trkjet_vz
tuple config
parse the configuration file
edm::EDGetTokenT< std::vector< reco::GenParticle > > GenParticleToken_
iterator end()
Definition: DetSetNew.h:56
std::vector< float > * m_trkExt_z0
std::vector< float > * m_matchtrk_d0
std::vector< float > * m_trkExt_chi2rphi
std::vector< float > * m_trk_matchtp_pt
std::vector< int > * m_trk_combinatoric
std::vector< float > * m_2ltrkjet_vz
std::vector< float > * m_allstub_y
std::vector< int > * m_matchtrk_lhits
std::vector< float > * m_trkExt_bendchi2
std::vector< int > * m_matchtrkExt_hitpattern
std::vector< float > * m_trkjetExt_pt
std::vector< float > * m_matchtrkExt_chi2rphi
std::vector< int > * m_2ltrkjet_nTight
Log< level::Warning, false > LogWarning
std::vector< int > * m_matchtrk_nstub
edm::EDGetTokenT< std::vector< l1t::TkJet > > TrackFastJetsToken_
double phi() const final
momentum azimuthal angle
T x() const
Definition: PV3DBase.h:59
edm::EDGetTokenT< l1t::TkJetCollection > TrackJetsExtendedToken_
std::vector< float > * m_2ltrkjet_eta
static constexpr auto TID
std::vector< float > * m_matchtrk_chi2
edm::EDGetTokenT< TTTrackAssociationMap< Ref_Phase2TrackerDigi_ > > ttTrackMCTruthExtendedToken_
edm::EDGetTokenT< std::vector< TrackingVertex > > TrackingVertexToken_
std::vector< int > * m_matchtrk_seed
std::vector< float > * m_matchtrkExt_chi2rz
Power< A, B >::type pow(const A &a, const B &b)
Definition: Power.h:29
std::vector< int > * m_allstub_layer
std::vector< float > * m_trkExt_pt
edm::EDGetTokenT< l1t::TkHTMissCollection > TrackMHTToken_
std::vector< float > * m_matchtrk_pt
std::vector< int > * m_matchtrkExt_nstub
std::vector< int > * m_2ltrkjetExt_nTight
iterator begin()
Definition: DetSetNew.h:54