ECCE @ 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 bPhi = m_cfg.varBinning.at("Phi");
25  PlotHelpers::Binning bEta = m_cfg.varBinning.at("Eta");
26  PlotHelpers::Binning bPt = m_cfg.varBinning.at("Pt");
27  PlotHelpers::Binning bNum = m_cfg.varBinning.at("Num");
28  ACTS_DEBUG("Initialize the histograms for fake rate plots");
29 
30  // number fo reco tracks
31  fakeRatePlotCache.nRecoTracks = PlotHelpers::bookHisto(
32  "nRecoTracks", "Number of reconstructed track candidates", bNum);
33  // number fo truth-matched tracks
34  fakeRatePlotCache.nTruthMatchedTracks = PlotHelpers::bookHisto(
35  "nTruthMatchedTracks", "Number of truth-matched track candidates", bNum);
36  // number fo fake tracks
37  fakeRatePlotCache.nFakeTracks = PlotHelpers::bookHisto(
38  "nFakeTracks", "Number of fake track candidates", bNum);
39 
40  // fake rate vs pT
41  fakeRatePlotCache.fakerate_vs_pT = PlotHelpers::bookEff(
42  "fakerate_vs_pT", "Tracking fake rate;pT [GeV/c];Fake rate", bPt);
43  // fake rate vs eta
44  fakeRatePlotCache.fakerate_vs_eta = PlotHelpers::bookEff(
45  "fakerate_vs_eta", "Tracking fake rate;#eta;Fake rate", bEta);
46  // fake rate vs phi
47  fakeRatePlotCache.fakerate_vs_phi = PlotHelpers::bookEff(
48  "fakerate_vs_phi", "Tracking fake rate;#phi;Fake rate", bPhi);
49 
50  // duplication number vs pT
51  fakeRatePlotCache.duplicationNum_vs_pT = PlotHelpers::bookProf(
52  "duplicationNum_vs_pT", "Duplication number vs. pT", bPt, bNum);
53  // duplication number vs eta
54  fakeRatePlotCache.duplicationNum_vs_eta = PlotHelpers::bookProf(
55  "duplicationNum_vs_eta", "Duplication number vs. #eta", bEta, bNum);
56  // duplication number vs phi
57  fakeRatePlotCache.duplicationNum_vs_phi = PlotHelpers::bookProf(
58  "duplicationNum_vs_phi", "Duplication number vs. #phi", bPhi, bNum);
59 }
60 
61 void FW::FakeRatePlotTool::clear(FakeRatePlotCache& fakeRatePlotCache) const {
62  delete fakeRatePlotCache.nRecoTracks;
63  delete fakeRatePlotCache.nTruthMatchedTracks;
64  delete fakeRatePlotCache.nFakeTracks;
65  delete fakeRatePlotCache.fakerate_vs_pT;
66  delete fakeRatePlotCache.fakerate_vs_eta;
67  delete fakeRatePlotCache.fakerate_vs_phi;
68  delete fakeRatePlotCache.duplicationNum_vs_pT;
69  delete fakeRatePlotCache.duplicationNum_vs_eta;
70  delete fakeRatePlotCache.duplicationNum_vs_phi;
71 }
72 
74  const FakeRatePlotTool::FakeRatePlotCache& fakeRatePlotCache) const {
75  ACTS_DEBUG("Write the plots to output file.");
76  fakeRatePlotCache.fakerate_vs_pT->Write();
77  fakeRatePlotCache.fakerate_vs_eta->Write();
78  fakeRatePlotCache.fakerate_vs_phi->Write();
79  fakeRatePlotCache.nRecoTracks->Write();
80  fakeRatePlotCache.nTruthMatchedTracks->Write();
81  fakeRatePlotCache.nFakeTracks->Write();
82  fakeRatePlotCache.duplicationNum_vs_pT->Write();
83  fakeRatePlotCache.duplicationNum_vs_eta->Write();
84  fakeRatePlotCache.duplicationNum_vs_phi->Write();
85 }
86 
88  FakeRatePlotTool::FakeRatePlotCache& fakeRatePlotCache,
89  const ActsFatras::Particle& truthParticle, bool status) const {
90  const auto t_phi = phi(truthParticle.unitDirection());
91  const auto t_eta = eta(truthParticle.unitDirection());
92  const auto t_pT = truthParticle.transverseMomentum();
93 
94  PlotHelpers::fillEff(fakeRatePlotCache.fakerate_vs_pT, t_pT, status);
95  PlotHelpers::fillEff(fakeRatePlotCache.fakerate_vs_eta, t_eta, status);
96  PlotHelpers::fillEff(fakeRatePlotCache.fakerate_vs_phi, t_phi, status);
97 }
98 
100  FakeRatePlotTool::FakeRatePlotCache& fakeRatePlotCache,
101  const ActsFatras::Particle& truthParticle, size_t nTruthMatchedTracks,
102  size_t nFakeTracks) const {
103  const auto t_phi = phi(truthParticle.unitDirection());
104  const auto t_eta = eta(truthParticle.unitDirection());
105  const auto t_pT = truthParticle.transverseMomentum();
106 
107  PlotHelpers::fillHisto(fakeRatePlotCache.nRecoTracks,
108  nTruthMatchedTracks + nFakeTracks);
110  nTruthMatchedTracks);
111  PlotHelpers::fillHisto(fakeRatePlotCache.nFakeTracks, nFakeTracks);
112 
113  PlotHelpers::fillProf(fakeRatePlotCache.duplicationNum_vs_pT, t_pT,
114  nTruthMatchedTracks);
115  PlotHelpers::fillProf(fakeRatePlotCache.duplicationNum_vs_eta, t_eta,
116  nTruthMatchedTracks);
117  PlotHelpers::fillProf(fakeRatePlotCache.duplicationNum_vs_phi, t_phi,
118  nTruthMatchedTracks);
119 }