Skip to content

Commit

Permalink
add 2d perf plots
Browse files Browse the repository at this point in the history
  • Loading branch information
XiaocongAi committed Nov 22, 2024
1 parent c3c4bf5 commit b3ef44f
Show file tree
Hide file tree
Showing 10 changed files with 144 additions and 17 deletions.
20 changes: 20 additions & 0 deletions Examples/Framework/include/ActsExamples/Utilities/Helpers.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,17 @@ void fillEff(TEfficiency* efficiency, float xValue, float yValue, bool status);
TProfile* bookProf(const char* profName, const char* profTitle,
const Binning& varXBinning, const Binning& varYBinning);

/// @brief book a TProfile2D plot
/// @param profName the name of plot
/// @param profTitle the title of plot
/// @param varXBinning the binning info of variable at x axis
/// @param varYBinning the binning info of variable at y axis
/// @param varZBinning the binning info of variable at z axis
/// @return TProfile2D pointer
TProfile2D* bookProf2D(const char* profName, const char* profTitle,
const Binning& varXBinning, const Binning& varYBinning,
const Binning& varZBinning);

/// @brief fill a TProfile plot
/// @param profile plot to fill
/// @param xValue xvalue to fill
Expand All @@ -143,4 +154,13 @@ TProfile* bookProf(const char* profName, const char* profTitle,
void fillProf(TProfile* profile, float xValue, float yValue,
float weight = 1.0);

/// @brief fill a TProfile plot
/// @param profile plot to fill
/// @param xValue xvalue to fill
/// @param yValue yvalue to fill
/// @param zValue zvalue to fill
/// @param weight weight to fill
void fillProf2D(TProfile* profile, float xValue, float yValue, float zValue,
float weight = 1.0);

} // namespace ActsExamples::PlotHelpers
Original file line number Diff line number Diff line change
Expand Up @@ -40,18 +40,22 @@ class DuplicationPlotTool {
std::map<std::string, PlotHelpers::Binning> varBinning = {
{"Eta", PlotHelpers::Binning("#eta", 40, -4, 4)},
{"Phi", PlotHelpers::Binning("#phi", 100, -3.15, 3.15)},
{"Pt", PlotHelpers::Binning("pT [GeV/c]", 40, 0, 100)},
{"Pt", PlotHelpers::Binning("p_{T} [GeV/c]", 40, 0, 100)},
{"Num", PlotHelpers::Binning("N", 30, -0.5, 29.5)}};
};

/// @brief Nested Cache struct
struct DuplicationPlotCache {
TProfile* nDuplicated_vs_pT; ///< Number of duplicated tracks vs pT
TProfile* nDuplicated_vs_eta; ///< Number of duplicated tracks vs eta
TProfile* nDuplicated_vs_phi; ///< Number of duplicated tracks vs phi
TEfficiency* duplicationRate_vs_pT; ///< Tracking duplication rate vs pT
TProfile* nDuplicated_vs_pT; ///< Number of duplicated tracks vs pT
TProfile* nDuplicated_vs_eta; ///< Number of duplicated tracks vs eta
TProfile* nDuplicated_vs_phi; ///< Number of duplicated tracks vs phi
TProfile2D*
nDuplicated_vs_pT_eta; ///< Number of duplicated tracks vs pT and eta
TEfficiency* duplicationRate_vs_pT; ///< Tracking duplication rate vs pT
TEfficiency* duplicationRate_vs_eta; ///< Tracking duplication rate vs eta
TEfficiency* duplicationRate_vs_phi; ///< Tracking duplication rate vs phi
TEfficiency*
duplicationRate_vs_pT_eta; ///< 2d tracking duplication rate vs pT
};

/// Constructor
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ class EffPlotTool {
std::map<std::string, PlotHelpers::Binning> varBinning = {
{"Eta", PlotHelpers::Binning("#eta", 40, -4, 4)},
{"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)},
{"Pt", PlotHelpers::Binning("p_{T} [GeV/c]", 40, 0, 100)},
{"Z0", PlotHelpers::Binning("z_{0} [mm]", 50, -200, 200)},
{"DeltaR", PlotHelpers::Binning("#Delta R", 100, 0, 0.3)}};
};

Expand All @@ -47,6 +47,8 @@ class EffPlotTool {
TEfficiency* trackEff_vs_DeltaR{
nullptr}; ///< Tracking efficiency vs distance to the closest truth
///< particle
TEfficiency* track2dEff_vs_pT_eta{
nullptr}; ///< 2d tracking efficiency vs pT and eta
};

/// Constructor
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ class FakeRatePlotTool {
std::map<std::string, PlotHelpers::Binning> varBinning = {
{"Eta", PlotHelpers::Binning("#eta", 40, -4, 4)},
{"Phi", PlotHelpers::Binning("#phi", 100, -3.15, 3.15)},
{"Pt", PlotHelpers::Binning("pT [GeV/c]", 40, 0, 100)},
{"Pt", PlotHelpers::Binning("p_{T} [GeV/c]", 40, 0, 100)},
{"Num", PlotHelpers::Binning("N", 30, -0.5, 29.5)}};
};

Expand All @@ -53,9 +53,10 @@ class FakeRatePlotTool {
///< scatter plot
TH2F* nFake_vs_eta; ///< Number of fake (truth-unmatched) tracks vs eta
///< scatter plot
TEfficiency* fakeRate_vs_pT; ///< Tracking fake rate vs pT
TEfficiency* fakeRate_vs_eta; ///< Tracking fake rate vs eta
TEfficiency* fakeRate_vs_phi; ///< Tracking fake rate vs phi
TEfficiency* fakeRate_vs_pT; ///< Tracking fake rate vs pT
TEfficiency* fakeRate_vs_eta; ///< Tracking fake rate vs eta
TEfficiency* fakeRate_vs_phi; ///< Tracking fake rate vs phi
TEfficiency* fakeRate_vs_pT_eta; ///< 2d tracking fake rate vs pT and eta
};

/// Constructor
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,12 @@ class TrackSummaryPlotTool {
TProfile* nHoles_vs_pt; ///< Number of holes vs pt
TProfile* nOutliers_vs_pt; ///< Number of outliers vs pt
TProfile* nSharedHits_vs_pt; ///< Number of Shared Hits vs pt
TProfile2D* nStates_vs_eta_pt; ///< Number of total states vs eta and pt
TProfile2D* nMeasurements_vs_eta_pt; ///< Number of non-outlier
///< measurements vs eta and pt
TProfile2D* nHoles_vs_eta_pt; ///< Number of holes vs eta and pt
TProfile2D* nOutliers_vs_eta_pt; ///< Number of outliers vs eta and pt
TProfile2D* nSharedHits_vs_eta_pt; ///< Number of Shared Hits vs eta and pt
};

/// Constructor
Expand Down
19 changes: 19 additions & 0 deletions Examples/Framework/src/Utilities/Helpers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -101,9 +101,28 @@ TProfile* bookProf(const char* profName, const char* profTitle,
return prof;
}

TProfile2D* bookProf2D(const char* profName, const char* profTitle,
const Binning& varXBinning, const Binning& varYBinning,
const Binning& varZBinning) {
TProfile2D* prof =
new TProfile2D(profName, profTitle, varXBinning.nBins, varXBinning.min,
varXBinning.max, varYBinning.nBins, varYBinning.min,
varYBinning.max, varZBinning.min, varZBinning.max);
prof->GetXaxis()->SetTitle(varXBinning.title.c_str());
prof->GetYaxis()->SetTitle(varYBinning.title.c_str());
prof->GetZaxis()->SetTitle(varZBinning.title.c_str());
return prof;
}

void fillProf(TProfile* profile, float xValue, float yValue, float weight) {
assert(profile != nullptr);
profile->Fill(xValue, yValue, weight);
}

void fillProf2D(TProfile2D* profile, float xValue, float yValue, float zValue,
float weight) {
assert(profile != nullptr);
profile->Fill(xValue, yValue, zValue, weight);
}

} // namespace ActsExamples::PlotHelpers
24 changes: 21 additions & 3 deletions Examples/Framework/src/Validation/DuplicationPlotTool.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,16 +34,21 @@ void ActsExamples::DuplicationPlotTool::book(
ACTS_DEBUG("Initialize the histograms for duplication rate plots");

// duplication rate vs pT
duplicationPlotCache.duplicationRate_vs_pT =
PlotHelpers::bookEff("duplicationRate_vs_pT",
"Duplication rate;pT [GeV/c];Duplication rate", bPt);
duplicationPlotCache.duplicationRate_vs_pT = PlotHelpers::bookEff(
"duplicationRate_vs_pT",
"Duplication rate;p_{T} [GeV/c];Duplication rate", bPt);
// duplication rate vs eta
duplicationPlotCache.duplicationRate_vs_eta = PlotHelpers::bookEff(
"duplicationRate_vs_eta", "Duplication rate;#eta;Duplication rate", bEta);
// duplication rate vs phi
duplicationPlotCache.duplicationRate_vs_phi = PlotHelpers::bookEff(
"duplicationRate_vs_phi", "Duplication rate;#phi;Duplication rate", bPhi);

// duplication rate vs pT and eta
duplicationPlotCache.duplicationRate_vs_pT_eta = PlotHelpers::bookEff(
"duplicationRate_vs_pT_eta",
"Duplication rate;p_{T} [GeV/c];#eta;Duplication rate", bPt, bEta);

// duplication number vs pT
duplicationPlotCache.nDuplicated_vs_pT = PlotHelpers::bookProf(
"nDuplicated_vs_pT", "Number of duplicated track candidates", bPt, bNum);
Expand All @@ -55,16 +60,23 @@ void ActsExamples::DuplicationPlotTool::book(
duplicationPlotCache.nDuplicated_vs_phi = PlotHelpers::bookProf(
"nDuplicated_vs_phi", "Number of duplicated track candidates", bPhi,
bNum);

// duplication number vs pT and eta
duplicationPlotCache.nDuplicated_vs_pT_eta = PlotHelpers::bookProf2D(
"nDuplicated_vs_pT_eta", "Number of duplicated track candidates", bPt,
bEta, bNum);
}

void ActsExamples::DuplicationPlotTool::clear(
DuplicationPlotCache& duplicationPlotCache) const {
delete duplicationPlotCache.duplicationRate_vs_pT;
delete duplicationPlotCache.duplicationRate_vs_eta;
delete duplicationPlotCache.duplicationRate_vs_phi;
delete duplicationPlotCache.duplicationRate_vs_pT_eta;
delete duplicationPlotCache.nDuplicated_vs_pT;
delete duplicationPlotCache.nDuplicated_vs_eta;
delete duplicationPlotCache.nDuplicated_vs_phi;
delete duplicationPlotCache.nDuplicated_vs_pT_eta;
}

void ActsExamples::DuplicationPlotTool::write(
Expand All @@ -74,9 +86,11 @@ void ActsExamples::DuplicationPlotTool::write(
duplicationPlotCache.duplicationRate_vs_pT->Write();
duplicationPlotCache.duplicationRate_vs_eta->Write();
duplicationPlotCache.duplicationRate_vs_phi->Write();
duplicationPlotCache.duplicationRate_vs_pT_eta->Write();
duplicationPlotCache.nDuplicated_vs_pT->Write();
duplicationPlotCache.nDuplicated_vs_eta->Write();
duplicationPlotCache.nDuplicated_vs_phi->Write();
duplicationPlotCache.nDuplicated_vs_pT_eta->Write();
}

void ActsExamples::DuplicationPlotTool::fill(
Expand All @@ -93,6 +107,8 @@ void ActsExamples::DuplicationPlotTool::fill(
status);
PlotHelpers::fillEff(duplicationPlotCache.duplicationRate_vs_phi, fit_phi,
status);
PlotHelpers::fillEff(duplicationPlotCache.duplicationRate_vs_pT_eta, fit_pT,
fit_eta, status);
}

void ActsExamples::DuplicationPlotTool::fill(
Expand All @@ -109,4 +125,6 @@ void ActsExamples::DuplicationPlotTool::fill(
nDuplicatedTracks);
PlotHelpers::fillProf(duplicationPlotCache.nDuplicated_vs_phi, t_phi,
nDuplicatedTracks);
PlotHelpers::fillProf2D(duplicationPlotCache.nDuplicated_vs_pT_eta, t_pT,
t_eta, nDuplicatedTracks);
}
13 changes: 11 additions & 2 deletions Examples/Framework/src/Validation/EffPlotTool.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@ void ActsExamples::EffPlotTool::book(
ACTS_DEBUG("Initialize the histograms for efficiency plots");
// efficiency vs pT
effPlotCache.trackEff_vs_pT = PlotHelpers::bookEff(
"trackeff_vs_pT", "Tracking efficiency;Truth pT [GeV/c];Efficiency", bPt);
"trackeff_vs_pT", "Tracking efficiency;Truth p_{T} [GeV/c];Efficiency",
bPt);
// efficiency vs eta
effPlotCache.trackEff_vs_eta = PlotHelpers::bookEff(
"trackeff_vs_eta", "Tracking efficiency;Truth #eta;Efficiency", bEta);
Expand All @@ -40,11 +41,16 @@ void ActsExamples::EffPlotTool::book(
"trackeff_vs_phi", "Tracking efficiency;Truth #phi;Efficiency", bPhi);
// efficiency vs z0
effPlotCache.trackEff_vs_z0 = PlotHelpers::bookEff(
"trackeff_vs_z0", "Tracking efficiency;Truth z_0 [mm];Efficiency", bZ0);
"trackeff_vs_z0", "Tracking efficiency;Truth z_{0} [mm];Efficiency", bZ0);
// efficiancy vs distance to the closest truth particle
effPlotCache.trackEff_vs_DeltaR = PlotHelpers::bookEff(
"trackeff_vs_DeltaR",
"Tracking efficiency;Closest track #Delta R;Efficiency", bDeltaR);
// efficiency vs pT and eta
effPlotCache.track2dEff_vs_pT_eta = PlotHelpers::bookEff(
"trackeff_vs_pT_eta",
"Tracking efficiency;Truth p_{T} [GeV/c];Truth #eta;Efficiency", bPt,
bEta);
}

void ActsExamples::EffPlotTool::clear(EffPlotCache& effPlotCache) const {
Expand All @@ -53,6 +59,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.track2dEff_vs_pT_eta;
}

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

void ActsExamples::EffPlotTool::fill(EffPlotTool::EffPlotCache& effPlotCache,
Expand All @@ -79,4 +87,5 @@ void ActsExamples::EffPlotTool::fill(EffPlotTool::EffPlotCache& effPlotCache,
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.track2dEff_vs_pT_eta, t_pT, t_eta, status);
}
10 changes: 9 additions & 1 deletion Examples/Framework/src/Validation/FakeRatePlotTool.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,13 +57,17 @@ void ActsExamples::FakeRatePlotTool::book(

// fake rate vs pT
fakeRatePlotCache.fakeRate_vs_pT = PlotHelpers::bookEff(
"fakerate_vs_pT", "Tracking fake rate;pT [GeV/c];Fake rate", bPt);
"fakerate_vs_pT", "Tracking fake rate;p_{T} [GeV/c];Fake rate", bPt);
// fake rate vs eta
fakeRatePlotCache.fakeRate_vs_eta = PlotHelpers::bookEff(
"fakerate_vs_eta", "Tracking fake rate;#eta;Fake rate", bEta);
// fake rate vs phi
fakeRatePlotCache.fakeRate_vs_phi = PlotHelpers::bookEff(
"fakerate_vs_phi", "Tracking fake rate;#phi;Fake rate", bPhi);
// fake rate vs pT and eta
fakeRatePlotCache.fakeRate_vs_pT_eta = PlotHelpers::bookEff(
"fakerate_vs_pT_eta", "Tracking fake rate;p_{T] [GeV/c];#eta;Fake rate",
bPt);
}

void ActsExamples::FakeRatePlotTool::clear(
Expand All @@ -77,6 +81,7 @@ void ActsExamples::FakeRatePlotTool::clear(
delete fakeRatePlotCache.fakeRate_vs_pT;
delete fakeRatePlotCache.fakeRate_vs_eta;
delete fakeRatePlotCache.fakeRate_vs_phi;
delete fakeRatePlotCache.fakeRate_vs_pT_eta;
}

void ActsExamples::FakeRatePlotTool::write(
Expand All @@ -91,6 +96,7 @@ void ActsExamples::FakeRatePlotTool::write(
fakeRatePlotCache.fakeRate_vs_pT->Write();
fakeRatePlotCache.fakeRate_vs_eta->Write();
fakeRatePlotCache.fakeRate_vs_phi->Write();
fakeRatePlotCache.fakeRate_vs_pT_eta->Write();
}

void ActsExamples::FakeRatePlotTool::fill(
Expand All @@ -104,6 +110,8 @@ void ActsExamples::FakeRatePlotTool::fill(
PlotHelpers::fillEff(fakeRatePlotCache.fakeRate_vs_pT, fit_pT, status);
PlotHelpers::fillEff(fakeRatePlotCache.fakeRate_vs_eta, fit_eta, status);
PlotHelpers::fillEff(fakeRatePlotCache.fakeRate_vs_phi, fit_phi, status);
PlotHelpers::fillEff(fakeRatePlotCache.fakeRate_vs_pT_eta, fit_pT, fit_eta,
status);
}

void ActsExamples::FakeRatePlotTool::fill(
Expand Down
40 changes: 40 additions & 0 deletions Examples/Framework/src/Validation/TrackSummaryPlotTool.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,25 @@ void ActsExamples::TrackSummaryPlotTool::book(
// number of Shared Hits versus pt
trackSummaryPlotCache.nSharedHits_vs_pt = PlotHelpers::bookProf(
"nSharedHits_vs_pT", "Number of Shared Hits vs. pT", bPt, bNum);
// number of track states versus eta and pt
trackSummaryPlotCache.nStates_vs_eta_pt = PlotHelpers::bookProf2D(
"nStates_vs_eta_pt", "Number of total states vs. #eta and pT", bEta, bPt,
bNum);
// number of measurements versus eta and pt
trackSummaryPlotCache.nMeasurements_vs_eta_pt = PlotHelpers::bookProf2D(
"nMeasurements_vs_eta_pt", "Number of measurements vs. #eta and pT", bEta,
bPt, bNum);
// number of holes versus eta and pt
trackSummaryPlotCache.nHoles_vs_eta_pt = PlotHelpers::bookProf2D(
"nHoles_vs_eta_pt", "Number of holes vs. #eta and pT", bEta, bPt, bNum);
// number of outliers versus eta and pt
trackSummaryPlotCache.nOutliers_vs_eta_pt = PlotHelpers::bookProf2D(
"nOutliers_vs_eta_pt", "Number of outliers vs. #eta and pT", bEta, bPt,
bNum);
// number of Shared Hits versus eta and pt
trackSummaryPlotCache.nSharedHits_vs_eta_pt = PlotHelpers::bookProf2D(
"nSharedHits_vs_eta_pt", "Number of Shared Hits vs. #eta and pT", bEta,
bPt, bNum);
}

void ActsExamples::TrackSummaryPlotTool::clear(
Expand All @@ -69,6 +88,11 @@ void ActsExamples::TrackSummaryPlotTool::clear(
delete trackSummaryPlotCache.nOutliers_vs_pt;
delete trackSummaryPlotCache.nHoles_vs_pt;
delete trackSummaryPlotCache.nSharedHits_vs_pt;
delete trackSummaryPlotCache.nStates_vs_eta_pt;
delete trackSummaryPlotCache.nMeasurements_vs_eta_pt;
delete trackSummaryPlotCache.nOutliers_vs_eta_pt;
delete trackSummaryPlotCache.nHoles_vs_eta_pt;
delete trackSummaryPlotCache.nSharedHits_vs_eta_pt;
}

void ActsExamples::TrackSummaryPlotTool::write(
Expand All @@ -85,6 +109,11 @@ void ActsExamples::TrackSummaryPlotTool::write(
trackSummaryPlotCache.nOutliers_vs_pt->Write();
trackSummaryPlotCache.nHoles_vs_pt->Write();
trackSummaryPlotCache.nSharedHits_vs_pt->Write();
trackSummaryPlotCache.nStates_vs_eta_pt->Write();
trackSummaryPlotCache.nMeasurements_vs_eta_pt->Write();
trackSummaryPlotCache.nOutliers_vs_eta_pt->Write();
trackSummaryPlotCache.nHoles_vs_eta_pt->Write();
trackSummaryPlotCache.nSharedHits_vs_eta_pt->Write();
}

void ActsExamples::TrackSummaryPlotTool::fill(
Expand Down Expand Up @@ -115,4 +144,15 @@ void ActsExamples::TrackSummaryPlotTool::fill(
PlotHelpers::fillProf(trackSummaryPlotCache.nHoles_vs_pt, fit_pT, nHoles);
PlotHelpers::fillProf(trackSummaryPlotCache.nSharedHits_vs_pt, fit_pT,
nSharedHits);

PlotHelpers::fillProf2D(trackSummaryPlotCache.nStates_vs_eta, fit_eta, fit_pT,
nStates);
PlotHelpers::fillProf2D(trackSummaryPlotCache.nMeasurements_vs_eta, fit_eta,
fit_pT, nMeasurements);
PlotHelpers::fillProf2D(trackSummaryPlotCache.nOutliers_vs_eta, fit_eta,
fit_pT, nOutliers);
PlotHelpers::fillProf2D(trackSummaryPlotCache.nHoles_vs_eta, fit_eta, fit_pT,
nHoles);
PlotHelpers::fillProf2D(trackSummaryPlotCache.nSharedHits_vs_eta, fit_eta,
fit_pT, nSharedHits);
}

0 comments on commit b3ef44f

Please sign in to comment.