ATLAS Offline Software
Loading...
Searching...
No Matches
BFieldConfigFlags.py
Go to the documentation of this file.
1# Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
2
3from AthenaConfiguration.AthConfigFlags import AthConfigFlags
4from AthenaCommon.Logging import logging
5
6msg = logging.getLogger('BFieldConfigFlags')
7
8
9#So far no attempt to auto-config field for MC or online-running
10#
11#The old-style config did auto-config the field for online based on IS
12#(see https://gitlab.cern.ch/atlas/athena/-/blob/1802605a4ab69cab7ee3e53d75f162c7da99a944/Reconstruction/RecExample/RecExOnline/python/OnlineISConfiguration.py#L52)
13#
14#The old-sytle config tried to auto-config the field based on in-file metadata, falling back to Geometry and Conditions tags. See
15#(see https://gitlab.cern.ch/atlas/athena/-/blob/1802605a4ab69cab7ee3e53d75f162c7da99a944/Reconstruction/RecExample/RecExConfig/python/AutoConfiguration.py#L181
16
17def _fieldAutoCfg(prevFlags):
18 if prevFlags.Input.isMC or prevFlags.Common.isOnline:
19 return [True,True]
20
21 from CoolConvUtilities.MagFieldUtils import getFieldForRun
22 lbs=prevFlags.Input.LumiBlockNumbers
23 fieldStat=getFieldForRun(run=prevFlags.Input.RunNumbers[0],lumiblock=0 if len(lbs)==0 else lbs[0],quiet=True)
24 if fieldStat is None:
25 msg.error("Unable to get field status from DCS, assume both magnets ON")
26 return [True,True]
27 return [fieldStat.solenoidCurrent()>1, fieldStat.toroidCurrent()>1]
28
29
30
32 bcf=AthConfigFlags()
33 # True when solenoid is on
34 bcf.addFlag("BField.solenoidOn", lambda prevFlags : _fieldAutoCfg(prevFlags)[0])
35 # True when barrel toroid is on
36 bcf.addFlag("BField.barrelToroidOn", lambda prevFlags : _fieldAutoCfg(prevFlags)[1])
37 # True when endcap toroid is on
38 bcf.addFlag("BField.endcapToroidOn", lambda prevFlags : _fieldAutoCfg(prevFlags)[1])
39 # Solenoid field scale
40 bcf.addFlag("BField.configuredSolenoidFieldScale", 1.)
41 return bcf