From 401a585d3a4a2fae7fc1d6ac24d0e69a1518930b Mon Sep 17 00:00:00 2001
From: schaffer <R.D.Schaffer@cern.ch>
Date: Wed, 12 Aug 2020 18:12:33 +0200
Subject: [PATCH] moving to allow for LockMapCurrents = True the field to turn
 on and off

---
 .../src/AtlasFieldCacheCondAlg.cxx            | 19 +++++++++++--------
 1 file changed, 11 insertions(+), 8 deletions(-)

diff --git a/MagneticField/MagFieldServices/src/AtlasFieldCacheCondAlg.cxx b/MagneticField/MagFieldServices/src/AtlasFieldCacheCondAlg.cxx
index dd39f3f560b..7263c882235 100644
--- a/MagneticField/MagFieldServices/src/AtlasFieldCacheCondAlg.cxx
+++ b/MagneticField/MagFieldServices/src/AtlasFieldCacheCondAlg.cxx
@@ -87,14 +87,11 @@ MagField::AtlasFieldCacheCondAlg::execute(const EventContext& ctx) const {
     //This will need to be filled before we construct the condition object 
     Cache cache{};
 
-    // set current scale factor from either conditions or from jobOption parameters if not locked
-    if (!m_lockMapCurrents) {
-        if (m_useDCS) {
-            ATH_CHECK( updateCurrentFromConditions(ctx, cache) );
-        }
-        else {
-            ATH_CHECK( updateCurrentFromParameters(cache) );
-        }
+    if (m_useDCS) {
+        ATH_CHECK( updateCurrentFromConditions(ctx, cache) );
+    }
+    else {
+        ATH_CHECK( updateCurrentFromParameters(cache) );
     }
     
     // Must read map cond object to get previously created map
@@ -113,6 +110,11 @@ MagField::AtlasFieldCacheCondAlg::execute(const EventContext& ctx) const {
         scaleField(cache, fieldMap);
     }
     else {
+        // For locked currents, we allow the SF to be either 0 or 1, i.e. allow the DCS currents to
+        // say whether or not the solenoid or toroid is on or not
+        cache.m_solScaleFactor = (cache.m_solenoidCurrent > 0) ? 1 : 0;
+        cache.m_torScaleFactor = (cache.m_toroidCurrent   > 0) ? 1 : 0;
+        
         ATH_MSG_INFO( "execute: map currents locked");
         ATH_MSG_INFO( "execute: Solenoid field scale factor " << cache.m_solScaleFactor << ". Desired current and map current: "
                       << cache.m_solenoidCurrent << "," << ((fieldMap) ? fieldMap->solenoidCurrent() : 0));
@@ -235,6 +237,7 @@ MagField::AtlasFieldCacheCondAlg::updateCurrentFromConditions(const EventContext
         torcur = 0.0;
         ATH_MSG_INFO( "UpdateCurrentFromConditions: Toroids are off" );
     }
+
     cache.m_solenoidCurrent = solcur;
     cache.m_toroidCurrent   = torcur;
 
-- 
GitLab