Belle II Software  light-2205-abys
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 in pdg.to_names(chargedStableList):
38 
39  plist = f"{pname}:ref"
40 
41  ma.fillParticleList(plist, "[pt > 0.1] and [thetaInCDCAcceptance]", path=path)
42 
43  ntup_vars = ma.calculateTrackIsolation(plist,
44  path,
45  *detectors)
46 
47  ma.printList(plist, full=True, path=path)
48  ma.printVariableValues(plist, ntup_vars, path=path)
49  ma.variablesToNtuple(plist,
50  ntup_vars,
51  treename=pname,
52  filename="TrackIsolationVariables.root", path=path)
53 v0_types = ['Lambda0:merged', 'K_S0:merged']
54 v0_functions = [stdv0.stdLambdas, stdv0.stdKshorts]
55 v0_decays = [' -> ^p+ ^pi-', ' -> ^pi+ ^pi-']
56 for v0_type, v0_function, v0_decay in zip(v0_types, v0_functions, v0_decays):
57  v0_function(path=path)
58 
59  ntup_vars = ma.calculateTrackIsolation(v0_type+v0_decay,
60  path,
61  *detectors)
62  track_vars = vu.create_aliases_for_selected(list_of_variables=ntup_vars,
63  decay_string=v0_type+v0_decay)
64  ma.printList(v0_type, full=True, path=path)
65  ma.printVariableValues(v0_type, track_vars, path=path)
66  ma.variablesToNtuple(v0_type,
67  track_vars,
68  treename=f"{v0_type.split(':')[0]}",
69  filename="TrackIsolationVariables.root", path=path)
71  with b2test_utils.set_loglevel(b2.LogLevel.INFO):
72  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:185
def to_names(pdg_codes)
Definition: pdg.py:97