From 34eae6fdcb5d709723f8ec49b0d8ca4223c21566 Mon Sep 17 00:00:00 2001 From: Frank Winklmeier <fwinkl@cern> Date: Thu, 13 Aug 2020 16:26:20 +0200 Subject: [PATCH] MagFieldServices: Use run-based IOVs for conditions objects When running with currents set from job options, use the run number as IOV to make sure it is being re-initialized during stop/start. Also cleanup some printouts and remove finalize() methods that only print an INFO message. Relates to ATLASRECTS-5604. --- .../MagFieldServices/AtlasFieldCacheCondAlg.h | 5 ++- .../MagFieldServices/AtlasFieldMapCondAlg.h | 3 +- .../src/AtlasFieldCacheCondAlg.cxx | 33 ++++++++--------- .../src/AtlasFieldMapCondAlg.cxx | 35 ++++++++----------- 4 files changed, 32 insertions(+), 44 deletions(-) diff --git a/MagneticField/MagFieldServices/MagFieldServices/AtlasFieldCacheCondAlg.h b/MagneticField/MagFieldServices/MagFieldServices/AtlasFieldCacheCondAlg.h index c1426976d40..f80106f3460 100644 --- a/MagneticField/MagFieldServices/MagFieldServices/AtlasFieldCacheCondAlg.h +++ b/MagneticField/MagFieldServices/MagFieldServices/AtlasFieldCacheCondAlg.h @@ -1,5 +1,5 @@ /* - Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration */ @@ -32,7 +32,6 @@ namespace MagField { StatusCode initialize() override final; StatusCode execute(const EventContext& ctx) const override final; - StatusCode finalize() override final; private: @@ -49,7 +48,7 @@ namespace MagField { EventIDRange m_condObjOutputRange {EventIDRange(EventIDBase(0,0), EventIDBase(EventIDBase::UNDEFNUM-1, EventIDBase::UNDEFEVT-1))}; }; StatusCode updateCurrentFromConditions(const EventContext& ctx, Cache& cache) const; - StatusCode updateCurrentFromParameters(Cache& cache) const; + StatusCode updateCurrentFromParameters(const EventContext& ctx, Cache& cache) const; void scaleField(Cache& cache, const MagField::AtlasFieldMap* fieldMap) const; // threshold below which currents are considered zero diff --git a/MagneticField/MagFieldServices/MagFieldServices/AtlasFieldMapCondAlg.h b/MagneticField/MagFieldServices/MagFieldServices/AtlasFieldMapCondAlg.h index 616ebd10ecb..ee3ffa2f763 100644 --- a/MagneticField/MagFieldServices/MagFieldServices/AtlasFieldMapCondAlg.h +++ b/MagneticField/MagFieldServices/MagFieldServices/AtlasFieldMapCondAlg.h @@ -1,5 +1,5 @@ /* - Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration */ @@ -33,7 +33,6 @@ namespace MagField { StatusCode start() override final; StatusCode initialize() override final; StatusCode execute(const EventContext& ctx) const override final; - StatusCode finalize() override final; private: diff --git a/MagneticField/MagFieldServices/src/AtlasFieldCacheCondAlg.cxx b/MagneticField/MagFieldServices/src/AtlasFieldCacheCondAlg.cxx index 7263c882235..bcad85206aa 100644 --- a/MagneticField/MagFieldServices/src/AtlasFieldCacheCondAlg.cxx +++ b/MagneticField/MagFieldServices/src/AtlasFieldCacheCondAlg.cxx @@ -35,7 +35,6 @@ MagField::AtlasFieldCacheCondAlg::~AtlasFieldCacheCondAlg()= default; StatusCode MagField::AtlasFieldCacheCondAlg::initialize() { - ATH_MSG_INFO ("Initialize"); // CondSvc ATH_CHECK( m_condSvc.retrieve() ); @@ -91,7 +90,7 @@ MagField::AtlasFieldCacheCondAlg::execute(const EventContext& ctx) const { ATH_CHECK( updateCurrentFromConditions(ctx, cache) ); } else { - ATH_CHECK( updateCurrentFromParameters(cache) ); + ATH_CHECK( updateCurrentFromParameters(ctx, cache) ); } // Must read map cond object to get previously created map @@ -140,7 +139,8 @@ MagField::AtlasFieldCacheCondAlg::execute(const EventContext& ctx) const { } ATH_MSG_INFO ( "execute: initialized AtlasFieldCacheCondObj and cache with SFs - sol/tor " - << cache.m_solScaleFactor << "/" << cache.m_torScaleFactor ); + << cache.m_solScaleFactor << "/" << cache.m_torScaleFactor + << ", EventRange " << cache.m_condObjOutputRange ); if (fieldMap) { ATH_MSG_INFO ( "execute: solenoid zone id " << fieldMap->solenoidZoneId()); } @@ -154,7 +154,6 @@ MagField::AtlasFieldCacheCondAlg::execute(const EventContext& ctx) const { StatusCode MagField::AtlasFieldCacheCondAlg::updateCurrentFromConditions(const EventContext& ctx, Cache& cache) const { - ATH_MSG_INFO ( "UpdateCurrentFromConditions " ); // readin current value SG::ReadCondHandle<CondAttrListCollection> readHandle {m_currInputKey, ctx}; @@ -246,10 +245,9 @@ MagField::AtlasFieldCacheCondAlg::updateCurrentFromConditions(const EventContext StatusCode -MagField::AtlasFieldCacheCondAlg::updateCurrentFromParameters(Cache& cache) const +MagField::AtlasFieldCacheCondAlg::updateCurrentFromParameters(const EventContext& ctx, Cache& cache) const { - ATH_MSG_INFO( "updateCurrentFromParameters" ); // take the current values from JobOptions double solcur{m_useSoleCurrent}; double torcur{m_useToroCurrent}; @@ -263,8 +261,17 @@ MagField::AtlasFieldCacheCondAlg::updateCurrentFromParameters(Cache& cache) cons } cache.m_solenoidCurrent = solcur; cache.m_toroidCurrent = torcur; - ATH_MSG_INFO("updateCurrentFromParameters: Update from job options: Range of input/output is " << cache.m_condObjOutputRange); - ATH_MSG_INFO("updateCurrentFromParameters: Currents taken from jobOption parameters " ); + + // in case of reading from DB or from FILE, the EventID range is always the current run + EventIDBase start, stop; + start.set_run_number(ctx.eventID().run_number()); + start.set_lumi_block(0); + stop.set_run_number(ctx.eventID().run_number()+1); + stop.set_lumi_block(0); + cache.m_condObjOutputRange = EventIDRange(start,stop); + + ATH_MSG_INFO("updateCurrentFromParameters: Update from job options: Range of input/output is " << cache.m_condObjOutputRange); + return StatusCode::SUCCESS; } @@ -306,13 +313,3 @@ MagField::AtlasFieldCacheCondAlg::scaleField(Cache& cache, const MagField::Atlas << cache.m_toroidCurrent << "," << ((fieldMap) ? fieldMap->toroidCurrent() : 0)); } } - - - - - -StatusCode -MagField::AtlasFieldCacheCondAlg::finalize() { - ATH_MSG_INFO ( " in finalize " ); - return StatusCode::SUCCESS; -} diff --git a/MagneticField/MagFieldServices/src/AtlasFieldMapCondAlg.cxx b/MagneticField/MagFieldServices/src/AtlasFieldMapCondAlg.cxx index c6cca3294f8..460fb0b2cdd 100644 --- a/MagneticField/MagFieldServices/src/AtlasFieldMapCondAlg.cxx +++ b/MagneticField/MagFieldServices/src/AtlasFieldMapCondAlg.cxx @@ -38,7 +38,6 @@ MagField::AtlasFieldMapCondAlg::~AtlasFieldMapCondAlg()= default; StatusCode MagField::AtlasFieldMapCondAlg::initialize() { - ATH_MSG_INFO ("Initialize"); // CondSvc ATH_CHECK( m_condSvc.retrieve() ); @@ -59,7 +58,7 @@ MagField::AtlasFieldMapCondAlg::initialize() { ATH_MSG_INFO ( "Initialize: Key " << m_mapCondObjOutputKey.fullKey() << " has been succesfully registered " ); if (m_useMapsFromCOOL) { - ATH_MSG_INFO ( "Initialize: Will update the field map from conditions"); // + ATH_MSG_INFO ( "Initialize: Will update the field map from conditions"); } else { ATH_MSG_INFO ( "Initialize: Will update the field map from jobOpt file name"); @@ -82,7 +81,7 @@ MagField::AtlasFieldMapCondAlg::start() { StatusCode MagField::AtlasFieldMapCondAlg::execute(const EventContext& ctx) const { - ATH_MSG_DEBUG ( "execute: entering "); + ATH_MSG_DEBUG ( "execute: entering " << ctx.eventID() ); // Check if output conditions object with field map object is still valid, if not replace it // with new map @@ -104,9 +103,7 @@ MagField::AtlasFieldMapCondAlg::execute(const EventContext& ctx) const { else { ATH_MSG_INFO ( "execute: no map read (currents == 0"); } - - - + // Save newly created map in conditions object, and record it in the conditions store, with its // own range auto fieldMapCondObj = std::make_unique<AtlasFieldMapCondObj>(); @@ -119,7 +116,7 @@ MagField::AtlasFieldMapCondAlg::execute(const EventContext& ctx) const { << " into Conditions Store"); return StatusCode::FAILURE; } - ATH_MSG_INFO ( "execute: recored AtlasFieldMapCondObj with field map"); + ATH_MSG_INFO ( "execute: recorded AtlasFieldMapCondObj with EventRange " << cache.m_mapCondObjOutputRange ); return StatusCode::SUCCESS; } @@ -200,13 +197,16 @@ MagField::AtlasFieldMapCondAlg::updateFieldMap(const EventContext& ctx, Cache& c cache.m_mapSoleCurrent = m_mapSoleCurrent; cache.m_mapToroCurrent = m_mapToroCurrent; - // Create a range from 0 to inf in terms of run, LB - const EventIDBase::number_type UNDEFNUM = EventIDBase::UNDEFNUM; - const EventIDBase::event_number_t UNDEFEVT = EventIDBase::UNDEFEVT; - EventIDRange rangeW (EventIDBase (0, UNDEFEVT, UNDEFNUM, 0, 0), - EventIDBase (UNDEFNUM-1, UNDEFEVT, UNDEFNUM, UNDEFNUM, 0)); - cache.m_mapCondObjOutputRange = rangeW; - ATH_MSG_INFO("updateFieldMap: useMapsFromCOOL == false, using default range " << rangeW); + // Create a range for the current run + EventIDBase start, stop; + start.set_run_number(ctx.eventID().run_number()); + start.set_lumi_block(0); + stop.set_run_number(ctx.eventID().run_number()+1); + stop.set_lumi_block(0); + cache.m_mapCondObjOutputRange = EventIDRange(start,stop); + + ATH_MSG_INFO("updateFieldMap: useMapsFromCOOL == false, using default range " + << cache.m_mapCondObjOutputRange); } // We allow to set currents via the TagInfoMgr which adds tags to the TagInfo object - only allowed for offline @@ -312,10 +312,3 @@ MagField::AtlasFieldMapCondAlg::updateFieldMap(const EventContext& ctx, Cache& c return StatusCode::SUCCESS; } - - -StatusCode -MagField::AtlasFieldMapCondAlg::finalize() { - ATH_MSG_INFO ( " in finalize " ); - return StatusCode::SUCCESS; -} -- GitLab