Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Adding efficiency vs production radius to output root files (Revision of PR #3539) #3981

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@ class EffPlotTool {
{"Phi", PlotHelpers::Binning("#phi", 100, -3.15, 3.15)},
{"Pt", PlotHelpers::Binning("pT [GeV/c]", 40, 0, 100)},
{"Z0", PlotHelpers::Binning("z_0 [mm]", 50, -200, 200)},
{"DeltaR", PlotHelpers::Binning("#Delta R", 100, 0, 0.3)}};
{"DeltaR", PlotHelpers::Binning("#Delta R", 100, 0, 0.3)},
{"prodR", PlotHelpers::Binning("prod_R [mm]", 100, 0, 200)}};
};

/// @brief Nested Cache struct
Expand All @@ -47,6 +48,8 @@ class EffPlotTool {
TEfficiency* trackEff_vs_DeltaR{
nullptr}; ///< Tracking efficiency vs distance to the closest truth
///< particle
TEfficiency* trackEff_vs_prodR{
nullptr}; ///< Tracking efficiency vs production radius
};

/// Constructor
Expand Down
11 changes: 11 additions & 0 deletions Examples/Framework/src/Validation/EffPlotTool.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ void ActsExamples::EffPlotTool::book(
PlotHelpers::Binning bPt = m_cfg.varBinning.at("Pt");
PlotHelpers::Binning bDeltaR = m_cfg.varBinning.at("DeltaR");
PlotHelpers::Binning bZ0 = m_cfg.varBinning.at("Z0");
PlotHelpers::Binning bProdR = m_cfg.varBinning.at("prodR");

ACTS_DEBUG("Initialize the histograms for efficiency plots");
// efficiency vs pT
effPlotCache.trackEff_vs_pT = PlotHelpers::bookEff(
Expand All @@ -45,6 +47,9 @@ void ActsExamples::EffPlotTool::book(
effPlotCache.trackEff_vs_DeltaR = PlotHelpers::bookEff(
"trackeff_vs_DeltaR",
"Tracking efficiency;Closest track #Delta R;Efficiency", bDeltaR);
effPlotCache.trackEff_vs_prodR = PlotHelpers::bookEff(
"trackeff_vs_prodR",
"Tracking efficiency;Production radius [mm];Efficiency", bProdR);
}

void ActsExamples::EffPlotTool::clear(EffPlotCache& effPlotCache) const {
Expand All @@ -53,6 +58,7 @@ void ActsExamples::EffPlotTool::clear(EffPlotCache& effPlotCache) const {
delete effPlotCache.trackEff_vs_phi;
delete effPlotCache.trackEff_vs_z0;
delete effPlotCache.trackEff_vs_DeltaR;
delete effPlotCache.trackEff_vs_prodR;
}

void ActsExamples::EffPlotTool::write(
Expand All @@ -63,6 +69,7 @@ void ActsExamples::EffPlotTool::write(
effPlotCache.trackEff_vs_phi->Write();
effPlotCache.trackEff_vs_z0->Write();
effPlotCache.trackEff_vs_DeltaR->Write();
effPlotCache.trackEff_vs_prodR->Write();
}

void ActsExamples::EffPlotTool::fill(EffPlotTool::EffPlotCache& effPlotCache,
Expand All @@ -73,10 +80,14 @@ void ActsExamples::EffPlotTool::fill(EffPlotTool::EffPlotCache& effPlotCache,
const auto t_pT = truthParticle.transverseMomentum();
const auto t_z0 = truthParticle.position().z();
const auto t_deltaR = deltaR;
const auto t_prodR =
std::sqrt(truthParticle.position().x() * truthParticle.position().x() +
truthParticle.position().y() * truthParticle.position().y());

PlotHelpers::fillEff(effPlotCache.trackEff_vs_pT, t_pT, status);
PlotHelpers::fillEff(effPlotCache.trackEff_vs_eta, t_eta, status);
PlotHelpers::fillEff(effPlotCache.trackEff_vs_phi, t_phi, status);
PlotHelpers::fillEff(effPlotCache.trackEff_vs_z0, t_z0, status);
PlotHelpers::fillEff(effPlotCache.trackEff_vs_DeltaR, t_deltaR, status);
PlotHelpers::fillEff(effPlotCache.trackEff_vs_prodR, t_prodR, status);
}
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,8 @@ class RootTrackSummaryWriter final : public WriterT<ConstTrackContainer> {
std::vector<float> m_t_d0;
/// The extrapolated truth longitudinal impact parameter
std::vector<float> m_t_z0;
/// Production radius of majority particle
std::vector<float> m_t_prodR;

/// If the track has fitted parameter
std::vector<bool> m_hasFittedParams;
Expand Down
5 changes: 5 additions & 0 deletions Examples/Io/Root/src/RootTrackSummaryWriter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ RootTrackSummaryWriter::RootTrackSummaryWriter(
m_outputTree->Branch("t_pT", &m_t_pT);
m_outputTree->Branch("t_d0", &m_t_d0);
m_outputTree->Branch("t_z0", &m_t_z0);
m_outputTree->Branch("t_prodR", &m_t_prodR);

m_outputTree->Branch("hasFittedParams", &m_hasFittedParams);
m_outputTree->Branch("eLOC0_fit", &m_eLOC0_fit);
Expand Down Expand Up @@ -299,6 +300,7 @@ ProcessCode RootTrackSummaryWriter::writeT(const AlgorithmContext& ctx,
float t_d0 = NaNfloat;
float t_z0 = NaNfloat;
float t_qop = NaNfloat;
float t_prodR = NaNfloat;

// Get the perigee surface
const Acts::Surface* pSurface =
Expand Down Expand Up @@ -339,6 +341,7 @@ ProcessCode RootTrackSummaryWriter::writeT(const AlgorithmContext& ctx,
t_eta = eta(particle.direction());
t_pT = t_p * perp(particle.direction());
t_qop = particle.qOverP();
t_prodR = std::sqrt(t_vx * t_vx + t_vy * t_vy);

if (pSurface != nullptr) {
auto intersection =
Expand Down Expand Up @@ -390,6 +393,7 @@ ProcessCode RootTrackSummaryWriter::writeT(const AlgorithmContext& ctx,
m_t_pT.push_back(t_pT);
m_t_d0.push_back(t_d0);
m_t_z0.push_back(t_z0);
m_t_prodR.push_back(t_prodR);

// Initialize the fitted track parameters info
std::array<float, Acts::eBoundSize> param = {NaNfloat, NaNfloat, NaNfloat,
Expand Down Expand Up @@ -575,6 +579,7 @@ ProcessCode RootTrackSummaryWriter::writeT(const AlgorithmContext& ctx,
m_t_eta.clear();
m_t_d0.clear();
m_t_z0.clear();
m_t_prodR.clear();

m_hasFittedParams.clear();
m_eLOC0_fit.clear();
Expand Down
4 changes: 2 additions & 2 deletions Examples/Scripts/Python/full_chain_odd_LRT.py
Original file line number Diff line number Diff line change
Expand Up @@ -233,8 +233,8 @@
args.gun_particles, acts.PdgParticle.eMuon, randomizeCharge=True
),
vtxGen=acts.examples.GaussianDisplacedVertexPositionGenerator(
rMean=2,
rStdDev=0.0125 * u.mm,
rMean=50,
rStdDev=50 * u.mm,
zMean=2,
zStdDev=55.5 * u.mm,
tMean=0,
Expand Down
Loading