From 07e57ab48a4dd70eb63eb2781a38de42d6b82a88 Mon Sep 17 00:00:00 2001
From: schaffer <R.D.Schaffer@cern.ch>
Date: Sat, 15 Aug 2020 18:22:55 +0200
Subject: [PATCH] since DCS has time-stamp IOV, for IOV when DCS currents say
 that solenoid or toroid is off, use just the current run number

---
 .../src/AtlasFieldMapCondAlg.cxx              | 32 +++++++------------
 1 file changed, 12 insertions(+), 20 deletions(-)

diff --git a/MagneticField/MagFieldServices/src/AtlasFieldMapCondAlg.cxx b/MagneticField/MagFieldServices/src/AtlasFieldMapCondAlg.cxx
index e37594b0fba0..2461c306f8b7 100644
--- a/MagneticField/MagFieldServices/src/AtlasFieldMapCondAlg.cxx
+++ b/MagneticField/MagFieldServices/src/AtlasFieldMapCondAlg.cxx
@@ -214,6 +214,8 @@ MagField::AtlasFieldMapCondAlg::updateFieldMap(const EventContext& ctx, Cache& c
         else {
             // For normal athena jobs, check the currents in DCS to check if one of the two magnets
             // is OFF so that the correct map can be used.
+            // If a field is off, set an IOV validity range to be the current run only.
+            // (Note DCS currents have a timestamp-based IOV, so this is not used.)
 
             //  Note: for the nominal maps from COOL, three maps are available:
             //    - Global with both solenoid and toroid
@@ -225,35 +227,25 @@ MagField::AtlasFieldMapCondAlg::updateFieldMap(const EventContext& ctx, Cache& c
             EventIDRange rangeDCS;
             ATH_CHECK( checkCurrentFromConditions(ctx, soleCurrent, toroCurrent, rangeDCS) );
 
-            bool useDCSIOVRange = false;
+            bool mustCreateIOVRange = false;
             if (soleCurrent < m_soleMinCurrent) {
                 cache.m_mapSoleCurrent = 0;
-                useDCSIOVRange = true;
+                mustCreateIOVRange = true;
                 ATH_MSG_INFO("updateFieldMap: set solenoid current to 0 from DCS");
             }
             if (toroCurrent < m_toroMinCurrent) {
                 cache.m_mapToroCurrent = 0;
-                useDCSIOVRange = true;
+                mustCreateIOVRange = true;
                 ATH_MSG_INFO("updateFieldMap: set toroid current to 0 from DCS");
             }
-            if (useDCSIOVRange) {
-                // Construct range - from DCS range, if not a TimeStamp IOV
+            if (mustCreateIOVRange) {
+                // The currents from DCS are zero for either solenoid or toroid, construct an range for one run
                 EventIDBase start, stop;
-                if (rangeDCS.start().isTimeStamp()) {
-                    // use ctx run number
-                    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);
-                }
-                else {
-                    // not just time stamp, use the DCS run number
-                    //  - require validity to be at least one full run
-                    start.set_run_number(rangeDCS.start().run_number());
-                    start.set_lumi_block(0);
-                    stop.set_run_number(std::max(rangeDCS.start().run_number() + 1, rangeDCS.stop().run_number()));
-                    stop.set_lumi_block(0);
-                }
+                // use ctx run number
+                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: map IOV  range " << cache.m_mapCondObjOutputRange);
             }
-- 
GitLab