ATLAS Offline Software
MagFieldServicesConfig.py
Go to the documentation of this file.
1 # Copyright (C) 2002-2023 CERN for the benefit of the ATLAS collaboration
2 
3 from AthenaConfiguration.AccumulatorCache import AccumulatorCache
4 from AthenaConfiguration.ComponentFactory import CompFactory
5 from AthenaConfiguration.ComponentAccumulator import ComponentAccumulator
6 
7 @AccumulatorCache
8 def AtlasFieldCacheCondAlgCfg(flags, **kwargs):
9  '''
10  Configure the CondAlgsfor the ATLAS magnetic field.
11  '''
12  result=ComponentAccumulator()
13 
14  # initialise required conditions DB folders
15  from IOVDbSvc.IOVDbSvcConfig import addFolders
16 
17  if flags.Input.isMC:
18  db='GLOBAL_OFL'
19  else:
20  db='GLOBAL'
21 
22  result.merge(addFolders(flags,['/GLOBAL/BField/Maps <noover/>'], detDb=db, className="CondAttrListCollection") )
23 
24  if not flags.Common.isOnline:
25  result.merge(addFolders(flags, ['/EXT/DCS/MAGNETS/SENSORDATA'], detDb='DCS_OFL', className="CondAttrListCollection") )
26 
27 
28  # AtlasFieldMapCondAlg - for reading in map
29  afmArgs = {
30  "name": "AtlasFieldMapCondAlg",
31  }
32  if flags.Common.isOnline:
33  # online does not use DCS
34  afmArgs.update( UseMapsFromCOOL = False )
35  # load map on start() for HLT
36  afmArgs.update( LoadMapOnStart = flags.Trigger.doHLT and flags.Trigger.Online.isPartition )
37  # consider field off if current is below these values:
38  afmArgs.update( SoleMinCurrent = 160 ) # Standby current is 150A
39  afmArgs.update( ToroMinCurrent = 210 ) # Standby current is 200A
40  else:
41  # UseMapsFromCOOL is default for standard running
42  afmArgs.update( UseMapsFromCOOL = True)
43  # However, for tests, this must be turned off. It is detected
44  # when UseDCS is set to False - UseDCS is directly an option for the field cache alg
45  if 'UseDCS' in kwargs and not kwargs['UseDCS']:
46  afmArgs['UseMapsFromCOOL'] = False
47  magFieldMapCondAlg = CompFactory.MagField.AtlasFieldMapCondAlg(**afmArgs)
48  result.addCondAlgo(magFieldMapCondAlg)
49 
50  # AtlasFieldCacheCondAlg - for reading in current
51  afcArgs = {
52  "name": "AtlasFieldCacheCondAlg",
53  }
54  if flags.Common.isOnline:
55  afcArgs.update( UseDCS = False )
56  afcArgs.update( UseSoleCurrent = 7730 )
57  afcArgs.update( UseToroCurrent = 20400 )
58  afcArgs.update( LockMapCurrents = True )
59  # consider field off if current is below these values:
60  afcArgs.update( SoleMinCurrent = 160 ) # Standby current is 150A
61  afcArgs.update( ToroMinCurrent = 210 ) # Standby current is 200A
62  elif flags.Input.isMC:
63  if flags.BField.configuredSolenoidFieldScale>160/7730 and flags.BField.configuredSolenoidFieldScale<1:
64  afcArgs.update( UseDCS = False )
65  afcArgs.update( UseSoleCurrent = flags.BField.configuredSolenoidFieldScale * 7730 )
66  else:
67  afcArgs.update( UseDCS = True )
68  else:
69  afcArgs.update( UseDCS = True )
70  # For test, UseDCS is set to False
71  if 'UseDCS' in kwargs:
72  afcArgs['UseDCS'] = kwargs['UseDCS']
73  magFieldCacheCondAlg = CompFactory.MagField.AtlasFieldCacheCondAlg(**afcArgs)
74  result.addCondAlgo(magFieldCacheCondAlg)
75 
76  return result
77 
78 if __name__=="__main__":
79  # To run this, do e.g.
80  # python ../athena/MagneticField/MagFieldServices/python/MagFieldServicesConfig.py
81 
82  from AthenaCommon.Logging import log
83  from AthenaCommon.Constants import VERBOSE
84  from AthenaConfiguration.AllConfigFlags import initConfigFlags
85 
86  log.setLevel(VERBOSE)
87  from AthenaConfiguration.TestDefaults import defaultTestFiles
88  flags = initConfigFlags()
89  flags.Input.Files = defaultTestFiles.RAW_RUN2
90  flags.Input.isMC = False
91  flags.lock()
92 
94 
96  log.verbose(acc)
97  cfg.merge(acc)
98 
99  f=open("MagneticFieldSvc.pkl","wb")
100  cfg.store(f)
101  f.close()
python.JetAnalysisCommon.ComponentAccumulator
ComponentAccumulator
Definition: JetAnalysisCommon.py:302
Constants
some useful constants -------------------------------------------------—
python.IOVDbSvcConfig.addFolders
def addFolders(flags, folderStrings, detDb=None, className=None, extensible=False, tag=None, db=None, modifiers='')
Definition: IOVDbSvcConfig.py:72
Trk::open
@ open
Definition: BinningType.h:40
python.AllConfigFlags.initConfigFlags
def initConfigFlags()
Definition: AllConfigFlags.py:19
python.MagFieldServicesConfig.AtlasFieldCacheCondAlgCfg
def AtlasFieldCacheCondAlgCfg(flags, **kwargs)
Definition: MagFieldServicesConfig.py:8