ATLAS Offline Software
testEDM.py
Go to the documentation of this file.
1 #!/usr/bin/env python
2 # Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
3 
4 from AthenaCommon.Logging import logging
5 from CLIDComps.clidGenerator import clidGenerator
6 log = logging.getLogger('testEDM')
7 
8 from TriggerEDM import (TriggerL2List, TriggerEFList, TriggerResultsList, TriggerResultsRun1List,
9  TriggerLvl1List, TriggerIDTruth, TriggerHLTList, _addExtraCollectionsToEDMList, isCLIDDefined)
10 from TriggerEDMRun2 import EDMDetails
11 from TrigEDMConfig.TriggerEDMDefs import InViews, allowTruncation
12 import TriggerEDMRun1
13 
14 def main():
15  import re
16  serializable_names = []
17  serializable_names_no_label = []
18  cgen = clidGenerator("", False)
19  TriggerList = TriggerL2List + TriggerEFList + TriggerResultsList + TriggerResultsRun1List + TriggerLvl1List + TriggerIDTruth + TriggerHLTList
20  TriggerList += TriggerEDMRun1.TriggerL2List + TriggerEDMRun1.TriggerEFList + TriggerEDMRun1.TriggerResultsRun1List
21  for TriggerSerializable in TriggerList:
22  #print TriggerSerializable
23  serializable_name = TriggerSerializable[0]
24  serializable_name_no_label = re.sub(r"\#.*", "", serializable_name)
25  if '#' not in serializable_name:
26  log.error("ERROR, no label for " + serializable_name)
27  return 1
28  #Check container can be assigned a CLID
29  if not isCLIDDefined(cgen, serializable_name_no_label):
30  log.error("no CLID for " + serializable_name)
31  return 1
32  if serializable_name_no_label not in EDMDetails.keys():
33  log.error(serializable_name_no_label + " does not correspond to any name in EDMDetails")
34 
35 
36  #check for Aux "."
37  if "Aux" in serializable_name and "Aux." not in serializable_name:
38  log.error("no final Aux. in label for " + serializable_name)
39 
40  file_types = TriggerSerializable[1].split(" ")
41 
42  allowed_file_types = ("", "BS", "DS", "ESD", "AODFULL", "AODSLIM", "AODVERYSLIM", "AODBLSSLIM", "AODCONV")
43 
44  for file_type in file_types:
45  if file_type not in allowed_file_types:
46  log.error("unknown file type " + file_type + " for " + serializable_name)
47  return 1
48 
49  serializable_names.append(serializable_name)
50  serializable_names_no_label.append(serializable_name_no_label)
51 
52  #check EDMDetails
53  for EDMDetail in EDMDetails.keys():
54  if EDMDetail not in serializable_names_no_label:
55  log.warning("EDMDetail for " + EDMDetail + " does not correspond to any name in TriggerList")
56 
57  # Check EDM flag manipulation
58  dummyEDM = [
59  ('xAOD::A#HLT_A', 'BS ESD', 'Steer', [InViews('SomeView1')]),
60  ('xAOD::AAuxContainer#HLT_AAux.', 'BS ESD', 'Steer'),
61  ('xAOD::B#HLT_B', 'BS ESD', 'Steer'),
62  ('xAOD::BAuxContainer#HLT_BAux.DecOne.', 'BS ESD', 'Steer'),
63  ('xAOD::B#HLT_C', 'BS ESD', 'Steer'),
64  ('xAOD::BAuxContainer#HLT_CAux.', 'BS ESD', 'Steer'),
65  ('xAOD::E#HLT_E', 'BS ESD', 'Steer', [allowTruncation]),
66  ('xAOD::EAuxContainer#HLT_EAux.', 'BS ESD', 'Steer', [allowTruncation]),
67  ]
68 
69  updateList = [
70  # Add new
71  ('xAOD::D#HLT_D', 'BS ESD AODFULL', 'Steer', [InViews('SomeView2')]),
72  ('xAOD::DAuxContainer#HLT_DAux.', 'BS ESD AODFULL', 'Steer'),
73  # Add decorations & target
74  ('xAOD::AAuxContainer#HLT_AAux.DecTwo.DecThree', 'BS ESD', 'Steer'),
75  ('xAOD::B#HLT_B', 'BS ESD AODFULL', 'Steer'),
76  ('xAOD::BAuxContainer#HLT_BAux.DecFour', 'BS ESD AODFULL', 'Steer'),
77  # Duplicate - leave untouched
78  ('xAOD::C#HLT_C', 'BS ESD', 'Steer'),
79  ('xAOD::CAuxContainer#HLT_CAux.', 'BS ESD', 'Steer'),
80  ]
81 
82  _addExtraCollectionsToEDMList(dummyEDM, updateList) # Note: Function updates dummyEDM in-place
83 
84  expectedEDM = [
85  ('xAOD::A#HLT_A', 'BS ESD', 'Steer', [InViews('SomeView1')]),
86  ('xAOD::AAuxContainer#HLT_AAux.DecTwo.DecThree', 'BS ESD', 'Steer'),
87  ('xAOD::B#HLT_B', 'BS ESD AODFULL', 'Steer'),
88  ('xAOD::BAuxContainer#HLT_BAux.DecOne.DecFour', 'BS ESD AODFULL', 'Steer'),
89  ('xAOD::C#HLT_C', 'BS ESD', 'Steer'),
90  ('xAOD::CAuxContainer#HLT_CAux.', 'BS ESD', 'Steer'),
91  ('xAOD::D#HLT_D', 'BS ESD AODFULL', 'Steer', [InViews('SomeView2')]),
92  ('xAOD::DAuxContainer#HLT_DAux.', 'BS ESD AODFULL', 'Steer'),
93  ('xAOD::E#HLT_E', 'BS ESD', 'Steer', [allowTruncation]),
94  ('xAOD::EAuxContainer#HLT_EAux.', 'BS ESD', 'Steer', [allowTruncation]),
95  ]
96 
97  if (dummyEDM != expectedEDM):
98  log.error("There is a problem in _addExtraCollectionsToEDMList, expecting:")
99  log.error(expectedEDM)
100  log.error("Got:")
101  log.error(dummyEDM)
102 
103 if __name__ == "__main__":
104  import sys
105  sys.exit(main())
python.TriggerEDM.isCLIDDefined
def isCLIDDefined(cgen, typename)
Definition: TriggerEDM.py:703
python.TriggerEDM._addExtraCollectionsToEDMList
def _addExtraCollectionsToEDMList(edmList, extraList)
Definition: TriggerEDM.py:70
python.testEDM.main
def main()
Definition: testEDM.py:14
Trk::split
@ split
Definition: LayerMaterialProperties.h:38