EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
ResPlotTool.hpp
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file ResPlotTool.hpp
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 
9 #pragma once
10 
15 
16 #include <map>
17 #include <memory>
18 #include <string>
19 
20 namespace ActsExamples {
21 
22 // Tools to make hists to show residual, i.e. smoothed_parameter -
23 // truth_parameter, and pull, i.e. (smoothed_parameter -
24 // truth_parameter)/smoothed_paramter_error, of track parameters at perigee
25 // surface
26 class ResPlotTool {
27  public:
29  struct Config {
31  std::vector<std::string> paramNames = {"d0", "z0", "phi",
32  "theta", "qop", "t"};
33 
35  std::map<std::string, PlotHelpers::Binning> varBinning = {
36  {"Eta", PlotHelpers::Binning("#eta", 40, -4, 4)},
37  {"Pt", PlotHelpers::Binning("pT [GeV/c]", 40, 0, 100)},
38  {"Pull", PlotHelpers::Binning("pull", 100, -5, 5)},
39  {"Residual_d0", PlotHelpers::Binning("r_{d0} [mm]", 100, -0.5, 0.5)},
40  {"Residual_z0", PlotHelpers::Binning("r_{z0} [mm]", 100, -0.5, 0.5)},
41  {"Residual_phi",
42  PlotHelpers::Binning("r_{#phi} [rad]", 100, -0.01, 0.01)},
43  {"Residual_theta",
44  PlotHelpers::Binning("r_{#theta} [rad]", 100, -0.01, 0.01)},
45  {"Residual_qop",
46  PlotHelpers::Binning("r_{q/p} [c/GeV]", 100, -0.1, 0.1)},
47  {"Residual_t", PlotHelpers::Binning("r_{t} [s]", 100, -1000, 1000)}};
48  };
49 
51  struct ResPlotCache {
52  std::map<std::string, TH1F*> res;
53  std::map<std::string, TH2F*> res_vs_eta;
54  std::map<std::string, TH1F*>
56  std::map<std::string, TH1F*>
58  std::map<std::string, TH2F*> res_vs_pT;
59  std::map<std::string, TH1F*>
61  std::map<std::string, TH1F*>
63 
64  std::map<std::string, TH1F*> pull;
65  std::map<std::string, TH2F*> pull_vs_eta;
66  std::map<std::string, TH1F*>
68  std::map<std::string, TH1F*>
70  std::map<std::string, TH2F*> pull_vs_pT;
71  std::map<std::string, TH1F*>
73  std::map<std::string, TH1F*>
75  };
76 
81  ResPlotTool(const Config& cfg, Acts::Logging::Level lvl);
82 
86  void book(ResPlotCache& resPlotCache) const;
87 
94  void fill(ResPlotCache& resPlotCache, const Acts::GeometryContext& gctx,
95  const ActsFatras::Particle& truthParticle,
96  const Acts::BoundTrackParameters& fittedParamters) const;
97 
102  void refinement(ResPlotCache& resPlotCache) const;
103 
107  void write(const ResPlotCache& resPlotCache) const;
108 
112  void clear(ResPlotCache& resPlotCache) const;
113 
114  private:
116  std::unique_ptr<const Acts::Logger> m_logger;
117 
119  const Acts::Logger& logger() const { return *m_logger; }
120 };
121 
122 } // namespace ActsExamples