import basf2
import modularAnalysis as ma
from vibe.core.utils.misc import fancy_validation_mode_header
from vibe.core.validation_mode import ValidationModeBaseClass
from vibe.core.helper.histogram_tools import Histogram, HistComponent, HistVariable
from vibe.core.helper.root_helper import makeROOTCompatible
[docs]
@fancy_validation_mode_header
class TrackingEfficiencyExample(ValidationModeBaseClass):
name = "TrackEff"
def create_basf2_path(self):
main_path = basf2.Path()
ma.fillParticleListFromMC(
decayString="pi+:gen",
cut="[mcPrimary > 0] and [PDG == 211]",
path=main_path,
)
ma.fillParticleList(
decayString="pi+:reco",
cut="",
path=main_path,
)
ma.matchMCTruth(
"pi+:reco",
path=main_path,
)
ma.applyCuts(list_name="pi+:reco", cut="[mcPrimary > 0] and [matchedMC(PDG) == 211]", path=main_path)
self.variables_to_validation_histogram(
decay_str="pi+:gen",
variables=[("p", 50, 0, 5)],
path=main_path,
)
self.variables_to_validation_histogram(
decay_str="pi+:reco",
variables=[("matchedMC(p)", 50, 0, 5)],
path=main_path,
)
self.variables_to_validation_ntuple(
decay_str="pi+:reco",
variables=["matchedMC(p)"],
path=main_path,
)
self.variables_to_validation_ntuple(
decay_str="pi+:gen",
variables=["matchedMC(p)"],
path=main_path,
)
return main_path
@property
def analysis_validation_histograms(self):
return [
Histogram(
name="mcP",
title="",
hist_variable=HistVariable(
df_label=makeROOTCompatible(variable="matchedMC(p)"),
label=r"$p_{MC}$",
unit=r"GeV/$c$",
bins=50,
scope=(0, 5),
),
hist_components=[
HistComponent(
label="All",
),
],
particle_list="pi+:gen",
)
]
@property
def particle_list_vars_for_efficiency(self):
return [(("pi+:reco", "matchedMC(p)"), ("pi+:gen", "p"))]