Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-06-21 08:09:22

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 #include "ActsExamples/Validation/TrackQualityPlotTool.hpp"
0010 
0011 #include "Acts/Utilities/VectorHelpers.hpp"
0012 
0013 #include <TEfficiency.h>
0014 #include <TProfile.h>
0015 
0016 using Acts::VectorHelpers::eta;
0017 using Acts::VectorHelpers::perp;
0018 using Acts::VectorHelpers::phi;
0019 using Acts::VectorHelpers::theta;
0020 
0021 namespace ActsExamples {
0022 
0023 TrackQualityPlotTool::TrackQualityPlotTool(const Config& cfg,
0024                                            Acts::Logging::Level lvl)
0025     : m_cfg(cfg),
0026       m_logger(Acts::getDefaultLogger("TrackCompletenessPlotTool", lvl)) {}
0027 
0028 void TrackQualityPlotTool::book(Cache& cache) const {
0029   PlotHelpers::Binning bPt = m_cfg.varBinning.at("Pt");
0030   PlotHelpers::Binning bEta = m_cfg.varBinning.at("Eta");
0031   PlotHelpers::Binning bPhi = m_cfg.varBinning.at("Phi");
0032   PlotHelpers::Binning bNum = m_cfg.varBinning.at("Num");
0033   ACTS_DEBUG("Initialize the histograms for completeness plots");
0034 
0035   // completeness vs pT
0036   cache.completeness_vs_pT = PlotHelpers::bookProf(
0037       "completeness_vs_pT", "Completeness;pT [GeV/c];Completeness", bPt, bNum);
0038   // completeness vs eta
0039   cache.completeness_vs_eta = PlotHelpers::bookProf(
0040       "completeness_vs_eta", "Completeness;#eta;Completeness", bEta, bNum);
0041   // completeness vs phi
0042   cache.completeness_vs_phi = PlotHelpers::bookProf(
0043       "completeness_vs_phi", "Completeness;#phi;Completeness", bPhi, bNum);
0044 
0045   // purity vs pT
0046   cache.purity_vs_pT = PlotHelpers::bookProf(
0047       "purity_vs_pT", "Purity;pT [GeV/c];Purity", bPt, bNum);
0048   // purity vs eta
0049   cache.purity_vs_eta =
0050       PlotHelpers::bookProf("purity_vs_eta", "Purity;#eta;Purity", bEta, bNum);
0051   // purity vs phi
0052   cache.purity_vs_phi =
0053       PlotHelpers::bookProf("purity_vs_phi", "Purity;#phi;Purity", bPhi, bNum);
0054 }
0055 
0056 void TrackQualityPlotTool::clear(Cache& cache) const {
0057   delete cache.completeness_vs_pT;
0058   delete cache.completeness_vs_eta;
0059   delete cache.completeness_vs_phi;
0060   delete cache.purity_vs_pT;
0061   delete cache.purity_vs_eta;
0062   delete cache.purity_vs_phi;
0063 }
0064 
0065 void TrackQualityPlotTool::write(const Cache& cache) const {
0066   ACTS_DEBUG("Write the plots to output file.");
0067   cache.completeness_vs_pT->Write();
0068   cache.completeness_vs_eta->Write();
0069   cache.completeness_vs_phi->Write();
0070   cache.purity_vs_pT->Write();
0071   cache.purity_vs_eta->Write();
0072   cache.purity_vs_phi->Write();
0073 }
0074 
0075 void TrackQualityPlotTool::fill(
0076     Cache& cache, const Acts::BoundTrackParameters& fittedParameters,
0077     double completeness, double purity) const {
0078   const auto momentum = fittedParameters.momentum();
0079   const double fit_phi = phi(momentum);
0080   const double fit_eta = eta(momentum);
0081   const double fit_pT = perp(momentum);
0082 
0083   PlotHelpers::fillProf(cache.completeness_vs_pT, fit_pT, completeness);
0084   PlotHelpers::fillProf(cache.completeness_vs_eta, fit_eta, completeness);
0085   PlotHelpers::fillProf(cache.completeness_vs_phi, fit_phi, completeness);
0086 
0087   PlotHelpers::fillProf(cache.purity_vs_pT, fit_pT, purity);
0088   PlotHelpers::fillProf(cache.purity_vs_eta, fit_eta, purity);
0089   PlotHelpers::fillProf(cache.purity_vs_phi, fit_phi, purity);
0090 }
0091 
0092 }  // namespace ActsExamples