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