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
2 merge requests!696182024-03-07: merge of 24.0 into main,!69568MagFieldServices: migrate CondAlg unit test to CA
# 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: # Declare the package name:
atlas_subdir( MagFieldServices ) atlas_subdir( MagFieldServices )
...@@ -20,11 +20,9 @@ atlas_install_python_modules( python/*.py POST_BUILD_CMD ${ATLAS_FLAKE8} ) ...@@ -20,11 +20,9 @@ atlas_install_python_modules( python/*.py POST_BUILD_CMD ${ATLAS_FLAKE8} )
if( NOT SIMULATIONBASE ) if( NOT SIMULATIONBASE )
atlas_add_test( MagFieldServicesConfig atlas_add_test( MagFieldServicesConfig
SCRIPT python -m MagFieldServices.MagFieldServicesConfig SCRIPT python -m MagFieldServices.MagFieldServicesConfig
PROPERTIES TIMEOUT 300 POST_EXEC_SCRIPT noerror.sh )
POST_EXEC_SCRIPT nopost.sh )
atlas_add_test( MagFieldCondAlg atlas_add_test( MagFieldCondAlg
SCRIPT athena --threads=1 ${CMAKE_CURRENT_SOURCE_DIR}/share/test_magFieldCondAlg.py SCRIPT ${CMAKE_CURRENT_SOURCE_DIR}/share/test_magFieldCondAlg.py
PROPERTIES TIMEOUT 300
LOG_SELECT_PATTERN "MagFieldCondReader" ) LOG_SELECT_PATTERN "MagFieldCondReader" )
endif() 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) # Testing IOVs and currents: (since LB, solenoid, toroids)
...@@ -23,6 +25,7 @@ currents = [(0, 7730, 20400), ...@@ -23,6 +25,7 @@ currents = [(0, 7730, 20400),
# Folder name # Folder name
folder = '/EXT/DCS/MAGNETS/SENSORDATA' folder = '/EXT/DCS/MAGNETS/SENSORDATA'
sqlite = 'magfield.db'
def createDB(): def createDB():
"""Create sqlite file with DCS currents""" """Create sqlite file with DCS currents"""
...@@ -32,11 +35,10 @@ def createDB(): ...@@ -32,11 +35,10 @@ def createDB():
from CoolConvUtilities import AtlCoolLib, AtlCoolTool from CoolConvUtilities import AtlCoolLib, AtlCoolTool
# Cleanup previous file # Cleanup previous file
import os if os.path.isfile(sqlite):
if os.path.isfile("magfield.db"): os.remove(sqlite)
os.remove("magfield.db")
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 = cool.RecordSpecification()
spec.extend("value", cool.StorageType.Float) spec.extend("value", cool.StorageType.Float)
spec.extend("quality_invalid", cool.StorageType.Bool) spec.extend("quality_invalid", cool.StorageType.Bool)
...@@ -60,34 +62,26 @@ def createDB(): ...@@ -60,34 +62,26 @@ def createDB():
# Create sqlite file with DCS currents # Create sqlite file with DCS currents
createDB() createDB()
# basic job configuration from AthenaConfiguration.AllConfigFlags import initConfigFlags
import AthenaCommon.AtlasUnixGeneratorJob # noqa: F401 from AthenaConfiguration.ComponentFactory import CompFactory
from AthenaCommon.AppMgr import theApp, ServiceMgr as svcMgr from AthenaConfiguration.MainServicesConfig import MainEvgenServicesCfg
from AthenaCommon.AlgSequence import AthSequencer, AlgSequence
flags = initConfigFlags()
# Increment LBN every event flags.Input.Files = []
from McEventSelector import McEventSelectorConf flags.Concurrency.NumThreads = 1
svcMgr += McEventSelectorConf.McEventSelector('EventSelector', EventsPerLB=1) flags.Exec.MaxEvents = currents[-1][0]+5 # 5 events per IOV
flags.IOVDb.GlobalTag = 'CONDBR2-BLKPA-RUN2-01'
# Conditions folder setup flags.IOVDb.SqliteInput = sqlite
from AthenaCommon.GlobalFlags import globalflags flags.IOVDb.SqliteFolders = (folder,)
globalflags.DataSource='data' flags.lock()
globalflags.ConditionsTag='CONDBR2-BLKPA-RUN2-01'
acc = MainEvgenServicesCfg(flags)
from IOVDbSvc.CondDB import conddb acc.getService('EventSelector').EventsPerLB = 1
conddb.setGlobalTag(globalflags.ConditionsTag())
conddb.addFolder('GLOBAL', '/GLOBAL/BField/Maps <noover/>', className="CondAttrListCollection") from MagFieldServices.MagFieldServicesConfig import AtlasFieldCacheCondAlgCfg
conddb.addFolder('magfield.db', folder, className='CondAttrListCollection') acc.merge( AtlasFieldCacheCondAlgCfg(flags, LockMapCurrents=False) )
# Magnetic field algorithm setup acc.addEventAlgo( CompFactory.MagField.CondReader('MagFieldCondReader') )
from AthenaCommon.CfgGetter import getAlgorithm
condSeq = AthSequencer("AthCondSeq") import sys
condSeq += getAlgorithm( "AtlasFieldMapCondAlg" ) sys.exit(acc.run().isFailure())
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
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