Belle II Software development
test_trackIsolationVariables.py
1
8
9import basf2 as b2
10import modularAnalysis as ma
11import stdV0s as stdv0
12import pdg
13from ROOT import Belle2
14import b2test_utils
15import variables.utils as vu
16
17path = b2.create_path()
18
20b2.set_random_seed("1337")
21
22ma.inputMdstList(filelist=[b2test_utils.require_file("mdst16.root", "validation")],
23 entrySequences=["0:1"],
24 path=path)
25detectors = ["CDC", "TOP", "ARICH", "ECL", "KLM"]
26
27# Pdg code of the charged stable particles & antiparticles.
28# Note that this is just to test module behaviour against different user's input:
29# in fact, for any choice of particle list's charge, the charge-conjugated one
30# gets loaded automatically.
31
32chargedStableList = []
33for idx in range(len(Belle2.Const.chargedStableSet)):
34 pdgId = Belle2.Const.chargedStableSet.at(idx).getPDGCode()
35 chargedStableList.extend([pdgId, -pdgId])
36
37for pname, pdgId in zip(pdg.to_names(chargedStableList), chargedStableList):
38
39 plist = f"{pname}:ref"
40
41 ma.fillParticleList(plist, "[pt > 0.1] and [thetaInCDCAcceptance]", path=path)
42
43 track_iso_vars = ma.calculateTrackIsolation(plist,
44 path,
45 *detectors,
46 exclude_pid_det_weights=True)
47
48 ma.printVariableValues(plist, track_iso_vars[pdgId], path=path)
49 ma.variablesToNtuple(plist,
50 track_iso_vars[pdgId],
51 treename=pname,
52 filename="TrackIsolationVariables.root",
53 path=path)
54
55v0_types = ["Lambda0:merged", "K_S0:merged"]
56v0_functions = [stdv0.stdLambdas, stdv0.stdKshorts]
57v0_decays = [" -> ^p+ ^pi-", " -> ^pi+ ^pi-"]
58
59for v0_type, v0_function, v0_decay in zip(v0_types, v0_functions, v0_decays):
60
61 v0_function(path=path)
62
63 track_iso_vars = ma.calculateTrackIsolation(v0_type+v0_decay,
64 path,
65 *detectors,
66 exclude_pid_det_weights=True)
67
68 ntup_vars_aliases = []
69 for ivars in track_iso_vars.values():
70 ntup_vars_aliases += vu.create_aliases_for_selected(list_of_variables=ivars,
71 decay_string=v0_type+v0_decay)
72
73 ma.printVariableValues(v0_type, ntup_vars_aliases, path=path)
74 ma.variablesToNtuple(v0_type,
75 ntup_vars_aliases,
76 treename=f"{v0_type.split(':')[0]}",
77 filename="TrackIsolationVariables.root", path=path)
78
80 with b2test_utils.set_loglevel(b2.LogLevel.INFO):
81 b2.process(path)
def require_file(filename, data_type="", py_case=None)
Definition: __init__.py:54
def clean_working_directory()
Definition: __init__.py:189
def configure_logging_for_tests(user_replacements=None)
Definition: __init__.py:106
def set_loglevel(loglevel)
Definition: __init__.py:77
def to_names(pdg_codes)
Definition: pdg.py:98