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__ = [
"photonEfficiency",
]
[docs]
@fancy_validation_mode_header
class photonEfficiency(ValidationModeBaseClass):
name = "photonEfficiency"
latex_str = r"$\gamma$ from $B\overline{B}$ events"
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", "", path=main)
ma.fillParticleListFromMC(
"gamma:gen",
"inECLAcceptance and [mcSecPhysProc == 0 or mcSecPhysProc == 3] and mcE > 0.01",
path=main,
skipNonPrimary=False,
skipNonPrimaryDaughters=False,
)
ma.matchMCTruth(list_name="gamma:selection", path=main)
ma.applyCuts(
"gamma:selection",
"mcPDG == 22 and inECLAcceptance and [mcSecPhysProc == 0 or mcSecPhysProc == 3] and mcE > 0.01",
path=main,
)
self.variables_to_validation_ntuple(
decay_str="gamma: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",
],
"^gamma:selection",
["gamma"],
),
path=main,
)
self.variables_to_validation_ntuple(
decay_str="gamma: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",
],
"^gamma:gen",
["gamma"],
),
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="gamma:selection",
hist_variable=HistVariable(
df_label=makeROOTCompatible(variable="gamma_mcTheta"),
label="$\\theta_{\\mathrm{MC}}^{\\gamma}$",
unit="rad",
bins=75,
scope=(0.0, 3.1415),
),
hist_components=[
HistComponent(
label="Signal",
additional_cut_str="gamma_isSignal == 1.0",
),
],
),
Histogram(
name="EResolution_ISRPhoton",
title="Energy Resolution of ISR Photon",
particle_list="gamma:gen",
hist_variable=HistVariable(
df_label=makeROOTCompatible(variable="gamma_mcTheta"),
label="$\\theta_{\\mathrm{MC}}^{\\gamma}$",
unit="rad",
bins=75,
scope=(0.0, 3.1415),
),
hist_components=[
HistComponent(
label="Signal",
additional_cut_str="gamma_isSignal == 1.0",
),
],
),
]