Skip to content
Snippets Groups Projects
Commit 580524b5 authored by Frank Winklmeier's avatar Frank Winklmeier Committed by R D Schaffer
Browse files

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.
parent cf7392eb
No related merge requests found
/*
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
......
/*
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:
......
......@@ -35,7 +35,6 @@ MagField::AtlasFieldCacheCondAlg::~AtlasFieldCacheCondAlg()= default;
StatusCode
MagField::AtlasFieldCacheCondAlg::initialize() {
ATH_MSG_INFO ("Initialize");
// CondSvc
ATH_CHECK( m_condSvc.retrieve() );
......@@ -92,7 +91,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
......@@ -129,7 +128,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());
}
......@@ -143,7 +143,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};
......@@ -234,10 +233,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};
......@@ -251,8 +249,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;
}
......@@ -294,13 +301,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;
}
......@@ -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;
}
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