ATLAS Offline Software
DQConfigFlags.py
Go to the documentation of this file.
1 #
2 # Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
3 #
4 
5 from AthenaConfiguration.AthConfigFlags import AthConfigFlags
6 from AthenaConfiguration.Enums import FlagEnum,HIMode
7 
8 _steeringFlags = [ 'doGlobalMon', 'doLVL1CaloMon', 'doLVL1InterfacesMon', 'doCTPMon', 'doHLTMon',
9  'doPixelMon', 'doSCTMon', 'doTRTMon', 'doInDetMon',
10  'doLArMon', 'doTileMon',
11  'doCaloGlobalMon', 'doMuonMon',
12  'doLucidMon', 'doAFPMon', 'doZDCMon',
13  'doHIMon', 'doEgammaMon', 'doJetMon', 'doMissingEtMon',
14  'doJetInputsMon',
15  'doTauMon', 'doJetTagMon', 'doDataFlowMon' ]
16 
17 _lowLevelSteeringFlags = [ 'InDet.doGlobalMon', 'InDet.doAlignMon',
18  'InDet.doPerfMon', 'Muon.doRawMon',
19  'Muon.doTrackMon', 'Muon.doAlignMon',
20  'Muon.doSegmentMon',
21  'Muon.doPhysicsMon', 'Muon.doTrkPhysMon',
22  'Muon.doCombinedMon', 'LVL1Calo.doValidation'
23  ]
24 
25 
26 class DQDataType(FlagEnum):
27  """Flag values for DQ.DataType"""
28  Collisions = 'collisions'
29  Cosmics = 'cosmics'
30  HeavyIon = 'heavyioncollisions'
31  MC = 'monteCarlo'
32  User = 'user'
33 
34 
36  acf=AthConfigFlags()
37  acf.addFlag('DQ.doMonitoring', False)
38  acf.addFlag('DQ.doStreamAwareMon', True)
39  acf.addFlag('DQ.disableAtlasReadyFilter', False)
40  acf.addFlag('DQ.disableFilledBunchFilter', False)
41  acf.addFlag('DQ.enableLumiAccess', True)
42  acf.addFlag('DQ.FileKey', 'CombinedMonitoring')
43  # two flags here, with different meaning.
44  # triggerDataAvailable determines whether we expect trigger objects in the event store
45  acf.addFlag('DQ.triggerDataAvailable', True)
46  # useTrigger determines whether we should use TrigDecisionTool
47  acf.addFlag('DQ.useTrigger', getUseTrigger)
48 
49  # computed
50  acf.addFlag('DQ.Environment', getEnvironment )
51  acf.addFlag('DQ.DataType', getDataType, type=DQDataType )
52 
53  # for in-Athena histogram postprocessing
54  acf.addFlag('DQ.doPostProcessing', False)
55  acf.addFlag('DQ.postProcessingInterval', 100)
56 
57  # steering ...
58  for flag in _steeringFlags + _lowLevelSteeringFlags:
59  if flag == 'doLVL1CaloMon':
60  continue
61  arg = True
62  if flag in ['doJetTagMon', 'doMissingEtMon', 'doTauMon']:
63  arg = lambda x: x.DQ.DataType is not DQDataType.Cosmics and x.Reco.HIMode is not HIMode.HI # noqa: E731
64  if flag in [ 'doJetMon','doJetTagMon'] :
65  arg = lambda x: x.DQ.DataType is not DQDataType.Cosmics # noqa: E731
66  if flag == 'doHLTMon':
67  # new HLT monitoring not yet compatible with pre-Run 3 data
68  # disable HLT monitoring if input is data AOD as not all HLT collections in AOD - ATR-28781
69  arg = lambda x: x.Trigger.EDMVersion == 3 and x.DQ.Environment != 'AOD' # noqa: E731
70  if flag == 'LVL1Calo.doValidation':
71  arg = False
72  acf.addFlag('DQ.Steering.' + flag, arg)
73 
74  # special protection for L1Calo monitoring : check L1Calo is indeed in
75  acf.addFlag('DQ.Steering.doLVL1CaloMon', _hasL1Calo)
76 
77  # HLT steering ...
78  from PyUtils.moduleExists import moduleExists
79  if moduleExists ('TrigHLTMonitoring'):
80  from TrigHLTMonitoring.TrigHLTMonitorAlgorithm import createHLTDQConfigFlags
81  acf.join(createHLTDQConfigFlags())
82  return acf
83 
84 def getUseTrigger(flags):
85  from PyUtils.moduleExists import moduleExists
86  hlt_exists = moduleExists ('TrigHLTMonitoring')
87  return hlt_exists and flags.DQ.triggerDataAvailable
88 
89 def getDataType(flags):
90  from AthenaConfiguration.Enums import BeamType
91  if flags.Input.isMC:
92  return DQDataType.MC
93  elif flags.Reco.EnableHI:
94  return DQDataType.HeavyIon
95  elif flags.Beam.Type is BeamType.Cosmics:
96  return DQDataType.Cosmics
97  elif flags.Beam.Type is BeamType.Collisions:
98  return DQDataType.Collisions
99  elif flags.Beam.Type is BeamType.SingleBeam:
100  # historically, singlebeam treated as collisions
101  return DQDataType.Collisions
102  else:
103  from AthenaCommon.Logging import logging
104  local_logger = logging.getLogger('DQConfigFlags_getDataType')
105  local_logger.warning('Unable to figure out beam type for DQ; using "User"')
106  return DQDataType.User
107 
108 def getEnvironment(flags):
109  if flags.Common.isOnline:
110  return 'online'
111  else:
112  # this could use being rethought to properly encode input and output types perhaps ...
113  from AthenaConfiguration.Enums import Format
114  if flags.Input.Format is Format.BS:
115  if flags.Output.AODFileName:
116  return 'tier0'
117  else:
118  return 'tier0Raw'
119  elif 'StreamESD' in flags.Input.ProcessingTags:
120  return 'tier0ESD'
121  elif 'StreamAOD' in flags.Input.ProcessingTags:
122  return 'AOD'
123  elif 'StreamDAOD_PHYS' in flags.Input.ProcessingTags:
124  return 'DAOD_PHYS'
125  else:
126  from AthenaCommon.Logging import logging
127  local_logger = logging.getLogger('DQConfigFlags_getEnvironment')
128  local_logger.warning('Unable to figure out environment for DQ; using "tier0ESD"')
129  return 'tier0ESD'
130 
131 def _hasL1Calo(flags):
132  from AthenaConfiguration.AutoConfigFlags import GetFileMD
133  md = GetFileMD(flags.Input.Files)
134  import eformat
135  detMask = eformat.helper.DetectorMask(f'{md.get("detectorMask",[0x0])[0]:032x}')
136  isEnabled = any([
137  detMask.is_set(eformat.helper.SubDetector.TDAQ_CALO_PREPROC),
138  detMask.is_set(eformat.helper.SubDetector.TDAQ_CALO_TOPO_PROC),
139  detMask.is_set(eformat.helper.SubDetector.TDAQ_CALO_FEAT_EXTRACT_DAQ),
140  detMask.is_set(eformat.helper.SubDetector.TDAQ_CALO_FEAT_EXTRACT_ROI)])
141  return isEnabled
142 
144  for flag in _steeringFlags:
145  setattr(getattr(flags, 'DQ.Steering'), flag, False)
python.AutoConfigFlags.GetFileMD
def GetFileMD(filenames, allowEmpty=True, maxLevel='peeker')
Definition: AutoConfigFlags.py:65
python.DQConfigFlags.getUseTrigger
def getUseTrigger(flags)
Definition: DQConfigFlags.py:84
TrigHLTMonitorAlgorithm.createHLTDQConfigFlags
def createHLTDQConfigFlags()
Definition: TrigHLTMonitorAlgorithm.py:19
python.DQConfigFlags._hasL1Calo
def _hasL1Calo(flags)
Definition: DQConfigFlags.py:131
python.DQConfigFlags.allSteeringFlagsOff
def allSteeringFlagsOff(flags)
Definition: DQConfigFlags.py:143
python.DQConfigFlags.getEnvironment
def getEnvironment(flags)
Definition: DQConfigFlags.py:108
python.DQConfigFlags.getDataType
def getDataType(flags)
Definition: DQConfigFlags.py:89
python.DQConfigFlags.createDQConfigFlags
def createDQConfigFlags()
Definition: DQConfigFlags.py:35
python.DQConfigFlags.DQDataType
Definition: DQConfigFlags.py:26