ATLAS Offline Software
Loading...
Searching...
No Matches
DetectStreamerInfoChanges.py
Go to the documentation of this file.
1#!/usr/bin/env python
2# Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration
3
4import os
5import sys
6import logging
7import re
8from shutil import copyfile
9import ROOT
10
11log = logging.getLogger(__name__)
12logging.basicConfig(format = '%(message)s', level = logging.INFO)
13
14# Needed for generating TStreamerInfo of xAOD::TrigConfKeys
15ROOT.gInterpreter.ProcessLine('#include "xAODTrigger/TrigConfKeys.h"')
16
17doTrigEDMOnly = True
18bs_filename = 'bs-streamerinfos.root'
19
20from TrigSerializeResult.dictwrite import update_streamerinfos
21
22
23def append_versions(objects, cname):
24 if "CPMTowerAuxContainer" in cname or "CMMEtSumsAuxContainer" in cname or "JEMHitsAuxContainer" in cname or "JEMEtSumsAuxContainer" in cname or "JetElementAuxContainer" in cname or "AFPDataAuxContainer" in cname or "_Alloc_hide" in cname or cname == "string" or "CMXJetTobAuxContainer" in cname or "RODHeaderAuxContainer" in cname or "CMMCPHitsAuxContainer" in cname or "CMXCPHitsAuxContainer" in cname or "TruthVertexAuxContainer" in cname or "CMXEtSumsAuxContainer" in cname or "CMXJetHitsAuxContainer" in cname or "CMMJetHitsAuxContainer" in cname or "CPMHitsAuxContain" in cname:
25 return
26 isxAOD = re.search('_v[0-9]$', class_name)
27 isxAODDV = re.search('_v[0-9]>$', class_name)
28 version = "1"
29 if isxAOD is not None:
30 version = [int(s) for s in cname.split("_v") if s.isdigit()][-1]
31 for i in range (1, version+1):
32 objects.append(cname.replace("_v"+str(version), "_v"+str(i)))
33 elif isxAODDV is not None:
34 version = [int(s) for s in re.split('_v|>',cname) if s.isdigit()][-1]
35 for i in range (1, version+1):
36 objects.append(cname.replace("_v"+str(version)+">", "_v"+str(i)+">"))
37 else:
38 pass
39 #objects.append(cname)
40
41if __name__ == '__main__':
42
43 is_main = os.getenv('AtlasBuildBranch') == 'main'
44
45 objects = []
46 if doTrigEDMOnly:
47 from TrigEDMConfig.TriggerEDM import getRawTriggerEDMList
48 from TrigEDMConfig.DataScoutingInfo import getAllDataScoutingIdentifiers
49 BS_destinations = ["BS"] + getAllDataScoutingIdentifiers()
50 log.info("BS_destinations = {}".format(BS_destinations))
51 for item in getRawTriggerEDMList(flags=None, runVersion=3):
52 if any(bs in item[1].split() for bs in BS_destinations):
53 objects.append(item[0].split("#")[0])
54 else:
55 # try to process all classes from the build
56 os.system("get_files -data clid.db")
57 classid = open("clid.db", "r")
58 for cl in classid:
59 items = cl.split("; ")
60 class_name = items[3].rstrip()
61 isxAOD = re.search('_v[0-9].*$', class_name)
62 if isxAOD is not None:
63 log.info (class_name + " is versioned xAOD class")
64 append_versions(objects, class_name)
65 else:
66 log.info (class_name + " is not an xAOD class")
67
68 objects = list(set(objects))
69
70 log.info("Will extract TStreamerInfo for the following types:")
71 log.info(objects)
72
73 copyfile(bs_filename, "original_" + bs_filename)
74
75 updated_objects = []
76 update_streamerinfos(objects, updated_objects)
77
78 # ignore messages about these types - apparently they will always be displayed
79 black_list = ["string::_Alloc_hider", "string"]
80 new_objects = [item for item in updated_objects if item[0] not in black_list]
81
82 if len(new_objects) > 0:
83 log.warning("The following {} new objects were detected:".format(len(new_objects)))
84 for item in new_objects:
85 log.warning("{}: 0x{:x}".format(item[0], item[1]))
86 log.warning("Please ask the Trigger EDM coordinator to add them to bs-streamerinfos.root")
87 else:
88 log.info("No new objects detected")
89
90 exit_code_err = len(new_objects)
91 if exit_code_err:
92 if is_main:
93 log.warning("New TStreamerInfos detected but ignoring this error for early Phase II commissioning period in main during P1 data taking.")
94 exit_code_err = 0 # ignore error for main
95 else:
96 log.error("New TStreamerInfos detected")
97 else:
98 log.info("No new TStreamerInfos detected")
99
100 log.info("DONE")
101
102 sys.exit(exit_code_err)
STL class.
std::vector< std::string > split(const std::string &s, const std::string &t=":")
Definition hcg.cxx:177