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")
30 debugModeOn = (os.getenv(
"BOOL_DEBUG_MODE") ==
"True")
42 '''Set up the partition (object still exists but invalid if offline)
43 and finds the current environment (testbed / p1)
45 partition: the partition object
46 isTestbed - boolean that indicates whether it's testbed or p1'''
51 partition = ispy.IPCPartition(
"")
if os.getenv(
"TDAQ_PARTITION")
is None else ispy.IPCPartition(os.getenv(
"TDAQ_PARTITION"))
55 environmentString = os.getenv(
"ENVIORNMENT")
57 if partition.isValid()
and environmentString
is None:
58 log.warning(
"Warning: Partition is valid but environmental variable ENVIORNMENT is not set!")
59 log.warning(
"Warning: In this case by default assumes environment is p1!")
61 isTestbed = (environmentString ==
"TB")
63 if partition.isValid():
64 log.info(
"Running Online with Partition: %s",partition.name())
66 log.info(
"Partition %s not found. Running Offline - must provide input files!", partition.name())
68 return partition, isTestbed
76 '''Set additional configuration flags for online environment'''
78 log.debug (
'Setting additional flags for online environment')
80 flags.Concurrency.NumThreads = 1
81 flags.Common.isOnline =
True
82 flags.DQ.Environment =
'online'
83 flags.DQ.enableLumiAccess =
False
84 flags.Common.useOnlineLumi =
True
85 flags.DQ.doStreamAwareMon =
False
88 flags.IOVDb.GlobalTag=
'CONDBR2-HLTP-2025-02'
89 flags.Trigger.triggerConfig =
'DB'
91 flags.LAr.doHVCorr =
False
92 flags.InDet.useSctDCS =
False
93 flags.InDet.useDCS =
False
95 flags.Output.doWriteESD =
False
96 flags.Output.doWriteAOD =
False
98 if (partition.isValid()
and partition.name() !=
'ATLAS'):
99 flags.DQ.useTrigger =
False
100 flags.DQ.triggerDataAvailable =
False
103 _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']
105 for flag
in _steeringFlags:
106 if flags.hasFlag(
'DQ.Steering.' + flag):
107 flags._set(
'DQ.Steering.' + flag,
False)
109 flags.addFlag(
'DQ.Steering.' + flag,
False)
112 _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',
'doCalo',
'doID',
'doMuon',
'doNavigationSlimming',
'enableL1CaloLegacy',
'endOfEventProcessing.Enabled',
'fastMenuGeneration',
'Online.BFieldAutoConfig']
114 for flag
in _triggerFlags:
115 if flags.hasFlag(
'Trigger.' + flag):
116 flags._set(
'Trigger.' + flag,
False)
118 flags.addFlag(
'Trigger.' + flag,
False)
122 _detectorFlags = [
'MDT',
'MM',
'Muon',
'RPC',
'TGC',
'sTGC']
123 for flag
in _detectorFlags:
124 if flags.hasFlag(
'Detector.Enable' + flag):
125 flags._set(
'Detector.Enable' + flag,
False)
127 flags.addFlag(
'Detector.Enable' + flag,
False)
129 if flags.hasFlag(
'Detector.Geometry' + flag):
130 flags._set(
'Detector.Geometry' + flag,
False)
132 flags.addFlag(
'Detector.Geometry' + flag,
False)
138 if isTestbed
and os.getenv(
"ZDC_STREAM_NAME") ==
"ZDCInjCalib":
139 flags.Input.OverrideRunNumber =
True
140 if os.getenv(
"RUN_NUMBER")
is None:
141 log.warning(
"Running on testbed and on injected-pulse stream data, yet RUN_NUMBER is NOT set!")
142 log.warning(
"Setting to be 488824 by default.")
143 flags.Input.RunNumbers = [488824]
145 flags.Input.RunNumbers = [
int(os.getenv(
"RUN_NUMBER"))]
149 '''If running on testbed, manually set Input.ProjectName flag from the OKS variable ZDC_PROJECT_NAME processed as an environmental variable
150 If running at P1, check for project name and set to default if not properly set
151 Necessary since ZdcStreamDependentFlagSetting will throw ValueError is ProjectName is not set'''
154 if os.getenv(
"ZDC_PROJECT_NAME")
is None:
155 log.warning(
"Running on testbed, yet ZDC_PROJECT_NAME is NOT set!")
156 log.warning(
"Setting to be data_test by default.")
157 flags.Input.ProjectName =
'data_test'
159 flags.Input.ProjectName = os.getenv(
"ZDC_PROJECT_NAME")
160 elif partition.isValid
and not flags.Input.ProjectName:
161 if partition.name() ==
'ATLAS':
162 log.warning(
"Running in ATLAS partition, but ProjectName is NOT correctly set!")
163 log.warning(
"Setting to be data24_hi by default. Could cause issues.")
164 flags.Input.ProjectName =
'data24_hi'
166 flags.Input.ProjectName =
'data_test'
171 '''manually set Input.TriggerStream flag from the OKS variable ZDC_STREAM_NAME processed as an environmental variable
172 Should only be called in the online environment (do NOT overwrite the TriggerStream info from offline metadata)'''
180 if (
not isTestbed
and partition.name() !=
'ATLAS'):
181 flags.Input.TriggerStream =
"calibration_DcmDummyProcessor"
185 if os.getenv(
"ZDC_STREAM_NAME")
is None:
186 log.warning(
"Running on testbed or on p1 in ATLAS partition, yet ZDC_STREAM_NAME is NOT set!")
187 log.warning(
"Assuming stream to be ZdcCalib by default! Likely to cause issues.")
188 flags.Input.TriggerStream =
"calibration_ZDCCalib"
189 elif os.getenv(
"ZDC_STREAM_NAME") ==
"ZDCCalib":
190 flags.Input.TriggerStream =
"calibration_ZDCCalib"
191 elif os.getenv(
"ZDC_STREAM_NAME") ==
"ZDCLEDCalib":
192 flags.Input.TriggerStream =
"calibration_ZDCLEDCalib"
193 elif os.getenv(
"ZDC_STREAM_NAME") ==
"ZDCInjCalib":
194 flags.Input.TriggerStream =
"calibration_ZDCInjCalib"
195 elif os.getenv(
"ZDC_STREAM_NAME") ==
"MinBias":
196 flags.Input.TriggerStream =
"physics_MinBias"
197 elif os.getenv(
"ZDC_STREAM_NAME") ==
"Standby":
198 flags.Input.TriggerStream =
"physics_Standby"
199 elif os.getenv(
"ZDC_STREAM_NAME") ==
"UCC":
200 flags.Input.TriggerStream =
"physics_UCC"
201 elif os.getenv(
"ZDC_STREAM_NAME") ==
"express":
202 flags.Input.TriggerStream =
"express_express"
207 if partition.name() ==
"zdcStandalone":
208 zdcStreamName = os.getenv(
"ZDC_STREAM_NAME",
"").lower()
209 if (
"led" in zdcStreamName):
210 standaloneDataType =
"led"
211 elif (
"inj" in zdcStreamName):
212 standaloneDataType =
"inj"
214 log.warning(
"Warning: The partition is zdcStandalone but ZDC_STREAM_NAME, lowered, contains neither led nor inj!")
215 log.warning(
"Warning: ZDC_STREAM_NAME value: %s", zdcStreamName)
216 log.warning(
"Warning: Set default mode as inj")
217 standaloneDataType =
"inj"
219 if flags.hasFlag(
"runInjForStandaloneData"):
220 flags._set(
"runInjForStandaloneData", standaloneDataType)
222 flags.addFlag(
"runInjForStandaloneData", standaloneDataType)
227 '''Prints debug messages (for now, always on)'''
230 log.debug (
'check if the os environment configs are correctly set')
231 log.debug (
'ZDC_RELEASE_NAME %s', os.getenv(
"ZDC_RELEASE"))
232 log.debug (
'ENVIORNMENT %s', os.getenv(
"ENVIORNMENT"))
233 log.debug (
'ZDC_KEY_COUNT %s', os.getenv(
"ZDC_KEY_COUNT"))
234 log.debug (
'ZDC_KEY %s', os.getenv(
"ZDC_KEY"))
235 log.debug (
'ZDC_ATHENA_JOB_NAME %s', os.getenv(
"ZDC_ATHENA_JOB_NAME"))
236 log.debug (
'ZDC_STREAM_NAME %s', os.getenv(
"ZDC_STREAM_NAME"))
237 log.debug (
'ZDC_STREAM_TYPE %s', os.getenv(
"ZDC_STREAM_TYPE"))
243 '''Configure byte-stream input service using environmental (OKS) variables'''
247 bytestreamConversion = CompFactory.ByteStreamCnvSvc()
248 acc.addService(bytestreamConversion, primary=
True)
250 from ByteStreamEmonSvc.EmonByteStreamConfig
import EmonByteStreamCfg
253 bsSvc = acc.getService(
"ByteStreamInputSvc")
254 bsSvc.Partition = partition.name()
257 bsSvc.Key =
"ReadoutApplication"
259 bsSvc.Key = os.environ.get(
"ZDC_KEY",
"dcm")
260 log.debug(
'the value being assigned to bssvc key is %s', os.environ.get(
"ZDC_KEY",
"dcm"))
262 log.info(
'final bssvc key: %s', bsSvc.Key)
263 bsSvc.KeyCount =
int(os.environ.get(
"ZDC_KEY_COUNT",
"250"))
264 log.info(
'final bssvc keycount: %s', bsSvc.KeyCount)
265 bsSvc.BufferSize = 120
266 bsSvc.UpdatePeriod = 30
267 bsSvc.Timeout = 240000
268 bsSvc.PublishName = os.getenv(
"ZDC_ATHENA_JOB_NAME",
"ZDC_Athena_monitor_test")
269 bsSvc.ExitOnPartitionShutdown =
False
270 bsSvc.ClearHistograms =
True
271 bsSvc.GroupName =
"RecExOnline"
273 bsSvc.StreamType = os.getenv(
"ZDC_STREAM_TYPE",
"physics")
if isTestbed
or partition.name() ==
"ATLAS" else "calibration"
274 bsSvc.StreamNames = os.getenv(
"ZDC_STREAM_NAME",
"ZDCCalib:ZDCLEDCalib:MinBias").
split(
":")
if isTestbed
or partition.name() ==
"ATLAS" else "ZDCLEDCalib".
split(
":")
275 bsSvc.StreamLogic = os.getenv(
"ZDC_STREAM_LOGIC",
"Or")
if partition.name() ==
"ATLAS" else "Ignore"
277 bsSvc.ISServer =
"Histogramming"
278 if os.getenv(
"ZDC_STREAM_NAME") ==
"MinBias" or os.getenv(
"ZDC_STREAM_NAME") ==
"Standby":
279 bsSvc.ISServer =
'Histogramming-ZDC-iss'
281 log.info(
'the ISServer is: %s', bsSvc.ISServer)
283 log.debug(
'Printing out for debugging at testing/developing stage')
284 log.debug(
'Testing if settings of these variables in ZDC athena segment OKS are correctly picked up by the python code')
285 log.debug(
'the stream type is: %s', bsSvc.StreamType)
286 log.debug(
'the stream names are: %s', bsSvc.StreamNames)
287 log.debug(
'the stream logic is: %s', bsSvc.StreamLogic)
296 if not partition.isValid()
and len(flags.Input.Files)==0:
297 log.fatal(
"FATAL: Running in offline mode but no input files provided")
301 if partition.isValid():
303 from AthenaConfiguration.AutoConfigOnlineRecoFlags
import autoConfigOnlineRecoFlags
305 log.info(
'the auto-configured globaltag is: %s', flags.IOVDb.GlobalTag)
310 flags.Output.AODFileName=
"AOD.pool.root"
311 flags.Output.HISTFileName=
"HIST.root"
312 flags.Output.doWriteAOD=
True
316 if partition.isValid():
328 from ZdcRec.ZdcRecConfig
import SetConfigTag
332 flags.Trigger.decodeHLT = (
'pO' in config
or 'OO' in config)
and flags.DQ.useTrigger
and flags.Input.TriggerStream ==
'physics_MinBias'
334 return isLED, isInj, isCalib, pn, config
341 from ZdcRec.ZdcRecConfig
import ZdcLEDRecCfg
343 acc.merge(ZdcLEDRecAcc)
344 daqMode = 1
if partition.name() ==
'zdcStandalone' else 2
345 ZdcLEDRecAcc.getEventAlgo(
'ZdcRecRun3').DAQMode = daqMode
346 log.info (
'CHECK: The DAQ mode for the LED reconstruction is %s', ZdcLEDRecAcc.getEventAlgo(
'ZdcRecRun3').DAQMode)
348 from ZdcRec.ZdcRecConfig
import ZdcRecCfg
357 if not flags.Input.isMC:
359 from ZdcMonitoring.ZdcLEDMonitorAlgorithm
import ZdcLEDMonitoringConfig
361 acc.merge(zdcLEDMonitorAcc)
363 if (isCalib
or isInj):
364 from ZdcMonitoring.ZdcMonitorAlgorithm
import ZdcMonitoringConfig
366 acc.merge(zdcMonitorAcc)
370 if __name__ ==
'__main__':
374 if partition.isValid():
384 flags.dump(evaluate=
True)
388 from AthenaConfiguration.MainServicesConfig
import MainServicesCfg
392 if partition.isValid():
395 log.info(
"Running Offline on %d files", len(flags.Input.Files))
403 from GaudiSvc.GaudiSvcConf
import THistSvc
404 THistSvc.OutputLevel = 5
406 from AtlasGeoModel.ForDetGeoModelConfig
import ForDetGeometryCfg
409 if flags.DQ.useTrigger:
411 from TriggerJobOpts.TriggerRecoConfig
import TriggerRecoCfgData
416 if (
"physics_" in flags.Input.TriggerStream
or flags.Input.TriggerStream ==
"express_express"):
421 acc.printConfig(withDetails=
True)
424 acc.foreach_component(
"*Zdc*").OutputLevel=DEBUG
425 acc.foreach_component(
"*ZDC*").OutputLevel=DEBUG
427 log.info(
"Configured Services: %s",
", ".
join(svc.name
for svc
in acc.getServices()))
428 log.info(
"Configured EventAlgos: %s",
", ".
join(alg.name
for alg
in acc.getEventAlgos()))
429 log.info(
"Configured CondAlgos: %s",
", ".
join(alg.name
for alg
in acc.getCondAlgos()))
431 if partition.isValid():
432 from IOVDbSvc.IOVDbSvcConfig
import addOverride
433 acc.merge(
addOverride(flags,
"/TRT/Onl/Calib/PID_NN",
"TRTCalibPID_NN_v2", db=
""))
435 acc.getService(
"PoolSvc").ReadCatalog += [
"xmlcatalog_file:/det/dqm/GlobalMonitoring/PoolFileCatalog_M7/PoolFileCatalog.xml"]
438 if status.isFailure():