Back to home page

sPhenix code displayed by LXR

 
 

    


File indexing completed on 2025-08-05 08:09:55

0001 // This file is part of the Acts project.
0002 //
0003 // Copyright (C) 2019 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 http://mozilla.org/MPL/2.0/.
0008 
0009 #include "ActsExamples/Validation/EffPlotTool.hpp"
0010 
0011 #include "Acts/Utilities/VectorHelpers.hpp"
0012 #include "ActsFatras/EventData/Particle.hpp"
0013 
0014 #include <TEfficiency.h>
0015 
0016 using Acts::VectorHelpers::eta;
0017 using Acts::VectorHelpers::perp;
0018 using Acts::VectorHelpers::phi;
0019 
0020 ActsExamples::EffPlotTool::EffPlotTool(
0021     const ActsExamples::EffPlotTool::Config& cfg, Acts::Logging::Level lvl)
0022     : m_cfg(cfg), m_logger(Acts::getDefaultLogger("EffPlotTool", lvl)) {}
0023 
0024 void ActsExamples::EffPlotTool::book(
0025     EffPlotTool::EffPlotCache& effPlotCache) const {
0026   PlotHelpers::Binning bPhi = m_cfg.varBinning.at("Phi");
0027   PlotHelpers::Binning bEta = m_cfg.varBinning.at("Eta");
0028   PlotHelpers::Binning bPt = m_cfg.varBinning.at("Pt");
0029   PlotHelpers::Binning bDeltaR = m_cfg.varBinning.at("DeltaR");
0030   ACTS_DEBUG("Initialize the histograms for efficiency plots");
0031   // efficiency vs pT
0032   effPlotCache.trackEff_vs_pT = PlotHelpers::bookEff(
0033       "trackeff_vs_pT", "Tracking efficiency;Truth pT [GeV/c];Efficiency", bPt);
0034   // efficiency vs eta
0035   effPlotCache.trackEff_vs_eta = PlotHelpers::bookEff(
0036       "trackeff_vs_eta", "Tracking efficiency;Truth #eta;Efficiency", bEta);
0037   // efficiency vs phi
0038   effPlotCache.trackEff_vs_phi = PlotHelpers::bookEff(
0039       "trackeff_vs_phi", "Tracking efficiency;Truth #phi;Efficiency", bPhi);
0040   // efficiancy vs distance to the closest truth particle
0041   effPlotCache.trackEff_vs_DeltaR = PlotHelpers::bookEff(
0042       "trackeff_vs_DeltaR",
0043       "Tracking efficiency;Closest track #Delta R;Efficiency", bDeltaR);
0044 }
0045 
0046 void ActsExamples::EffPlotTool::clear(EffPlotCache& effPlotCache) const {
0047   delete effPlotCache.trackEff_vs_pT;
0048   delete effPlotCache.trackEff_vs_eta;
0049   delete effPlotCache.trackEff_vs_phi;
0050   delete effPlotCache.trackEff_vs_DeltaR;
0051 }
0052 
0053 void ActsExamples::EffPlotTool::write(
0054     const EffPlotTool::EffPlotCache& effPlotCache) const {
0055   ACTS_DEBUG("Write the plots to output file.");
0056   effPlotCache.trackEff_vs_pT->Write();
0057   effPlotCache.trackEff_vs_eta->Write();
0058   effPlotCache.trackEff_vs_phi->Write();
0059   effPlotCache.trackEff_vs_DeltaR->Write();
0060 }
0061 
0062 void ActsExamples::EffPlotTool::fill(EffPlotTool::EffPlotCache& effPlotCache,
0063                                      const ActsFatras::Particle& truthParticle,
0064                                      double deltaR, bool status) const {
0065   const auto t_phi = phi(truthParticle.direction());
0066   const auto t_eta = eta(truthParticle.direction());
0067   const auto t_pT = truthParticle.transverseMomentum();
0068   const auto t_deltaR = deltaR;
0069 
0070   PlotHelpers::fillEff(effPlotCache.trackEff_vs_pT, t_pT, status);
0071   PlotHelpers::fillEff(effPlotCache.trackEff_vs_eta, t_eta, status);
0072   PlotHelpers::fillEff(effPlotCache.trackEff_vs_phi, t_phi, status);
0073   PlotHelpers::fillEff(effPlotCache.trackEff_vs_DeltaR, t_deltaR, status);
0074 }