Skip to content
Snippets Groups Projects
Commit d897d5d9 authored by Frank Winklmeier's avatar Frank Winklmeier
Browse files

MagFieldServices: migrate CondAlg unit test to CA

parent d0b7f2ac
No related branches found
No related tags found
No related merge requests found
# Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
# Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
# Declare the package name:
atlas_subdir( MagFieldServices )
......@@ -20,11 +20,9 @@ atlas_install_python_modules( python/*.py POST_BUILD_CMD ${ATLAS_FLAKE8} )
if( NOT SIMULATIONBASE )
atlas_add_test( MagFieldServicesConfig
SCRIPT python -m MagFieldServices.MagFieldServicesConfig
PROPERTIES TIMEOUT 300
POST_EXEC_SCRIPT nopost.sh )
POST_EXEC_SCRIPT noerror.sh )
atlas_add_test( MagFieldCondAlg
SCRIPT athena --threads=1 ${CMAKE_CURRENT_SOURCE_DIR}/share/test_magFieldCondAlg.py
PROPERTIES TIMEOUT 300
SCRIPT ${CMAKE_CURRENT_SOURCE_DIR}/share/test_magFieldCondAlg.py
LOG_SELECT_PATTERN "MagFieldCondReader" )
endif()
# Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration
#!/usr/bin/env python
#
# Job options to test magnetic field conditions algs with varying currents.
# Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
#
# Test magnetic field conditions algs with varying currents.
#
# Testing IOVs and currents: (since LB, solenoid, toroids)
......@@ -23,6 +25,7 @@ currents = [(0, 7730, 20400),
# Folder name
folder = '/EXT/DCS/MAGNETS/SENSORDATA'
sqlite = 'magfield.db'
def createDB():
"""Create sqlite file with DCS currents"""
......@@ -32,11 +35,10 @@ def createDB():
from CoolConvUtilities import AtlCoolLib, AtlCoolTool
# Cleanup previous file
import os
if os.path.isfile("magfield.db"):
os.remove("magfield.db")
if os.path.isfile(sqlite):
os.remove(sqlite)
db = cool.DatabaseSvcFactory.databaseService().createDatabase('sqlite://;schema=magfield.db;dbname=CONDBR2')
db = cool.DatabaseSvcFactory.databaseService().createDatabase(f'sqlite://;schema={sqlite};dbname=CONDBR2')
spec = cool.RecordSpecification()
spec.extend("value", cool.StorageType.Float)
spec.extend("quality_invalid", cool.StorageType.Bool)
......@@ -60,34 +62,26 @@ def createDB():
# Create sqlite file with DCS currents
createDB()
# basic job configuration
import AthenaCommon.AtlasUnixGeneratorJob # noqa: F401
from AthenaCommon.AppMgr import theApp, ServiceMgr as svcMgr
from AthenaCommon.AlgSequence import AthSequencer, AlgSequence
# Increment LBN every event
from McEventSelector import McEventSelectorConf
svcMgr += McEventSelectorConf.McEventSelector('EventSelector', EventsPerLB=1)
# Conditions folder setup
from AthenaCommon.GlobalFlags import globalflags
globalflags.DataSource='data'
globalflags.ConditionsTag='CONDBR2-BLKPA-RUN2-01'
from IOVDbSvc.CondDB import conddb
conddb.setGlobalTag(globalflags.ConditionsTag())
conddb.addFolder('GLOBAL', '/GLOBAL/BField/Maps <noover/>', className="CondAttrListCollection")
conddb.addFolder('magfield.db', folder, className='CondAttrListCollection')
# Magnetic field algorithm setup
from AthenaCommon.CfgGetter import getAlgorithm
condSeq = AthSequencer("AthCondSeq")
condSeq += getAlgorithm( "AtlasFieldMapCondAlg" )
condSeq += getAlgorithm( "AtlasFieldCacheCondAlg" )
condSeq.AtlasFieldCacheCondAlg.LockMapCurrents = False
import AthenaCommon.CfgMgr as CfgMgr
topSequence = AlgSequence()
topSequence += CfgMgr.MagField__CondReader("MagFieldCondReader")
theApp.EvtMax = currents[-1][0]+5 # 5 events per IOV
from AthenaConfiguration.AllConfigFlags import initConfigFlags
from AthenaConfiguration.ComponentFactory import CompFactory
from AthenaConfiguration.MainServicesConfig import MainEvgenServicesCfg
flags = initConfigFlags()
flags.Input.Files = []
flags.Concurrency.NumThreads = 1
flags.Exec.MaxEvents = currents[-1][0]+5 # 5 events per IOV
flags.IOVDb.GlobalTag = 'CONDBR2-BLKPA-RUN2-01'
flags.IOVDb.SqliteInput = sqlite
flags.IOVDb.SqliteFolders = (folder,)
flags.lock()
acc = MainEvgenServicesCfg(flags)
acc.getService('EventSelector').EventsPerLB = 1
from MagFieldServices.MagFieldServicesConfig import AtlasFieldCacheCondAlgCfg
acc.merge( AtlasFieldCacheCondAlgCfg(flags, LockMapCurrents=False) )
acc.addEventAlgo( CompFactory.MagField.CondReader('MagFieldCondReader') )
import sys
sys.exit(acc.run().isFailure())
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment