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__ = [
"DtoKsPiPiSystValidationMode",
]
[docs]
@fancy_validation_mode_header
class DtoKsPiPiSystValidationMode(ValidationModeBaseClass):
name = "DtoKsPiPiSyst"
latex_str = r"$D^{*+}\rightarrow (D^0 \rightarrow K_S^0 \pi^+ \pi^-) \pi^+$"
[docs]
def create_basf2_path(self, is_data):
main_path = basf2.Path()
ma.fillParticleList("pi+:D0", "abs(dr) < 2 and abs(dz) < 4 and pt > 0.1", path=main_path)
ma.fillParticleList("pi+:slow", "abs(dr) < 2 and abs(dz) < 4", path=main_path)
stdKshorts(prioritiseV0=True, fitter="TreeFit", updateAllDaughters=True, path=main_path)
ma.applyCuts("K_S0:merged", "0.480 < M < 0.516", path=main_path)
ma.reconstructDecay("D0:Kspipi -> K_S0:merged pi+:D0 pi-:D0", "1.82 < M < 1.91", path=main_path)
ma.reconstructDecay(
"D*+:Dpi -> D0:Kspipi pi+:slow", "0.144 < massDifference(0) < 0.147 and useCMSFrame(p) > 1.6", path=main_path)
if not is_data:
ma.matchMCTruth("D*+:Dpi", path=main_path)
# aliases
va.variables.addAlias('p_cm','useCMSFrame(p)')
va.variables.addAlias('E_cm','useCMSFrame(E)')
va.variables.addAlias('theta_cm','useCMSFrame(theta)')
va.variables.addAlias('ctheta','cosTheta')
va.variables.addAlias("deltaM", "massDifference(0)")
va.variables.addAlias("moth", "genMotherPDG(0)")
va.variables.addAlias("gmoth", "genMotherPDG(1)")
va.variables.addAlias("unqId", "formula(runNum+evtNum*10000)")
va.variables.addAlias("pointAngle", "daughter(0,pointingAngle(0))")
va.variables.addAlias('V0d0_0', 'V0d0(0)')
va.variables.addAlias('V0d0_1', 'V0d0(1)')
va.variables.addAlias('V0z0_0', 'V0z0(0)')
va.variables.addAlias('V0z0_1', 'V0z0(1)')
va.variables.addAlias('ancDz', 'hasAncestor(421)')
va.variables.addAlias('ancDstp', 'hasAncestor(413)')
va.variables.addAlias('hlt_hadron', 'SoftwareTriggerResult(software_trigger_cut&skim&accept_hadron)')
va.variables.addAlias('deltaM_dist','abs(deltaM-0.1455)')
va.variables.addAlias('deltaM_rank','extraInfo(deltaM_rank)')
ma.rankByLowest(particleList='D*+:Dpi',
variable='deltaM_dist',
outputVariable='deltaM_rank',
path=main_path)
# variables
part_vars = ['charge']
v0_mc = []
if not is_data:
part_vars += ['moth','gmoth','mcPDG','mcErrors','isSignal']
v0_mc += ['mcSecPhysProc']
kin_vars = ['p','p_cm','px','py','pz','E','E_cm','theta','theta_cm',
'phi','InvM','M','ctheta']
track_vars = ['d0','z0','dr','dz'] + vc.track_hits +\
['firstPXDLayer','firstSVDLayer', 'firstCDCLayer'] + kin_vars
v0_vars = part_vars + kin_vars + v0_mc +\
['dr','ancDz','ancDstp',
'cosAngleBetweenMomentumAndVertexVector',
'cosAngleBetweenMomentumAndVertexVectorInXYPlane',
'V0Deltad0','V0Deltaz0',
'particleSource', 'isFromV0',
'V0d0_0', 'V0d0_1', 'V0z0_0', 'V0z0_1', 'goodBelleKshort']+\
vc.vertex+vc.flight_info
if not is_data:
v0_vars += vc.mc_vertex + vc.mc_kinematics
bg_vars = [
"nECLOutOfTimeCrystals",
"nECLOutOfTimeCrystalsBWDEndcap",
"nECLOutOfTimeCrystalsFWDEndcap",
"nECLOutOfTimeCrystalsBarrel",
"nExtraCDCHitsPostCleaning",
"nExtraCDCHits",
"nExtraCDCSegments",
"timeSinceLastInjectionSignalMicroSeconds",
"timeSinceLastInjectionSignalClockTicks",
"hasRecentInjection",
"injectionInHER",
"isPoissonTriggerInInjectionVeto",
"hasRecentInjection",
"injectionInHER",
]
dstar_vars = part_vars + kin_vars \
+ ['deltaM','unqId','pointAngle','hlt_hadron','deltaM_rank'] \
+ vu.create_daughter_aliases(v0_vars,[0,0], prefix='ks', include_indices=False) \
+ vu.create_daughter_aliases(track_vars,[0,1], prefix='pi_1', include_indices=False) \
+ vu.create_daughter_aliases(track_vars,[0,2], prefix='pi_2', include_indices=False) \
+ vu.create_daughter_aliases(part_vars+kin_vars,0, prefix='dz', include_indices=False) \
+ vu.create_daughter_aliases(track_vars,1, prefix='pi', include_indices=False) \
+ vu.create_daughter_aliases(kin_vars,0, prefix='d', include_indices=False) \
+ vu.create_daughter_aliases(track_vars+['phi','charge'], [0,0,0], prefix='t0', include_indices=False) \
+ vu.create_daughter_aliases(track_vars+['phi','charge'], [0,0,1], prefix='t1', include_indices=False) \
+ bg_vars
self.variables_to_validation_ntuple(
decay_str="D*+:Dpi",
variables=dstar_vars,
path=main_path,
)
return main_path