Analysis Software
Documentation for sPHENIX simulation software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
DuplicationPlotTool.cpp
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file DuplicationPlotTool.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 
14 
15 #include <TEfficiency.h>
16 #include <TProfile.h>
17 
22 
26  : m_cfg(cfg),
27  m_logger(Acts::getDefaultLogger("DuplicationPlotTool", lvl)) {}
28 
30  DuplicationPlotTool::DuplicationPlotCache& duplicationPlotCache) const {
31  PlotHelpers::Binning bPt = m_cfg.varBinning.at("Pt");
32  PlotHelpers::Binning bEta = m_cfg.varBinning.at("Eta");
33  PlotHelpers::Binning bPhi = m_cfg.varBinning.at("Phi");
34  PlotHelpers::Binning bNum = m_cfg.varBinning.at("Num");
35  ACTS_DEBUG("Initialize the histograms for duplication rate plots");
36 
37  // duplication rate vs pT
38  duplicationPlotCache.duplicationRate_vs_pT =
39  PlotHelpers::bookEff("duplicationRate_vs_pT",
40  "Duplication rate;pT [GeV/c];Duplication rate", bPt);
41  // duplication rate vs eta
42  duplicationPlotCache.duplicationRate_vs_eta = PlotHelpers::bookEff(
43  "duplicationRate_vs_eta", "Duplication rate;#eta;Duplication rate", bEta);
44  // duplication rate vs phi
45  duplicationPlotCache.duplicationRate_vs_phi = PlotHelpers::bookEff(
46  "duplicationRate_vs_phi", "Duplication rate;#phi;Duplication rate", bPhi);
47 
48  // duplication number vs pT
49  duplicationPlotCache.nDuplicated_vs_pT = PlotHelpers::bookProf(
50  "nDuplicated_vs_pT", "Number of duplicated track candidates", bPt, bNum);
51  // duplication number vs eta
52  duplicationPlotCache.nDuplicated_vs_eta = PlotHelpers::bookProf(
53  "nDuplicated_vs_eta", "Number of duplicated track candidates", bEta,
54  bNum);
55  // duplication number vs phi
56  duplicationPlotCache.nDuplicated_vs_phi = PlotHelpers::bookProf(
57  "nDuplicated_vs_phi", "Number of duplicated track candidates", bPhi,
58  bNum);
59 }
60 
62  DuplicationPlotCache& duplicationPlotCache) const {
63  delete duplicationPlotCache.duplicationRate_vs_pT;
64  delete duplicationPlotCache.duplicationRate_vs_eta;
65  delete duplicationPlotCache.duplicationRate_vs_phi;
66  delete duplicationPlotCache.nDuplicated_vs_pT;
67  delete duplicationPlotCache.nDuplicated_vs_eta;
68  delete duplicationPlotCache.nDuplicated_vs_phi;
69 }
70 
72  const DuplicationPlotTool::DuplicationPlotCache& duplicationPlotCache)
73  const {
74  ACTS_DEBUG("Write the plots to output file.");
75  duplicationPlotCache.duplicationRate_vs_pT->Write();
76  duplicationPlotCache.duplicationRate_vs_eta->Write();
77  duplicationPlotCache.duplicationRate_vs_phi->Write();
78  duplicationPlotCache.nDuplicated_vs_pT->Write();
79  duplicationPlotCache.nDuplicated_vs_eta->Write();
80  duplicationPlotCache.nDuplicated_vs_phi->Write();
81 }
82 
84  DuplicationPlotTool::DuplicationPlotCache& duplicationPlotCache,
85  const Acts::BoundTrackParameters& fittedParameters, bool status) const {
86  const auto momentum = fittedParameters.momentum();
87  const double fit_phi = phi(momentum);
88  const double fit_eta = eta(momentum);
89  const double fit_pT = perp(momentum);
90 
91  PlotHelpers::fillEff(duplicationPlotCache.duplicationRate_vs_pT, fit_pT,
92  status);
93  PlotHelpers::fillEff(duplicationPlotCache.duplicationRate_vs_eta, fit_eta,
94  status);
95  PlotHelpers::fillEff(duplicationPlotCache.duplicationRate_vs_phi, fit_phi,
96  status);
97 }
98 
100  DuplicationPlotTool::DuplicationPlotCache& duplicationPlotCache,
101  const ActsFatras::Particle& truthParticle, size_t nDuplicatedTracks) const {
102  const auto t_phi = phi(truthParticle.direction());
103  const auto t_eta = eta(truthParticle.direction());
104  const auto t_pT = truthParticle.transverseMomentum();
105 
106  PlotHelpers::fillProf(duplicationPlotCache.nDuplicated_vs_pT, t_pT,
107  nDuplicatedTracks);
108  PlotHelpers::fillProf(duplicationPlotCache.nDuplicated_vs_eta, t_eta,
109  nDuplicatedTracks);
110  PlotHelpers::fillProf(duplicationPlotCache.nDuplicated_vs_phi, t_phi,
111  nDuplicatedTracks);
112 }