ATLAS Offline Software
test_magFieldCondAlg.py
Go to the documentation of this file.
1 #!/usr/bin/env python
2 #
3 # Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
4 #
5 # Test magnetic field conditions algs with varying currents.
6 #
7 # Folder name
8 import sys
9 from MagFieldServices.createDBForTest import createDB
10 folder = '/EXT/DCS/MAGNETS/SENSORDATA'
11 sqlite = 'magfieldForTest.db'
12 
13 
14 # Testing IOVs and currents: (since LB, solenoid, toroids)
15 # Default test - should read both mag field files, and turn off fields for events 5 to 9, and back on for 10 to 14
16 currents = [(0, 7730, 20400),
17  (5, 0, 0),
18  (10, 7730, 20400)]
19 
20 # Optional test: only toroid is on for whole run. Scale factor for solenoid will become 1 at event 5,
21 # but solenoid field will still be off
22 # currents = [(0, 0, 20400),
23 # (5, 7730, 20400),
24 # (10, 7730, 20400)]
25 
26 # Optional test: only solenoid is on for whole run. Scale factor for toroid will become 1 at event 5,
27 # but toroid field will still be off
28 # currents = [(0, 7730, 0),
29 # (5, 7730, 20400),
30 # (10, 7730, 20400)]
31 
32 
33 # Create sqlite file with DCS currents
34 createDB(folder, sqlite, currents)
35 
36 from MagFieldServices.MagFieldServicesConfig import AtlasFieldCacheCondAlgCfg
37 from AthenaConfiguration.MainServicesConfig import MainEvgenServicesCfg
38 from AthenaConfiguration.ComponentFactory import CompFactory
39 from AthenaConfiguration.AllConfigFlags import initConfigFlags
40 
41 flags = initConfigFlags()
42 flags.Input.Files = []
43 flags.Concurrency.NumThreads = 1
44 flags.Exec.MaxEvents = currents[-1][0]+5 # 5 events per IOV
45 flags.IOVDb.GlobalTag = 'CONDBR2-BLKPA-RUN2-01'
46 flags.IOVDb.SqliteInput = sqlite
47 flags.IOVDb.SqliteFolders = (folder,)
48 flags.lock()
49 
51 acc.getService('EventSelector').EventsPerLB = 1
52 
53 acc.merge(AtlasFieldCacheCondAlgCfg(flags, LockMapCurrents=False))
54 
55 acc.addEventAlgo(CompFactory.MagField.CondReader('MagFieldCondReader'))
56 
57 sys.exit(acc.run().isFailure())
python.createDBForTest.createDB
def createDB(folder, sqlite, currents)
Definition: createDBForTest.py:5
python.MainServicesConfig.MainEvgenServicesCfg
def MainEvgenServicesCfg(flags, LoopMgr="AthenaEventLoopMgr", withSequences=True)
Definition: MainServicesConfig.py:353
python.AllConfigFlags.initConfigFlags
def initConfigFlags()
Definition: AllConfigFlags.py:19
python.MagFieldServicesConfig.AtlasFieldCacheCondAlgCfg
def AtlasFieldCacheCondAlgCfg(flags, **kwargs)
Definition: MagFieldServicesConfig.py:8