from typing import List
import basf2
import modularAnalysis as ma # type: ignore
import variables.collections as vc # type: ignore
import variables.utils as vu # type: ignore
from vibe.core.utils.misc import fancy_validation_mode_header
from vibe.core.validation_mode import ValidationModeBaseClass
from vibe.core.helper.histogram_tools import HistVariable, Histogram, HistComponent
from vibe.core.helper.root_helper import makeROOTCompatible
__all__ = [
"pi0Efficiency",
]
[docs]
@fancy_validation_mode_header
class pi0Efficiency(ValidationModeBaseClass):
name = "pi0Efficiency"
latex_str = r"$e^+ e^- \rightarrow \mu^+ \mu^- \gamma$"
plotting_strategies = ["particle_list_efficiency"]
[docs]
def create_basf2_path(self, **kwargs):
"""
Reconstruction script for photons.
"""
main = basf2.create_path()
# Filling photon lists from ECL clusters and MC (we only consider primary photons and the ones from bremsstrahlung)
ma.fillParticleList("gamma:selection", "mcSecPhysProc==0", path=main)
ma.reconstructDecay("pi0:selection -> gamma:selection gamma:selection", "", path=main)
ma.fillParticleListFromMC(
"pi0:gen", "mcSecPhysProc==0", skipNonPrimaryDaughters=False, skipNonPrimary=False, path=main
)
ma.matchMCTruth(list_name="pi0:selection", path=main)
self.variables_to_validation_ntuple(
decay_str="pi0:selection",
variables=vu.create_aliases_for_selected(
self.base_particle_vars
+ self.cluster_vars
+ vc.mc_truth
+ vc.mc_kinematics
+ vc.mc_variables
+ [
"mcTheta",
"clusterMCMatchWeight",
"clusterTotalMCMatchWeight",
"clusterBestMCMatchWeight",
"mcSecPhysProc",
],
"^pi0:selection",
["pi0"],
),
path=main,
)
self.variables_to_validation_ntuple(
decay_str="pi0:gen",
variables=vu.create_aliases_for_selected(
self.base_particle_vars
+ self.cluster_vars
+ vc.mc_truth
+ vc.mc_kinematics
+ vc.mc_variables
+ [
"mcTheta",
"clusterMCMatchWeight",
"clusterTotalMCMatchWeight",
"clusterBestMCMatchWeight",
"mcSecPhysProc",
],
"^pi0:gen",
["pi0"],
),
path=main,
)
return main
@property
def base_particle_vars(self):
return vc.kinematics + vc.inv_mass + vc.momentum_uncertainty + vc.pid
@property
def cluster_vars(self):
return vc.cluster + [
"clusterE",
"clusterUncorrE",
"clusterThetaID",
"clusterMdstIndex",
"clusterCellID",
"clusterSecondMoment",
"clusterTrackMatch",
]
@property
def analysis_validation_histograms(self) -> List[Histogram]:
return [
Histogram(
name="EResolution_ISRPhoton",
title="Energy Resolution of ISR Photon",
particle_list="pi0:selection",
hist_variable=HistVariable(
df_label=makeROOTCompatible(variable="pi0_mcTheta"),
label="$\\theta_{\\mathrm{MC}}^{\\pi^0}$",
unit="rad",
bins=75,
scope=(0.0, 3.1415),
),
hist_components=[
HistComponent(
label="Signal",
additional_cut_str="pi0_isSignal == 1.0",
),
],
),
Histogram(
name="EResolution_ISRPhoton",
title="Energy Resolution of ISR Photon",
particle_list="pi0:gen",
hist_variable=HistVariable(
df_label=makeROOTCompatible(variable="pi0_mcTheta"),
label="$\\theta_{\\mathrm{MC}}^{\\pi^0}$",
unit="rad",
bins=75,
scope=(0.0, 3.1415),
),
hist_components=[
HistComponent(
label="Signal",
additional_cut_str="pi0_isSignal == 1.0",
),
],
),
]