Back to home page

EIC code displayed by LXR

 
 

    


Warning, file /acts/Examples/Framework/include/ActsExamples/Validation/ResPlotTool.hpp was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).

0001 // This file is part of the ACTS project.
0002 //
0003 // Copyright (C) 2016 CERN for the benefit of the ACTS project
0004 //
0005 // This Source Code Form is subject to the terms of the Mozilla Public
0006 // License, v. 2.0. If a copy of the MPL was not distributed with this
0007 // file, You can obtain one at https://mozilla.org/MPL/2.0/.
0008 
0009 #pragma once
0010 
0011 #include "Acts/EventData/TrackParameters.hpp"
0012 #include "Acts/Geometry/GeometryContext.hpp"
0013 #include "Acts/Utilities/Logger.hpp"
0014 #include "ActsExamples/EventData/SimParticle.hpp"
0015 #include "ActsExamples/Utilities/Helpers.hpp"
0016 
0017 #include <map>
0018 #include <memory>
0019 #include <string>
0020 #include <vector>
0021 
0022 class TH1F;
0023 class TH2F;
0024 
0025 namespace ActsExamples {
0026 
0027 /// Tools to make hists to show residual, i.e. smoothed_parameter -
0028 /// truth_parameter, and pull, i.e. (smoothed_parameter -
0029 /// truth_parameter)/smoothed_paramter_error, of track parameters at perigee
0030 /// surface
0031 class ResPlotTool {
0032  public:
0033   /// @brief Nested configuration struct
0034   struct Config {
0035     /// parameter sets to do plots
0036     std::vector<std::string> paramNames = {"d0",    "z0",  "phi",
0037                                            "theta", "qop", "t"};
0038 
0039     /// Binning info for variables
0040     std::map<std::string, PlotHelpers::Binning> varBinning = {
0041         {"Eta", PlotHelpers::Binning("#eta", 40, -4, 4)},
0042         {"Pt", PlotHelpers::Binning("pT [GeV/c]", 40, 0, 100)},
0043         {"Pull", PlotHelpers::Binning("pull", 100, -5, 5)},
0044         {"Residual_d0", PlotHelpers::Binning("r_{d0} [mm]", 100, -0.5, 0.5)},
0045         {"Residual_z0", PlotHelpers::Binning("r_{z0} [mm]", 100, -0.5, 0.5)},
0046         {"Residual_phi",
0047          PlotHelpers::Binning("r_{#phi} [rad]", 100, -0.01, 0.01)},
0048         {"Residual_theta",
0049          PlotHelpers::Binning("r_{#theta} [rad]", 100, -0.01, 0.01)},
0050         {"Residual_qop",
0051          PlotHelpers::Binning("r_{q/p} [c/GeV]", 100, -0.1, 0.1)},
0052         {"Residual_t", PlotHelpers::Binning("r_{t} [s]", 100, -1000, 1000)}};
0053   };
0054 
0055   /// @brief Nested Cache struct
0056   struct Cache {
0057     /// Residual distribution
0058     std::map<std::string, TH1F*> res;
0059     /// Residual vs eta scatter plot
0060     std::map<std::string, TH2F*> res_vs_eta;
0061     /// Residual mean vs eta distribution
0062     std::map<std::string, TH1F*> resMean_vs_eta;
0063     /// Residual width vs eta distribution
0064     std::map<std::string, TH1F*> resWidth_vs_eta;
0065     /// Residual vs pT scatter plot
0066     std::map<std::string, TH2F*> res_vs_pT;
0067     /// Residual mean vs pT distribution
0068     std::map<std::string, TH1F*> resMean_vs_pT;
0069     /// Residual width vs pT distribution
0070     std::map<std::string, TH1F*> resWidth_vs_pT;
0071 
0072     /// Pull distribution
0073     std::map<std::string, TH1F*> pull;
0074     /// Pull vs eta scatter plot
0075     std::map<std::string, TH2F*> pull_vs_eta;
0076     /// Pull mean vs eta distribution
0077     std::map<std::string, TH1F*> pullMean_vs_eta;
0078     /// Pull width vs eta distribution
0079     std::map<std::string, TH1F*> pullWidth_vs_eta;
0080     /// Pull vs pT scatter plot
0081     std::map<std::string, TH2F*> pull_vs_pT;
0082     /// Pull mean vs pT distribution
0083     std::map<std::string, TH1F*> pullMean_vs_pT;
0084     /// Pull width vs pT distribution
0085     std::map<std::string, TH1F*> pullWidth_vs_pT;
0086   };
0087 
0088   /// Constructor
0089   ///
0090   /// @param cfg Configuration struct
0091   /// @param level Message level declaration
0092   ResPlotTool(const Config& cfg, Acts::Logging::Level lvl);
0093 
0094   /// @brief book the histograms
0095   ///
0096   /// @param cache the cache for residual/pull histograms
0097   void book(Cache& cache) const;
0098 
0099   /// @brief fill the histograms
0100   ///
0101   /// @param cache the cache for residual/pull histograms
0102   /// @param gctx the geometry context
0103   /// @param truthParticle the truth particle
0104   /// @param fittedParamters the fitted parameters at perigee surface
0105   void fill(Cache& cache, const Acts::GeometryContext& gctx,
0106             const SimParticleState& truthParticle,
0107             const Acts::BoundTrackParameters& fittedParamters) const;
0108 
0109   /// @brief extract the details of the residual/pull plots and fill details
0110   ///
0111   /// into separate histograms
0112   /// @param cache the cache object for residual/pull histograms
0113   void refinement(Cache& cache) const;
0114 
0115   /// @brief write the histograms to output file
0116   ///
0117   /// @param cache the cache object for residual/pull histograms
0118   void write(const Cache& cache) const;
0119 
0120   /// @brief delete the histograms
0121   ///
0122   /// @param cache the cache object for residual/pull histograms
0123   void clear(Cache& cache) const;
0124 
0125  private:
0126   /// The config class
0127   Config m_cfg;
0128   /// The logging instance
0129   std::unique_ptr<const Acts::Logger> m_logger;
0130 
0131   /// The logger
0132   const Acts::Logger& logger() const { return *m_logger; }
0133 };
0134 
0135 }  // namespace ActsExamples