ATLAS Offline Software
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 
4 import os
5 import sys
6 import logging
7 import re
8 from shutil import copyfile
9 import ROOT
10 
11 log = logging.getLogger(__name__)
12 logging.basicConfig(format = '%(message)s', level = logging.INFO)
13 
14 # Needed for generating TStreamerInfo of xAOD::TrigConfKeys
15 ROOT.gInterpreter.ProcessLine('#include "xAODTrigger/TrigConfKeys.h"')
16 
17 doTrigEDMOnly = True
18 bs_filename = 'bs-streamerinfos.root'
19 
20 from TrigSerializeResult.dictwrite import update_streamerinfos
21 
22 
23 def 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 
41 if __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)
python.TriggerEDM.getRawTriggerEDMList
def getRawTriggerEDMList(flags, runVersion=-1)
Definition: TriggerEDM.py:125
CaloCellPos2Ntuple.int
int
Definition: CaloCellPos2Ntuple.py:24
python.DataScoutingInfo.getAllDataScoutingIdentifiers
def getAllDataScoutingIdentifiers()
Definition: DataScoutingInfo.py:79
dictwrite.update_streamerinfos
def update_streamerinfos(objects, updated_objects)
Definition: dictwrite.py:27
histSizes.list
def list(name, path='/')
Definition: histSizes.py:38
CxxUtils::set
constexpr std::enable_if_t< is_bitmask_v< E >, E & > set(E &lhs, E rhs)
Convenience function to set bits in a class enum bitmask.
Definition: bitmask.h:232
python.DetectStreamerInfoChanges.append_versions
def append_versions(objects, cname)
Definition: DetectStreamerInfoChanges.py:23
python.DetectStreamerInfoChanges.format
format
Definition: DetectStreamerInfoChanges.py:12
Trk::open
@ open
Definition: BinningType.h:40
str
Definition: BTagTrackIpAccessor.cxx:11
Trk::split
@ split
Definition: LayerMaterialProperties.h:38