From ec61e601bf6116ba457a66a46fef2e5f5f52a088 Mon Sep 17 00:00:00 2001
From: John Chapman <jchapman@cern.ch>
Date: Tue, 5 Feb 2019 18:08:17 +0100
Subject: [PATCH] Add a new Common.Project ConfigFlag

---
 Control/AthenaConfiguration/python/AllConfigFlags.py      | 8 ++++++++
 .../SCT_GeoModel/python/SCT_GeoModelConfig.py             | 3 +--
 .../TRT_GeoModel/python/TRT_GeoModelConfig.py             | 3 +--
 MuonSpectrometer/MuonConfig/python/MuonGeometryConfig.py  | 3 +--
 4 files changed, 11 insertions(+), 6 deletions(-)

diff --git a/Control/AthenaConfiguration/python/AllConfigFlags.py b/Control/AthenaConfiguration/python/AllConfigFlags.py
index 50c16040d7a..dbabb4d27df 100644
--- a/Control/AthenaConfiguration/python/AllConfigFlags.py
+++ b/Control/AthenaConfiguration/python/AllConfigFlags.py
@@ -25,6 +25,14 @@ def _createCfgFlags():
 
     acf.addFlag('Common.isOnline', False ) #  Job runs in an online environment (access only to resources available at P1) # former global.isOnline
 
+    def _checkProject():
+        import os
+        if "AthSimulation_DIR" in os.environ:
+            return "AthSimulation"
+        #TODO expand this method.
+        return "Athena"
+    acf.addFlag('Common.Project', _checkProject())
+
     # replace global.Beam*
     acf.addFlag('Beam.BunchSpacing', 25) # former global.BunchSpacing
     acf.addFlag("Beam.NumberOfCollisions",0) # former global.NumberOfCollisions
diff --git a/InnerDetector/InDetDetDescr/SCT_GeoModel/python/SCT_GeoModelConfig.py b/InnerDetector/InDetDetDescr/SCT_GeoModel/python/SCT_GeoModelConfig.py
index 89e8786c714..579c6679a32 100644
--- a/InnerDetector/InDetDetDescr/SCT_GeoModel/python/SCT_GeoModelConfig.py
+++ b/InnerDetector/InDetDetDescr/SCT_GeoModel/python/SCT_GeoModelConfig.py
@@ -49,8 +49,7 @@ def SCT_GeometryCfg( flags ):
             acc.merge(addFoldersSplitOnline(flags,"INDET","/Indet/Onl/Align","/Indet/Align",className="AlignableTransformContainer"))
         else:
             acc.merge(addFoldersSplitOnline(flags,"INDET","/Indet/Onl/Align","/Indet/Align"))
-    import os
-    if "AthSimulation_DIR" not in os.environ: # Protection for AthSimulation builds
+    if flags.Common.Project is not "AthSimulation": # Protection for AthSimulation builds
         if (not flags.Detector.SimulateSCT) or flags.Detector.OverlaySCT:
             from SCT_ConditionsAlgorithms.SCT_ConditionsAlgorithmsConf import SCT_AlignCondAlg
             sctAlignCondAlg = SCT_AlignCondAlg(name = "SCT_AlignCondAlg",
diff --git a/InnerDetector/InDetDetDescr/TRT_GeoModel/python/TRT_GeoModelConfig.py b/InnerDetector/InDetDetDescr/TRT_GeoModel/python/TRT_GeoModelConfig.py
index 80c868a2eb8..7f0d04275f2 100644
--- a/InnerDetector/InDetDetDescr/TRT_GeoModel/python/TRT_GeoModelConfig.py
+++ b/InnerDetector/InDetDetDescr/TRT_GeoModel/python/TRT_GeoModelConfig.py
@@ -46,8 +46,7 @@ def TRT_GeometryCfg( flags ):
             acc.merge(addFoldersSplitOnline(flags,"TRT","/TRT/Onl/Align","/TRT/Align",className="AlignableTransformContainer"))
         else:
             acc.merge(addFoldersSplitOnline(flags,"TRT","/TRT/Onl/Align","/TRT/Align"))
-    import os
-    if "AthSimulation_DIR" not in os.environ: # Protection for AthSimulation builds
+    if flags.Common.Project is not "AthSimulation": # Protection for AthSimulation builds
         if (not flags.Detector.SimulateTRT) or flags.Detector.OverlayTRT:
             acc.addCondAlgo(TRTAlignCondAlg)
 
diff --git a/MuonSpectrometer/MuonConfig/python/MuonGeometryConfig.py b/MuonSpectrometer/MuonConfig/python/MuonGeometryConfig.py
index 378db9f7990..fe628090392 100644
--- a/MuonSpectrometer/MuonConfig/python/MuonGeometryConfig.py
+++ b/MuonSpectrometer/MuonConfig/python/MuonGeometryConfig.py
@@ -7,7 +7,6 @@ from MuonIdHelpers.MuonIdHelpersConf import Muon__MuonIdHelperTool
 from AGDD2GeoSvc.AGDD2GeoSvcConf import AGDDtoGeoSvc
 from MuonAGDD.MuonAGDDConf import MuonAGDDTool, NSWAGDDTool
 from StoreGate.StoreGateConf import StoreGateSvc
-import os
 
 def MuonGeoModelCfg(flags):
     acc = ComponentAccumulator()
@@ -19,7 +18,7 @@ def MuonGeoModelCfg(flags):
     detTool = MuonDetectorTool()
     detTool.UseConditionDb = 1
     detTool.UseIlinesFromGM = 1
-    if ( ( not flags.Detector.SimulateMuon or flags.Detector.OverlayMuon ) and "AthSimulation_DIR" not in os.environ ):
+    if ( ( not flags.Detector.SimulateMuon or flags.Detector.OverlayMuon ) and flags.Common.Project is not "AthSimulation" ):
         # Needs configuration from MuonSpectrometer/MuonReconstruction/MuonRecExample/python/MuonAlignConfig.py to be migrated
         #detTool.TheMuonAlignmentTool = "MuonAlignmentDbTool/MGM_AlignmentDbTool"
         pass
-- 
GitLab