Source code for vibe.analysis_validation_modes.clustering.KL0Efficiency

from typing import List, Optional

import basf2
import modularAnalysis as ma  # type: ignore
from variables import variables as vm  # type: ignore
import variables.collections as vc  # type: ignore
import variables.utils as vu  # type: ignore
import pandas as pd  # 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__ = [
    "KL0Efficiency",
]


[docs] @fancy_validation_mode_header class KL0Efficiency(ValidationModeBaseClass): name = "KL0Efficiency" 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 ma.fillParticleList("K_L0:selection", "inECLAcceptance and isFromECL > 0", path=main) ma.matchMCTruth(list_name="K_L0:selection", path=main) ma.fillParticleListFromMC("K_L0:gen", "inECLAcceptance", path=main) vm.addAlias("mcPDGMother", "mcMother(PDG)") ma.fillParticleListFromMC( decayString="K_L0:gen", cut="inECLAcceptance", skipNonPrimary=True, skipNonPrimaryDaughters=True, path=main ) self.variables_to_validation_ntuple( decay_str="K_L0: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", ], "^K_L0:selection", ["K_L0"], ), path=main, ) self.variables_to_validation_ntuple( decay_str="K_L0: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", ], "^K_L0:gen", ["K_L0"], ), 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="K_L0:selection", hist_variable=HistVariable( df_label=makeROOTCompatible(variable="K_L0_mcTheta"), label="$\\theta_{\\mathrm{MC}}^{\\pi^0}$", unit="rad", bins=75, scope=(0.0, 3.1415), ), hist_components=[ HistComponent( label="Signal", additional_cut_str="K_L0_isSignal == 1.0", ), ], ), Histogram( name="EResolution_ISRPhoton", title="Energy Resolution of ISR Photon", particle_list="K_L0:gen", hist_variable=HistVariable( df_label=makeROOTCompatible(variable="K_L0_mcTheta"), label="$\\theta_{\\mathrm{MC}}^{\\pi^0}$", unit="rad", bins=75, scope=(0.0, 3.1415), ), hist_components=[ HistComponent( label="Signal", additional_cut_str="K_L0_isSignal == 1.0", ), ], ), ]
[docs] def get_number_of_signal_for_efficiency(self, df: pd.DataFrame, particle_list: Optional[str] = None) -> float: return df["K_L0_isSignal"].sum()