Belle II Software  release-08-01-10
test_trackIsolationVariables.py
1 
8 
9 import basf2 as b2
10 import modularAnalysis as ma
11 import stdV0s as stdv0
12 import pdg
13 from ROOT import Belle2
14 import b2test_utils
15 import variables.utils as vu
16 
17 path = b2.create_path()
18 
20 b2.set_random_seed("1337")
21 
22 ma.inputMdstList(filelist=[b2test_utils.require_file("mdst14.root", "validation")],
23  entrySequences=["0:1"],
24  path=path)
25 detectors = ["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 
32 chargedStableList = []
33 for idx in range(len(Belle2.Const.chargedStableSet)):
34  pdgId = Belle2.Const.chargedStableSet.at(idx).getPDGCode()
35  chargedStableList.extend([pdgId, -pdgId])
36 
37 for 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 
55 v0_types = ["Lambda0:merged", "K_S0:merged"]
56 v0_functions = [stdv0.stdLambdas, stdv0.stdKshorts]
57 v0_decays = [" -> ^p+ ^pi-", " -> ^pi+ ^pi-"]
58 
59 for 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 configure_logging_for_tests(user_replacements=None)
Definition: __init__.py:106
def set_loglevel(loglevel)
Definition: __init__.py:77
def require_file(filename, data_type="", py_case=None)
Definition: __init__.py:54
def clean_working_directory()
Definition: __init__.py:189
def to_names(pdg_codes)
Definition: pdg.py:97