11 from AthenaConfiguration.ComponentFactory
import CompFactory
12 from AthenaConfiguration.ComponentAccumulator
import ComponentAccumulator
13 from AthenaConfiguration.AllConfigFlags
import initConfigFlags
15 from ZdcRecConfig
import ZdcGenericFlagSetting, ZdcStreamDependentFlagSetting
17 from ZdcPhysRecConfig
import FCalRecCfg, PhysStreamAdditionalFlagSetting
22 from AthenaCommon.Logging
import logging
23 log = logging.getLogger(
"ZdcOnlineRecMonitorConfig")
29 '''Set up the partition (object still exists but invalid if offline)
30 and finds the current environment (testbed / p1)
32 partition: the partition object
33 isTestbed - boolean that indicates whether it's testbed or p1'''
38 partition = ispy.IPCPartition(
"")
if os.getenv(
"TDAQ_PARTITION")
is None else ispy.IPCPartition(os.getenv(
"TDAQ_PARTITION"))
42 environmentString = os.getenv(
"ENVIORNMENT")
44 if partition.isValid()
and environmentString
is None:
45 log.warning(
"Warning: Partition is valid but environmental variable ENVIORNMENT is not set!")
46 log.warning(
"Warning: In this case by default assumes environment is p1!")
48 isTestbed = (environmentString ==
"TB")
50 if partition.isValid():
51 log.info(
"Running Online with Partition: %s",partition.name())
53 log.info(
"Partition %s not found. Running Offline - must provide input files!", partition.name())
55 return partition, isTestbed
59 '''Set additional configuration flags for online environment'''
61 log.debug (
'Setting additional flags for online environment')
63 flags.Concurrency.NumThreads = 1
64 flags.Common.isOnline =
True
65 flags.DQ.Environment =
'online'
66 flags.DQ.enableLumiAccess =
False
67 flags.Common.useOnlineLumi =
True
68 flags.DQ.doStreamAwareMon =
False
71 flags.IOVDb.GlobalTag=
'CONDBR2-HLTP-2025-02'
72 flags.Trigger.triggerConfig =
'DB'
74 flags.LAr.doHVCorr =
False
75 flags.InDet.useSctDCS =
False
76 flags.InDet.useDCS =
False
78 flags.Output.doWriteESD =
False
79 flags.Output.doWriteAOD =
False
81 if (partition.isValid()
and partition.name() !=
'ATLAS'):
82 flags.DQ.useTrigger =
False
83 flags.DQ.triggerDataAvailable =
False
86 _steeringFlags = [
'HLT.doBjet',
'HLT.doBphys',
'HLT.doCalo',
'HLT.doEgamma',
'HLT.doGeneral',
'HLT.doInDet',
'HLT.doJet',
'HLT.doMET',
'HLT.doMinBias',
'HLT.doMuon',
'HLT.doTau',
'InDet.doAlignMon',
'InDet.doGlobalMon',
'InDet.doPerfMon',
'LVL1Calo.doValidation',
'Muon.doAlignMon',
'Muon.doCombinedMon',
'Muon.doPhysicsMon',
'Muon.doRawMon',
'Muon.doSegmentMon',
'Muon.doTrackMon',
'Muon.doTrkPhysMon',
'doAFPMon',
'doCTPMon',
'doCaloGlobalMon',
'doDataFlowMon',
'doEgammaMon',
'doGlobalMon',
'doHIMon',
'doHLTMon',
'doInDetMon',
'doJetInputsMon',
'doJetMon',
'doJetTagMon',
'doLArMon',
'doLVL1CaloMon',
'doLVL1InterfacesMon',
'doLucidMon',
'doMissingEtMon',
'doMuonMon',
'doPixelMon',
'doSCTMon',
'doTRTMon',
'doTauMon',
'doTileMon']
88 for flag
in _steeringFlags:
89 if flags.hasFlag(
'DQ.Steering.' + flag):
90 flags._set(
'DQ.Steering.' + flag,
False)
92 flags.addFlag(
'DQ.Steering.' + flag,
False)
95 _triggerFlags = [
'CostMonitoring.doCostMonitoring',
'CostMonitoring.monitorROBs',
'DecisionMakerValidation.Execute',
'Jet.fastbtagPFlow',
'Jet.fastbtagVertex',
'enableL1CaloPhase1',
'enableL1MuonPhase1',
'L1.doMuon',
'L1.doCalo',
'L1.doTopo',
'L1MuonSim.NSWVetoMode',
'L1MuonSim.doBIS78',
'L1MuonSim.doMMTrigger',
'L1MuonSim.doPadTrigger',
'doLVL1',
'doHLT',
'doMuon',
'doNavigationSlimming',
'enableL1CaloLegacy',
'endOfEventProcessing.Enabled',
'fastMenuGeneration',
'Online.BFieldAutoConfig']
97 for flag
in _triggerFlags:
98 if flags.hasFlag(
'Trigger.' + flag):
99 flags._set(
'Trigger.' + flag,
False)
101 flags.addFlag(
'Trigger.' + flag,
False)
105 _detectorFlags = [
'MDT',
'MM',
'Muon',
'RPC',
'TGC',
'sTGC']
106 for flag
in _detectorFlags:
107 if flags.hasFlag(
'Detector.Enable' + flag):
108 flags._set(
'Detector.Enable' + flag,
False)
110 flags.addFlag(
'Detector.Enable' + flag,
False)
112 if flags.hasFlag(
'Detector.Geometry' + flag):
113 flags._set(
'Detector.Geometry' + flag,
False)
115 flags.addFlag(
'Detector.Geometry' + flag,
False)
121 '''If running on testbed, manually set Input.ProjectName flag from the OKS variable ZDC_PROJECT_NAME processed as an environmental variable
122 If running at P1, check for project name and set to default if not properly set
123 Necessary since ZdcStreamDependentFlagSetting will throw ValueError is ProjectName is not set'''
126 if os.getenv(
"ZDC_PROJECT_NAME")
is None:
127 log.warning(
"Running on testbed, yet ZDC_PROJECT_NAME is NOT set!")
128 log.warning(
"Setting to be data_test by default.")
129 flags.Input.ProjectName =
'data_test'
131 flags.Input.ProjectName = os.getenv(
"ZDC_PROJECT_NAME")
132 elif partition.isValid
and not flags.Input.ProjectName:
133 if partition.name() ==
'ATLAS':
134 log.warning(
"Running in ATLAS partition, but ProjectName is NOT correctly set!")
135 log.warning(
"Setting to be data24_hi by default. Could cause issues.")
136 flags.Input.ProjectName =
'data24_hi'
138 flags.Input.ProjectName =
'data_test'
143 '''manually set Input.TriggerStream flag from the OKS variable ZDC_STREAM_NAME processed as an environmental variable
144 Should only be called in the online environment (do NOT overwrite the TriggerStream info from offline metadata)'''
152 if (
not isTestbed
and partition.name() !=
'ATLAS'):
153 flags.Input.TriggerStream =
"calibration_DcmDummyProcessor"
157 if os.getenv(
"ZDC_STREAM_NAME")
is None:
158 log.warning(
"Running on testbed or on p1 in ATLAS partition, yet ZDC_STREAM_NAME is NOT set!")
159 log.warning(
"Assuming stream to be ZdcCalib by default! Likely to cause issues.")
160 flags.Input.TriggerStream =
"calibration_ZDCCalib"
161 elif os.getenv(
"ZDC_STREAM_NAME") ==
"ZDCCalib":
162 flags.Input.TriggerStream =
"calibration_ZDCCalib"
163 elif os.getenv(
"ZDC_STREAM_NAME") ==
"ZDCLEDCalib":
164 flags.Input.TriggerStream =
"calibration_ZDCLEDCalib"
165 elif os.getenv(
"ZDC_STREAM_NAME") ==
"ZDCInjCalib":
166 flags.Input.TriggerStream =
"calibration_ZDCInjCalib"
167 elif os.getenv(
"ZDC_STREAM_NAME") ==
"MinBias":
168 flags.Input.TriggerStream =
"physics_MinBias"
169 elif os.getenv(
"ZDC_STREAM_NAME") ==
"Standby":
170 flags.Input.TriggerStream =
"physics_Standby"
171 elif os.getenv(
"ZDC_STREAM_NAME") ==
"UCC":
172 flags.Input.TriggerStream =
"physics_UCC"
173 elif os.getenv(
"ZDC_STREAM_NAME") ==
"express":
174 flags.Input.TriggerStream =
"express_express"
178 '''Prints debug messages (for now, always on)'''
181 log.debug (
'check if the os environment configs are correctly set')
182 log.debug (
'ZDC_RELEASE_NAME %s', os.getenv(
"ZDC_RELEASE"))
183 log.debug (
'ENVIORNMENT %s', os.getenv(
"ENVIORNMENT"))
184 log.debug (
'ZDC_KEY_COUNT %s', os.getenv(
"ZDC_KEY_COUNT"))
185 log.debug (
'ZDC_KEY %s', os.getenv(
"ZDC_KEY"))
186 log.debug (
'ZDC_ATHENA_JOB_NAME %s', os.getenv(
"ZDC_ATHENA_JOB_NAME"))
187 log.debug (
'ZDC_STREAM_NAME %s', os.getenv(
"ZDC_STREAM_NAME"))
188 log.debug (
'ZDC_STREAM_TYPE %s', os.getenv(
"ZDC_STREAM_TYPE"))
194 '''Configure byte-stream input service using environmental (OKS) variables'''
198 bytestreamConversion = CompFactory.ByteStreamCnvSvc()
199 acc.addService(bytestreamConversion, primary=
True)
201 from ByteStreamEmonSvc.EmonByteStreamConfig
import EmonByteStreamCfg
204 bsSvc = acc.getService(
"ByteStreamInputSvc")
205 bsSvc.Partition = partition.name()
208 bsSvc.Key =
"ReadoutApplication"
210 bsSvc.Key = os.environ.get(
"ZDC_KEY",
"dcm")
211 log.debug(
'the value being assigned to bssvc key is %s', os.environ.get(
"ZDC_KEY",
"dcm"))
213 log.info(
'final bssvc key: %s', bsSvc.Key)
214 bsSvc.KeyCount =
int(os.environ.get(
"ZDC_KEY_COUNT",
"250"))
215 log.info(
'final bssvc keycount: %s', bsSvc.KeyCount)
216 bsSvc.BufferSize = 120
217 bsSvc.UpdatePeriod = 30
218 bsSvc.Timeout = 240000
219 bsSvc.PublishName = os.getenv(
"ZDC_ATHENA_JOB_NAME",
"ZDC_Athena_monitor_test")
220 bsSvc.ExitOnPartitionShutdown =
False
221 bsSvc.ClearHistograms =
True
222 bsSvc.GroupName =
"RecExOnline"
224 bsSvc.StreamType = os.getenv(
"ZDC_STREAM_TYPE",
"physics")
if isTestbed
or partition.name() ==
"ATLAS" else "calibration"
225 bsSvc.StreamNames = os.getenv(
"ZDC_STREAM_NAME",
"ZDCCalib:ZDCLEDCalib:MinBias").
split(
":")
if isTestbed
or partition.name() ==
"ATLAS" else "ZDCLEDCalib".
split(
":")
226 bsSvc.StreamLogic = os.getenv(
"ZDC_STREAM_LOGIC",
"Or")
if partition.name() ==
"ATLAS" else "Ignore"
228 bsSvc.ISServer =
"Histogramming"
229 if os.getenv(
"ZDC_STREAM_NAME") ==
"MinBias" or os.getenv(
"ZDC_STREAM_NAME") ==
"Standby":
230 bsSvc.ISServer =
'Histogramming-ZDC-iss'
232 log.info(
'the ISServer is: %s', bsSvc.ISServer)
234 log.debug(
'Printing out for debugging at testing/developing stage')
235 log.debug(
'Testing if settings of these variables in ZDC athena segment OKS are correctly picked up by the python code')
236 log.debug(
'the stream type is: %s', bsSvc.StreamType)
237 log.debug(
'the stream names are: %s', bsSvc.StreamNames)
238 log.debug(
'the stream logic is: %s', bsSvc.StreamLogic)
247 if not partition.isValid()
and len(flags.Input.Files)==0:
248 log.fatal(
"FATAL: Running in offline mode but no input files provided")
252 if partition.isValid():
254 from AthenaConfiguration.AutoConfigOnlineRecoFlags
import autoConfigOnlineRecoFlags
256 log.info(
'the auto-configured globaltag is: %s', flags.IOVDb.GlobalTag)
261 flags.Output.AODFileName=
"AOD.pool.root"
262 flags.Output.HISTFileName=
"HIST.root"
263 flags.Output.doWriteAOD=
True
267 if partition.isValid():
276 from ZdcRec.ZdcRecConfig
import SetConfigTag
280 flags.Trigger.decodeHLT = (
'pO' in config
or 'OO' in config)
and flags.DQ.useTrigger
and flags.Input.TriggerStream ==
'physics_MinBias'
282 return isLED, isInj, isCalib, pn, config
289 from ZdcRec.ZdcRecConfig
import ZdcLEDRecCfg
291 acc.merge(ZdcLEDRecAcc)
292 daqMode = 1
if partition.name() ==
'zdcStandalone' else 2
293 ZdcLEDRecAcc.getEventAlgo(
'ZdcRecRun3').DAQMode = daqMode
294 log.info (
'CHECK: The DAQ mode for the LED reconstruction is %s', ZdcLEDRecAcc.getEventAlgo(
'ZdcRecRun3').DAQMode)
296 from ZdcRec.ZdcRecConfig
import ZdcRecCfg
305 if not flags.Input.isMC:
307 from ZdcMonitoring.ZdcLEDMonitorAlgorithm
import ZdcLEDMonitoringConfig
309 acc.merge(zdcLEDMonitorAcc)
311 if (isCalib
or isInj):
312 from ZdcMonitoring.ZdcMonitorAlgorithm
import ZdcMonitoringConfig
314 acc.merge(zdcMonitorAcc)
318 if __name__ ==
'__main__':
321 debugModeOn = (os.getenv(
"BOOL_DEBUG_MODE") ==
"True")
334 if partition.isValid():
344 flags.dump(evaluate=
True)
348 from AthenaConfiguration.MainServicesConfig
import MainServicesCfg
352 if partition.isValid():
355 log.info(
"Running Offline on %d files", len(flags.Input.Files))
363 from GaudiSvc.GaudiSvcConf
import THistSvc
364 THistSvc.OutputLevel = 5
366 from AtlasGeoModel.ForDetGeoModelConfig
import ForDetGeometryCfg
369 if flags.DQ.useTrigger:
371 from TriggerJobOpts.TriggerRecoConfig
import TriggerRecoCfgData
376 if (
"physics_" in flags.Input.TriggerStream
or flags.Input.TriggerStream ==
"express_express"):
381 acc.printConfig(withDetails=
True)
384 acc.foreach_component(
"*Zdc*").OutputLevel=DEBUG
385 acc.foreach_component(
"*ZDC*").OutputLevel=DEBUG
387 log.info(
"Configured Services: %s",
", ".
join(svc.name
for svc
in acc.getServices()))
388 log.info(
"Configured EventAlgos: %s",
", ".
join(alg.name
for alg
in acc.getEventAlgos()))
389 log.info(
"Configured CondAlgos: %s",
", ".
join(alg.name
for alg
in acc.getCondAlgos()))
391 if partition.isValid():
392 from IOVDbSvc.IOVDbSvcConfig
import addOverride
393 acc.merge(
addOverride(flags,
"/TRT/Onl/Calib/PID_NN",
"TRTCalibPID_NN_v2", db=
""))
395 acc.getService(
"PoolSvc").ReadCatalog += [
"xmlcatalog_file:/det/dqm/GlobalMonitoring/PoolFileCatalog_M7/PoolFileCatalog.xml"]
398 if status.isFailure():