Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-06-30 07:52:31

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/DuplicationPlotTool.hpp"
0010 
0011 #include "Acts/Utilities/VectorHelpers.hpp"
0012 #include "ActsExamples/EventData/SimParticle.hpp"
0013 
0014 #include <TEfficiency.h>
0015 #include <TProfile.h>
0016 
0017 using Acts::VectorHelpers::eta;
0018 using Acts::VectorHelpers::perp;
0019 using Acts::VectorHelpers::phi;
0020 using Acts::VectorHelpers::theta;
0021 
0022 namespace ActsExamples {
0023 
0024 DuplicationPlotTool::DuplicationPlotTool(const DuplicationPlotTool::Config& cfg,
0025                                          Acts::Logging::Level lvl)
0026     : m_cfg(cfg),
0027       m_logger(Acts::getDefaultLogger("DuplicationPlotTool", lvl)) {}
0028 
0029 void DuplicationPlotTool::book(Cache& cache) const {
0030   PlotHelpers::Binning bPt = m_cfg.varBinning.at("Pt");
0031   PlotHelpers::Binning bEta = m_cfg.varBinning.at("Eta");
0032   PlotHelpers::Binning bPhi = m_cfg.varBinning.at("Phi");
0033   PlotHelpers::Binning bNum = m_cfg.varBinning.at("Num");
0034   ACTS_DEBUG("Initialize the histograms for duplication ratio plots");
0035 
0036   // duplication ratio vs pT
0037   cache.duplicationRatio_vs_pT = PlotHelpers::bookEff(
0038       "duplicationRatio_vs_pT",
0039       "Duplication ratio;pT [GeV/c];Duplication ratio", bPt);
0040   // duplication ratio vs eta
0041   cache.duplicationRatio_vs_eta =
0042       PlotHelpers::bookEff("duplicationRatio_vs_eta",
0043                            "Duplication ratio;#eta;Duplication ratio", bEta);
0044   // duplication ratio vs phi
0045   cache.duplicationRatio_vs_phi =
0046       PlotHelpers::bookEff("duplicationRatio_vs_phi",
0047                            "Duplication ratio;#phi;Duplication ratio", bPhi);
0048 
0049   // duplication number vs pT
0050   cache.nDuplicated_vs_pT = PlotHelpers::bookProf(
0051       "nDuplicated_vs_pT", "Number of duplicated track candidates", bPt, bNum);
0052   // duplication number vs eta
0053   cache.nDuplicated_vs_eta = PlotHelpers::bookProf(
0054       "nDuplicated_vs_eta", "Number of duplicated track candidates", bEta,
0055       bNum);
0056   // duplication number vs phi
0057   cache.nDuplicated_vs_phi = PlotHelpers::bookProf(
0058       "nDuplicated_vs_phi", "Number of duplicated track candidates", bPhi,
0059       bNum);
0060 }
0061 
0062 void DuplicationPlotTool::clear(Cache& cache) const {
0063   delete cache.duplicationRatio_vs_pT;
0064   delete cache.duplicationRatio_vs_eta;
0065   delete cache.duplicationRatio_vs_phi;
0066   delete cache.nDuplicated_vs_pT;
0067   delete cache.nDuplicated_vs_eta;
0068   delete cache.nDuplicated_vs_phi;
0069 }
0070 
0071 void DuplicationPlotTool::write(const Cache& cache) const {
0072   ACTS_DEBUG("Write the plots to output file.");
0073   cache.duplicationRatio_vs_pT->Write();
0074   cache.duplicationRatio_vs_eta->Write();
0075   cache.duplicationRatio_vs_phi->Write();
0076   cache.nDuplicated_vs_pT->Write();
0077   cache.nDuplicated_vs_eta->Write();
0078   cache.nDuplicated_vs_phi->Write();
0079 }
0080 
0081 void DuplicationPlotTool::fill(
0082     Cache& cache, const Acts::BoundTrackParameters& fittedParameters,
0083     bool status) const {
0084   const auto momentum = fittedParameters.momentum();
0085   const double fit_phi = phi(momentum);
0086   const double fit_eta = eta(momentum);
0087   const double fit_pT = perp(momentum);
0088 
0089   PlotHelpers::fillEff(cache.duplicationRatio_vs_pT, fit_pT, status);
0090   PlotHelpers::fillEff(cache.duplicationRatio_vs_eta, fit_eta, status);
0091   PlotHelpers::fillEff(cache.duplicationRatio_vs_phi, fit_phi, status);
0092 }
0093 
0094 void DuplicationPlotTool::fill(Cache& cache,
0095                                const SimParticleState& truthParticle,
0096                                std::size_t nDuplicatedTracks) const {
0097   const auto t_phi = phi(truthParticle.direction());
0098   const auto t_eta = eta(truthParticle.direction());
0099   const auto t_pT = truthParticle.transverseMomentum();
0100 
0101   PlotHelpers::fillProf(cache.nDuplicated_vs_pT, t_pT, nDuplicatedTracks);
0102   PlotHelpers::fillProf(cache.nDuplicated_vs_eta, t_eta, nDuplicatedTracks);
0103   PlotHelpers::fillProf(cache.nDuplicated_vs_phi, t_phi, nDuplicatedTracks);
0104 }
0105 
0106 }  // namespace ActsExamples