From 5df1408b211581d8e7ee66833e14c12e121b25cf Mon Sep 17 00:00:00 2001
From: Walter Lampl <walter.lampl@cern.ch>
Date: Tue, 27 Mar 2018 22:20:34 +0000
Subject: [PATCH] Experimental Config flags for job config prototype

---
 .../CaloRec/python/CaloRecConfigFlags.py      |  23 ---
 .../CaloRec/python/CaloTopoClusterConfig.py   |  32 ++--
 .../python/CaloTopoClusterConfigFlags.py      |   6 -
 .../CaloTools/python/CaloNoiseToolConfig.py   |  26 +--
 .../python/AllConfigFlags.py                  |  59 +++++++
 .../python/AthConfigFlags.py                  | 161 ++++++++++++++++++
 .../python/ComponentAccumulator.py            |  46 ++---
 .../python/ConfigFlagCatalog.py               |  64 -------
 .../AthenaConfiguration/python/ConfigFlags.py | 120 -------------
 .../AthenaConfiguration/python/GlobalFlags.py |  29 ----
 .../python/testAllConfigFlags.py              |  44 +++++
 .../python/testConfigFlags.py                 |  54 ------
 .../python/HelloWorldConfig.py                |   2 +-
 .../AthenaPoolCnvSvc/python/PoolReadConfig.py |   7 +-
 Database/IOVDbSvc/python/IOVDbAutoCfgFlags.py |  19 +++
 Database/IOVDbSvc/python/IOVDbConfigFlags.py  |  24 ---
 Database/IOVDbSvc/python/IOVDbSvcConfig.py    |  19 ++-
 .../AtlasGeoModel/python/GeoModelConfig.py    |   4 +-
 .../AtlasGeoModel/python/GeoModelFlags.py     |   4 -
 .../AtlasGeoModel/python/LArGMConfig.py       |  11 --
 .../LArGeoAlgsNV/python/LArGMConfig.py        |  12 +-
 .../LArGeoAlgsNV/python/LArGeoModelFlags.py   |   7 -
 .../TileGeoModel/python/TileGMConfig.py       |   4 +-
 23 files changed, 363 insertions(+), 414 deletions(-)
 delete mode 100644 Calorimeter/CaloRec/python/CaloRecConfigFlags.py
 delete mode 100644 Calorimeter/CaloRec/python/CaloTopoClusterConfigFlags.py
 create mode 100644 Control/AthenaConfiguration/python/AllConfigFlags.py
 create mode 100644 Control/AthenaConfiguration/python/AthConfigFlags.py
 delete mode 100644 Control/AthenaConfiguration/python/ConfigFlagCatalog.py
 delete mode 100644 Control/AthenaConfiguration/python/ConfigFlags.py
 delete mode 100644 Control/AthenaConfiguration/python/GlobalFlags.py
 create mode 100644 Control/AthenaConfiguration/python/testAllConfigFlags.py
 delete mode 100644 Control/AthenaConfiguration/python/testConfigFlags.py
 create mode 100644 Database/IOVDbSvc/python/IOVDbAutoCfgFlags.py
 delete mode 100644 Database/IOVDbSvc/python/IOVDbConfigFlags.py
 delete mode 100644 DetectorDescription/GeoModel/AtlasGeoModel/python/GeoModelFlags.py
 delete mode 100644 DetectorDescription/GeoModel/AtlasGeoModel/python/LArGMConfig.py
 delete mode 100644 LArCalorimeter/LArGeoModel/LArGeoAlgsNV/python/LArGeoModelFlags.py

diff --git a/Calorimeter/CaloRec/python/CaloRecConfigFlags.py b/Calorimeter/CaloRec/python/CaloRecConfigFlags.py
deleted file mode 100644
index 45523a8f51c2..000000000000
--- a/Calorimeter/CaloRec/python/CaloRecConfigFlags.py
+++ /dev/null
@@ -1,23 +0,0 @@
-from AthenaConfiguration.ConfigFlags import ConfigFlag
-
-class doHVCorr(ConfigFlag):
-    """ Flag to activate  HV correction at LAr cell level from DCS cool database undoing the online applied factor
-    """  
-    def getDefault(self,prevFlags):
-        return not prevFlags.get("AthenaConfiguration.GlobalConfigFlags.isMC")
-       
-class doLArCellEmMisCalib(ConfigFlag):
-    """ Flag to activate artificial miscalibration of simulated cell energies
-    """
-    def getDefault(self,prevFlags):
-        return prevFlags.get("AthenaConfiguration.GlobalConfigFlags.isMC")
-       
-
-class fixedLumiForNoise(ConfigFlag):
-    """Hardcoded luminosity value for pileup noise scaling"""
-    def getDefault(self,prevFlags):
-        return -1
-
-class useCaloNoiseLumi(ConfigFlag):
-    def getDefault(self,prevFlags):
-        return True
diff --git a/Calorimeter/CaloRec/python/CaloTopoClusterConfig.py b/Calorimeter/CaloRec/python/CaloTopoClusterConfig.py
index 90d1f36d4fc2..6738ef8e8a65 100644
--- a/Calorimeter/CaloRec/python/CaloTopoClusterConfig.py
+++ b/Calorimeter/CaloRec/python/CaloTopoClusterConfig.py
@@ -1,10 +1,9 @@
 # Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
 
 from AthenaConfiguration.ComponentAccumulator import ComponentAccumulator
-from AthenaConfiguration.ConfigFlags import ConfigFlagContainer
 from AthenaCommon.SystemOfUnits import MeV
 
-def CaloTopoClusterCfg(inputFlags):
+def CaloTopoClusterCfg(configFlags):
     result=ComponentAccumulator()
     
     from LArGeoAlgsNV.LArGMConfig import LArGMCfg
@@ -18,9 +17,9 @@ def CaloTopoClusterCfg(inputFlags):
     from CaloRec.CaloRecConf import CaloTopoClusterMaker, CaloTopoClusterSplitter, CaloClusterMomentsMaker, CaloClusterMaker, CaloClusterSnapshot #, CaloClusterLockVars, CaloClusterPrinter
 
     
-    result.executeModule(LArGMCfg,inputFlags)
-    result.executeModule(TileGMCfg,inputFlags)    
-    result.executeModule(CaloNoiseToolCfg,inputFlags)
+    result.addConfig(LArGMCfg,configFlags)
+    result.addConfig(TileGMCfg,configFlags)    
+    result.addConfig(CaloNoiseToolCfg,configFlags)
 
     theCaloNoiseTool=result.getPublicTool("CaloNoiseTool")
 
@@ -59,7 +58,7 @@ def CaloTopoClusterCfg(inputFlags):
     TopoMaker.SeedCutsInAbsE                 = True
     TopoMaker.ClusterEtorAbsEtCut            = 0.0*MeV
     # use 2-gaussian or single gaussian noise for TileCal
-    TopoMaker.TwoGaussianNoise = inputFlags.get("CaloRec.CaloTopoClusterConfigFlags.doTwoGaussianNoise")
+    TopoMaker.TwoGaussianNoise = configFlags.get("Calo.TopoCluster.doTwoGaussianNoise")
         
     TopoSplitter = CaloTopoClusterSplitter("TopoSplitter")
     # cells from the following samplings will be able to form local
@@ -81,7 +80,7 @@ def CaloTopoClusterCfg(inputFlags):
                                            "FCAL1","FCAL2"]
     TopoSplitter.ShareBorderCells = True
     TopoSplitter.RestrictHECIWandFCalNeighbors  = False
-    TopoSplitter.WeightingOfNegClusters = inputFlags.get("CaloRec.CaloTopoClusterConfigFlags.doTreatEnergyCutAsAbsolute")
+    TopoSplitter.WeightingOfNegClusters = configFlags.get("Calo.TopoCluster.doTreatEnergyCutAsAbsolute")
     #
     # the following options are not set, since these are the default
     # values
@@ -102,17 +101,22 @@ def CaloTopoClusterCfg(inputFlags):
 
 
 if __name__=="__main__":
-    cfg=ComponentAccumulator()
     from AthenaConfiguration.CfgLogMsg import cfgLogMsg
+    from AthenaConfiguration.AllConfigFlags import ConfigFlags
+
     cfgLogMsg.setLevel("debug")
-    cfgFlags=ConfigFlagContainer()
-    cfgFlags.set("AthenaConfiguration.GlobalFlags.isMC",False)
-    cfgFlags.set("AthenaConfiguration.GlobalFlags.InputFiles",["myESD.pool.root"])
+    
 
-    from AthenaPoolCnvSvc.PoolReadConfig import PoolReadCfg
-    cfg.executeModule(PoolReadCfg,cfgFlags)
+    ConfigFlags.set("global.isMC",False)
+    ConfigFlags.set("global.InputFiles",["myESD.pool.root"])
+    ConfigFlags.lock()
 
-    cfg.executeModule(CaloTopoClusterCfg,cfgFlags)
+    cfg=ComponentAccumulator()
+
+    from AthenaPoolCnvSvc.PoolReadConfig import PoolReadCfg
+    cfg.addConfig(PoolReadCfg,ConfigFlags)
+    
+    cfg.addConfig(CaloTopoClusterCfg,ConfigFlags)
     cfg.getEventAlgo("CaloTopoCluster").ClustersOutputName="CaloCalTopoClustersNew" 
 
     f=open("CaloTopoCluster.pkl","w")
diff --git a/Calorimeter/CaloRec/python/CaloTopoClusterConfigFlags.py b/Calorimeter/CaloRec/python/CaloTopoClusterConfigFlags.py
deleted file mode 100644
index 44f23e924221..000000000000
--- a/Calorimeter/CaloRec/python/CaloTopoClusterConfigFlags.py
+++ /dev/null
@@ -1,6 +0,0 @@
-from AthenaConfiguration.ConfigFlags import makeFlag
-
-doTwoGaussianNoise=makeFlag("doTwoGaussianNoise",True)
-
-doTreatEnergyCutAsAbsolute=makeFlag("doTreatEnergyCutAsAbsolute",False)
-
diff --git a/Calorimeter/CaloTools/python/CaloNoiseToolConfig.py b/Calorimeter/CaloTools/python/CaloNoiseToolConfig.py
index 0ee143dd4cd8..e2873b6bd965 100644
--- a/Calorimeter/CaloTools/python/CaloNoiseToolConfig.py
+++ b/Calorimeter/CaloTools/python/CaloNoiseToolConfig.py
@@ -3,21 +3,21 @@ from IOVDbSvc.IOVDbSvcConfig import addFolders
 from CaloTools.CaloToolsConf import CaloNoiseToolDB
 from AthenaConfiguration.CfgLogMsg import cfgLogMsg
 
-def CaloNoiseToolCfg(inputFlags):
+def CaloNoiseToolCfg(configFlags):
 
     result=ComponentAccumulator()
 
-    isMC=inputFlags.get("AthenaConfiguration.GlobalFlags.isMC")
-    fixedLumi=inputFlags.get("CaloRec.CaloRecConfigFlags.fixedLumiForNoise")
-    useCaloLumi=inputFlags.get("CaloRec.CaloRecConfigFlags.useCaloNoiseLumi")
+    isMC=configFlags.get("global.isMC")
+    fixedLumi=configFlags.get("Calo.Noise.fixedLumiForNoise")
+    useCaloLumi=configFlags.get("Calo.Noise.useCaloNoiseLumi")
     
     caloNoiseToolDB=CaloNoiseToolDB("CaloNoiseTool")
 
 
-    if inputFlags.get("AthenaConfiguration.GlobalFlags.isOnline"):
+    if configFlags.get("global.isOnline"):
         #online mode:
         folder  = "/CALO/Noise/CellNoise"
-        result.executeModule(addFolders,inputFlags,folder,'CALO_ONL')
+        result.addConfig(addFolders,configFlags,inputFlags,folder,'CALO_ONL')
         caloNoiseToolDB.FolderNames=[folder,]
         if fixedLumi >= 0 :
             caloNoiseToolDB.Luminosity = fixedLumi
@@ -25,7 +25,7 @@ def CaloNoiseToolCfg(inputFlags):
         else:
             if useCaloLumi:
                 lumiFolder='/CALO/Noise/PileUpNoiseLumi'
-                result.executeModule(addFolders,inputFlags,lumiFolder,'CALO')
+                result.addConfig(addFolders,configFlags,lumiFolder,'CALO')
                 caloNoiseToolDB.LumiFolderName = lumiFolder
                 caloNoiseToolDB.Luminosity = -1.
                 cfgLogMsg.info("online mode: use luminosity from /CALO/Noise/PileUpNoiseLumi to scale pileup noise")
@@ -44,12 +44,12 @@ def CaloNoiseToolCfg(inputFlags):
         else:
             if useCaloLumi:
                 lumiFolder='/CALO/Ofl/Noise/PileUpNoiseLumi'
-                result.executeModule(addFolders,inputFlags,lumiFolder,'CALO_OFL')
+                result.addConfig(addFolders,configFlags,lumiFolder,'CALO_OFL')
                 cfgLogMsg.info("offline mode: use luminosity from /CALO/Ofl/Noise/PileuUpNoiseLumi to scale pileup noise")
                 caloNoiseToolDB.LumiFolderName = lumiFolder
                 caloNoiseToolDB.Luminosity=-1.
             else:
-                estimatedLumi=inputFlags.get("AthenaConfiguration.GlobalFlags.estimatedLuminosity")
+                estimatedLumi=configFlag.get("global.estimatedLuminosity")
                 caloNoiseToolDB.Luminosity=estimatedLumi/1e+33
                 cfgLogMsg.info("  Luminosity (in 10**33) units used for pileup noise from global flags: %f"%caloNoiseToolDB.Luminosity)
 
@@ -68,11 +68,11 @@ def CaloNoiseToolCfg(inputFlags):
             caloNoiseToolDB.Luminosity = -1
             if useCaloLumi:
                 lumiFolder='/CALO/Ofl/Noise/PileUpNoiseLumi'
-                result.executeModule(addFolders,inputFlags,lumiFolder,'CALO_OFL')
+                result.addConfig(addFolders,configFlags,lumiFolder,'CALO_OFL')
                 cfgLogMsg.info("offline mode: use luminosity from /CALO/Ofl/Noise/PileUpNoiseLumi to scale pileup noise")
             else:
                 lumiFolder = '/TRIGGER/LUMI/LBLESTONL'
-                result.executeModule(addFolders,inputFlags,lumiFolder,'TRIGGER_ONL');
+                result.addConfig(addFolders,configFlags,lumiFolder,'TRIGGER_ONL');
                 cfgLogMsg.info("offline mode: use luminosity = f(Lumiblock) to scale pileup noise")
                 caloNoiseToolDB.LumiFolderName = lumiFolder
 
@@ -81,7 +81,7 @@ def CaloNoiseToolCfg(inputFlags):
                  ("TILE_OFL","/TILE/OFL02/NOISE/CELL")
                  ]
         
-        if inputFlags.get("IOVDbSvc.IOVDbConfigFlags.DatabaseInstance")=="COMP200":
+        if configFlags.get("IOVDb.DatabaseInstance")=="COMP200":
             folders.append(("CALO_OFL","/CALO/Ofl/Noise/CellNoise")),
         
         #Fixme: Add rescaling of noise based on HV! 
@@ -90,7 +90,7 @@ def CaloNoiseToolCfg(inputFlags):
         pass #end of real data case
     
     for (db,fldr) in folders:
-        result.executeModule(addFolders,inputFlags,fldr,db)
+        result.addConfig(addFolders,configFlags,fldr,db)
     
     caloNoiseToolDB.FolderNames=[f[1] for f in folders]    
 
diff --git a/Control/AthenaConfiguration/python/AllConfigFlags.py b/Control/AthenaConfiguration/python/AllConfigFlags.py
new file mode 100644
index 000000000000..5e8556024e2f
--- /dev/null
+++ b/Control/AthenaConfiguration/python/AllConfigFlags.py
@@ -0,0 +1,59 @@
+# Copyright (C) 2002-2018 CERN for the benefit of the ATLAS collaboration
+
+from AthenaConfiguration.AthConfigFlags import AthConfigFlags
+from AthenaCommon.SystemOfUnits import TeV
+
+def _createCfgFlags():
+
+    acf=AthConfigFlags()
+#Global Flags:
+
+    acf.addFlag('global.isMC',True)
+    acf.addFlag('global.isOnline',False)
+    acf.addFlag('global.GeoLayout',"atlas")
+    acf.addFlag('global.ProjectName',"data17_13TeV")
+    acf.addFlag('global.InputFiles',["_ATHENA_GENERIC_INPUTFILE_NAME_",])
+    acf.addFlag('global.BunchSpacing',25) # Bunch spacing in ns
+    acf.addFlag("global.NumberOfCollisions",0) #"Number of collisions per beam crossing. Should be 2.3*(L/10**33)*(bunchSpacing/25 ns)
+    acf.addFlag("global.BeamType",'collisions') # "Specify data taking type: 'collisions' (default), 'singlebeam','cosmics'")
+    acf.addFlag("global.BeamEnergy",7*TeV)
+    acf.addFlag("global.estimatedLuminosity",lambda prevFlags : 1E33*(prevFlags.get("global.NumberOfCollisions")/2.3)* \
+                    (25./prevFlags.get("global.BunchSpacing")))
+
+#Geo Model Flags:
+    acf.addFlag("GeoModel.AtlasVersion","ATLAS-R2-2016-01-00-01")
+
+
+#IOVDbSvc Flags:
+    acf.addFlag("IOVDb.GlobalTag","CONDBR2-BLKPA-2017-05")
+    from IOVDbSvc.IOVDbAutoCfgFlags import getDatabaseInstanceDefault
+    acf.addFlag("IOVDb.DatabaseInstance",getDatabaseInstanceDefault)
+
+
+#LAr Flags:
+    acf.addFlag("LAr.doAlign",lambda prevFlags : prevFlags.get("global.GeoLayout")=="atlas")
+    acf.addFlag("LAr.doHVCorr",lambda prevFlags : not prevFlags.get("global.isMC"))
+    acf.addFlag("LAr.doCellEmMisCalib",lambda prevFlags : prevFlags.get("global.isMC"))
+    
+
+#CaloNoise Flags
+    acf.addFlag("Calo.Noise.fixedLumiForNoise",-1)
+    acf.addFlag("Calo.Noise.useCaloNoiseLumi",True)
+                
+
+#TopoCluster Flags:
+    acf.addFlag("Calo.TopoCluster.doTwoGaussianNoise",True)
+    acf.addFlag("Calo.TopoCluster.doTreatEnergyCutAsAbsolute",False)
+
+
+    return acf
+
+
+ConfigFlags=_createCfgFlags()
+
+del _createCfgFlags
+
+if __name__=="__main__":
+    ConfigFlags.initAll()
+    ConfigFlags.dump()
+    
diff --git a/Control/AthenaConfiguration/python/AthConfigFlags.py b/Control/AthenaConfiguration/python/AthConfigFlags.py
new file mode 100644
index 000000000000..2853a25e5406
--- /dev/null
+++ b/Control/AthenaConfiguration/python/AthConfigFlags.py
@@ -0,0 +1,161 @@
+# Copyright (C) 2002-2018 CERN for the benefit of the ATLAS collaboration
+
+from copy import deepcopy
+
+class CfgFlag(object):
+    __slots__ = ['_value','_setDef']
+
+    def __init__(self,default):
+        if default is None:
+            raise RuntimeError("Default value of a flag must not be None")
+        if callable(default):
+            self._value=None
+            self._setDef=default
+        else:
+            self._value=default
+            self._setDef=None
+        return
+
+
+    def set(self,value):
+        self._value=value
+        return
+    
+    def get(self,flagdict=None):
+        if self._value is None:
+            #Have to call the method to obtain the default value
+            #print "AutoConfiguring a config flag"
+            self._value=self._setDef(flagdict)
+        return deepcopy(self._value) 
+
+    def __repr__(self):
+        if self._value is not None:
+            return repr(self._value)
+        else:
+            return "[function]"
+        
+
+
+class AthConfigFlags(object):
+    def __init__(self,flagdict=dict()):
+        self._flagdict=flagdict
+        self._locked=False
+
+
+    def addFlag(self,name,setDef=None):
+        if (self._locked):
+            raise RuntimeError("Attempt to add a flag to an already-locked container")
+
+        if self._flagdict.has_key(name):
+            raise KeyError("Duplicated flag name: %s" % name);
+        
+        self._flagdict[name]=CfgFlag(setDef)
+        return
+
+
+    def set(self,name,value):
+        if (self._locked):
+            raise RuntimeError("Attempt to set a flag of an already-locked container")
+        try:
+            self._flagdict[name].set(value)
+        except KeyError:
+            errString="No flag with name \'%s\' found" % name
+            from difflib import get_close_matches
+            closestMatch=get_close_matches(name,self._flagdict.keys(),1)
+            if len(closestMatch)>0:
+                errString+=". Did you mean \'%s\'?" %  closestMatch[0] 
+            raise KeyError(errString)
+
+    def get(self,name):
+        try:
+            return self._flagdict[name].get(self)
+        except KeyError:
+            errString="No flag with name \'%s\' found" % name
+            from difflib import get_close_matches
+            closestMatch=get_close_matches(name,self._flagdict.keys(),1)
+            if len(closestMatch)>0:
+                errString+=". Did you mean \'%s\'?" %  closestMatch[0] 
+            raise KeyError(errString)
+
+    def __call__(self,name):
+        return self.get(name)
+
+    def lock(self):
+        self._locked=True
+        return
+
+    def locked(self):
+        return self._locked
+
+
+    def clone(self):
+        #return and unlocked copy of self
+        return AthConfigFlags(deepcopy(self._flagdict))
+
+
+    def cloneAndReplace(self,subsetToReplace,replacementSubset):
+        #This is to replace subsets of configuration flags like
+        #egamamaFlags.GSF by egamma.TrigGSFFlavor1
+
+        if not subsetToReplace.endswith("."):
+            subsetToReplace+="."
+            pass
+        if not replacementSubset.endswith("."):
+            replacementSubset+="."
+            pass
+
+        #Sanity check: Don't replace a by a 
+        if (subsetToReplace == replacementSubset):
+            raise RunTimeError("Called cloneAndReplace with identical strings")
+
+        replacedNames=set()
+        replacementNames=set()
+        newFlagDict=dict()
+        for (name,flag) in self._flagdict.items():
+            if name.startswith(subsetToReplace):
+                replacedNames.add(name[len(subsetToReplace):]) #Add the
+                pass #Do not copy stuff thats going to be replaced
+            elif name.startswith(replacementSubset):
+                subName=name[len(replacementSubset):]
+                replacementNames.add(subName)
+                #Move the flag to the new name:
+                
+                newFlagDict[subsetToReplace+subName]=deepcopy(flag) 
+                #If we lock the container right away, we don't need to deepcopy
+                pass
+            else: 
+                newFlagDict[name]=deepcopy(flag) #All other flags are simply copied
+                #If we lock the container right away, we don't need to deepcopy
+                pass
+            #End loop over flags
+            pass
+
+        #Last sanity check: Make sure that teh replaced section still contains teh same names:
+        if (replacedNames!=replacementNames):
+            print replacedNames
+            print replacementNames
+            raise RuntimeError("Attempt to replace incompatible subsets: None matching flag names are " 
+                               + repr(replacedNames ^ replacementNames ))
+
+        return AthConfigFlags(newFlagDict)
+
+
+
+    def join(self,other):
+         if (self._locked):
+            raise RuntimeError("Attempt to join with and already-locked container")
+         for (name,flag) in other._flagdict:
+             if self._flagdict.has_key(name):
+                 raise KeyError("Duplicated flag name: %s" % name);
+             self._flagdict[name]=flag
+         return
+
+    def dump(self):
+        print  "%40.40s : %s" % ("Flag Name","Value")
+        for name,flag in self._flagdict.iteritems():
+            print "%40.40s : %s" % (name,repr(flag))
+
+    def initAll(self): #Mostly a self-test method
+        for n,f in self._flagdict.items():
+            f.get(self)
+        return
diff --git a/Control/AthenaConfiguration/python/ComponentAccumulator.py b/Control/AthenaConfiguration/python/ComponentAccumulator.py
index f9b705a86615..9e775bb3ab4d 100644
--- a/Control/AthenaConfiguration/python/ComponentAccumulator.py
+++ b/Control/AthenaConfiguration/python/ComponentAccumulator.py
@@ -7,6 +7,7 @@ from AthenaCommon.Configurable import Configurable,ConfigurableService,Configura
 from AthenaCommon.CFElements import isSequence,findSubSequence,findAlgorithm,flatSequencers
 from AthenaCommon.AlgSequence import AlgSequence
 
+from AthenaConfiguration.AthConfigFlags import AthConfigFlags
 import GaudiKernel.GaudiHandles as GaudiHandles
 import ast
 from collections import defaultdict
@@ -265,7 +266,7 @@ class ComponentAccumulator(object):
         self._theAppProps[key]=value
         pass
 
-    def __merge(self,other):        
+    def __merge(self,other):
         """ Merging in the other accumulator """
         if not isinstance(other,ComponentAccumulator):
             raise TypeError("Attempt merge wrong type %s. Only instances of ComponentAccumulator can be added" % type(other).__name__)
@@ -319,20 +320,23 @@ class ComponentAccumulator(object):
         for (k,v) in other._theAppProps.iteritems():
             self.setAppProperty(k,v)  #Will warn about overrides
 
-    def __iadd__(self,other):
-        self.__merge(other)
-        return self
-
     
-    def addConfig(self,fct,configFlags, *args,**kwargs):
+    def addConfig(self,fct,configFlags,*args,**kwargs):
         """ The heart and soul of configuration system. You need to read the whole documentation. 
 
         This method eliminates possibility that a downstream configuration alters the upstream one. 
         It is done by a two-fold measures:
-        - the flags are cloned so downstream access only the copy of the flags
         - the sub-accumulators can not access the upstream accumulators and thus alter any configuration.
           The combination process is defined in the __merge method of this class. Less flexibility == robustness.
         """
+
+        #Safety check: Verify that the ConfigFlags are indeed locked:
+        if not isinstance(configFlags,AthConfigFlags):
+            raise ConfigurationError("Expected an instance of AthConfigFlags as parameter")
+
+        if not configFlags.locked():
+            raise ConfigurationError("You are trying to create a job using unlocked configFlags!")
+
         
         currentSeq = seq = CurrentSequence.get()
         if kwargs.has_key('sequence'):            
@@ -343,9 +347,8 @@ class ComponentAccumulator(object):
                 del kwargs['sequence']
             CurrentSequence.set( seq )
 
-        cfconst=deepcopy(configFlags)
         self._msg.info("Excuting configuration function %s" % fct.__name__)
-        retval=fct(cfconst,*args,**kwargs)
+        retval=fct(configFlags,*args,**kwargs)
         CurrentSequence.set( currentSeq )
 
         self.__merge(retval)
@@ -359,10 +362,6 @@ class ComponentAccumulator(object):
         return
 
 
-    def executeModule(self,fct,configFlags, *args,**kwargs):        
-        self._msg.info("Please start using addConfig instead of executeModule")
-        return self.addConfig(fct, configFlags, *args, **kwargs )
- 
     def appendConfigurable(self,confElem):
         name=confElem.getJobOptName() #FIXME: Don't overwrite duplicates! 
         #Hack for public Alg tools, drop multiple mentions of ToolSvc 
@@ -427,9 +426,14 @@ class ComponentAccumulator(object):
 
 
 
+        #Hack for now:   
+        self._jocfg["ApplicationMgr"]["CreateSvc"]=['ToolSvc/ToolSvc', 'AthDictLoaderSvc/AthDictLoaderSvc', 'AthenaSealSvc/AthenaSealSvc', 'CoreDumpSvc/CoreDumpSvc']
+
         svcList=ast.literal_eval(self._jocfg["ApplicationMgr"]["ExtSvc"])
         for svc in self._services:
             svcname=svc.getJobOptName()
+            if (svcname=="GeoModelSvc"): self._jocfg["ApplicationMgr"]["CreateSvc"]+=['GeoModelSvc',]
+
             svcList.append(svc.getFullName())
             #for k, v in svc.getValuedProperties().items():
             #    self._jocat[svcname][k]=str(v)
@@ -438,8 +442,7 @@ class ComponentAccumulator(object):
 
         self._jocfg["ApplicationMgr"]["EvtMax"]=nEvents
 
-        #Hack for now:   
-        self._jocfg["ApplicationMgr"]["CreateSvc"]=['ToolSvc/ToolSvc', 'AthDictLoaderSvc/AthDictLoaderSvc', 'AthenaSealSvc/AthenaSealSvc', 'CoreDumpSvc/CoreDumpSvc','GeoModelSvc']
+       
 
         for (k,v) in self._theAppProps.iteritems():
             self._jocfg["ApplicationMgr"][k]=v
@@ -454,10 +457,12 @@ class ComponentAccumulator(object):
 if __name__ == "__main__":
     # trivial case without any nested sequences
     from AthenaCommon.Configurable import ConfigurablePyAlgorithm # guinea pig algorithms
-    from AthenaConfiguration.ConfigFlags import ConfigFlagContainer
     from AthenaCommon.CFElements import *
     cfgLogMsg.setLevel("debug")
 
+    dummyCfgFlags=AthConfigFlags()
+    dummyCfgFlags.lock()
+
     class Algo(ConfigurablePyAlgorithm):
         def __init__(self, name):
             super( ConfigurablePyAlgorithm, self ).__init__( name )
@@ -471,14 +476,13 @@ if __name__ == "__main__":
 
     def AlgsConf2(flags):
         acc = ComponentAccumulator()
-        acc.executeModule( AlgsConf1, flags )
+        acc.addConfig( AlgsConf1, flags )
         acc.addEventAlgo( Algo("Algo3") )
         return acc
 
     acc = ComponentAccumulator()
-    flags=ConfigFlagContainer()
     
-    acc.executeModule( AlgsConf2, flags )
+    acc.addConfig( AlgsConf2,dummyCfgFlags )
     # checks
     assert findAlgorithm(AlgSequence("AthAlgSeq"), "Algo1", 1), "Algorithm not added to a top sequence"
     assert findAlgorithm(AlgSequence("AthAlgSeq"), "Algo2", 1), "Algorithm not added to a top sequence"
@@ -492,7 +496,7 @@ if __name__ == "__main__":
 
     def AlgsConf4(flags):
         acc = ComponentAccumulator()
-        acc.executeModule( AlgsConf3, flags )
+        acc.addConfig( AlgsConf3,flags )
         NestedAlgo2 = Algo("NestedAlgo2")
         NestedAlgo2.OutputLevel=7
         acc.addEventAlgo( NestedAlgo2 )
@@ -508,7 +512,7 @@ if __name__ == "__main__":
     assert findSubSequence(AlgSequence("AthAlgSeq"), "sub2Sequence1"), "Adding sub-sequence failed"
     assert findSubSequence( findSubSequence(AlgSequence("AthAlgSeq"), "subSequence1"), "sub2Sequence1" ), "Adding sub-sequence doen in a wrong place"
 
-    acc.executeModule( AlgsConf4, flags, sequence="subSequence1" )    
+    acc.addConfig( AlgsConf4, dummyCfgFlags, sequence="subSequence1" )    
     assert findAlgorithm(AlgSequence("AthAlgSeq"), "NestedAlgo1" ), "Algorithm added to nested seqeunce"
     assert findAlgorithm(AlgSequence("AthAlgSeq"), "NestedAlgo1", 1 ) == None, "Algorithm mistakenly in top sequence"
     assert findAlgorithm( findSubSequence(AlgSequence("AthAlgSeq"), "subSequence1"), "NestedAlgo1", 1 ), "Algorithm not in right sequence"
diff --git a/Control/AthenaConfiguration/python/ConfigFlagCatalog.py b/Control/AthenaConfiguration/python/ConfigFlagCatalog.py
deleted file mode 100644
index 3f0f8dfd50d2..000000000000
--- a/Control/AthenaConfiguration/python/ConfigFlagCatalog.py
+++ /dev/null
@@ -1,64 +0,0 @@
-from AthenaConfiguration.ConfigFlags import ConfigFlag, cfgLogMsg
-import sys,os
-
-
-def isGoodFile(pathname):
-    result=False
-    if pathname.endswith("Flags.py") and os.path.isfile(pathname):
-        fp=open(pathname)
-        for l in fp:
-            if "AthenaConfiguration" in l: 
-                result=True
-                break
-            pass
-        fp.close()
-    return result
-        
-
-def buildConfigFlagCatalog():
-
-    result=dict()
-
-    seenFiles=set()
-
-    for p in sys.path:
-        if not os.path.isdir(p): continue
-        for p1 in os.listdir(p):
-            if os.path.isdir(p+"/"+p1):
-                for f in  os.listdir(p+"/"+p1):
-                    if isGoodFile("/".join((p,p1,f))):
-                        cfgFlagFileName=f[:-3] # drop trailing .py
-                        cfgFlagMod=p1
-                        if (cfgFlagMod,cfgFlagFileName) in seenFiles: continue
-                        seenFiles.add((cfgFlagMod,cfgFlagFileName))
-                        #print "Working on module %s.%s" % (cfgFlagMod,cfgFlagFileName)
-                        try:
-                            exec "import %s.%s as cfgMod" %(cfgFlagMod,cfgFlagFileName)
-                        except ImportError:
-                            cfgLogMsg.warning("Failed to import file %s" % "/".join((p,p1,f)))
-                            continue
-                        for cfgObjName in dir(cfgMod):
-                            if not cfgObjName.startswith("_") and not cfgObjName is "ConfigFlag":
-                                cfgObj=getattr(cfgMod,cfgObjName)
-                                #print cfgObj
-                                try:
-                                    if issubclass(cfgObj,ConfigFlag):
-                                        #found a ConfigFlag:
-                                        cfgLogMsg.debug("Found ConfigFlag %s in module %s" % (cfgObjName,cfgMod.__name__))
-                                        if result.has_key(cfgObjName):
-                                            raise KeyError("Error, duplicate job config flag",cfgObjName)
-                                        else:
-                                            result[cfgObjName]=cfgObj
-                                except TypeError: 
-                                    del cfgObj
-                                    pass
-                        del cfgMod
-    cfgLogMsg.info("Build catalog of configuration flags with %i entries" % len(result))
-    return result
-
-
-configFlagCatalog=buildConfigFlagCatalog()
-
-
-if __name__=="__main__":
-    print buildConfigFlagCatalog()
diff --git a/Control/AthenaConfiguration/python/ConfigFlags.py b/Control/AthenaConfiguration/python/ConfigFlags.py
deleted file mode 100644
index 613b1a32c4e1..000000000000
--- a/Control/AthenaConfiguration/python/ConfigFlags.py
+++ /dev/null
@@ -1,120 +0,0 @@
-from copy import deepcopy
-from AthenaConfiguration.CfgLogMsg import cfgLogMsg
-
-class ConfigFlag(object):
-    def __init__(self,initialValue=None):
-        self._value=initialValue
-        self._alreadySet=False
-        pass
-
-   
-    def set_Value(self,newvalue):
-        if not self._alreadySet:
-            self._value=newvalue
-            self._alreadySet=True
-            return True
-        else:
-            print("Config Flag '%s' already set" % self.__class__.__name__)
-            return False
-
-    def get_Value(self):
-        return deepcopy(self._value)
-
-    def __call__(self):
-        return self.get_Value()  
-    
-    def wasSet(self):
-        return self._alreadySet
-
-
-class pseudomodule(object):
-    def __init__(self,flagsContainer,upstream):
-        self._fc=flagsContainer
-        self._location=upstream
-    
-    def __getattr__(self,nextLevel):
-        newloc=self._location+"."+nextLevel
-        #print "NewLoc=",newloc
-        if len(newloc.split("."))==3:
-            return self._fc.get(newloc)
-        else:
-            return pseudomodule(self._fc,newloc)
-
-
-
-class ConfigFlagContainer(object):
-    def __init__(self,otherFlags=None):
-        if otherFlags is None:
-            self._flagdict=dict()
-        else:
-            self._flagdict=deepcopy(otherFlags._flagdict)
-
-    def importFlag(self,fullname):
-        if len(fullname.split("."))==1:
-            from AthenaConfiguration.ConfigFlagCatalog import configFlagCatalog
-            #abbrevated path, try get the flag from the catalog
-            if configFlagCatalog.has_key(fullname):
-                cfgLogMsg.debug("Getting flag %s for flag-catalog" % fullname)
-                return configFlagCatalog[fullname]
-            else:
-                raise KeyError("Flag '%s' is not known")
-            pass
-        
-        elif len(fullname.split("."))==3:
-            (p,m,f)=fullname.split(".")
-            cfgLogMsg.debug("Importing flag %s from module %s.%s" % (f,p,m))
-            exec "import %s.%s as newmodule" % (p,m)
-            if not hasattr(newmodule,f):
-                raise ImportError("Module %s.%s has no class called %s" % (p,m,f))
-
-            flagclass=getattr(newmodule,f)
-            if not issubclass(flagclass,ConfigFlag):
-                raise TypeError("Class %s is not a subclass of ConfigFlag" % f)
-            return flagclass
-        else:
-            raise KeyError("Flag name format is <package>.<module>.<flag>")
-        pass
-    
-    def get(self,name):
-        if not self._flagdict.has_key(name):
-            newFlag_t=self.importFlag(name)
-            newFlag=newFlag_t()
-
-            #"Simple"-flags have no getDefault function but a _defaultvalue attr
-            if hasattr(newFlag_t,'_defaultvalue'):
-                newFlag._value=newFlag_t._defaultvalue
-            if hasattr(newFlag,"getDefault"):
-                newFlag._value=newFlag.getDefault(self)
-            self._flagdict[name]=newFlag
-            pass
-        f=self._flagdict[name]
-        return f.get_Value()
-
-    def set(self,name,value):
-        if not self._flagdict.has_key(name):
-            newFlag=self.importFlag(name)
-            self._flagdict[name]=newFlag()
-        return self._flagdict[name].set_Value(value)
-
-    def dump(self):
-        print "Content of ConfigFlagContainer:"
-        for n,f in self._flagdict.iteritems():
-            state = "(  set  )" if f.wasSet() else "(default)"
-            print "  ",n,state,":",f.get_Value()
-
-
-
-#Decorator to emulate pass-by-value behavior of flags
-def cloneflags( configFunc ):
-    def copied_flags( *args ):
-        cargs =  [ deepcopy( a ) if issubclass(a,ConfigFlagContainer) else a for a in args ]
-
-        return configFunc( *cargs )
-    return copied_flags
-
-
-
-#A function returning a class to create a job config-class in one line
-def makeFlag(name, defaultvalue,doc=None):
-    return type(name,(ConfigFlag,),{'_defaultvalue':defaultvalue,'__doc__':doc})
-
diff --git a/Control/AthenaConfiguration/python/GlobalFlags.py b/Control/AthenaConfiguration/python/GlobalFlags.py
deleted file mode 100644
index d2bb808a5a9d..000000000000
--- a/Control/AthenaConfiguration/python/GlobalFlags.py
+++ /dev/null
@@ -1,29 +0,0 @@
-from AthenaConfiguration.ConfigFlags import ConfigFlag,makeFlag
-from AthenaCommon.SystemOfUnits import TeV
-
-isMC=makeFlag('isMC',True)
-
-isOnline=makeFlag('isOnline',False)
-
-GeoLayout=makeFlag('GeoLayout',"atlas")
-
-projectName=makeFlag("ProjectName","data17_13TeV")     #should autoconfigure! 
-
-InputFiles=makeFlag("InputFiles",["_ATHENA_GENERIC_INPUTFILE_NAME_",])
-
-
-#Beam-related flags:
-bunchSpacing=makeFlag("BunchSpacing",25,"Bunch spacing in ns")
-
-numberOfCollisions=makeFlag("numberOfCollisions",0, "Number of collisions per beam crossing. Should be 2.3*(L/10**33)*(bunchSpacing/25 ns)")
-
-beamType=makeFlag("beamType",'collisions', "Specify data taking type: 'collisions' (default), 'singlebeam','cosmics'")
-
-beamEnergy=makeFlag("beamEnergy",7*TeV)
-
-class estimatedLuminosity(ConfigFlag):
-    def getDefault(self,prevFlags):
-        return 1E33*(prevFlags.get("AthenaConfiguration.GlobalFlags.numberOfCollisions")/2.3)* \
-            (25./prevFlags.get("AthenaConfiguration.GlobalFlags.bunchSpacing"))
-                     
-
diff --git a/Control/AthenaConfiguration/python/testAllConfigFlags.py b/Control/AthenaConfiguration/python/testAllConfigFlags.py
new file mode 100644
index 000000000000..b273dac31a22
--- /dev/null
+++ b/Control/AthenaConfiguration/python/testAllConfigFlags.py
@@ -0,0 +1,44 @@
+from AthenaConfiguration.AthConfigFlags import AthConfigFlags
+acf=AthConfigFlags()
+acf.addFlag("flag1",1)
+acf.addFlag("flag2",2)
+acf.addFlag("flag3", lambda prev: prev.get("flag2")*2 )
+acf.addFlag("flag7", lambda prev: prev.get("flag1")+27)
+
+print acf.get("flag1")
+print acf.get("flag3")
+
+#acf.addFlag("flag4", lambda prev: prev.get("flag5")*2 )
+#acf.addFlag("flag5", lambda prev: prev.get("flag4")*2 )
+#print acf.get("flag4") -> Circular dependency!  
+
+
+acf.addFlag("domain1.flag1","bla")
+acf.addFlag("domain1.flag2",lambda prev: prev.get("domain1.flag1")*2)
+acf.addFlag("domain2.flag1","geh")
+acf.addFlag("domain2.flag2","xyz")
+#acf.addFlag("domain2.flagxxx","will fail")
+
+acf.lock()
+
+print "Initial flag container"
+acf.dump()
+
+acfPrime=acf.clone()
+acfPrime.set("flag3",42)
+
+print "Cloned flag container"
+acfPrime.dump()
+
+acfMod=acf.cloneAndReplace("domain1","domain2")
+
+print "After cloneAndReplace"
+acfMod.dump()
+
+ff=acf.initAll()
+
+print "Frozen dict:" 
+acf.dump()
+
+
+
diff --git a/Control/AthenaConfiguration/python/testConfigFlags.py b/Control/AthenaConfiguration/python/testConfigFlags.py
deleted file mode 100644
index f6a843fd9eaf..000000000000
--- a/Control/AthenaConfiguration/python/testConfigFlags.py
+++ /dev/null
@@ -1,54 +0,0 @@
-from AthenaConfiguration.ConfigFlags import ConfigFlagContainer
-
-
-if __name__=="__main__":
-    cont=ConfigFlagContainer()
-
-
-    #get a 'simple' flag:
-    mc1=cont.get("AthenaConfiguration.GlobalFlags.isMC")
-
-    print "Default value of isMC=",mc1
-
-    #set it to someting different:
-    rv=cont.set("AthenaConfiguration.GlobalFlags.isMC",not mc1)
-    print "Attempt to set isMC:",rv
-
-
-    mc2=cont.get("AthenaConfiguration.GlobalFlags.isMC")
-    print "New value of isMC=",mc2
-
-
-    #Try to set anohter time:
-    rv=cont.set("AthenaConfiguration.GlobalFlags.isMC",mc1)
-    print "Attempt to set isMC:",rv
-    print "New value of isMC=",mc2
-
-
-
-    #get a complicated flag:
-    el1=cont.get("AthenaConfiguration.GlobalFlags.estimatedLuminosity")
-    
-    print "Default value of estimatedLuminosity:",el1
-
-
-    rv=cont.set("AthenaConfiguration.GlobalFlags.estimatedLuminosity",42)
-    print "Attempt to set estimatedLuminosity:",rv
-
-
-    el2=cont.get("AthenaConfiguration.GlobalFlags.estimatedLuminosity")
-    print "New value of estimatedLuminosity:",el2
-
-    rv=cont.set("AthenaConfiguration.GlobalFlags.estimatedLuminosity",142)
-    print "Attempt to set estimatedLuminosity a:",rv
-    el2=cont.get("AthenaConfiguration.GlobalFlags.estimatedLuminosity")
-    print "New value of estimatedLuminosity:",el2
-
-
-    #Get a flag via shorthand description
-
-    be=cont.get("beamEnergy")
-    print "beam energy is",be
-
-
-    cont.dump()
diff --git a/Control/AthenaExamples/AthExHelloWorld/python/HelloWorldConfig.py b/Control/AthenaExamples/AthExHelloWorld/python/HelloWorldConfig.py
index a55d9e6f8c08..d378233e6693 100644
--- a/Control/AthenaExamples/AthExHelloWorld/python/HelloWorldConfig.py
+++ b/Control/AthenaExamples/AthExHelloWorld/python/HelloWorldConfig.py
@@ -3,7 +3,7 @@
 from AthenaCommon.JobProperties import jobproperties
 from AthenaConfiguration.ComponentAccumulator import ComponentAccumulator
 
-def HelloWorldCfg(ConfigFlags=None):
+def HelloWorldCfg():
     result=ComponentAccumulator()
     
     from AthExHelloWorld.AthExHelloWorldConf import HelloAlg
diff --git a/Database/AthenaPOOL/AthenaPoolCnvSvc/python/PoolReadConfig.py b/Database/AthenaPOOL/AthenaPoolCnvSvc/python/PoolReadConfig.py
index 0cb504cb5629..9c31cf4acf33 100644
--- a/Database/AthenaPOOL/AthenaPoolCnvSvc/python/PoolReadConfig.py
+++ b/Database/AthenaPOOL/AthenaPoolCnvSvc/python/PoolReadConfig.py
@@ -1,13 +1,12 @@
-
 from AthenaConfiguration.ComponentAccumulator import ComponentAccumulator
 
-def PoolReadCfg(inputFlags):
+def PoolReadCfg(configFlags):
     """
-    creates A ComponentAccumulator instance containing the 
+    Creates a ComponentAccumulator instance containing the 
     athena services required for POOL file reading
     """
 
-    filenames=inputFlags.get("AthenaConfiguration.GlobalFlags.InputFiles")
+    filenames=configFlags("global.InputFiles")
 
     result=ComponentAccumulator()
 
diff --git a/Database/IOVDbSvc/python/IOVDbAutoCfgFlags.py b/Database/IOVDbSvc/python/IOVDbAutoCfgFlags.py
new file mode 100644
index 000000000000..b6350759deec
--- /dev/null
+++ b/Database/IOVDbSvc/python/IOVDbAutoCfgFlags.py
@@ -0,0 +1,19 @@
+
+
+def getDatabaseInstanceDefault(prevFlags):
+    isMC=prevFlags.get("global.isMC")
+    if (isMC):
+        return "OFLP200"
+    
+    # real-data
+    projectName=prevFlags.get("global.ProjectName")
+    try:
+        year=int(projectName[4:6]);
+    except:
+        cfgLogMsg.warning("Failed to extract year from project tag "+ projectName+". Guessing run2")
+        return "CONDBR2"
+        
+    if (year>13):
+        return "CONDBR2"
+    else:
+        return "COMP200" 
diff --git a/Database/IOVDbSvc/python/IOVDbConfigFlags.py b/Database/IOVDbSvc/python/IOVDbConfigFlags.py
deleted file mode 100644
index 07608e861248..000000000000
--- a/Database/IOVDbSvc/python/IOVDbConfigFlags.py
+++ /dev/null
@@ -1,24 +0,0 @@
-from AthenaConfiguration.ConfigFlags import ConfigFlag,makeFlag
-from AthenaConfiguration.CfgLogMsg import cfgLogMsg
-
-class DatabaseInstance(ConfigFlag):
-    def getDefault(self,prevFlags):
-        isMC=prevFlags.get("AthenaConfiguration.GlobalFlags.isMC")
-        if (isMC):
-            return "OFLP200"
-    
-        # real-data
-        projectName=prevFlags.get("AthenaConfiguration.GlobalFlags.projectName")
-        try:
-            year=int(projectName[4:6]);
-        except:
-            cfgLogMsg.warning("Failed to extract year from project tag "+ projectName+". Guessing run2")
-            return "CONDBR2"
-        
-        if (year>13):
-            return "CONDBR2"
-        else:
-            return "COMP200" 
-    
-GlobalTag=makeFlag("GlobalTag","CONDBR2-BLKPA-2017-05")
-
diff --git a/Database/IOVDbSvc/python/IOVDbSvcConfig.py b/Database/IOVDbSvc/python/IOVDbSvcConfig.py
index 12374f71a28d..b472ff7c0af0 100644
--- a/Database/IOVDbSvc/python/IOVDbSvcConfig.py
+++ b/Database/IOVDbSvc/python/IOVDbSvcConfig.py
@@ -3,7 +3,7 @@
 from AthenaConfiguration.ComponentAccumulator import ComponentAccumulator, ConfigurationError
 import os
 
-def IOVDbSvcCfg(inputFlags):
+def IOVDbSvcCfg(configFlags):
 
     result=ComponentAccumulator()
 
@@ -26,11 +26,11 @@ def IOVDbSvcCfg(inputFlags):
     #m_h_metaDataTool("IOVDbMetaDataTool"),
     #m_h_tagInfoMgr("TagInfoMgr", name),
 
-    isMC=inputFlags.get("AthenaConfiguration.GlobalFlags.isMC")
+    isMC=configFlags.get("global.isMC")
 
     # Set up IOVDbSvc
     iovDbSvc=IOVDbSvc()
-    dbname=inputFlags.get("IOVDbSvc.IOVDbConfigFlags.DatabaseInstance")
+    dbname=configFlags.get("IOVDb.DatabaseInstance")
 
     localfile="sqlite://;schema=mycool.db;dbname="
     iovDbSvc.dbConnection=localfile+dbname
@@ -41,7 +41,7 @@ def IOVDbSvcCfg(inputFlags):
         iovDbSvc.CacheAlign=3
 
 
-    iovDbSvc.GlobalTag=inputFlags.get("IOVDbSvc.IOVDbConfigFlags.GlobalTag")
+    iovDbSvc.GlobalTag=configFlags.get("IOVDb.GlobalTag")
 
     result.addService(iovDbSvc)
 
@@ -74,18 +74,16 @@ def IOVDbSvcCfg(inputFlags):
 
 #Convenience method to add folders:
 
-def addFolders(inputFlags,folderstrings,detDb=None):
-
-    #result=IOVDbSvcCfg(inputFlags)
+def addFolders(configFlags,folderstrings,detDb=None):
     result=ComponentAccumulator()
-    result.executeModule(IOVDbSvcCfg,inputFlags)
+    result.addConfig(IOVDbSvcCfg,configFlags)
 
     
     
     iovDbSvc=result.getService("IOVDbSvc")
     
     if detDb is not None:
-        dbname=inputFlags.get("IOVDbSvc.IOVDbConfigFlags.DatabaseInstance")
+        dbname=configFlags.get("IOVDb.DatabaseInstance")
         if not detDb in _dblist.keys():
             raise ConfigurationError("Error, db shorthand %s not known")
         dbstr="<db>"+_dblist[detDb]+"/"+dbname+"</db>"
@@ -161,3 +159,6 @@ _dblist={
     'CALO_OFL':'COOLOFL_CALO',
     'FWD_OFL':'COOLOFL_FWD'
     }
+
+
+
diff --git a/DetectorDescription/GeoModel/AtlasGeoModel/python/GeoModelConfig.py b/DetectorDescription/GeoModel/AtlasGeoModel/python/GeoModelConfig.py
index 58f061e1595d..8853c7b5ee86 100644
--- a/DetectorDescription/GeoModel/AtlasGeoModel/python/GeoModelConfig.py
+++ b/DetectorDescription/GeoModel/AtlasGeoModel/python/GeoModelConfig.py
@@ -1,7 +1,7 @@
 from AthenaConfiguration.ComponentAccumulator import ComponentAccumulator
 
-def GeoModelCfg(ConfigFlagContainer):
-    version=ConfigFlagContainer.get("AtlasGeoModel.GeoModelFlags.AtlasVersion")
+def GeoModelCfg(configFlags):
+    version=configFlags.get("GeoModel.AtlasVersion")
 
     from AthenaCommon.AppMgr import release_metadata
     rel_metadata = release_metadata()
diff --git a/DetectorDescription/GeoModel/AtlasGeoModel/python/GeoModelFlags.py b/DetectorDescription/GeoModel/AtlasGeoModel/python/GeoModelFlags.py
deleted file mode 100644
index aee79e379807..000000000000
--- a/DetectorDescription/GeoModel/AtlasGeoModel/python/GeoModelFlags.py
+++ /dev/null
@@ -1,4 +0,0 @@
-from AthenaConfiguration.ConfigFlags import ConfigFlag,makeFlag
-
-AtlasVersion=makeFlag("AtlasVersion","ATLAS-R2-2016-01-00-01")
-
diff --git a/DetectorDescription/GeoModel/AtlasGeoModel/python/LArGMConfig.py b/DetectorDescription/GeoModel/AtlasGeoModel/python/LArGMConfig.py
deleted file mode 100644
index a0de2681710c..000000000000
--- a/DetectorDescription/GeoModel/AtlasGeoModel/python/LArGMConfig.py
+++ /dev/null
@@ -1,11 +0,0 @@
-from AthenaConfiguration.ComponentAccumulator import ComponentAccumulator
-from AtlasGeoModel.GeoModelConfig import GeoModelCfg
-
-def LArGMCfg():
-    result=GeoModelCfg()
-    from LArGeoAlgsNV.LArGeoAlgsNVConf import LArDetectorToolNV
-    gm=result.getService("GeoModelSvc")[0]
-    gm.DetectorTools.append(LArDetectorToolNV())
-
-    return result
-
diff --git a/LArCalorimeter/LArGeoModel/LArGeoAlgsNV/python/LArGMConfig.py b/LArCalorimeter/LArGeoModel/LArGeoAlgsNV/python/LArGMConfig.py
index 64382a3b1814..2eff7b7a9c58 100644
--- a/LArCalorimeter/LArGeoModel/LArGeoAlgsNV/python/LArGMConfig.py
+++ b/LArCalorimeter/LArGeoModel/LArGeoAlgsNV/python/LArGMConfig.py
@@ -2,23 +2,23 @@ from AthenaConfiguration.ComponentAccumulator import ComponentAccumulator
 from AtlasGeoModel.GeoModelConfig import GeoModelCfg
 from IOVDbSvc.IOVDbSvcConfig import addFolders
 
-def LArGMCfg(ConfigFlags):
+def LArGMCfg(configFlags):
     result=ComponentAccumulator()
     
-    result.executeModule(GeoModelCfg,ConfigFlags)
+    result.addConfig(GeoModelCfg,configFlags)
 
-    doAlignment=ConfigFlags.get("LArGeoAlgsNV.LArGeoModelFlags.doAlign")
+    doAlignment=configFlags("LAr.doAlign")
     
     from LArGeoAlgsNV.LArGeoAlgsNVConf import LArDetectorToolNV
     result.getService("GeoModelSvc").DetectorTools += [ LArDetectorToolNV(ApplyAlignments=doAlignment) ]
 
     if doAlignment:
-        if ConfigFlags.get("AthenaConfiguration.GlobalFlags.isMC"):
+        if configFlags.get("global.isMC"):
             #Monte Carlo case:
-            result.executeModule(addFolders,ConfigFlags,["/LAR/Align","/LAR/LArCellPositionShift"],"LAR_OFL")
+            result.addConfig(addFolders,configFlags,["/LAR/Align","/LAR/LArCellPositionShift"],"LAR_OFL")
         else:
             #Regular offline data processing
-            result.executeModule(addFolders, ConfigFlags,["/LAR/Align","/LAR/LArCellPositionShift"],"LAR_ONL")
+            result.addConfig(addFolders,configFlags,["/LAR/Align","/LAR/LArCellPositionShift"],"LAR_ONL")
 
         
     return result
diff --git a/LArCalorimeter/LArGeoModel/LArGeoAlgsNV/python/LArGeoModelFlags.py b/LArCalorimeter/LArGeoModel/LArGeoAlgsNV/python/LArGeoModelFlags.py
deleted file mode 100644
index 235bfe7e7f21..000000000000
--- a/LArCalorimeter/LArGeoModel/LArGeoAlgsNV/python/LArGeoModelFlags.py
+++ /dev/null
@@ -1,7 +0,0 @@
-from AthenaConfiguration.ConfigFlags import ConfigFlag
-
-class doAlign(ConfigFlag):
-    """ Flag to activate LAr Alignment
-    """  
-    def getDefault(self,prevFlags):
-        return prevFlags.get("AthenaConfiguration.GlobalFlags.GeoLayout")=="atlas"
diff --git a/TileCalorimeter/TileGeoModel/python/TileGMConfig.py b/TileCalorimeter/TileGeoModel/python/TileGMConfig.py
index 3fbee8787186..917e65ac7e6f 100644
--- a/TileCalorimeter/TileGeoModel/python/TileGMConfig.py
+++ b/TileCalorimeter/TileGeoModel/python/TileGMConfig.py
@@ -1,10 +1,10 @@
 from AthenaConfiguration.ComponentAccumulator import ComponentAccumulator
 from AtlasGeoModel.GeoModelConfig import GeoModelCfg
 
-def TileGMCfg(ConfigFlags):
+def TileGMCfg(configFlags):
     result=ComponentAccumulator()
     
-    result.executeModule(GeoModelCfg,ConfigFlags)
+    result.addConfig(GeoModelCfg,configFlags)
 
     from TileGeoModel.TileGeoModelConf import TileDetectorTool
     result.getService("GeoModelSvc").DetectorTools += [ TileDetectorTool() ]
-- 
GitLab