import basf2
import modularAnalysis as ma
import variables.collections as vc
import variables.utils as vu
import stdPhotons
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 typing import List
import os
os.environ["QT_QPA_PLATFORM"] = "offscreen"
[docs]
@fancy_validation_mode_header
class Pi0Yield(ValidationModeBaseClass):
name = "pi0Yield"
[docs]
def create_basf2_path(self, fraction_to_process=0.01):
main_path = basf2.Path()
# Process only fraction of events due to large size of the resulting ntuples
ma.applyEventCuts(
cut=f"eventRandom < {fraction_to_process}",
path=main_path,
)
# use standard final state particle lists
#
stdPhotons.stdPhotons(
listtype="all", beamBackgroundMVAWeight="MC16rd", fakePhotonMVAWeight="MC16rd", path=main_path
)
ma.fillParticleList("pi+:tracks", cut="pt>0.1", path=main_path)
ma.cutAndCopyList(
outputListName="gamma:test", inputListName="gamma:all", cut="abs(clusterTiming)<200", path=main_path
)
ma.reconstructDecay(
decayString="pi0:test -> gamma:test gamma:test", cut="InvM > 0.07 and InvM < 0.2", path=main_path
)
ma.reconstructDecay(
decayString="eta:test -> gamma:test gamma:test", cut="InvM > 0.450 and InvM < 0.650", path=main_path
)
# perform MC matching (MC truth association)
ma.matchMCTruth(list_name="pi0:test", path=main_path)
ma.matchMCTruth(list_name="eta:test", path=main_path)
ma.buildEventShape(
inputListNames=["pi+:tracks", "gamma:test"],
cleoCones=False,
collisionAxis=False,
foxWolfram=True,
harmonicMoments=False,
jets=False,
sphericity=False,
thrust=True,
path=main_path,
)
pi0_vars = vu.create_aliases_for_selected(
list_of_variables=vc.inv_mass + vc.mc_truth + vc.kinematics + vc.mc_kinematics,
decay_string="^pi0 -> gamma gamma",
prefix="pi0",
)
gamma1_vars = vu.create_aliases_for_selected(
list_of_variables=vc.cluster
+ vc.kinematics
+ vc.mc_truth
+ vc.mc_kinematics
+ ["beamBackgroundSuppression", "fakePhotonSuppression"],
decay_string="pi0 -> ^gamma gamma",
prefix="gamma1",
)
gamma2_vars = vu.create_aliases_for_selected(
list_of_variables=vc.cluster
+ vc.kinematics
+ vc.mc_truth
+ vc.mc_kinematics
+ ["beamBackgroundSuppression", "fakePhotonSuppression"],
decay_string="pi0 -> gamma ^gamma",
prefix="gamma2",
)
eta_vars = vu.create_aliases_for_selected(
list_of_variables=vc.inv_mass + vc.mc_truth + vc.kinematics + vc.mc_kinematics,
decay_string="^eta -> gamma gamma",
prefix="eta",
)
gamma1_from_eta_vars = vu.create_aliases_for_selected(
list_of_variables=vc.cluster
+ vc.kinematics
+ vc.mc_truth
+ vc.mc_kinematics
+ ["beamBackgroundSuppression", "fakePhotonSuppression"],
decay_string="eta -> ^gamma gamma",
prefix="gamma1",
)
gamma2_from_eta_vars = vu.create_aliases_for_selected(
list_of_variables=vc.cluster
+ vc.kinematics
+ vc.mc_truth
+ vc.mc_kinematics
+ ["beamBackgroundSuppression", "fakePhotonSuppression"],
decay_string="eta -> gamma ^gamma",
prefix="gamma2",
)
self.variables_to_validation_histogram(
decay_str="pi0:test",
variables=[("InvM", 50, 0, 0.2)],
path=main_path,
)
self.variables_to_validation_histogram(
decay_str="pi0:test",
variables=[("E", 50, 0, 5)],
path=main_path,
)
self.variables_to_validation_ntuple(
decay_str="pi0:test",
variables=pi0_vars + gamma1_vars + gamma2_vars + ["thrust", "foxWolframR2"],
path=main_path,
)
self.variables_to_validation_ntuple(
decay_str="eta:test",
variables=eta_vars + gamma1_from_eta_vars + gamma2_from_eta_vars,
path=main_path,
)
return main_path
@property
def analysis_validation_histograms(self) -> List[Histogram]:
hist = []
# rimuove eventi jet-like
common_cuts = "foxWolframR2 < 0.94"
cuts = [
("", "Inclusive"),
("log(pi0_p)/log(10) >= -0.8 and log(pi0_p)/log(10) < -0.6", "-0.8 ≤ log10(p) < -0.6"),
("log(pi0_p)/log(10) >= -0.6 and log(pi0_p)/log(10) < -0.4", "-0.6 ≤ log10(p) < -0.4"),
("log(pi0_p)/log(10) >= -0.4 and log(pi0_p)/log(10) < -0.2", "-0.4 ≤ log10(p) < -0.2"),
("log(pi0_p)/log(10) >= -0.2 and log(pi0_p)/log(10) < 0.0", "-0.2 ≤ log10(p) < 0.0"),
("log(pi0_p)/log(10) >= 0.0 and log(pi0_p)/log(10) < 0.2", "0.0 ≤ log10(p) < 0.2"),
("log(pi0_p)/log(10) >= 0.2 and log(pi0_p)/log(10) < 0.4", "0.2 ≤ log10(p) < 0.4"),
("log(pi0_p)/log(10) >= 0.4 and log(pi0_p)/log(10) < 0.6", "0.4 ≤ log10(p) < 0.6"),
("log(pi0_p)/log(10) >= 0.6 and log(pi0_p)/log(10) < 0.8", "0.6 ≤ log10(p) < 0.8"),
("log(pi0_p)/log(10) >= 0.8 and log(pi0_p)/log(10) < 1.0", "0.8 ≤ log10(p) < 1.0"),
]
for i, (cut, label_tag) in enumerate(cuts):
# costruzione selezione finale
if cut:
final_cut = f"{common_cuts} and {cut}"
else:
final_cut = common_cuts
for var, label, unit, scope in [
("pi0_M", "pi0_M", "GeV/c^2", (0.07, 0.20)),
# ("pi0_p", "pi0_p", "GeV/c", (0, 5)),
# ("eta_M", "eta_M", "GeV/c^2", (0.3, 0.9)),
# ("eta_p", "eta_p", "GeV/c", (0, 5)),
# ("phi", "phi", "rad", (-3, 3)),
# ("dip", "dip", "degree", (-90, 90)),
]:
hist.append(
Histogram(
name=f"{var}_pi0_bin{i}",
title=rf"{label} (pi0, {label_tag})",
particle_list="pi0:test",
hist_variable=HistVariable(
df_label=var,
label=label,
unit=unit,
bins=100,
scope=scope,
),
hist_components=[
HistComponent(
label="pi0",
additional_cut_str=final_cut,
)
],
)
)
return hist