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