Source code for vibe.analysis_validation_modes.physics.dtokspipi_validation_mode

from typing import List
import pandas as pd

import basf2
import modularAnalysis as ma
import vertex as vx
import variables.collections as vc
import variables.utils as vu
import variables as va
from stdV0s import stdKshorts

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__ = [
    "DtoKsPiPiValidationMode",
]

[docs] @fancy_validation_mode_header class DtoKsPiPiValidationMode(ValidationModeBaseClass): name = "DtoKsPiPi" latex_str = r"$D \rightarrow K_S^0\pi\pi$"
[docs] def create_basf2_path(self): main_path = basf2.Path() ma.fillParticleList("K+:D0", "thetaInCDCAcceptance and abs(d0) < 1 and abs(z0) < 3", path=main_path) ma.fillParticleList("pi+:D0", "thetaInCDCAcceptance and abs(d0) < 1 and abs(z0) < 3", path=main_path) stdKshorts(prioritiseV0=True, fitter="TreeFit", path=main_path) ma.reconstructDecay("D0:Kspipi -> K_S0:merged pi+:D0 pi-:D0", "1.6 < M < 2.1", path=main_path) ma.reconstructDecay( "D*+:Dpi -> D0:Kspipi pi+:D0", "massDifference(0)<0.17 and useCMSFrame(p)>1.9", path=main_path ) ma.matchMCTruth("D*+:Dpi", path=main_path) vx.treeFit("D*+:Dpi", 0.001, massConstraint=[310], ipConstraint=True, updateAllDaughters=True, path=main_path) ma.applyCuts( "D*+:Dpi", "massDifference(0) < 0.16 and 1.66 < daughter(0,M) < 2.06 and useCMSFrame(p) > 2.0", path=main_path ) kinematics = ["pt", "p", "E", "cosTheta", "theta", "phi"] cms_kinematics = vu.create_aliases(kinematics, "useCMSFrame({variable})", "CMS") va.variables.addAlias("deltaM", "massDifference(0)") va.variables.addAlias("deltaM_Err", "massDifferenceError(0)") dst_vars = ( vc.mc_truth + vc.inv_mass + kinematics + cms_kinematics + ["charge", "Q", "deltaM", "deltaM_Err", "chiProb", "pErr", "ptErr", "thetaErr"] ) pi_vars = vu.create_aliases_for_selected( list_of_variables=vc.mc_truth + kinematics + cms_kinematics + vc.track + vc.track_hits + ["M", "charge", "protonID", "electronID", "kaonID", "pionID", "muonID"], decay_string="D*+ -> [D0 -> K_S0 ^pi+ ^pi-] pi+", ) ks_vars = vu.create_aliases_for_selected( list_of_variables=vc.mc_truth + kinematics + cms_kinematics + vc.flight_info + vc.vertex + ["significanceOfDistance"], decay_string="D*+ -> [D0 -> ^K_S0 pi+ pi-] pi+", ) d_vars = vu.create_aliases_for_selected( list_of_variables=vc.mc_truth + vc.inv_mass + kinematics + cms_kinematics + vc.flight_info + vc.vertex, decay_string="D*+ -> [^D0 -> K_S0 pi+ pi-] pi+", ) pis_vars = vu.create_aliases_for_selected( list_of_variables=vc.mc_truth + kinematics + cms_kinematics + vc.track + vc.track_hits + ["M", "charge", "protonID", "electronID", "kaonID", "pionID", "muonID", "pErr", "ptErr", "thetaErr"], decay_string="D*+ -> [D0 -> K_S0 pi+] ^pi+", ) self.variables_to_validation_ntuple( decay_str="D*+:Dpi", variables=dst_vars + d_vars + ks_vars + pi_vars + pis_vars, path=main_path, ) return main_path
@property def analysis_validation_histograms(self) -> List[Histogram]: return [ Histogram( name="deltaM", title="", hist_variable=HistVariable( df_label=makeROOTCompatible(variable="deltaM"), label=r"$\Delta M$", unit=r"GeV/$c^2$", bins=50, scope=(0.14, 0.16), ), hist_components=[ HistComponent( label="Signal", additional_cut_str="isSignal == 1", color="red", ), HistComponent( label="Background", additional_cut_str="isSignal != 1", color="blue", ), ], ), Histogram( name="D0_K_S0_p", title="", hist_variable=HistVariable( df_label=makeROOTCompatible(variable="D0_K_S0_p"), label=r"$p(K_S^0)$", unit="GeV/$c$", bins=50, scope=(0.0, 5.0), ), hist_components=[ HistComponent( label="All", ), ], ), Histogram( name="D0_K_S0_significanceOfDistance", title="", hist_variable=HistVariable( df_label=makeROOTCompatible(variable="D0_K_S0_significanceOfDistance"), label=r"significance of distance($K_S^0$)", unit="$", bins=50, scope=(0.0, 50.0), ), hist_components=[ HistComponent( label="All", ), ], ), ]
[docs] def get_number_of_signal_for_efficiency(self, df: pd.DataFrame) -> float: return df["isSignal"].sum()