EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
FakeRatePlotTool.cpp
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file FakeRatePlotTool.cpp
1 // This file is part of the Acts project.
2 //
3 // Copyright (C) 2019 CERN for the benefit of the Acts project
4 //
5 // This Source Code Form is subject to the terms of the Mozilla Public
6 // License, v. 2.0. If a copy of the MPL was not distributed with this
7 // file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 
10 
12 
17 
20  : m_cfg(cfg), m_logger(Acts::getDefaultLogger("FakeRatePlotTool", lvl)) {}
21 
23  FakeRatePlotTool::FakeRatePlotCache& fakeRatePlotCache) const {
24  PlotHelpers::Binning bPt = m_cfg.varBinning.at("Pt");
25  PlotHelpers::Binning bEta = m_cfg.varBinning.at("Eta");
26  PlotHelpers::Binning bPhi = m_cfg.varBinning.at("Phi");
27  PlotHelpers::Binning bNum = m_cfg.varBinning.at("Num");
28  ACTS_DEBUG("Initialize the histograms for fake rate plots");
29 
30  // number of reco tracks vs pT scatter plots
31  fakeRatePlotCache.nReco_vs_pT = PlotHelpers::bookHisto(
32  "nRecoTracks_vs_pT", "Number of reconstructed track candidates", bPt,
33  bNum);
34  // number of truth-matched tracks vs pT scatter plots
35  fakeRatePlotCache.nTruthMatched_vs_pT = PlotHelpers::bookHisto(
36  "nTruthMatchedTracks_vs_pT", "Number of truth-matched track candidates",
37  bPt, bNum);
38  // number of fake tracks vs pT scatter plots
39  fakeRatePlotCache.nFake_vs_pT = PlotHelpers::bookHisto(
40  "nFakeTracks_vs_pT", "Number of fake track candidates", bPt, bNum);
41 
42  // number of reco tracks vs eta scatter plots
43  fakeRatePlotCache.nReco_vs_eta = PlotHelpers::bookHisto(
44  "nRecoTracks_vs_eta", "Number of reconstructed track candidates", bEta,
45  bNum);
46  // number of truth-matched tracks vs eta scatter plots
47  fakeRatePlotCache.nTruthMatched_vs_eta = PlotHelpers::bookHisto(
48  "nTruthMatchedTracks_vs_eta", "Number of truth-matched track candidates",
49  bEta, bNum);
50  // number of fake tracks vs eta scatter plots
51  fakeRatePlotCache.nFake_vs_eta = PlotHelpers::bookHisto(
52  "nFakeTracks_vs_eta", "Number of fake track candidates", bEta, bNum);
53 
54  // fake rate vs pT
55  fakeRatePlotCache.fakeRate_vs_pT = PlotHelpers::bookEff(
56  "fakerate_vs_pT", "Tracking fake rate;pT [GeV/c];Fake rate", bPt);
57  // fake rate vs eta
58  fakeRatePlotCache.fakeRate_vs_eta = PlotHelpers::bookEff(
59  "fakerate_vs_eta", "Tracking fake rate;#eta;Fake rate", bEta);
60  // fake rate vs phi
61  fakeRatePlotCache.fakeRate_vs_phi = PlotHelpers::bookEff(
62  "fakerate_vs_phi", "Tracking fake rate;#phi;Fake rate", bPhi);
63 }
64 
66  FakeRatePlotCache& fakeRatePlotCache) const {
67  delete fakeRatePlotCache.nReco_vs_pT;
68  delete fakeRatePlotCache.nTruthMatched_vs_pT;
69  delete fakeRatePlotCache.nFake_vs_pT;
70  delete fakeRatePlotCache.nReco_vs_eta;
71  delete fakeRatePlotCache.nTruthMatched_vs_eta;
72  delete fakeRatePlotCache.nFake_vs_eta;
73  delete fakeRatePlotCache.fakeRate_vs_pT;
74  delete fakeRatePlotCache.fakeRate_vs_eta;
75  delete fakeRatePlotCache.fakeRate_vs_phi;
76 }
77 
79  const FakeRatePlotTool::FakeRatePlotCache& fakeRatePlotCache) const {
80  ACTS_DEBUG("Write the plots to output file.");
81  fakeRatePlotCache.nReco_vs_pT->Write();
82  fakeRatePlotCache.nTruthMatched_vs_pT->Write();
83  fakeRatePlotCache.nFake_vs_pT->Write();
84  fakeRatePlotCache.nReco_vs_eta->Write();
85  fakeRatePlotCache.nTruthMatched_vs_eta->Write();
86  fakeRatePlotCache.nFake_vs_eta->Write();
87  fakeRatePlotCache.fakeRate_vs_pT->Write();
88  fakeRatePlotCache.fakeRate_vs_eta->Write();
89  fakeRatePlotCache.fakeRate_vs_phi->Write();
90 }
91 
93  FakeRatePlotTool::FakeRatePlotCache& fakeRatePlotCache,
94  const Acts::BoundTrackParameters& fittedParameters, bool status) const {
95  const auto& momentum = fittedParameters.momentum();
96  const double fit_phi = phi(momentum);
97  const double fit_eta = eta(momentum);
98  const double fit_pT = perp(momentum);
99 
100  PlotHelpers::fillEff(fakeRatePlotCache.fakeRate_vs_pT, fit_pT, status);
101  PlotHelpers::fillEff(fakeRatePlotCache.fakeRate_vs_eta, fit_eta, status);
102  PlotHelpers::fillEff(fakeRatePlotCache.fakeRate_vs_phi, fit_phi, status);
103 }
104 
106  FakeRatePlotTool::FakeRatePlotCache& fakeRatePlotCache,
107  const ActsFatras::Particle& truthParticle, size_t nTruthMatchedTracks,
108  size_t nFakeTracks) const {
109  const auto t_eta = eta(truthParticle.unitDirection());
110  const auto t_pT = truthParticle.transverseMomentum();
111 
112  PlotHelpers::fillHisto(fakeRatePlotCache.nReco_vs_pT, t_pT,
113  nTruthMatchedTracks + nFakeTracks);
114  PlotHelpers::fillHisto(fakeRatePlotCache.nTruthMatched_vs_pT, t_pT,
115  nTruthMatchedTracks);
116  PlotHelpers::fillHisto(fakeRatePlotCache.nFake_vs_pT, t_pT, nFakeTracks);
117 
118  PlotHelpers::fillHisto(fakeRatePlotCache.nReco_vs_eta, t_eta,
119  nTruthMatchedTracks + nFakeTracks);
120  PlotHelpers::fillHisto(fakeRatePlotCache.nTruthMatched_vs_eta, t_eta,
121  nTruthMatchedTracks);
122  PlotHelpers::fillHisto(fakeRatePlotCache.nFake_vs_eta, t_eta, nFakeTracks);
123 }