Analysis Software
Documentation for sPHENIX simulation 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 
16 
17 #include <map>
18 #include <memory>
19 #include <string>
20 #include <vector>
21 
22 class TH1F;
23 class TH2F;
24 namespace ActsFatras {
25 class Particle;
26 } // namespace ActsFatras
27 
28 namespace ActsExamples {
29 
30 // Tools to make hists to show residual, i.e. smoothed_parameter -
31 // truth_parameter, and pull, i.e. (smoothed_parameter -
32 // truth_parameter)/smoothed_paramter_error, of track parameters at perigee
33 // surface
34 class ResPlotTool {
35  public:
37  struct Config {
39  std::vector<std::string> paramNames = {"d0", "z0", "phi",
40  "theta", "qop", "t"};
41 
43  std::map<std::string, PlotHelpers::Binning> varBinning = {
44  {"Eta", PlotHelpers::Binning("#eta", 40, -4, 4)},
45  {"Pt", PlotHelpers::Binning("pT [GeV/c]", 40, 0, 100)},
46  {"Pull", PlotHelpers::Binning("pull", 100, -5, 5)},
47  {"Residual_d0", PlotHelpers::Binning("r_{d0} [mm]", 100, -0.5, 0.5)},
48  {"Residual_z0", PlotHelpers::Binning("r_{z0} [mm]", 100, -0.5, 0.5)},
49  {"Residual_phi",
50  PlotHelpers::Binning("r_{#phi} [rad]", 100, -0.01, 0.01)},
51  {"Residual_theta",
52  PlotHelpers::Binning("r_{#theta} [rad]", 100, -0.01, 0.01)},
53  {"Residual_qop",
54  PlotHelpers::Binning("r_{q/p} [c/GeV]", 100, -0.1, 0.1)},
55  {"Residual_t", PlotHelpers::Binning("r_{t} [s]", 100, -1000, 1000)}};
56  };
57 
59  struct ResPlotCache {
60  std::map<std::string, TH1F*> res;
61  std::map<std::string, TH2F*> res_vs_eta;
62  std::map<std::string, TH1F*>
64  std::map<std::string, TH1F*>
66  std::map<std::string, TH2F*> res_vs_pT;
67  std::map<std::string, TH1F*>
69  std::map<std::string, TH1F*>
71 
72  std::map<std::string, TH1F*> pull;
73  std::map<std::string, TH2F*> pull_vs_eta;
74  std::map<std::string, TH1F*>
76  std::map<std::string, TH1F*>
78  std::map<std::string, TH2F*> pull_vs_pT;
79  std::map<std::string, TH1F*>
81  std::map<std::string, TH1F*>
83  };
84 
90 
94  void book(ResPlotCache& resPlotCache) const;
95 
102  void fill(ResPlotCache& resPlotCache, const Acts::GeometryContext& gctx,
103  const ActsFatras::Particle& truthParticle,
104  const Acts::BoundTrackParameters& fittedParamters) const;
105 
110  void refinement(ResPlotCache& resPlotCache) const;
111 
115  void write(const ResPlotCache& resPlotCache) const;
116 
120  void clear(ResPlotCache& resPlotCache) const;
121 
122  private:
124  std::unique_ptr<const Acts::Logger> m_logger;
125 
127  const Acts::Logger& logger() const { return *m_logger; }
128 };
129 
130 } // namespace ActsExamples