Belle II Software  release-06-00-14
udst_compatibility-v04-02-04.py
1 #!/usr/bin/env python3
2 # -*- coding: utf-8 -*-
3 
4 
11 
12 """
13 Test backwards compatibility for a udst file produced with release-04-01-04.
14 
15 This is not always guaranteed. Analysis objects may break backwards
16 compatibility for older files. Some niche corner cases might be problematic for
17 file produced with release older than release-05-00-00.
18 
19 See https://confluence.desy.de/display/BI/Backward+Compatibility for more
20 """
21 
22 import basf2
23 import b2test_utils
24 import udst
25 
26 if __name__ == "__main__":
27 
28  # clear out stray env variables and set seeding for reproducible results
30  basf2.set_random_seed(1)
31 
32  # configure processing path - input file is the first 3 events from Phil's
33  # favourite test udst file from https://questions.belle2.org/question/9758/
34  main = basf2.create_path()
35  main.add_module(
36  "RootInput", inputFileName=basf2.find_file("analysis/tests/udst-v04-02-04.root")
37  )
38  main.add_module("EventInfoPrinter")
39 
40  # this function does the hard work
41  udst.add_udst_dump(main, True)
42 
43  # also dump some variables just in case the DataStorePrinter hides some
44  # problems (like has happened once: PR #7525 / BII-7148).
45  sanity_check_variables = [
46  "mcPDG",
47  "daughter(0, mcPDG)", # check the MCParticle <--> Particle relation (or array index lookup)
48  "Mbc", "InvM", "deltaE",
49  "daughter(1, pionID)", # check the PIDLikelihoods <--> Particle relation
50  "daughter(1, kaonID)",
51  "daughter(1, clusterE)", # check the ECLCluster <--> Particle relation (or array index lookup)
52  "daughter(1, klmClusterLayers)", # check the KLMCluster <--> Particle relation (or array index lookup)
53  ]
54  main.add_module(
55  "ParticlePrinter", listName="B0:semileptonic", variables=sanity_check_variables)
56 
57  # only 3 events in the file, but set explicitly case this test script gets copied
58  basf2.process(main, 3)
def configure_logging_for_tests(user_replacements=None)
Definition: __init__.py:106
def add_udst_dump(path, print_untested=False)
Definition: udst.py:166