Belle II Software  release-05-01-25
assert_same_streamers.py
1 import ROOT
2 from ROOT import Belle2
3 
4 from b2test_utils import get_object_with_name, get_streamer_checksums
5 
6 
7 # A mapping name -> version, checksum of the expected objects
8 EXPECTED_CHECKSUMS = {
9  'Belle2::EventMetaData': (4, 2999207747),
10  'Belle2::ROIid': (1, 1743241213),
11  'Belle2::ROIpayload': (2, 610869861),
12  'Belle2::RawARICH': (1, 3497179043),
13  'Belle2::RawCDC': (1, 1985095356),
14  'Belle2::RawCOPPER': (3, 3824346631),
15  'Belle2::RawDataBlock': (3, 2371206983),
16  'Belle2::RawECL': (1, 2693252500),
17  'Belle2::RawFTSW': (2, 1181247934),
18  'Belle2::RawKLM': (1, 101994230),
19  'Belle2::RawPXD': (2, 924270514),
20  'Belle2::RawSVD': (1, 1772361339),
21  'Belle2::RawTOP': (1, 1772361339),
22  'Belle2::RawTRG': (1, 1772361339),
23  'Belle2::RelationsInterface<TObject>': (0, 3862127315),
24  'Belle2::SoftwareTrigger::SoftwareTriggerVariables': (1, 638196437),
25  'Belle2::SoftwareTriggerResult': (5, 241059817),
26  'Belle2::TRGSummary': (7, 1658421299),
27 }
28 
29 # Map the name of the DataStore objects to their corresponding C++ object names
30 NAME_TO_CPP_REPLACEMENTS = {
31  "SoftwareTriggerVariables": "SoftwareTrigger::SoftwareTriggerVariables",
32  "ROIs": "ROIid",
33  "RawARICHs": "RawARICH",
34  "RawCDCs": "RawCDC",
35  "RawCOPPERs": "RawCOPPER",
36  "RawECLs": "RawECL",
37  "RawFTSWs": "RawFTSW",
38  "RawKLMs": "RawKLM",
39  "RawPXDs": "RawPXD",
40  "RawSVDs": "RawSVD",
41  "RawTOPs": "RawTOP",
42  "RawTRGs": "RawTRG",
43 }
44 
45 
46 if __name__ == "__main__":
47  from softwaretrigger.constants import ALWAYS_SAVE_OBJECTS, RAWDATA_OBJECTS
48 
49  # Lets use everything which will be stored to raw data
50  objects_names = ALWAYS_SAVE_OBJECTS + RAWDATA_OBJECTS
51 
52  # We need to fix some names, as they do not correspond to the ROOT object classes
53  objects_names = [NAME_TO_CPP_REPLACEMENTS.get(name, name) for name in objects_names]
54 
55  # Now get the actual objects corresponding to the names
56  objects = [get_object_with_name(object_name)() for object_name in objects_names]
57 
58  # Check the checksums of every entry
59  problems = []
60 
61  for key, checksum in get_streamer_checksums(objects).items():
62  if key not in EXPECTED_CHECKSUMS:
63  problems.append(f"There is no {key} in the checksum dictionary!")
64 
65  expected_checksum = EXPECTED_CHECKSUMS[key]
66 
67  if expected_checksum != checksum:
68  problems.append(f"The checksum {checksum[1]} for {key} (version {checksum[0]}) "
69  f"is not equal to the expected checksum {expected_checksum[1]} (version {expected_checksum[0]}).")
70 
71  if not problems:
72  print("Check finished")
73  else:
74  problems = "\n\t" + "\n\t".join(problems)
75  print("Check finished with problems. ",
76  "Either you changed them by accident or you need to adjust the expected checksum list in this test):",
77  problems)
78  exit(1)
softwaretrigger.constants
Definition: constants.py:1