diff --git a/Calorimeter/CaloRec/python/CaloCellRecConfig.py b/Calorimeter/CaloRec/python/CaloCellRecConfig.py
new file mode 100644
index 0000000000000000000000000000000000000000..3c994f33d861c6d8ef1b5fc87e4366f9ba2f6c1d
--- /dev/null
+++ b/Calorimeter/CaloRec/python/CaloCellRecConfig.py
@@ -0,0 +1,851 @@
+# Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
+
+from AthenaConfiguration.ComponentAccumulator import ComponentAccumulator
+from AthenaConfiguration.ConfigFlags import cloneflags
+
+@cloneflags
+def CaloCellRecCfg(ConfigFlags):
+    result=ComponentAccumulator()
+    
+    from CaloRec.CaloRecConf import CaloCellMaker    
+    from CaloRec.CaloRecConf import CaloCellContainerCorrectorTool
+    theCaloCellMaker=CaloCellMaker()
+    
+    from LArCellRec.LArCellRecConf import LArCellBuilderFromLArRawChannelTool     
+    theCaloCellMaker=CaloCellMaker()
+
+    theCaloCellMaker.CaloCellMakerToolNames += [theLArCellBuilder]
+
+
+    if ConfigFlags.get("CaloRec.CaloCellCfgFlags.doLArCellEmMisCalib"):
+        from LArCellRec.LArCellRecConf import LArCellEmMiscalib
+        theLArCellEmMiscalib = LArCellEmMiscalib("LArCellEmMiscalib")
+        
+        from CaloIdentifier import SUBCALO
+        theMisCalibTool = CaloCellContainerCorrectorTool("MisCalibTool",
+                                                         CaloNums=[ SUBCALO.LAREM ],
+                                                         CellCorrectionToolNames=[ theLArCellEmMiscalib])        
+
+        pass 
+
+    doHVCorr=ConfigFlags.get("CaloRec.CaloCellCfgFlags.doHVCorr")
+
+    if doHVCorr:
+        theHVCorrTool = CaloCellContainerCorrectorTool("HVCorrTool",
+                                                       CaloNums=[ SUBCALO.LAREM, SUBCALO.LARHEC, SUBCALO.LARFCAL ],
+                                                       CellCorrectionToolNames=[ theLArCellHVCorr])
+        
+
+    from CaloRec.CaloRecConf import CaloCellContainerFinalizerTool     
+    theCaloCellContainerFinalizerTool=CaloCellContainerFinalizerTool()
+    theCaloCellMaker += theCaloCellContainerFinalizerTool
+    theCaloCellMaker.CaloCellMakerToolNames += [theCaloCellContainerFinalizerTool ]
+        
+    result.addEventAlgo(theCaloCellMaker)
+
+
+
+# specifies Calo cell making
+# so far only handle the RawChannel->CaloCell step
+# not all possibility of CaloCellMaker_jobOptions.py integrated yet
+from AthenaCommon.Constants import *
+from RecExConfig.Configured import Configured
+from AthenaCommon.AthenaCommonFlags import athenaCommonFlags
+from RecExConfig.RecFlags import rec
+
+class CaloCellGetter (Configured)  :
+    _outputType = "CaloCellContainer"
+    _output = { _outputType : "AllCalo" }
+
+        
+    def configure(self):
+        from AthenaCommon.Logging import logging
+        mlog = logging.getLogger('CaloCellGetter::configure:')
+        mlog.info ('entering')        
+
+        doStandardCellReconstruction = True
+        from CaloRec.CaloCellFlags import jobproperties
+        
+        if not jobproperties.CaloCellFlags.doFastCaloSim.statusOn:
+            doFastCaloSim = False
+            mlog.info("doFastCaloSim not set, so not using it")
+        else:
+            doFastCaloSim = jobproperties.CaloCellFlags.doFastCaloSim()
+            if doFastCaloSim:
+                mlog.info("doFastCaloSim requested")
+                doStandardCellReconstruction = False
+                if jobproperties.CaloCellFlags.doFastCaloSimAddCells():
+                    doStandardCellReconstruction = True
+                    mlog.info("doFastCaloSimAddCells requested: FastCaloSim is added to fullsim calorimeter")
+                else:    
+                    mlog.info("doFastCaloSimAddCells not requested: Stand alone FastCaloSim is running")
+            else:    
+                mlog.info("doFastCaloSim explicitly not requested")
+
+
+
+        # get handle to upstream object
+        # handle tile
+
+        if doStandardCellReconstruction:
+            # handle LAr
+            import traceback
+            try:
+                from LArROD.LArRODFlags import larRODFlags
+                from AthenaCommon.GlobalFlags import globalflags
+                if larRODFlags.readDigits() and globalflags.DataSource() == 'data':
+                    from AthenaCommon.KeyStore import CfgItemList
+                    CfgItemList("KeyStore_inputFile").removeItem("LArRawChannelContainer#LArRawChannels")
+                if (not larRODFlags.readDigits()) and globalflags.InputFormat() == 'bytestream':
+                    from AthenaCommon.AppMgr import ServiceMgr as svcMgr
+                    try:
+                        if not "LArRawChannelContainer/LArRawChannels" in svcMgr.ByteStreamAddressProviderSvc.TypeNames:
+                            svcMgr.ByteStreamAddressProviderSvc.TypeNames += ["LArRawChannelContainer/LArRawChannels"]
+                    except:
+                        mlog.warning("Cannot remove LArRawChannelContainer/LArRawChannels from bytestream list")
+                from LArROD.LArRawChannelGetter import LArRawChannelGetter
+                theLArRawChannelGetter = LArRawChannelGetter()
+            except:
+                mlog.error("could not get handle to LArRawChannel Quit")
+                print traceback.format_exc()
+                return False
+
+            if not theLArRawChannelGetter.usable():
+                if not self.ignoreConfigError():
+                    mlog.error("LArRawChannelGetter unusable. Quit.")
+                    return False
+                else:
+                    mlog.error("LArRawChannelGetter unusable. Continue nevertheless")
+        
+        # writing of thinned digits
+        if jobproperties.CaloCellFlags.doLArThinnedDigits.statusOn and jobproperties.CaloCellFlags.doLArThinnedDigits():
+            from AthenaCommon.GlobalFlags import globalflags
+            if globalflags.DataSource() == 'data':
+                try:
+                    from LArROD.LArDigits import DefaultLArDigitThinner
+                    LArDigitThinner = DefaultLArDigitThinner('LArDigitThinner')  # automatically added to topSequence
+                    LArDigitThinner.InputContainerName = "FREE"
+                    LArDigitThinner.OutputContainerName = "LArDigitContainer_Thinned"
+                except Exception:
+                    treatException("Problem with LArDigitThinner ")
+
+        # now configure the algorithm, part of this could be done in a separate class
+        # cannot have same name
+        try:        
+            from CaloRec.CaloRecConf import CaloCellMaker                
+        except:
+            mlog.error("could not import CaloRec.CaloCellMaker")
+            print traceback.format_exc()
+            return False
+
+        theCaloCellMaker = CaloCellMaker()
+        self._CaloCellMakerHandle = theCaloCellMaker ;
+
+        from AthenaCommon.AppMgr import ToolSvc
+
+        if doStandardCellReconstruction:
+            # configure CaloCellMaker here
+            # check LArCellMakerTool_jobOptions.py for full configurability 
+            # FIXME 
+
+            from RecExConfig.RecFlags import rec
+
+            if rec.doLArg():
+                try:
+                    from LArCellRec.LArCellRecConf import LArCellBuilderFromLArRawChannelTool
+                    theLArCellBuilder = LArCellBuilderFromLArRawChannelTool()
+                except:
+                    mlog.error("could not get handle to LArCellBuilderFromLArRawChannel Quit")
+                    print traceback.format_exc()
+                    return False
+
+                if jobproperties.CaloCellFlags.doLArCreateMissingCells():
+                    # bad channel tools
+                    try:
+                        from LArBadChannelTool.LArBadChannelToolConf import LArBadChanTool
+                        theLArBadChannelTool = LArBadChanTool()
+                    except:
+                        mlog.error("could not access bad channel tool Quit")
+                        print traceback.format_exc()
+                        return False
+                    ToolSvc += theLArBadChannelTool
+                    theLArCellBuilder.addDeadOTX = True
+                    theLArCellBuilder.badChannelTool = theLArBadChannelTool
+
+                # add the tool to list of tool ( should use ToolHandle eventually) 
+                theCaloCellMaker += theLArCellBuilder
+                theCaloCellMaker.CaloCellMakerToolNames += [theLArCellBuilder]
+            
+
+            if rec.doTile():
+
+                from AthenaCommon.GlobalFlags import globalflags
+                if globalflags.DataSource() == 'data' and globalflags.InputFormat() == 'bytestream':
+                    from AthenaCommon.AppMgr import ServiceMgr as svcMgr
+                    try:
+                        svcMgr.ByteStreamCnvSvc.ROD2ROBmap = [ "-1" ]
+                        if not "TileDigitsContainer/TileDigitsCnt" in svcMgr.ByteStreamAddressProviderSvc.TypeNames:
+                            svcMgr.ByteStreamAddressProviderSvc.TypeNames+=["TileBeamElemContainer/TileBeamElemCnt",
+                                                                            "TileDigitsContainer/TileDigitsCnt",
+                                                                            "TileL2Container/TileL2Cnt",
+                                                                            "TileLaserObject/TileLaserObj",
+                                                                            "TileMuonReceiverContainer/TileMuRcvCnt" ]
+                    except:
+                        mlog.warning("Cannot add TileDigitsContainer/TileDigitsCnt et al. to bytestream list")
+
+                    # set options for TileRawChannelMaker
+                    from TileRecUtils.TileRecFlags import jobproperties
+                    jobproperties.TileRecFlags.TileRunType = 1;  # physics run type
+
+                    # reading of digits can be disabled before calling CaloCellGetter
+                    # if this is not done, but digits are not available in BS file
+                    # reading of digits is automatically disabled at start of run
+                    if jobproperties.TileRecFlags.readDigits()                \
+                        and not (jobproperties.TileRecFlags.doTileFlat        \
+                                 or jobproperties.TileRecFlags.doTileFit      \
+                                 or jobproperties.TileRecFlags.doTileFitCool  \
+                                 or jobproperties.TileRecFlags.doTileOpt      \
+                                 or jobproperties.TileRecFlags.doTileOF1      \
+                                 or jobproperties.TileRecFlags.doTileOpt2     \
+                                 or jobproperties.TileRecFlags.doTileOptATLAS \
+                                 or jobproperties.TileRecFlags.doTileMF):
+                        
+                        from AthenaCommon.BeamFlags import jobproperties
+                        # run Opt filter with iterations by default, both for cosmics and collisions before 2011
+                        # run Opt filter without iterations for collisions in 2011 and later 
+                        if not 'doTileOpt2' in dir():
+                            from RecExConfig.AutoConfiguration import GetRunNumber
+                            rn = GetRunNumber()
+                            if rn > 0 and rn < 171194:  
+                                doTileOpt2 = True
+                            elif jobproperties.Beam.beamType()=='collisions':
+                                doTileOpt2 = False; # use OF without iterations for collisions
+                            else:
+                                doTileOpt2 = True; # always run OF with iterations for cosmics
+                                    
+                        # jobproperties.TileRecFlags.calibrateEnergy=True; # use pCb for RawChannels
+                        # please, note that time correction and best phase are used only for collisions
+                        if doTileOpt2:
+                            jobproperties.TileRecFlags.doTileOpt2 = True;  # run optimal filter with iterations
+                            jobproperties.TileRecFlags.doTileOptATLAS = False;  # disable optimal filter without iterations
+                            jobproperties.TileRecFlags.correctAmplitude = False;  # don't do parabolic correction
+                            if jobproperties.Beam.beamType() == 'collisions':
+                                jobproperties.TileRecFlags.correctTime = True;  # apply time correction in physics runs
+                                jobproperties.TileRecFlags.BestPhaseFromCOOL = False;  # best phase is not needed for iterations
+                        else:
+                            jobproperties.TileRecFlags.doTileOpt2 = False;  # disable optimal filter with iterations
+                            jobproperties.TileRecFlags.doTileOptATLAS = True;  # run optimal filter without iterations
+                            jobproperties.TileRecFlags.correctAmplitude = True;  # apply parabolic correction
+                            if jobproperties.Beam.beamType() == 'collisions':
+                                jobproperties.TileRecFlags.correctTime = False;  # don't need time correction if best phase is used
+                                jobproperties.TileRecFlags.BestPhaseFromCOOL = True;  # use best phase stored in DB
+
+                    try:
+                        from TileRecUtils.TileRawChannelGetter import TileRawChannelGetter
+                        theTileRawChannelGetter = TileRawChannelGetter()
+                    except:
+                        mlog.error("could not load TileRawChannelGetter Quit")
+                        print traceback.format_exc()
+                        return False
+
+                    try:
+                        from TileRecAlgs.TileRecAlgsConf import TileDigitsFilter
+                        from AthenaCommon.AlgSequence import AlgSequence
+                        topSequence = AlgSequence()
+                        topSequence += TileDigitsFilter()
+                    except:
+                        mlog.error("Could not configure TileDigitsFilter")
+      
+                try:
+                    from TileRecUtils.TileRecUtilsConf import TileCellBuilder
+                    theTileCellBuilder = TileCellBuilder()
+                    from TileRecUtils.TileRecFlags import jobproperties
+                    theTileCellBuilder.TileRawChannelContainer = jobproperties.TileRecFlags.TileRawChannelContainer()
+
+                    if not hasattr( ToolSvc, "TileBeamInfoProvider" ):
+                        from TileRecUtils.TileRecUtilsConf import TileBeamInfoProvider
+                        ToolSvc += TileBeamInfoProvider()
+
+                    if globalflags.DataSource() == 'data' and globalflags.InputFormat() == 'bytestream':
+                        if jobproperties.TileRecFlags.readDigits():
+                            # everything is already corrected at RawChannel level
+                            theTileCellBuilder.correctTime = False;
+                            theTileCellBuilder.correctAmplitude = False;
+                        else:
+                            ToolSvc.TileBeamInfoProvider.TileRawChannelContainer = "TileRawChannelCnt"
+                            # by default parameters are tuned for opt.filter without iterations
+                            theTileCellBuilder.correctTime = jobproperties.TileRecFlags.correctTime()
+                            theTileCellBuilder.correctAmplitude = jobproperties.TileRecFlags.correctAmplitude()
+                            theTileCellBuilder.AmpMinForAmpCorrection = jobproperties.TileRecFlags.AmpMinForAmpCorrection()
+                            if jobproperties.TileRecFlags.TimeMaxForAmpCorrection() <= jobproperties.TileRecFlags.TimeMinForAmpCorrection() :
+                                from AthenaCommon.BeamFlags import jobproperties
+                                mlog.info("adjusting min/max time of parabolic correction for %s" % jobproperties.Beam.bunchSpacing)
+                                halfBS = jobproperties.Beam.bunchSpacing.get_Value()/2.
+                                jobproperties.TileRecFlags.TimeMinForAmpCorrection = -halfBS
+                                jobproperties.TileRecFlags.TimeMaxForAmpCorrection = halfBS
+                            if jobproperties.TileRecFlags.TimeMaxForAmpCorrection() > jobproperties.TileRecFlags.TimeMinForAmpCorrection():
+                                theTileCellBuilder.TimeMinForAmpCorrection = jobproperties.TileRecFlags.TimeMinForAmpCorrection()
+                                theTileCellBuilder.TimeMaxForAmpCorrection = jobproperties.TileRecFlags.TimeMaxForAmpCorrection()
+
+                    theCaloCellMaker += theTileCellBuilder
+                    theCaloCellMaker.CaloCellMakerToolNames += [theTileCellBuilder]
+                except:    
+                    mlog.error("could not get handle to TileCellBuilder Quit")
+                    print traceback.format_exc()
+                    return False
+             
+
+        if doFastCaloSim:
+            mlog.info ('configuring FastCaloSim here')        
+            
+            try:
+                from FastCaloSim.FastCaloSimConf import EmptyCellBuilderTool
+                theEmptyCellBuilderTool=EmptyCellBuilderTool()
+                theCaloCellMaker += theEmptyCellBuilderTool
+                theCaloCellMaker.CaloCellMakerToolNames += [ theEmptyCellBuilderTool ]
+
+                print theEmptyCellBuilderTool
+                mlog.info("configure EmptyCellBuilderTool worked")
+            except:
+                mlog.error("could not get handle to EmptyCellBuilderTool Quit")
+                print traceback.format_exc()
+                return False
+            
+
+            try:
+                from FastCaloSim.FastCaloSimFactory import FastCaloSimFactory
+                theFastShowerCellBuilderTool=FastCaloSimFactory()
+
+                theCaloCellMaker += theFastShowerCellBuilderTool
+                theCaloCellMaker.CaloCellMakerToolNames += [ theFastShowerCellBuilderTool ]
+                mlog.info("configure FastShowerCellBuilderTool worked")
+            except:
+                mlog.error("could not get handle to FastShowerCellBuilderTool Quit")
+                print traceback.format_exc()
+                return False
+
+
+            doFastCaloSimNoise=jobproperties.CaloCellFlags.doFastCaloSimNoise()
+            if doFastCaloSimNoise:
+                try:
+                    from FastCaloSim.FastCaloSimConf import AddNoiseCellBuilderTool
+                    theAddNoiseCellBuilderTool=AddNoiseCellBuilderTool()
+                    
+                    from CaloTools.CaloNoiseToolDefault import CaloNoiseToolDefault
+                    theCaloNoiseTool = CaloNoiseToolDefault()
+                    from AthenaCommon.AppMgr import ToolSvc
+                    ToolSvc += theCaloNoiseTool
+                    
+                    theAddNoiseCellBuilderTool.CaloNoiseTool=theCaloNoiseTool.getFullName()
+                    
+                    print theAddNoiseCellBuilderTool
+
+                    theCaloCellMaker += theAddNoiseCellBuilderTool
+                    theCaloCellMaker.CaloCellMakerToolNames += [ theAddNoiseCellBuilderTool ]
+                    mlog.info("configure AddNoiseCellBuilderTool worked")
+                except:
+                    mlog.error("could not get handle to AddNoiseCellBuilderTool Quit")
+                    print traceback.format_exc()
+                    return False
+
+
+
+
+        #
+        # CaloCellContainerFinalizerTool : closing container and setting up iterators
+        #
+    
+        from CaloRec.CaloRecConf import CaloCellContainerFinalizerTool     
+        theCaloCellContainerFinalizerTool=CaloCellContainerFinalizerTool()
+        theCaloCellMaker += theCaloCellContainerFinalizerTool
+        theCaloCellMaker.CaloCellMakerToolNames += [theCaloCellContainerFinalizerTool ]
+
+        #
+        # Mergeing of calo cellcontainer with sparse raw channel container with improved energies
+        #
+
+        doLArMerge = False
+        if  globalflags.DataSource() == 'data'  and jobproperties.CaloCellFlags.doLArRawChannelMerge.statusOn and jobproperties.CaloCellFlags.doLArRawChannelMerge():
+            from LArROD.LArRODFlags import larRODFlags
+            if larRODFlags.readDigits() and larRODFlags.keepDSPRaw():
+                doLArMerge = True
+        if doLArMerge:
+            try:
+                from LArCellRec.LArCellRecConf import LArCellMerger
+                theLArCellMerger = LArCellMerger()
+            except:
+                mlog.error("could not get handle to LArCellMerge Quit")
+                print traceback.format_exc()
+                return False
+            theLArCellMerger.RawChannelsName = larRODFlags.RawChannelFromDigitsContainerName()
+            theCaloCellMaker += theLArCellMerger
+            theCaloCellMaker.CaloCellMakerToolNames += [theLArCellMerger]
+
+
+        #
+        # masking of noisy and sporadic noisy cells in LAr
+        #
+
+        doNoiseMask = False
+        if jobproperties.CaloCellFlags.doLArNoiseMasking.statusOn and jobproperties.CaloCellFlags.doLArNoiseMasking():
+            doNoiseMask = True
+        doSporadicMask = False
+        if jobproperties.CaloCellFlags.doLArSporadicMasking.statusOn and jobproperties.CaloCellFlags.doLArSporadicMasking():
+            doSporadicMask = True
+   
+        if doNoiseMask or doSporadicMask :
+            try:
+                from LArCellRec.LArCellRecConf import LArCellNoiseMaskingTool
+                theLArCellNoiseMaskingTool = LArCellNoiseMaskingTool()
+            except:
+                mlog.error("could not get handle to LArCellNoiseMaskingTool Quit")
+                print traceback.format_exc()
+                return False
+
+            # bad channel tools
+            try:
+                from LArBadChannelTool.LArBadChannelToolConf import LArBadChanTool
+                theLArBadChannelTool = LArBadChanTool()
+            except:
+                mlog.error("could not access bad channel tool Quit")
+                print traceback.format_exc()
+                return False
+            ToolSvc += theLArBadChannelTool
+
+            if doSporadicMask:
+                try:
+                    from LArBadChannelTool.LArBadChannelToolConf import LArBadChannelMasker
+                    theLArSporadicNoiseMasker = LArBadChannelMasker("LArSporadicNoiseMasker")
+                except:
+                    mlog.error("could not access bad channel tool Quit")
+                    print traceback.format_exc()
+                    return False
+                theLArSporadicNoiseMasker.TheLArBadChanTool = theLArBadChannelTool
+                theLArSporadicNoiseMasker.DoMasking = True
+                theLArSporadicNoiseMasker.ProblemsToMask = ["sporadicBurstNoise"]
+                ToolSvc += theLArSporadicNoiseMasker
+                theLArCellNoiseMaskingTool.MaskingSporadicTool = theLArSporadicNoiseMasker
+
+            if doNoiseMask:
+                try:
+                    from LArBadChannelTool.LArBadChannelToolConf import LArBadChannelMasker
+                    theLArNoiseMasker = LArBadChannelMasker("LArNoiseMasker")
+                except:
+                    mlog.error("could not access bad channel tool Quit")
+                    print traceback.format_exc()
+                    return False
+                theLArNoiseMasker.TheLArBadChanTool = theLArBadChannelTool
+                theLArNoiseMasker.DoMasking=True
+                theLArNoiseMasker.ProblemsToMask= ["highNoiseHG","highNoiseMG","highNoiseLG","deadReadout","deadPhys"]
+                ToolSvc+=theLArNoiseMasker
+                theLArCellNoiseMaskingTool.MaskingTool = theLArNoiseMasker
+
+            theLArCellNoiseMaskingTool.maskNoise = doNoiseMask
+            theLArCellNoiseMaskingTool.maskSporadic = doSporadicMask
+            # quality cut for sporadic noise masking
+            theLArCellNoiseMaskingTool.qualityCut=4000
+            theCaloCellMaker += theLArCellNoiseMaskingTool
+            theCaloCellMaker.CaloCellMakerToolNames += [theLArCellNoiseMaskingTool]
+
+        # 
+        #  masking of Feb problems
+        #
+        doBadFebMasking = False
+        if jobproperties.CaloCellFlags.doLArBadFebMasking.statusOn and jobproperties.CaloCellFlags.doLArBadFebMasking():
+            from AthenaCommon.GlobalFlags import globalflags
+            if globalflags.DataSource() == 'data':
+                doBadFebMasking = True
+
+        if doBadFebMasking:
+            try:
+                from LArCellRec.LArCellRecConf import LArBadFebMaskingTool
+                theLArBadFebMaskingTool = LArBadFebMaskingTool()
+            except:
+                mlog.error("could not get handle to LArBadFebMaskingTool Quit")
+                print traceback.format_exc()
+                return False
+            theCaloCellMaker += theLArBadFebMaskingTool
+
+            # bad channel tools
+            try:
+                from LArBadChannelTool.LArBadChannelToolConf import LArBadChanTool
+                theLArBadChannelTool = LArBadChanTool()
+            except:
+                mlog.error("could not access bad channel tool Quit")
+                print traceback.format_exc()
+                return False
+            ToolSvc += theLArBadChannelTool
+
+            theLArBadFebMaskingTool.badChannelTool = theLArBadChannelTool
+            theCaloCellMaker.CaloCellMakerToolNames += [theLArBadFebMaskingTool]
+
+        #
+        #  emulate gain pathologies on MC
+        #
+        doGainPathology=False
+        if jobproperties.CaloCellFlags.doLArCellGainPathology.statusOn and jobproperties.CaloCellFlags.doLArCellGainPathology():
+            from AthenaCommon.GlobalFlags import globalflags
+            if globalflags.DataSource() == 'geant4': 
+                doGainPathology=True
+
+        if doGainPathology:
+            try:
+                from LArCellRec.LArCellRecConf import LArCellGainPathology
+                theLArCellGainPathology = LArCellGainPathology()
+            except:
+                mlog.error("could not get handle to LArCellGainPatholog< Quit")
+                print traceback.format_exc()
+                return False
+            theCaloCellMaker += theLArCellGainPathology
+
+            theCaloCellMaker.CaloCellMakerToolNames += [theLArCellGainPathology]
+
+
+
+
+        # lar miscalibration if MC only  (should be done after finalisation)  
+
+        if not jobproperties.CaloCellFlags.doLArCellEmMisCalib.statusOn:
+            # the flag has not been set, so decide a reasonable default
+            # this is the old global flags should use the new one as
+            # soon as monitoring does 
+            from AthenaCommon.GlobalFlags import globalflags
+            if globalflags.DataSource() == 'data':
+                doLArCellEmMisCalib = False
+                mlog.info("jobproperties.CaloCellFlags.doLArMisCalib not set and real data: do not apply LArCellEmMisCalibTool")
+            else:
+                doLArCellEmMisCalib = True
+                mlog.info("jobproperties.CaloCellFlags.doLArMisCalib not set and Monte Carlo: apply LArCellEmMisCalibTool")          
+        else:
+            doLArCellEmMisCalib=jobproperties.CaloCellFlags.doLArCellEmMisCalib()
+            if doLArCellEmMisCalib:
+                mlog.info("LArCellEmMisCalibTool requested")
+            else:    
+                mlog.info("LArCellEmMisCalibTool explicitly not requested")
+                
+        if doLArCellEmMisCalib:        
+            try:
+                from LArCellRec.LArCellRecConf import LArCellEmMiscalib
+                theLArCellEmMiscalib = LArCellEmMiscalib("LArCellEmMiscalib")
+            except:
+                mlog.error("could not get handle to LArCellEmMisCalib Quit")
+                print traceback.format_exc()
+                return False
+
+            # examples on how to change miscalibration. Default values are 0.005 and 0.007 
+            #        theLArCellEmMiscalib.SigmaPerRegion = 0.005;
+            #        theLArCellEmMiscalib.SigmaPerCell = 0.005;
+
+            ToolSvc += theLArCellEmMiscalib
+
+
+            try:
+                from CaloRec.CaloRecConf import CaloCellContainerCorrectorTool
+                from CaloIdentifier import SUBCALO
+                theMisCalibTool = CaloCellContainerCorrectorTool("MisCalibTool",
+                        CaloNums=[ SUBCALO.LAREM ],
+                        CellCorrectionToolNames=[ theLArCellEmMiscalib])
+            except:
+                mlog.error("could not get handle to MisCalibTool Quit")
+                print traceback.format_exc()
+                return False
+
+            theCaloCellMaker+=theMisCalibTool
+            theCaloCellMaker.CaloCellMakerToolNames += [theMisCalibTool]
+
+        #
+        # Pedestal shift correction
+        #
+        doPedestalCorr = False
+        if jobproperties.CaloCellFlags.doPedestalCorr.statusOn:
+           from AthenaCommon.GlobalFlags import globalflags
+           if jobproperties.CaloCellFlags.doPedestalCorr() and (globalflags.DataSource() == 'data' or jobproperties.CaloCellFlags.doPileupOffsetBCIDCorr) : 
+               doPedestalCorr = True
+               mlog.info("Apply cell level pedestal shift correction")
+
+        import os
+        if doPedestalCorr and os.getenv("CMTPATH") and "AtlasTrigger" in os.getenv("CMTPATH"):
+            try:
+                from CaloCellCorrection.CaloCellPedestalCorrDefault import CaloCellPedestalCorrDefault
+                theCaloCellPedestalCorr = CaloCellPedestalCorrDefault()
+                theCaloCellMaker += theCaloCellPedestalCorr
+                theCaloCellMaker.CaloCellMakerToolNames += [theCaloCellPedestalCorr]
+            except:
+                mlog.error("could not get handle to CaloCellPedestalCorr")
+                print traceback.format_exc()
+
+
+        # 
+        # HV correction for offline reprocessing, reading HV from Cool-DCS database
+        #
+        doHVCorr = False
+        from AthenaCommon.DetFlags import DetFlags
+        if DetFlags.dcs.LAr_on():
+            if jobproperties.CaloCellFlags.doLArHVCorr.statusOn:
+               from AthenaCommon.GlobalFlags import globalflags
+               if jobproperties.CaloCellFlags.doLArHVCorr() and globalflags.DataSource() == 'data': 
+                   doHVCorr = True
+                   mlog.info("Redoing HV correction at cell level from COOL/DCS database")
+       
+
+        if doHVCorr:
+            from LArCellRec.LArCellHVCorrDefault import LArCellHVCorrDefault
+            theLArCellHVCorr=LArCellHVCorrDefault()
+            
+            try:
+                from CaloRec.CaloRecConf import CaloCellContainerCorrectorTool
+                from CaloIdentifier import SUBCALO 
+                theHVCorrTool = CaloCellContainerCorrectorTool("HVCorrTool",
+                        CaloNums=[ SUBCALO.LAREM, SUBCALO.LARHEC, SUBCALO.LARFCAL ],
+                        CellCorrectionToolNames=[ theLArCellHVCorr])
+            except:
+                mlog.error("could not get handle to HVCorrTool Quit")
+                print traceback.format_exc()
+                return False
+            theCaloCellMaker += theHVCorrTool
+            theCaloCellMaker.CaloCellMakerToolNames += [theHVCorrTool]
+
+        #
+        # correction to undo online calibration and apply new LAr electronics calibration for ADC->MeV conversion
+        #
+        doLArRecalibration = False
+        if jobproperties.CaloCellFlags.doLArRecalibration.statusOn:
+           from AthenaCommon.GlobalFlags import globalflags
+           from LArConditionsCommon.LArCondFlags import larCondFlags
+           if jobproperties.CaloCellFlags.doLArRecalibration() and globalflags.DataSource() == 'data' and (not larCondFlags.SingleVersion()) :
+               doLArRecalibration = True
+               mlog.info("Redoing LAr electronics calibration for ADC->MeV")
+
+
+        if doLArRecalibration:
+
+            # get tool for cell recalibration
+            try:
+                from LArCellRec.LArCellRecConf import LArCellRecalibration
+                theLArCellRecalibration = LArCellRecalibration("LArCellRecalibration")
+            except:
+                mlog.error("could not get handle to LArCellRecalibration Quit")
+                print traceback.format_exc()
+                return False
+            ToolSvc += theLArCellRecalibration
+
+            # get new ADC2MeVTool
+            try:
+                from LArRecUtils.LArADC2MeVToolDefault import LArADC2MeVToolDefault
+                theLArADC2MeVToolDefault = LArADC2MeVToolDefault()
+            except:
+                mlog.error("Could not get handle to LArADC2MeVToolDefault Quit")
+                print traceback.format_exc()
+                return False
+            ToolSvc += theLArADC2MeVToolDefault
+
+            # get old  ADC2MeVTool
+            try:
+                from LArRecUtils.LArADC2MeVToolOnline import LArADC2MeVToolOnline
+                theLArADC2MeVToolOnline = LArADC2MeVToolOnline()
+            except:
+                mlog.error("Could not get handle to LArADC2MeVToolOnline Quit")
+                print traceback.format_exc()
+                return False
+            ToolSvc += theLArADC2MeVToolOnline
+
+            theLArCellRecalibration.adc2MeVTool = theLArADC2MeVToolDefault
+            theLArCellRecalibration.adc2MeVToolOnline = theLArADC2MeVToolOnline
+
+
+            try:
+                from CaloRec.CaloRecConf import CaloCellContainerCorrectorTool
+                from CaloIdentifier import SUBCALO 
+                theLArRecalibrationTool = CaloCellContainerCorrectorTool("LArRecalibrationTool",
+                        CaloNums=[ SUBCALO.LAREM, SUBCALO.LARHEC, SUBCALO.LARFCAL ],
+                        CellCorrectionToolNames=[ theLArCellRecalibration])
+            except:
+                mlog.error("could not get handle to HVCorrTool Quit")
+                print traceback.format_exc()
+                return False
+            theCaloCellMaker += theLArRecalibrationTool
+            theCaloCellMaker.CaloCellMakerToolNames += [theLArRecalibrationTool]
+
+
+        #
+        # Correction for MinBias energy shift for MC pileup reco
+        #
+        doMinBiasAverage = False
+        if jobproperties.CaloCellFlags.doMinBiasAverage.statusOn:
+           from AthenaCommon.GlobalFlags import globalflags  
+           from AthenaCommon.BeamFlags import jobproperties
+           if jobproperties.CaloCellFlags.doMinBiasAverage() and globalflags.DataSource() == 'geant4' and (not jobproperties.Beam.zeroLuminosity()):
+              doMinBiasAverage = True
+        
+        if doMinBiasAverage:
+
+           try:
+               from CaloTools.CaloMBAverageToolDefault import CaloMBAverageToolDefault
+               theCaloMBAverageTool = CaloMBAverageToolDefault()
+           except:
+               mlog.error("could not get handle to CaloMBAverageTool  Quit")
+               print traceback.format_exc()
+               return False
+           ToolSvc+=theCaloMBAverageTool
+
+           try:
+               from CaloCellCorrection.CaloCellCorrectionConf import CaloCellMBAverageCorr
+               theCaloCellMBAverageCorr = CaloCellMBAverageCorr("CaloCellMBAverageCorr")
+               theCaloCellMBAverageCorr.CaloMBAverageTool = theCaloMBAverageTool
+           except:
+               mlog.error("could not get handle to  CaloCellMBAverageCorr  Quit")
+               print traceback.format_exc()
+               return False
+           ToolSvc +=  theCaloCellMBAverageCorr
+
+           try:
+              from CaloRec.CaloRecConf import CaloCellContainerCorrectorTool
+              from CaloIdentifier import SUBCALO 
+              theMBAverageTool = CaloCellContainerCorrectorTool("MBAverageTool",
+                           CaloNums = [ SUBCALO.NSUBCALO],
+                           CellCorrectionToolNames = [theCaloCellMBAverageCorr] )
+           except:
+               mlog.error("could not get handle to CaloCellContainerCorrectorTool/MBAverageTool Quit")
+               print traceback.format_exc()
+               return False
+
+           theCaloCellMaker += theMBAverageTool
+           theCaloCellMaker.CaloCellMakerToolNames += [theMBAverageTool]
+
+
+        #
+        # Correction for dead cells, where we average the energy density of neighbor cells                     
+        #
+        doNeighborsAverage = False
+        if jobproperties.CaloCellFlags.doDeadCellCorr.statusOn:
+            if jobproperties.CaloCellFlags.doDeadCellCorr():
+                doNeighborsAverage = True
+
+        if doNeighborsAverage :
+           try:
+               from CaloCellCorrection.CaloCellCorrectionConf import CaloCellNeighborsAverageCorr
+               theCaloCellNeighborsAverageCorr = CaloCellNeighborsAverageCorr("CaloCellNeighborsAverageCorr")
+               theCaloCellNeighborsAverageCorr.testMode = False;
+           except:
+               mlog.error("could not get handle to  CaloCellNeighborsAverageCorr  Quit")
+               print traceback.format_exc()
+               return False
+           theCaloCellMaker +=  theCaloCellNeighborsAverageCorr
+           theCaloCellMaker.CaloCellMakerToolNames += [theCaloCellNeighborsAverageCorr]
+
+
+        # 
+        # correction for missing Febs based on L1 readout
+        doLArDeadOTXCorr = False
+        if jobproperties.CaloCellFlags.doLArDeadOTXCorr.statusOn and jobproperties.CaloCellFlags.doLArCreateMissingCells.statusOn :
+           if jobproperties.CaloCellFlags.doLArDeadOTXCorr() and jobproperties.CaloCellFlags.doLArCreateMissingCells() and doStandardCellReconstruction:
+               if rec.doTrigger():
+                   doLArDeadOTXCorr=True
+               else:
+                   mlog.warning("Trigger is switched off. Can't run deadOTX correction.")
+
+        if doLArDeadOTXCorr:
+
+            try:
+                from LArCellRec.LArCellDeadOTXCorrToolDefault import LArCellDeadOTXCorrToolDefault
+                theLArCellDeadOTXCorr = LArCellDeadOTXCorrToolDefault()
+            except:
+                mlog.error("could not get handle to LArCellDeadOTXCorr Quit")
+                print traceback.format_exc()
+
+            theCaloCellMaker += theLArCellDeadOTXCorr
+            theCaloCellMaker.CaloCellMakerToolNames += [theLArCellDeadOTXCorr]
+
+        doCaloEnergyRescaler=False
+        if jobproperties.CaloCellFlags.doCaloCellEnergyCorr() and globalflags.DataSource() == 'data' and not athenaCommonFlags.isOnline():
+            
+            try:
+                from CaloCellCorrection.CaloCellCorrectionConf import CaloCellEnergyRescaler
+                theCCERescalerTool = CaloCellEnergyRescaler()
+                theCCERescalerTool.Folder = "/LAR/CellCorrOfl/EnergyCorr"
+                from IOVDbSvc.CondDB import conddb
+                # conddb.addFolder("","/LAR/CellCorrOfl/EnergyCorr<tag>EnergyScale-00</tag><db>sqlite://;schema=escale.db;dbname=COMP200</db>")
+                conddb.addFolder("LAR_OFL", "/LAR/CellCorrOfl/EnergyCorr")
+                theCaloCellMaker += theCCERescalerTool
+                theCaloCellMaker.CaloCellMakerToolNames += [theCCERescalerTool]
+            except:
+                mlog.error("could not get handle to CaloCellEnergyRescaler Quit")
+                print traceback.format_exc()
+                return False
+            pass
+
+
+        if jobproperties.CaloCellFlags.doCaloCellTimeCorr() and globalflags.DataSource() == 'data' and not athenaCommonFlags.isOnline():
+            try:
+                from CaloRec.CaloRecConf import CaloCellContainerCorrectorTool
+                from CaloCellCorrection.CaloCellCorrectionConf import CaloCellTimeCorrTool
+                theLArTimeCorr = CaloCellTimeCorrTool()
+                theLArTimeCorr.Folder = "/LAR/TimeCorrectionOfl/CellTimeOffset"
+                ToolSvc += theLArTimeCorr
+                from IOVDbSvc.CondDB import conddb
+                # conddb.addFolder("","/LAR/TimeCorrectionOfl/CellTimeOffset<tag>LARTimeCorrectionOflCellTimeOffset-empty</tag><db>sqlite://;schema=timecorr.db;dbname=COMP200</db>")
+                conddb.addFolder("LAR_OFL", "/LAR/TimeCorrectionOfl/CellTimeOffset")
+                theCaloTimeCorrTool = CaloCellContainerCorrectorTool("LArTimeCorrTool",
+                                                                   CellCorrectionToolNames=[theLArTimeCorr]
+                                                                   )
+                theCaloCellMaker += theCaloTimeCorrTool
+                theCaloCellMaker.CaloCellMakerToolNames += [theCaloTimeCorrTool]
+                
+            except:
+                mlog.error("could not get handle to CaloCellTimeCorrTool Quit")
+                print traceback.format_exc()
+                return False
+  
+            pass
+    
+        
+        # make lots of checks (should not be necessary eventually)
+        # to print the check add:
+
+        from CaloRec.CaloRecConf import CaloCellContainerCheckerTool   
+        theCaloCellContainerCheckerTool = CaloCellContainerCheckerTool()     
+        # FIXME
+        # theCaloCellContainerCheckerTool.OutputLevel=DEBUG
+
+        theCaloCellMaker += theCaloCellContainerCheckerTool
+        theCaloCellMaker.CaloCellMakerToolNames += [theCaloCellContainerCheckerTool] 
+
+
+        #
+
+        # sets output key  
+        theCaloCellMaker.CaloCellsOutputName=self.outputKey()        
+
+
+        # register output in objKeyStore
+        from RecExConfig.ObjKeyStore import objKeyStore
+
+        objKeyStore.addStreamESD(self.outputType(),self.outputKey())
+
+
+        
+        # now add algorithm to topSequence
+        # this should always come at the end
+
+        mlog.info(" now adding CaloCellMaker to topSequence")        
+
+        from AthenaCommon.AlgSequence import AlgSequence
+        topSequence = AlgSequence()
+
+        topSequence += theCaloCellMaker ;
+        
+        return True
+
+    def CaloCellMakerHandle(self):
+        return self._CaloCellMakerHandle
+
+   
+# would work only if one output object type
+    def outputKey(self):
+        return self._output[self._outputType]
+
+    def outputType(self):
+        return self._outputType
+
+
+
diff --git a/Calorimeter/CaloRec/python/CaloRecConfigFlags.py b/Calorimeter/CaloRec/python/CaloRecConfigFlags.py
new file mode 100644
index 0000000000000000000000000000000000000000..a19180204997b5b12896f7e652bffebd1545741c
--- /dev/null
+++ b/Calorimeter/CaloRec/python/CaloRecConfigFlags.py
@@ -0,0 +1,27 @@
+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
+    """  
+    @staticmethod
+    def getDefault(prevFlags):
+        return not prevFlags.get("AthenaConfiguration.GlobalConfigFlags.isMC")
+       
+class doLArCellEmMisCalib(ConfigFlag):
+    """ Flag to activate artificial miscalibration of simulated cell energies
+    """
+    @staticmethod
+    def getDefault(prevFlags):
+        return prevFlags.get("AthenaConfiguration.GlobalConfigFlags.isMC")
+       
+
+class fixedLumiForNoise(ConfigFlag):
+    """Hardcoded luminosity value for pileup noise scaling"""
+    @staticmethod
+    def getDefault(prevFlags):
+        return -1
+
+class useCaloNoiseLumi(ConfigFlag):
+    @staticmethod
+    def getDefault(prevFlags):
+        return True
diff --git a/Calorimeter/CaloRec/python/CaloTopoClusterConfig.py b/Calorimeter/CaloRec/python/CaloTopoClusterConfig.py
index bb3be1730ffed3a66ebbb619a803fd710cc7d3d1..c569a5ef713c2fe6e56435baef42ce72eb609c53 100644
--- a/Calorimeter/CaloRec/python/CaloTopoClusterConfig.py
+++ b/Calorimeter/CaloRec/python/CaloTopoClusterConfig.py
@@ -1,25 +1,28 @@
 # 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=None):
+def CaloTopoClusterCfg(inputFlags):
     result=ComponentAccumulator()
     
+    from LArGeoAlgsNV.LArGMConfig import LArGMCfg
+    from TileGeoModel.TileGMConfig import TileGMCfg
+    from CaloTools.CaloNoiseToolConfig import CaloNoiseToolCfg
     
     #from CaloUtils.CaloUtilsConf import CaloLCClassificationTool, CaloLCWeightTool, CaloLCOutOfClusterTool, CaloLCDeadMaterialTool
 
-    #from CaloClusterCorrection.CaloClusterCorrectionConf import CaloClusterLocalCalib
-    #from CaloClusterCorrection.CaloClusterCorrectionConf import CaloClusterCellWeightCalib
-
-
+    from CaloClusterCorrection.CaloClusterCorrectionConf import CaloClusterLocalCalib
+    from CaloClusterCorrection.CaloClusterCorrectionConf import CaloClusterCellWeightCalib
     from CaloRec.CaloRecConf import CaloTopoClusterMaker, CaloTopoClusterSplitter, CaloClusterMomentsMaker, CaloClusterMaker, CaloClusterSnapshot #, CaloClusterLockVars, CaloClusterPrinter
 
     
+    result.executeModule(LArGMCfg,inputFlags)
+    result.executeModule(TileGMCfg,inputFlags)    
+    result.executeModule(CaloNoiseToolCfg,inputFlags)
 
-    #from CaloTools.CaloNoiseToolDefault import CaloNoiseToolDefault
-    #theCaloNoiseTool = CaloNoiseToolDefault()
+    theCaloNoiseTool=result.getPublicTool("CaloNoiseTool")
 
     # maker tools
     TopoMaker = CaloTopoClusterMaker("TopoMaker")
@@ -38,7 +41,7 @@ def CaloTopoClusterCfg(inputFlags=None):
                                    "TileExt0", "TileExt1", "TileExt2",
                                    "TileGap1", "TileGap2", "TileGap3",
                                    "FCAL0", "FCAL1", "FCAL2"] 
-    #TopoMaker.CaloNoiseTool=theCaloNoiseTool
+    TopoMaker.CaloNoiseTool=theCaloNoiseTool
     TopoMaker.UseCaloNoiseTool=True
     TopoMaker.UsePileUpNoise=True
     TopoMaker.NeighborOption = "super3D"
@@ -56,7 +59,7 @@ def CaloTopoClusterCfg(inputFlags=None):
     TopoMaker.SeedCutsInAbsE                 = True
     TopoMaker.ClusterEtorAbsEtCut            = 0.0*MeV
     # use 2-gaussian or single gaussian noise for TileCal
-    TopoMaker.TwoGaussianNoise = inputFlags.CaloTopoClusterFlags.doTwoGaussianNoise()
+    TopoMaker.TwoGaussianNoise = inputFlags.get("CaloRec.CaloTopoClusterConfigFlags.doTwoGaussianNoise")
         
     TopoSplitter = CaloTopoClusterSplitter("TopoSplitter")
     # cells from the following samplings will be able to form local
@@ -78,7 +81,7 @@ def CaloTopoClusterCfg(inputFlags=None):
                                            "FCAL1","FCAL2"]
     TopoSplitter.ShareBorderCells = True
     TopoSplitter.RestrictHECIWandFCalNeighbors  = False
-    TopoSplitter.WeightingOfNegClusters = inputFlags.CaloTopoClusterFlags.doTreatEnergyCutAsAbsolute()
+    TopoSplitter.WeightingOfNegClusters = inputFlags.get("CaloRec.CaloTopoClusterConfigFlags.doTreatEnergyCutAsAbsolute")
     #
     # the following options are not set, since these are the default
     # values
@@ -89,10 +92,30 @@ def CaloTopoClusterCfg(inputFlags=None):
         
 
     CaloTopoCluster=CaloClusterMaker("CaloTopoCluster")
-    CaloTopoCluster.ClustersOutputName="CaloCalTopoClusters"    # cluster maker
+    CaloTopoCluster.ClustersOutputName="CaloCalTopoClusters"   
 
     CaloTopoCluster.ClusterMakerTools = [TopoMaker, TopoSplitter]
             
     result.addEventAlgo(CaloTopoCluster)
     return result
 
+
+
+if __name__=="__main__":
+    cfg=ComponentAccumulator()
+
+    cfgFlags=ConfigFlagContainer()
+    cfgFlags.set("AthenaConfiguration.GlobalConfigFlags.isMC",False)
+    cfgFlags.set("AthenaConfiguration.GlobalConfigFlags.InputFiles",["myESD.pool.root"])
+
+    from AthenaPoolCnvSvc.PoolReadConfig import PoolReadCfg
+    cfg.executeModule(PoolReadCfg,cfgFlags)
+    
+    cfg.executeModule(CaloTopoClusterCfg,cfgFlags)
+
+    cfg.getEventAlgo("CaloTopoCluster").ClustersOutputName="CaloCalTopoClustersNew" 
+
+    f=open("CaloTopoCluster.pkl","w")
+    cfg.store(f)
+    f.close()
+    
diff --git a/Calorimeter/CaloRec/python/CaloTopoClusterConfigFlags.py b/Calorimeter/CaloRec/python/CaloTopoClusterConfigFlags.py
new file mode 100644
index 0000000000000000000000000000000000000000..e8e671dc7702f04f86c9b8fac12a015a2683d075
--- /dev/null
+++ b/Calorimeter/CaloRec/python/CaloTopoClusterConfigFlags.py
@@ -0,0 +1,13 @@
+from AthenaConfiguration.ConfigFlags import ConfigFlag
+
+class doTwoGaussianNoise(ConfigFlag):
+    @staticmethod
+    def getDefault(prevFlags):
+        return True
+
+
+class doTreatEnergyCutAsAbsolute(ConfigFlag):
+    @staticmethod
+    def getDefault(prevFlags):
+        return False
+
diff --git a/Calorimeter/CaloRec/python/CaloTopoClusterFlags.py b/Calorimeter/CaloRec/python/CaloTopoClusterFlags.py
index 25cee055a5e2a79972eb421c13fe7c296aba0544..8f842edae0c2983a65dcdaf0205b61390ef3b66e 100644
--- a/Calorimeter/CaloRec/python/CaloTopoClusterFlags.py
+++ b/Calorimeter/CaloRec/python/CaloTopoClusterFlags.py
@@ -1,3 +1,4 @@
+
 # Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
 
 #
diff --git a/Calorimeter/CaloTools/python/CaloNoiseToolConfig.py b/Calorimeter/CaloTools/python/CaloNoiseToolConfig.py
new file mode 100644
index 0000000000000000000000000000000000000000..9996b340a9c660366b2e6888b549adf8058f3453
--- /dev/null
+++ b/Calorimeter/CaloTools/python/CaloNoiseToolConfig.py
@@ -0,0 +1,99 @@
+from AthenaConfiguration.ComponentAccumulator import ComponentAccumulator
+from IOVDbSvc.IOVDbSvcConfig import addFolders
+from CaloTools.CaloToolsConf import CaloNoiseToolDB
+from AthenaConfiguration.CfgLogMsg import cfgLogMsg
+
+def CaloNoiseToolCfg(inputFlags):
+
+    result=ComponentAccumulator()
+
+    isMC=inputFlags.get("AthenaConfiguration.GlobalConfigFlags.isMC")
+    fixedLumi=inputFlags.get("CaloRec.CaloRecConfigFlags.fixedLumiForNoise")
+    useCaloLumi=inputFlags.get("CaloRec.CaloRecConfigFlags.useCaloNoiseLumi")
+    
+    caloNoiseToolDB=CaloNoiseToolDB("CaloNoiseTool")
+
+
+    if inputFlags.get("AthenaConfiguration.GlobalConfigFlags.isOnline"):
+        #online mode:
+        folder  = "/CALO/Noise/CellNoise"
+        result.executeModule(addFolders,inputFlags,folder,'CALO_ONL')
+        caloNoiseToolDB.FolderNames=[folder,]
+        if fixedLumi >= 0 :
+            caloNoiseToolDB.Luminosity = fixedLumi
+            cfgLogMsg.info("online mode: use fixed luminosity for scaling pileup noise: %f"%fixedLumi)
+        else:
+            if useCaloLumi:
+                lumiFolder='/CALO/Noise/PileUpNoiseLumi'
+                result.executeModule(addFolders,inputFlags,lumiFolder,'CALO')
+                caloNoiseToolDB.LumiFolderName = lumiFolder
+                caloNoiseToolDB.Luminosity = -1.
+                cfgLogMsg.info("online mode: use luminosity from /CALO/Noise/PileUpNoiseLumi to scale pileup noise")
+            else:
+                caloNoiseToolDB.Luminosity = 0.
+                mlog.info("online mode: ignore pileup noise")
+                pass
+        result.addPublicTool(caloNoiseToolDB)
+        return result
+
+    #The not-online case:
+    if isMC:
+        if fixedLumi >= 0 :
+            caloNoiseToolDB.Luminosity=fixedLumi
+            cfgLogMsg.info("Luminosity (in 10**33) units used for pileup noise from CaloNoiseFlags : %f" % fixedLumi)
+        else:
+            if useCaloLumi:
+                lumiFolder='/CALO/Ofl/Noise/PileUpNoiseLumi'
+                result.executeModule(addFolders,inputFlags,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")
+                caloNoiseToolDB.Luminosity=estimatedLumi/1e+33
+                cfgLogMsg.info("  Luminosity (in 10**33) units used for pileup noise from global flags: %f"%caloNoiseToolDB.Luminosity)
+
+
+        folders  = (("CALO_OFL","/CALO/Ofl/Noise/CellNoise"),
+                    ("LAR_OFL","/LAR/NoiseOfl/CellNoise"),
+                    ("TILE_OFL","/TILE/OFL02/NOISE/CELL")
+                    ) 
+        pass
+    else: # Real data case:
+        # for luminosity
+        if fixedLumi >= 0 :
+            caloNoiseToolDB.Luminosity = fixedLumi
+            mlog.info("offline mode: use fixed luminosity for scaling pileup noise: %f"%fixedLumi)
+        else :
+            caloNoiseToolDB.Luminosity = -1
+            if useCaloLumi:
+                lumiFolder='/CALO/Ofl/Noise/PileUpNoiseLumi'
+                result.executeModule(addFolders,inputFlags,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');
+                cfgLogMsg.info("offline mode: use luminosity = f(Lumiblock) to scale pileup noise")
+                caloNoiseToolDB.LumiFolderName = lumiFolder
+
+
+        folders=[("LAR_OFL","/LAR/NoiseOfl/CellNoise"),
+                 ("TILE_OFL","/TILE/OFL02/NOISE/CELL")
+                 ]
+        
+        if inputFlags.get("IOVDbSvc.IOVDbConfigFlags.DatabaseInstance")=="COMP200":
+            folders.append(("CALO_OFL","/CALO/Ofl/Noise/CellNoise")),
+        
+        #Fixme: Add rescaling of noise based on HV! 
+
+
+        pass #end of real data case
+    
+    for (db,fldr) in folders:
+        result.executeModule(addFolders,inputFlags,fldr,db)
+    
+    caloNoiseToolDB.FolderNames=[f[1] for f in folders]    
+
+    result.addPublicTool(caloNoiseToolDB)
+    
+    return result
diff --git a/Control/AthenaCommon/python/Configurable.py b/Control/AthenaCommon/python/Configurable.py
index 93b26633052ec52ee79552fd807166f1462073f5..8c88102befa5620d9e10e8a6813e30f6f3dfa9f2 100755
--- a/Control/AthenaCommon/python/Configurable.py
+++ b/Control/AthenaCommon/python/Configurable.py
@@ -4,13 +4,12 @@
 # Author: Wim Lavrijsen (WLavrijsen@lbl.gov)
 # Author: Martin Woudstra (Martin.Woudstra@cern.ch)
 
-import copy, types, os, weakref
+import copy, types, os, weakref,sys
 import ConfigurableMeta
 
 # Note: load iProperty etc. from GaudiPython only as-needed
 import GaudiKernel.GaudiHandles as GaudiHandles
 
-
 ### data ---------------------------------------------------------------------
 __version__ = '3.2.0'
 __author__  = 'Wim Lavrijsen (WLavrijsen@lbl.gov)'
@@ -110,62 +109,63 @@ class Configurable( object ):
          raise NameError( '"%s": type separator "/" no allowed in component name, '\
                           'typename is derived from configurable instead' % name )
 
-    # ordinary recycle case
-      try:
-         conf = cls.configurables[ name ]
-
-       # initialize additional properties, if any
-         for n,v in kwargs.items():
-            try:
-               setattr( conf, n, v )
-            except AttributeError, originalAttributeError:
-             # rather annoying that we have to be somewhat silent here (the
-             # most common cases are 'name' and user kw args to be supplied
-             # to an overridden __init__)
-               log.debug( 'not accepting keyword "%s" as a property', n )
-
-             # now for a completely different can of worms ...
-               acceptableKeyWord = False
-
-             # little helper
-               def flat( classtree ):
-                  if isinstance( classtree, list ) or isinstance( classtree, tuple ):
-                     return [ j for i in classtree for j in flat( i ) ]
-                  else:
-                     return [ classtree ]
-
-             # the following attempts to figure out if the missing attribute
-             # is in fact an acceptable formal function argument to __init__,
-               import inspect
-               allclasses = flat( inspect.getclasstree( [ conf.__class__ ] ) )
-               for confklass in allclasses:
-                  try:
-                   # the following may result in the same init tried several
-                   # times, but we shouldn't be in this loop too often anyway
-                     confinit = getattr( confklass, '__init__' )
-                     if n in confinit.func_code.co_varnames:
-                        log.debug( 'accepting keyword "%s" as an argument for %s.__init__' % (n,confklass.__name__) )
-                        acceptableKeyWord = True
-                        break
-                  except AttributeError:
-                     pass
-
-             # raising here will break the usage of keywords in __init__, but
-             # there don't appear to be such cases in ATLAS yet ...
-               if not acceptableKeyWord:
-                  raise originalAttributeError
-         return conf
-      except KeyError:
-         pass
+      if 'AthenaConfiguration.ComponentAccumulator' not in sys.modules.keys():
+         # ordinary recycle case
+         try:
+            conf = cls.configurables[ name ]
 
-    # the following is purely for debugging support and should realistically bomb
-      try:
-         conf = cls.allConfigurables[ name ]
-         raise TypeError( 'attempt to redefine type of "%s" (was: %s, new: %s)' %
-                          (name,conf.__class__.__name__,cls.__name__) )
-      except KeyError:
-         pass
+          # initialize additional properties, if any
+            for n,v in kwargs.items():
+               try:
+                  setattr( conf, n, v )
+               except AttributeError, originalAttributeError:
+                # rather annoying that we have to be somewhat silent here (the
+                # most common cases are 'name' and user kw args to be supplied
+                # to an overridden __init__)
+                  log.debug( 'not accepting keyword "%s" as a property', n )
+
+                # now for a completely different can of worms ...
+                  acceptableKeyWord = False
+
+                # little helper
+                  def flat( classtree ):
+                     if isinstance( classtree, list ) or isinstance( classtree, tuple ):
+                        return [ j for i in classtree for j in flat( i ) ]
+                     else:
+                        return [ classtree ]
+
+                # the following attempts to figure out if the missing attribute
+                # is in fact an acceptable formal function argument to __init__,
+                  import inspect
+                  allclasses = flat( inspect.getclasstree( [ conf.__class__ ] ) )
+                  for confklass in allclasses:
+                     try:
+                      # the following may result in the same init tried several
+                      # times, but we shouldn't be in this loop too often anyway
+                        confinit = getattr( confklass, '__init__' )
+                        if n in confinit.func_code.co_varnames:
+                           log.debug( 'accepting keyword "%s" as an argument for %s.__init__' % (n,confklass.__name__) )
+                           acceptableKeyWord = True
+                           break
+                     except AttributeError:
+                        pass
+
+                # raising here will break the usage of keywords in __init__, but
+                # there don't appear to be such cases in ATLAS yet ...
+                  if not acceptableKeyWord:
+                     raise originalAttributeError
+            return conf
+         except KeyError:
+            pass
 
+       # the following is purely for debugging support and should realistically bomb
+         try:
+            conf = cls.allConfigurables[ name ]
+            raise TypeError( 'attempt to redefine type of "%s" (was: %s, new: %s)' %
+                             (name,conf.__class__.__name__,cls.__name__) )
+         except KeyError:
+            pass
+      pass #end if not new configuration approach
     # still here: create a new instance ...
       conf = object.__new__( cls )
 
diff --git a/Control/AthenaCommon/python/ConfigurationShelve.py b/Control/AthenaCommon/python/ConfigurationShelve.py
index 751819a4058bb8878036a79b5137d8e38174b998..42a18463e19dc5cb2ebf56355c0db83319a19e61 100644
--- a/Control/AthenaCommon/python/ConfigurationShelve.py
+++ b/Control/AthenaCommon/python/ConfigurationShelve.py
@@ -311,7 +311,10 @@ def loadJobOptionsCatalogue( cfg_fname ):
          # In Gaudi v28, the second argument of the ctor is passed by move,
          # which pyroot doesn't handle correctly.  Do this as a workaround.
          p = gaudi.StringProperty( n, '' )
-         p.fromString(v).ignore()
+         try:
+            p.fromString(v).ignore()
+         except:
+            print "Failed to convert",n,v
 
          if not josvc.addPropertyToCatalogue( client, p ).isSuccess():
             raise RuntimeError( 'could not add property [%s.%s = %s]' % (client, n, v) )
diff --git a/Control/AthenaConfiguration/python/CfgLogMsg.py b/Control/AthenaConfiguration/python/CfgLogMsg.py
new file mode 100644
index 0000000000000000000000000000000000000000..81d3bf805efb07433ceb6ac0ab7cde85a4f2b3ef
--- /dev/null
+++ b/Control/AthenaConfiguration/python/CfgLogMsg.py
@@ -0,0 +1,66 @@
+import os, inspect
+
+class CfgLogMsg():
+
+    def __init__(self,level="info"):
+        self._lvl=self._lvlFromString(level)
+        pass
+
+    
+    def _lvlFromString(self,level):
+        #No ERROR message: Errors reported via exceptions!
+        if (level.lower()=="none"):
+            return 0
+        elif (level.lower()=="warning"):
+            return 1
+        elif (level.lower()=="info"):
+            return 2
+        elif (level.lower()=="debug"):
+            return 3
+        else:
+            raise TypeError('Allowed message levels are only "none", "info" or "debug", got %s' % level)
+        pass
+
+    def setLevel(self,level):
+        self._lvl=self._lvlFromString(level)
+        pass
+
+
+    def warning(self,message):
+        if self._lvl>=1:
+            (callfile,callfunc)=self.getCaller()
+            print "%s:%s  WARN %s" % (callfile,callfunc,message)
+
+    def info(self,message):
+        if self._lvl>=2:
+            (callfile,callfunc)=self.getCaller()
+            print "%s:%s  INFO %s" % (callfile,callfunc,message)
+
+    def debug(self,message):
+        if self._lvl>=3:
+            (callfile,callfunc)=self.getCaller()
+            print "%s:%s  DEBUG %s" % (callfile,callfunc,message)
+
+    def getCaller(self):
+        try:
+            #print inspect.stack()
+            callfile=inspect.stack()[2][1].split("/")[-1]
+            callfunc=inspect.stack()[2][3]
+        except Exception, e:
+            print e 
+            (callfile,callfunc)=("","")
+            pass
+        
+        return (callfile,callfunc)
+        
+
+
+_level=None
+if 'ATH_CFG_MSG_LVL' in os.environ:
+    _level=os.environ["ATH_CFG_MSG_LVL"]
+else:
+    _level="info"
+
+cfgLogMsg=CfgLogMsg(_level)
+
+del _level
diff --git a/Control/AthenaConfiguration/python/ComponentAccumulator.py b/Control/AthenaConfiguration/python/ComponentAccumulator.py
index 9311f3c83031d58718ca0531f3da5f7f3baaf183..68de05236ca151b04bb2814ac7984961b69e1de0 100644
--- a/Control/AthenaConfiguration/python/ComponentAccumulator.py
+++ b/Control/AthenaConfiguration/python/ComponentAccumulator.py
@@ -1,105 +1,150 @@
 # Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
 
 
-from AthenaCommon.Logging import logging
-from AthenaCommon.Configurable import ConfigurableService,ConfigurableAlgorithm
+#from AthenaCommon.Logging import logging
+from AthenaConfiguration.CfgLogMsg import cfgLogMsg
+from AthenaCommon.Configurable import Configurable,ConfigurableService,ConfigurableAlgorithm,ConfigurableAlgTool
 import GaudiKernel.GaudiHandles as GaudiHandles
 import ast
 from collections import defaultdict
+from copy import deepcopy
+
+
+class DeduplicatonFailed(RuntimeError):
+    pass
+
+class ConfigurationError(RuntimeError):
+    pass 
 
 class ComponentAccumulator(object): 
     
     def __init__(self):
-        self._msg=logging.getLogger('ComponentAccumulator')
+        self._msg=cfgLogMsg  #logging.getLogger('ComponentAccumulator')
         self._eventAlgs={}     #Unordered list of event processing algorithms per sequence + their private tools 
         self._conditionsAlgs=[]                #Unordered list of conditions algorithms + their private tools 
         self._services=[]                      #List of service, not yet sure if the order matters here in the MT age
         self._conditionsInput=set()            #List of database folder (as string), eventually passed to IOVDbSvc
         self._eventInputs=set()                #List of items (as strings) to be read from the input (required at least for BS-reading).
         self._outputPerStream={}               #Dictionary of {streamName,set(items)}, all as strings
+
+        #Properties of the ApplicationMgr
+        self._theAppProps=dict()            
+
+        #Backward compatiblity hack: Allow also public tools:
+        self._publicTools=[]
         pass
 
 
     def addEventAlgo(self,algo,sequence="AthAlgSeq"):
         if not isinstance(algo, ConfigurableAlgorithm):
-            self._msg.error("Attempt to add wrong type as event algorithm")
-            #raise exception ..
+            raise TypeError("Attempt to add wrong type as event algorithm")
             pass
 
         if sequence not in self._eventAlgs.keys():
             self._msg.info("Adding EventAlg sequence %s to the job" % sequence)
             self._eventAlgs[sequence]=[]
             pass
+        self._msg.debug("Adding EventAlgo %s to sequence %s" % (algo.getFullName(), sequence))
         self._eventAlgs[sequence].append(algo)
         pass
 
 
-    def getEventAlgo(self,name,sequence="TopSequence"):
-        #Fixme, deduplicate here? 
-        hits=[a for a in self._eventAlgs if a.getName()==name]
-        return hits
+    def getEventAlgo(self,name,sequence="AthAlgSeq"):
+        hits=[a for a in self._eventAlgs[sequence] if a.getName()==name]
+        if (len(hits)>1):
+            print hits
+            raise ConfigurationError("More than one Algorithm with name %s found in sequence %s" %(name,sequence))
+        
+        return hits[0]
 
     def addCondAlgo(self,algo):
         if not isinstance(algo, ConfigurableAlgorithm):
-            self._msg.error("Attempt to add wrong type as conditions algorithm")
-            #raise exception ..
+            raise TypeError("Attempt to add wrong type as conditions algorithm")
             pass
-        self._conditionsAlgs.append(algo)
-        pass
+        self._deduplicate(algo,self._conditionsAlgs) #will raise on conflict
+        return
+        
 
     def getCondAlgo(self,name):
-        #Fixme, deduplicate here? 
         hits=[a for a in self._conditionsAlgs if a.getName()==name]
-        return hits
+        if (len(hits)>1):
+            raise ConfigurationError("More than one Algorithm with name %s found in sequence %s" %(name,sequence))
+        return hits[0]
 
     def addService(self,newSvc):
         if not isinstance(newSvc,ConfigurableService):
-            self._msg.error("Attempt to add wrong type as service")
-            #raise exception ..
+            raise TypeError("Attempt to add wrong type as service")
             pass
-        #self._services.append(svc)
+        self._deduplicate(newSvc,self._services)  #will raise on conflict
+        return 
 
-        #Check for duplicates:
-        for svc in self._services:
-            if svc.getType()==newSvc.getType():
-                #Found service of the same type
-                if svc.getJobOptName()==newSvc.getJobOptName():
-                    #Found service of the same type and name:
-                    if (svc==newsvc):
-                        #the new service is an identical copy of an existing one. Ignore it.
-                        return
-                    else:
-                        #Now it gets tricky: Same name but different configuration
-                        #Loop over properties:
-                        for prop in svc.getProperties():
-                            if not prop.startswith('_'):
-                                oldprop=getattr(svc,prop)
-                                newprop=getattr(newsvc,prop)
-                                if (oldprop!=newprop):
-                                    #found property mismatch
-                                    if isinstance(oldprop,list): #if properties are concatinable, do that!
-                                        oldprop+=newprop
-                                        setattr(svc,oldprop)
-                                    else:
-                                        self._msg.error("service '%s' defined mutiple times with mismatching configuraton" % svcs[i].getJobOptName())
-                                        return None
-                                    pass 
-                                #end if prop-mismatch
-                            #end if startswith("_")
-                        #end loop over properties
-                    #end else
-                return # We found a service of the same type and name and could reconcile the two instances
-                #end if same name
-            #end if same type
-        
 
-        #No duplication, simply append 
-        self._services.append(newSvc)
-        pass
+    def addPublicTool(self,newTool):
+        if not isinstance(newTool,ConfigurableAlgTool):
+            raise TypeError("Attempt to add wrong type as AlgTool")
+        newTool.setParent("ToolSvc")
+        self._deduplicate(newTool,self._publicTools)
+        return
 
+    def _deduplicate(self,newComp,compList):
+        #Check for duplicates:
+        for comp in compList:
+            if comp.getType()==newComp.getType() and comp.getJobOptName()==newComp.getJobOptName():
+                #Found component of the same type and name
+                #print "Checking ", comp.getType(), comp.getJobOptName()
+                allProps=frozenset(comp.getValuedProperties().keys()+newComp.getValuedProperties().keys())
+                for prop in allProps:
+                    if not prop.startswith('_'):
+                        try:
+                            oldprop=getattr(comp,prop)
+                        except AttributeError:
+                            oldprop=None
+                        try:
+                            newprop=getattr(newComp,prop)
+                        except AttributeError:
+                            newprop=None
+
+                        #Note that getattr for a list property works, even if it's not in ValuedProperties
+                        if (oldprop!=newprop):
+                            #found property mismatch
+                            if isinstance(oldprop,list): #if properties are concatinable, do that!
+                                oldprop+=newprop
+                                #print "concatinating list-property",comp.getJobOptname(),prop
+                                setattr(comp,prop,oldprop)
+                            else:
+                                #self._msg.error("component '%s' defined mutiple times with mismatching configuraton" % svcs[i].getJobOptName())
+                                raise DeduplicationFailed("component '%s' defined mutiple times with mismatching property %s" % \
+                                                                  comp.getJobOptName(),prop)
+                            pass 
+                            #end if prop-mismatch
+                        pass
+                        #end if startswith("_")
+                    pass
+                    #end loop over properties
+                #We found a service of the same type and name and could reconcile the two instances
+                self._msg.debug("Reconciled configuration of component %s" % comp.getJobOptName())
+                return False #False means nothing got added
+            #end if same name & type
+        #end loop over existing components
+
+        #No component of the same type & name found, simply append 
+        self._msg.debug("Adding service/Tool/CondAlog %s to the job" % newComp.getFullName())
+        compList.append(newComp)
+        return True #True means something got added
+    
     def getService(self,name):
-        hits=[a for a in self._services if a.getName()==name]
-        return hits
+        for svc in self._services: 
+            if svc.getName()==name:
+                return svc
+        raise KeyError("No service with name %s known" % name)
+
+
+    def getPublicTool(self,name):
+        for pt in self._publicTools:
+            if pt.getName()==name:
+                return pt
+        raise KeyError("No public tool with name %s known" % name)
+
 
     def addConditionsInput(self,condObj):
         #That's a string, should do some sanity checks on formatting
@@ -128,20 +173,43 @@ class ComponentAccumulator(object):
         pass
 
 
+    def setAppProperty(self,key,value):
+        if self._theAppProps.has_key(key) and  self._theAppProps[key]!=value:
+            #Not sure if we should allow that ...
+            self._msg.info("ApplicationMgr property '%s' already set to '%s'. Overwriting with %s"% (key,str(self._theAppProps[key]),str(value)))
+        self._theAppProps[key]=value
+        pass
+
+
     def merge(self,other):
         if not isinstance(other,ComponentAccumulator):
-            self._msg.error("Attempt merge wrong type")
-            #raise exception
-            pass
+            raise TypeError("Attempt merge wrong type. Only instances of ComponentAccumulator can be added")
         
-        self._eventAlgs+=other._eventAlgs
-        self._conditionsAlgs+=other._conditionsAlgs
-        #self._services+=other._services
+        # Merge Algorithms per sequence
+        allkeys=set(self._eventAlgs.keys()) | set(other._eventAlgs.keys())
+        for k in allkeys:
+            if not self._eventAlgs.has_key(k): 
+                self._eventAlgs[k]=other._eventAlgs[k] #sequence only known to other
+            elif not other._eventAlgs.has_key[k]: #sequence only known to self
+                pass 
+            else: #sequence known to both self and other
+                self._eventAlgs[k]+=other._eventAlgs[k] 
+
+
+        # Merge Conditions inputs
         self._conditionsInput|=other._conditionsInput
+        
+        #self._conditionsAlgs+=other._conditionsAlgs
+        for condAlg in other._conditionsAlgs:
+            self.addCondAlgo(condAlgo) #Profit from deduplicaton here
+
 
         for svc in other._services:
             self.addService(svc) #Profit from deduplicaton here
 
+        for pt in other._publicTools:
+            self.addPublicTool(pt) #Profit from deduplicaton here
+
 
         for k in other._outputPerStream.keys():
             if k in self._outputPerStream:
@@ -149,35 +217,49 @@ class ComponentAccumulator(object):
             else: #New stream type
                 self._outputPerStream[k]=other._outputPerStream[k]
                 
-                
+        #Merge AppMgr properties:
+        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 executeModule(self,fct,configFlags,*args,**kwargs):
+        cfconst=deepcopy(configFlags)
+        self._msg.info("Excuting configuration function %s" % fct.__name__)
+        cm=fct(cfconst,*args,**kwargs)
+        self.merge(cm)
+
+
  
     def appendConfigurable(self,confElem):
         name=confElem.getJobOptName() #FIXME: Don't overwrite duplicates! 
+        #Hack for public Alg tools, drop multiple mentions of ToolSvc 
+        nTS=0
+        for n in name.split("."):
+            if n=="ToolSvc":
+                nTS+=1
+            else:
+                break
+        if nTS>2:
+            name=".".join(name.split(".")[nTS-1:])
         for k, v in confElem.getValuedProperties().items():
-            if isinstance(v,GaudiHandles.GaudiHandle):
-                self._jocat[name][k]=v.getJobOptName()
-                self.appendConfigurable(v)
+            if isinstance(v,Configurable):
+                self._jocat[name][k]=v.getFullName()
             elif isinstance(v,GaudiHandles.GaudiHandleArray):
-                #self._jocat[name][k]=[]#[ v1.getJobOptName() for v1 in v ]
-                children=[]
-                for v1 in v:
-                    children.append(v1.getFullName())
-                    #print "Appending ",v1.getJobOptName(),"to", name, k
-                    self.appendConfigurable(v1)
-                self._jocat[name][k]=str(children)
+                self._jocat[name][k]=str([ v1.getFullName() for v1 in v ])
+                #print name,k,self._jocat[name][k]
             else:
                 self._jocat[name][k]=str(v)
-            
-        
+        #print "All Children:",confElem.getAllChildren()
+        for ch in confElem.getAllChildren():
+            self.appendConfigurable(ch)
         return
-        
 
-    def store(self,outfile):
+
+    def store(self,outfile,nEvents=10):
         from AthenaCommon.Utils.unixtools import find_datafile
         from collections import defaultdict
         import pickle
@@ -208,6 +290,13 @@ class ComponentAccumulator(object):
         self._jocat["AthCondSeq"]["Members"]=str(condalgseq)
 
 
+        #Public Tools:
+        for pt in self._publicTools:
+            #print "Appending public Tool",pt.getFullName(),pt.getJobOptName()
+            self.appendConfigurable(pt)
+
+
+
         svcList=ast.literal_eval(self._jocfg["ApplicationMgr"]["ExtSvc"])
         for svc in self._services:
             svcname=svc.getJobOptName()
@@ -216,6 +305,16 @@ class ComponentAccumulator(object):
             #    self._jocat[svcname][k]=str(v)
             self.appendConfigurable(svc)
         self._jocfg["ApplicationMgr"]["ExtSvc"]=str(svcList)
+
+        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
+
+
         pickle.dump( self._jocat, outfile ) 
         pickle.dump( self._jocfg, outfile ) 
         pickle.dump( self._pycomps, outfile )     
diff --git a/Control/AthenaConfiguration/python/ConfigFlags.py b/Control/AthenaConfiguration/python/ConfigFlags.py
new file mode 100644
index 0000000000000000000000000000000000000000..bd5215396624a6202a94e6cdf6bb3824fef43a80
--- /dev/null
+++ b/Control/AthenaConfiguration/python/ConfigFlags.py
@@ -0,0 +1,97 @@
+from copy import deepcopy
+from AthenaConfiguration.CfgLogMsg import cfgLogMsg
+
+class ConfigFlag(object):
+    def __init__(self,initialValue=None):
+        self._value=initialValue
+        self._alreadySet=False
+        pass
+
+    @staticmethod
+    def getDefault(prevContainer):
+        pass
+
+    def set_Value(self,newvalue):
+        if not self._alreadySet:
+            self._value=newvalue
+            self._alreadySet=True
+        else:
+            print "Config Flag '%s' already set" % self.__class__.__name__
+
+    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 not len(fullname.split(".")):
+            raise KeyError("Flag name format is <package>.<module>.<flag>")
+        (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
+
+
+    def get(self,name):
+        if not self._flagdict.has_key(name):
+            newFlag=self.importFlag(name)
+            self._flagdict[name]=newFlag()
+            self._flagdict[name]._value=newFlag.getDefault(self)
+            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
diff --git a/Control/AthenaConfiguration/python/GlobalConfigFlags.py b/Control/AthenaConfiguration/python/GlobalConfigFlags.py
new file mode 100644
index 0000000000000000000000000000000000000000..0385d121e86594b5bf166bf55f50fdb42fdaa66c
--- /dev/null
+++ b/Control/AthenaConfiguration/python/GlobalConfigFlags.py
@@ -0,0 +1,67 @@
+from AthenaConfiguration.ConfigFlags import ConfigFlag
+
+class isMC(ConfigFlag):
+    @staticmethod
+    def getDefault(prevFlags):
+        return True
+
+
+class isOnline(ConfigFlag):
+    @staticmethod
+    def getDefault(prevFlags):
+        return False
+
+class GeoLayout(ConfigFlag):
+    @staticmethod
+    def getDefault(prevFlags):
+        return "atlas"
+
+class projectName(ConfigFlag):
+    #should autoconfigure! 
+    @staticmethod 
+    def getDefault(prevFlags):
+        return "data17_13TeV"
+
+class InputFiles(ConfigFlag):
+    @staticmethod
+    def getDefault(prevFlags):
+        return ["_ATHENA_GENERIC_INPUFILE_NAME_"]
+
+
+#Beam-related flags:
+class bunchSpacing(ConfigFlag):
+    """ Bunch spacing in ns"""
+    @staticmethod
+    def getDefault(prevFlags):
+        return 25
+
+class numberOfCollisions(ConfigFlag):
+    """ Number of collisions per beam crossing
+    Should be 2.3*(L/10**33)*(bunchSpacing/25 ns)
+    """
+    @staticmethod
+    def getDefault(prevFlags):
+        return 0
+
+class beamType(ConfigFlag):
+    """ Specify data taking type : with colliding beams (default),
+    single beam or cosmics 
+    """  
+    @staticmethod
+    def getDefault(prevFlags):
+        return 'collisions'
+
+class energy (ConfigFlag):
+    """ Specify beam energy (MeV)     """ 
+    @staticmethod
+    def getDefault(prevFlags):
+        from AthenaCommon.SystemOfUnits import TeV
+        return 7*TeV
+
+class estimatedLuminosity(ConfigFlag):
+    @staticmethod
+    def getDefault(prevFlags):
+        return 1E33*(prevFlags.get("AthenaConfiguration.GlobalConfigFlags.numberOfCollisions")/2.3)* \
+            (25./prevFlags.get("AthenaConfiguration.GlobalConfigFlags.bunchSpacing"))
+                     
+
diff --git a/Control/AthenaConfiguration/python/__init__.py b/Control/AthenaConfiguration/python/__init__.py
index 0be210962036dc110c2fd7f7cc6ac89283a48424..a258afc5332653bed568346e013295e1929721cb 100644
--- a/Control/AthenaConfiguration/python/__init__.py
+++ b/Control/AthenaConfiguration/python/__init__.py
@@ -1 +1 @@
-__all__=[ 'ComponentAccumulator', ]
+__all__=[ 'ComponentAccumulator', 'ConfigFlags']
diff --git a/Control/AthenaConfiguration/python/bootstrap.pkl b/Control/AthenaConfiguration/python/bootstrap.pkl
index d3e1d39ff61aef8f82f92da685d4786b12a86d74..ee9a1a2234f4f82f108eb16c0daa30ecfa3ece17 100644
--- a/Control/AthenaConfiguration/python/bootstrap.pkl
+++ b/Control/AthenaConfiguration/python/bootstrap.pkl
@@ -27,524 +27,480 @@ sS'EvtStore'
 p14
 S'StoreGateSvc'
 p15
-sS'UserStore'
-p16
-S'UserDataSvc/UserDataSvc'
-p17
 sS'ExtraInputs'
-p18
+p16
 S'[]'
-p19
+p17
 sS'Sequential'
-p20
+p18
 S'True'
-p21
+p19
 sS'Members'
-p22
+p20
 S"['AthIncFirerAlg/BeginIncFiringAlg', 'IncidentProcAlg/IncidentProcAlg1']"
-p23
+p21
 sS'NeededResources'
-p24
+p22
 S'[]'
-p25
+p23
 sS'DetStore'
-p26
+p24
 S'StoreGateSvc/DetectorStore'
-p27
+p25
 ssS'CoreDumpSvc'
-p28
-(dp29
+p26
+(dp27
 S'Signals'
-p30
+p28
 S'[11, 7, 4, 8]'
-p31
+p29
 sS'FatalHandler'
-p32
+p30
 S'-1'
-p33
+p31
 ssS'AuditorSvc'
-p34
-(dp35
+p32
+(dp33
 S'Auditors'
-p36
+p34
 S"['AlgContextAuditor/AlgContextAuditor']"
-p37
+p35
 ssS'ClassIDSvc'
-p38
-(dp39
+p36
+(dp37
 S'CLIDDBFiles'
-p40
+p38
 S"['clid.db', 'Gaudi_clid.db']"
-p41
+p39
 ssS'AthOutSeq'
-p42
-(dp43
+p40
+(dp41
 S'ExtraOutputs'
-p44
+p42
 S'[]'
-p45
+p43
 sS'EvtStore'
-p46
+p44
 S'StoreGateSvc'
+p45
+sS'ExtraInputs'
+p46
+S'[]'
 p47
-sS'UserStore'
+sS'Members'
 p48
-S'UserDataSvc/UserDataSvc'
+S'[]'
 p49
-sS'ExtraInputs'
+sS'NeededResources'
 p50
 S'[]'
 p51
-sS'Members'
+sS'DetStore'
 p52
-S'[]'
+S'StoreGateSvc/DetectorStore'
 p53
-sS'NeededResources'
+ssS'BeginIncFiringAlg'
 p54
-S'[]'
-p55
-sS'DetStore'
+(dp55
+S'ExtraOutputs'
 p56
-S'StoreGateSvc/DetectorStore'
+S'[]'
 p57
-ssS'BeginIncFiringAlg'
+sS'EvtStore'
 p58
-(dp59
-S'ExtraOutputs'
+S'StoreGateSvc'
+p59
+sS'ExtraInputs'
 p60
 S'[]'
 p61
-sS'EvtStore'
+sS'FireSerial'
 p62
-S'StoreGateSvc'
+S'False'
 p63
-sS'ExtraInputs'
+sS'Incidents'
 p64
-S'[]'
+S"['BeginEvent']"
 p65
-sS'UserStore'
+sS'NeededResources'
 p66
-S'UserDataSvc/UserDataSvc'
+S'[]'
 p67
-sS'FireSerial'
+sS'DetStore'
 p68
-S'False'
+S'StoreGateSvc/DetectorStore'
 p69
-sS'Incidents'
+ssS'AthCondSeq'
 p70
-S"['BeginEvent']"
-p71
-sS'NeededResources'
+(dp71
+S'ExtraOutputs'
 p72
 S'[]'
 p73
-sS'DetStore'
+sS'EvtStore'
 p74
-S'StoreGateSvc/DetectorStore'
+S'StoreGateSvc'
 p75
-ssS'AthCondSeq'
+sS'ExtraInputs'
 p76
-(dp77
-S'ExtraOutputs'
+S'[]'
+p77
+sS'Members'
 p78
 S'[]'
 p79
-sS'EvtStore'
+sS'NeededResources'
 p80
-S'StoreGateSvc'
+S'[]'
 p81
-sS'UserStore'
+sS'DetStore'
 p82
-S'UserDataSvc/UserDataSvc'
+S'StoreGateSvc/DetectorStore'
 p83
-sS'ExtraInputs'
+ssS'AthMasterSeq'
 p84
-S'[]'
-p85
-sS'Members'
+(dp85
+S'ExtraOutputs'
 p86
 S'[]'
 p87
-sS'NeededResources'
+sS'EvtStore'
 p88
-S'[]'
+S'StoreGateSvc'
 p89
-sS'DetStore'
+sS'ExtraInputs'
 p90
-S'StoreGateSvc/DetectorStore'
+S'[]'
 p91
-ssS'AthMasterSeq'
+sS'Sequential'
 p92
-(dp93
-S'ExtraOutputs'
+S'True'
+p93
+sS'StopOverride'
 p94
-S'[]'
+S'True'
 p95
-sS'EvtStore'
+sS'Members'
 p96
-S'StoreGateSvc'
+S"['AthSequencer/AthAlgEvtSeq', 'AthSequencer/AthOutSeq', 'AthSequencer/AthRegSeq']"
 p97
-sS'UserStore'
+sS'NeededResources'
 p98
-S'UserDataSvc/UserDataSvc'
+S'[]'
 p99
-sS'ExtraInputs'
+sS'DetStore'
 p100
-S'[]'
+S'StoreGateSvc/DetectorStore'
 p101
-sS'Sequential'
+ssS'AthAlgEvtSeq'
 p102
-S'True'
-p103
-sS'Members'
+(dp103
+S'ExtraOutputs'
 p104
-S"['AthSequencer/AthAlgEvtSeq', 'AthSequencer/AthOutSeq', 'AthSequencer/AthRegSeq']"
+S'[]'
 p105
-sS'NeededResources'
+sS'EvtStore'
 p106
-S'[]'
+S'StoreGateSvc'
 p107
-sS'DetStore'
+sS'ExtraInputs'
 p108
-S'StoreGateSvc/DetectorStore'
+S'[]'
 p109
-ssS'AthAlgEvtSeq'
+sS'Sequential'
 p110
-(dp111
-S'ExtraOutputs'
+S'True'
+p111
+sS'StopOverride'
 p112
-S'[]'
+S'True'
 p113
-sS'EvtStore'
+sS'Members'
 p114
-S'StoreGateSvc'
+S"['AthSequencer/AthBeginSeq', 'AthSequencer/AthAllAlgSeq', 'AthSequencer/AthEndSeq']"
 p115
-sS'UserStore'
+sS'NeededResources'
 p116
-S'UserDataSvc/UserDataSvc'
+S'[]'
 p117
-sS'ExtraInputs'
+sS'DetStore'
 p118
-S'[]'
+S'StoreGateSvc/DetectorStore'
 p119
-sS'Sequential'
+ssS'AthEndSeq'
 p120
-S'True'
-p121
-sS'StopOverride'
+(dp121
+S'ExtraOutputs'
 p122
-S'True'
+S'[]'
 p123
-sS'Members'
+sS'EvtStore'
 p124
-S"['AthSequencer/AthBeginSeq', 'AthSequencer/AthAllAlgSeq', 'AthSequencer/AthEndSeq']"
+S'StoreGateSvc'
 p125
-sS'NeededResources'
+sS'ExtraInputs'
 p126
 S'[]'
 p127
-sS'DetStore'
+sS'Sequential'
 p128
-S'StoreGateSvc/DetectorStore'
+S'True'
 p129
-ssS'AthEndSeq'
+sS'Members'
 p130
-(dp131
-S'ExtraOutputs'
+S"['AthIncFirerAlg/EndIncFiringAlg', 'IncidentProcAlg/IncidentProcAlg2']"
+p131
+sS'NeededResources'
 p132
 S'[]'
 p133
-sS'EvtStore'
+sS'DetStore'
 p134
-S'StoreGateSvc'
+S'StoreGateSvc/DetectorStore'
 p135
-sS'UserStore'
+ssS'AthRegSeq'
 p136
-S'UserDataSvc/UserDataSvc'
-p137
-sS'ExtraInputs'
+(dp137
+S'ExtraOutputs'
 p138
 S'[]'
 p139
-sS'Sequential'
+sS'EvtStore'
 p140
-S'True'
+S'StoreGateSvc'
 p141
-sS'Members'
+sS'ExtraInputs'
 p142
-S"['AthIncFirerAlg/EndIncFiringAlg', 'IncidentProcAlg/IncidentProcAlg2']"
+S'[]'
 p143
-sS'NeededResources'
+sS'Members'
 p144
 S'[]'
 p145
-sS'DetStore'
+sS'NeededResources'
 p146
-S'StoreGateSvc/DetectorStore'
+S'[]'
 p147
-ssS'AthRegSeq'
+sS'DetStore'
 p148
-(dp149
-S'ExtraOutputs'
+S'StoreGateSvc/DetectorStore'
+p149
+ssS'EndIncFiringAlg'
 p150
-S'[]'
-p151
-sS'EvtStore'
+(dp151
+S'ExtraOutputs'
 p152
-S'StoreGateSvc'
+S'[]'
 p153
-sS'UserStore'
+sS'EvtStore'
 p154
-S'UserDataSvc/UserDataSvc'
+S'StoreGateSvc'
 p155
 sS'ExtraInputs'
 p156
 S'[]'
 p157
-sS'Members'
+sS'FireSerial'
 p158
-S'[]'
+S'False'
 p159
-sS'NeededResources'
+sS'Incidents'
 p160
-S'[]'
+S"['EndEvent']"
 p161
-sS'DetStore'
+sS'NeededResources'
 p162
-S'StoreGateSvc/DetectorStore'
+S'[]'
 p163
-ssS'EndIncFiringAlg'
+sS'DetStore'
 p164
-(dp165
-S'ExtraOutputs'
+S'StoreGateSvc/DetectorStore'
+p165
+ssS'Streams'
 p166
-S'[]'
-p167
-sS'EvtStore'
+(dp167
+S'ExtraOutputs'
 p168
-S'StoreGateSvc'
+S'[]'
 p169
-sS'ExtraInputs'
+sS'EvtStore'
 p170
-S'[]'
+S'StoreGateSvc'
 p171
-sS'UserStore'
+sS'ExtraInputs'
 p172
-S'UserDataSvc/UserDataSvc'
+S'[]'
 p173
-sS'FireSerial'
+sS'Members'
 p174
-S'False'
+S'[]'
 p175
-sS'Incidents'
+sS'NeededResources'
 p176
-S"['EndEvent']"
+S'[]'
 p177
-sS'NeededResources'
+sS'DetStore'
 p178
-S'[]'
+S'StoreGateSvc/DetectorStore'
 p179
-sS'DetStore'
+ssS'NTupleSvc'
 p180
-S'StoreGateSvc/DetectorStore'
-p181
-ssS'Streams'
+(dp181
+S'InhibitPathes'
 p182
-(dp183
-S'ExtraOutputs'
+S'[]'
+p183
+sS'Input'
 p184
 S'[]'
 p185
-sS'EvtStore'
+sS'Output'
 p186
-S'StoreGateSvc'
+S'[]'
 p187
-sS'UserStore'
+ssS'EventPersistencySvc'
 p188
-S'UserDataSvc/UserDataSvc'
-p189
-sS'ExtraInputs'
+(dp189
+S'CnvServices'
 p190
 S'[]'
 p191
-sS'Members'
+ssS'AthAlgSeq'
 p192
-S'[]'
-p193
-sS'NeededResources'
+(dp193
+S'ExtraOutputs'
 p194
 S'[]'
 p195
-sS'DetStore'
+sS'EvtStore'
 p196
-S'StoreGateSvc/DetectorStore'
+S'StoreGateSvc'
 p197
-ssS'NTupleSvc'
+sS'ExtraInputs'
 p198
-(dp199
-S'InhibitPathes'
-p200
 S'[]'
+p199
+sS'StopOverride'
+p200
+S'True'
 p201
-sS'Input'
+sS'Members'
 p202
 S'[]'
 p203
-sS'Output'
+sS'NeededResources'
 p204
 S'[]'
 p205
-ssS'EventPersistencySvc'
+sS'DetStore'
 p206
-(dp207
-S'CnvServices'
+S'StoreGateSvc/DetectorStore'
+p207
+ssS'AthAllAlgSeq'
 p208
-S'[]'
-p209
-ssS'AthAlgSeq'
-p210
-(dp211
+(dp209
 S'ExtraOutputs'
-p212
+p210
 S'[]'
-p213
+p211
 sS'EvtStore'
-p214
+p212
 S'StoreGateSvc'
+p213
+sS'ExtraInputs'
+p214
+S'[]'
 p215
-sS'UserStore'
+sS'Members'
 p216
-S'UserDataSvc/UserDataSvc'
+S"['AthSequencer/AthCondSeq', 'AthSequencer/AthAlgSeq']"
 p217
-sS'ExtraInputs'
+sS'NeededResources'
 p218
 S'[]'
 p219
-sS'StopOverride'
+sS'DetStore'
 p220
-S'True'
+S'StoreGateSvc/DetectorStore'
 p221
-sS'Members'
+ssS'AthenaSealSvc'
 p222
-S'[]'
-p223
-sS'NeededResources'
+(dp223
+S'DictNames'
 p224
 S'[]'
 p225
-sS'DetStore'
+sS'IgnoreDicts'
 p226
-S'StoreGateSvc/DetectorStore'
+S"['libSealCLHEPDict']"
 p227
-ssS'AthAllAlgSeq'
+sS'IgnoreNames'
 p228
-(dp229
-S'ExtraOutputs'
+S"['Gaudi', 'GaudiPython::Interface', 'GaudiPython::Helper', 'FactoryTable', 'IInterface', 'IFactory', 'IAlgFactory', 'ISvcFactory', 'IToolFactory', 'InterfaceID', 'StatusCode', 'IAppMgrUI', 'IProperty', 'Property', 'std::vector<Property*>', 'std::vector<const Property*>', 'std::list<IAlgorithm*>', 'std::list<IService*>', 'std::list<const IFactory*>', 'std::vector<IRegistry*>', 'SimpleProperty', 'SimplePropertyRef', 'IService', 'IAlgorithm', 'ISvcManager', 'IAlgManager', 'IJobOptionsSvc', 'ISvcLocator', 'IEventProcessor', 'IDataProviderSvc', 'IDataManagerSvc', 'IRegistry', 'ContainedObject', 'std::vector<const ContainedObject*>', 'DataObject', 'IHistogramSvc', 'AIDA::I', 'Algorithm', 'Service', 'GaudiPython::PyAlgorithm', 'GaudiPython::PyAlgorithmWrap', 'IParticlePropertySvc', 'ParticleProperty', 'StoreGateSvc', 'IStoragePolicy', 'CharDbArray', 'DoubleDbArray', 'FloatDbArray', 'IntDbArray', 'LongDbArray', 'ShortDbArray', 'AthenaEventLoopMgr', 'MinimalEventLoopMgr', 'PyAthenaEventLoopMgr', 'NTuple::Directory', 'NTuple::File ', 'NTuple::Tuple', 'INTuple', 'NTuple::Tuple', 'greater<int>', 'allocator<', 'string']"
+p229
+ssS'IncidentProcAlg2'
 p230
-S'[]'
-p231
-sS'EvtStore'
+(dp231
+S'ExtraOutputs'
 p232
-S'StoreGateSvc'
+S'[]'
 p233
-sS'UserStore'
+sS'NeededResources'
 p234
-S'UserDataSvc/UserDataSvc'
+S'[]'
 p235
 sS'ExtraInputs'
 p236
 S'[]'
 p237
-sS'Members'
+ssS'DetectorStore'
 p238
-S"['AthSequencer/AthCondSeq', 'AthSequencer/AthAlgSeq']"
-p239
-sS'NeededResources'
+(dp239
+S'IncidentSvc'
 p240
-S'[]'
+S'IncidentSvc'
 p241
-sS'DetStore'
+sS'ProxyProviderSvc'
 p242
-S'StoreGateSvc/DetectorStore'
+S'ProxyProviderSvc'
 p243
-ssS'AthenaSealSvc'
+ssS'IncidentProcAlg1'
 p244
 (dp245
-S'DictNames'
+S'ExtraOutputs'
 p246
 S'[]'
 p247
-sS'IgnoreDicts'
+sS'NeededResources'
 p248
-S"['libSealCLHEPDict']"
+S'[]'
 p249
-sS'IgnoreNames'
+sS'ExtraInputs'
 p250
-S"['Gaudi', 'GaudiPython::Interface', 'GaudiPython::Helper', 'FactoryTable', 'IInterface', 'IFactory', 'IAlgFactory', 'ISvcFactory', 'IToolFactory', 'InterfaceID', 'StatusCode', 'IAppMgrUI', 'IProperty', 'Property', 'std::vector<Property*>', 'std::vector<const Property*>', 'std::list<IAlgorithm*>', 'std::list<IService*>', 'std::list<const IFactory*>', 'std::vector<IRegistry*>', 'SimpleProperty', 'SimplePropertyRef', 'IService', 'IAlgorithm', 'ISvcManager', 'IAlgManager', 'IJobOptionsSvc', 'ISvcLocator', 'IEventProcessor', 'IDataProviderSvc', 'IDataManagerSvc', 'IRegistry', 'ContainedObject', 'std::vector<const ContainedObject*>', 'DataObject', 'IHistogramSvc', 'AIDA::I', 'Algorithm', 'Service', 'GaudiPython::PyAlgorithm', 'GaudiPython::PyAlgorithmWrap', 'IParticlePropertySvc', 'ParticleProperty', 'StoreGateSvc', 'IStoragePolicy', 'CharDbArray', 'DoubleDbArray', 'FloatDbArray', 'IntDbArray', 'LongDbArray', 'ShortDbArray', 'AthenaEventLoopMgr', 'MinimalEventLoopMgr', 'PyAthenaEventLoopMgr', 'NTuple::Directory', 'NTuple::File ', 'NTuple::Tuple', 'INTuple', 'NTuple::Tuple', 'greater<int>', 'allocator<', 'string']"
+S'[]'
 p251
-ssS'IncidentProcAlg2'
+ssS'HistogramDataSvc'
 p252
 (dp253
-S'ExtraOutputs'
+S'Input'
 p254
 S'[]'
 p255
-sS'NeededResources'
+sS'InhibitPathes'
 p256
 S'[]'
 p257
-sS'ExtraInputs'
-p258
-S'[]'
-p259
-ssS'DetectorStore'
-p260
-(dp261
-S'IncidentSvc'
-p262
-S'IncidentSvc'
-p263
-sS'ProxyProviderSvc'
-p264
-S'ProxyProviderSvc'
-p265
-ssS'IncidentProcAlg1'
-p266
-(dp267
-S'ExtraOutputs'
-p268
-S'[]'
-p269
-sS'NeededResources'
-p270
-S'[]'
-p271
-sS'ExtraInputs'
-p272
-S'[]'
-p273
-ssS'HistogramDataSvc'
-p274
-(dp275
-S'Input'
-p276
-S'[]'
-p277
-sS'InhibitPathes'
-p278
-S'[]'
-p279
 ssS'HistoryStore'
-p280
-(dp281
+p258
+(dp259
 S'IncidentSvc'
-p282
+p260
 S'IncidentSvc'
-p283
+p261
 sS'ProxyProviderSvc'
-p284
+p262
 S'ProxyProviderSvc'
-p285
+p263
 ss.ccollections
 defaultdict
 p1
@@ -615,7 +571,7 @@ p30
 g12
 sS'errorColorCode'
 p31
-S'[]'
+S"['white', 'red']"
 p32
 sS'alwaysLimit'
 p33
@@ -704,7 +660,7 @@ S'500'
 p69
 sS'fatalColorCode'
 p70
-S'[]'
+S"['blue', 'red']"
 p71
 sS'loggedStreams'
 p72
@@ -742,7 +698,7 @@ S'[]'
 p87
 sS'warningColorCode'
 p88
-S'[]'
+S"['yellow']"
 p89
 ssS'AthenaSealSvc'
 p90
@@ -830,7 +786,7 @@ p122
 g7
 sS'SEARCHPATH'
 p123
-S'.:/home/wlampl/jobConfig2017/build/x86_64-slc6-gcc62-opt/jobOptions:/cvmfs/atlas-nightlies.cern.ch/repo/sw/master/2017-04-09T2225/GAUDI/22.0.0/InstallArea/x86_64-slc6-gcc62-opt/jobOptions:/home/wlampl/jobConfig2017:/cvmfs/atlas-nightlies.cern.ch/repo/sw/master/2017-04-09T2225/Athena/22.0.0/InstallArea/x86_64-slc6-gcc62-opt/jobOptions:/cvmfs/atlas-nightlies.cern.ch/repo/sw/master/2017-04-09T2225/AthenaExternals/22.0.0/InstallArea/x86_64-slc6-gcc62-opt/jobOptions'
+S'.:/cvmfs/atlas-nightlies.cern.ch/repo/sw/master/2017-12-17T2303/Athena/22.0.0/InstallArea/x86_64-slc6-gcc62-opt/jobOptions:/cvmfs/atlas-nightlies.cern.ch/repo/sw/master/2017-12-17T2303/AthenaExternals/22.0.0/InstallArea/x86_64-slc6-gcc62-opt/jobOptions:/cvmfs/atlas-nightlies.cern.ch/repo/sw/master/2017-12-17T2303/GAUDI/22.0.0/InstallArea/x86_64-slc6-gcc62-opt/jobOptions'
 p124
 sS'AuditInitialize'
 p125
@@ -840,7 +796,7 @@ p126
 g7
 sS'OutputLevel'
 p127
-S'0'
+S'3'
 sS'AuditStart'
 p128
 g7
diff --git a/Control/AthenaExamples/AthExHelloWorld/CMakeLists.txt b/Control/AthenaExamples/AthExHelloWorld/CMakeLists.txt
index b396823e88cc244fa933ffed0e4560ccbde104d5..dbecc2d79f0e2d4c0cd5f2424eec8a30537c9cea 100644
--- a/Control/AthenaExamples/AthExHelloWorld/CMakeLists.txt
+++ b/Control/AthenaExamples/AthExHelloWorld/CMakeLists.txt
@@ -22,6 +22,6 @@ atlas_add_component( AthExHelloWorld
 # Install files from the package:
 atlas_install_headers( AthExHelloWorld )
 atlas_install_joboptions( share/*.py )
-atlas_install_python_modules( share/HelloWorldConfig.py )
+atlas_install_python_modules( python/HelloWorldConfig.py )
 atlas_install_runtime( test/AthExHelloWorld_TestConfiguration.xml )
 
diff --git a/Control/AthenaExamples/AthExHelloWorld/share/HelloWorldConfig.py b/Control/AthenaExamples/AthExHelloWorld/python/HelloWorldConfig.py
similarity index 77%
rename from Control/AthenaExamples/AthExHelloWorld/share/HelloWorldConfig.py
rename to Control/AthenaExamples/AthExHelloWorld/python/HelloWorldConfig.py
index 3aba1222c3054a535ed13e42df847aba638cbf6c..a55d9e6f8c083e4385c1f786f19d8694297c8717 100644
--- a/Control/AthenaExamples/AthExHelloWorld/share/HelloWorldConfig.py
+++ b/Control/AthenaExamples/AthExHelloWorld/python/HelloWorldConfig.py
@@ -1,5 +1,6 @@
 
 
+from AthenaCommon.JobProperties import jobproperties
 from AthenaConfiguration.ComponentAccumulator import ComponentAccumulator
 
 def HelloWorldCfg(ConfigFlags=None):
@@ -46,9 +47,29 @@ def HelloWorldCfg(ConfigFlags=None):
     HelloWorld.MyMatrix += [ [ 7, 8, 9 ] ]
 
     from AthExHelloWorld.AthExHelloWorldConf import HelloTool
-    HelloWorld.MyPrivateHelloTool = HelloTool( "HelloTool" )
+    ht=HelloTool( "HelloTool" )
+    HelloWorld.MyPrivateHelloTool = ht #HelloTool( "HelloTool" )
     HelloWorld.MyPrivateHelloTool.MyMessage = "A Private Message!"
 
+    pt=HelloTool( "PublicHello")
+    pt.MyMessage="A public Message!"    
+
+    result.addPublicTool(pt)
+    print pt
+
+
+    HelloWorld.MyPublicHelloTool=pt
+
+
+    #print HelloWorld
 
     result.addEventAlgo(HelloWorld)
     return result
+
+
+if __name__=="__main__":
+    cfg=HelloWorldCfg()
+    f=open("HelloWorld.pkl","w")
+    cfg.store(f)
+    f.close()
+
diff --git a/Database/AthenaPOOL/AthenaPoolCnvSvc/python/PoolReadConfig.py b/Database/AthenaPOOL/AthenaPoolCnvSvc/python/PoolReadConfig.py
new file mode 100644
index 0000000000000000000000000000000000000000..06a6e2402311eae9fbb5bc6ef79bcb2bde164d30
--- /dev/null
+++ b/Database/AthenaPOOL/AthenaPoolCnvSvc/python/PoolReadConfig.py
@@ -0,0 +1,39 @@
+
+from AthenaConfiguration.ComponentAccumulator import ComponentAccumulator
+
+def PoolReadCfg(inputFlags):
+    """
+    creates A ComponentAccumulator instance containing the 
+    athena services required for POOL file reading
+    """
+
+    filenames=inputFlags.get("AthenaConfiguration.GlobalConfigFlags.InputFiles")
+
+    result=ComponentAccumulator()
+
+    from PoolSvc.PoolSvcConf import PoolSvc
+    from SGComps.SGCompsConf import ProxyProviderSvc
+    from AthenaPoolCnvSvc.AthenaPoolCnvSvcConf import AthenaPoolCnvSvc
+    from EventSelectorAthenaPool.EventSelectorAthenaPoolConf import AthenaPoolAddressProviderSvc, EventSelectorAthenaPool
+    from GaudiSvc.GaudiSvcConf import EvtPersistencySvc
+    
+
+
+    result.addService(PoolSvc(MaxFilesOpen=0))
+    apcs=AthenaPoolCnvSvc()
+    result.addService(apcs)
+    result.addService(EvtPersistencySvc("EventPersistencySvc",CnvServices=[apcs.getFullJobOptName(),])) #No service handle yet???
+
+    apaps=AthenaPoolAddressProviderSvc()
+    result.addService(apaps)
+    result.addService(ProxyProviderSvc(ProviderNames=[apaps.getFullJobOptName(),])) #No service handle yet???
+
+
+    evSel=EventSelectorAthenaPool(InputCollections = filenames)
+
+    result.addService(evSel)
+    result.setAppProperty("EvtSel",evSel.getFullJobOptName())
+
+    #(possibly) missing: MetaDataSvc, AddressRemappingSvc
+
+    return result
diff --git a/Database/IOVDbSvc/python/IOVDbConfigFlags.py b/Database/IOVDbSvc/python/IOVDbConfigFlags.py
new file mode 100644
index 0000000000000000000000000000000000000000..1ac8262a24b39a9ada47b786ba64cda5630aca57
--- /dev/null
+++ b/Database/IOVDbSvc/python/IOVDbConfigFlags.py
@@ -0,0 +1,28 @@
+from AthenaConfiguration.ConfigFlags import ConfigFlag
+from AthenaConfiguration.CfgLogMsg import cfgLogMsg
+
+class DatabaseInstance(ConfigFlag):
+    @staticmethod
+    def getDefault(prevFlags):
+        isMC=prevFlags.get("AthenaConfiguration.GlobalConfigFlags.isMC")
+        if (isMC):
+            return "OFLP200"
+    
+        # real-data
+        projectName=prevFlags.get("AthenaConfiguration.GlobalConfigFlags.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" 
+    
+
+class GlobalTag(ConfigFlag):
+    @staticmethod
+    def getDefault(prevFlags):
+        return "CONDBR2-BLKPA-2017-05"
diff --git a/Database/IOVDbSvc/python/IOVDbSvcConfig.py b/Database/IOVDbSvc/python/IOVDbSvcConfig.py
new file mode 100644
index 0000000000000000000000000000000000000000..45292d81c69ef3ffff665978430a4c7661441b1f
--- /dev/null
+++ b/Database/IOVDbSvc/python/IOVDbSvcConfig.py
@@ -0,0 +1,163 @@
+# Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
+
+from AthenaConfiguration.ComponentAccumulator import ComponentAccumulator, ConfigurationError
+import os
+
+def IOVDbSvcCfg(inputFlags):
+
+    result=ComponentAccumulator()
+
+    from IOVDbSvc.IOVDbSvcConf import IOVDbSvc
+    from IOVSvc.IOVSvcConf import CondSvc
+    from IOVSvc.IOVSvcConf import CondInputLoader
+    from SGComps.SGCompsConf import ProxyProviderSvc
+
+    #Properties of IOVDbSvc to be set here:
+    #online-mode, DBInstance (slite)
+    
+    #Services it (sometimes) depends upon:
+    # m_h_IOVSvc     ("IOVSvc", name),
+    #m_h_sgSvc      ("StoreGateSvc", name),
+    #m_h_detStore   ("DetectorStore", name),
+    #m_h_metaDataStore ("StoreGateSvc/MetaDataStore", name), 
+    #m_h_persSvc    ("EventPersistencySvc", name),
+    #m_h_clidSvc    ("ClassIDSvc", name),
+    #m_h_poolSvc    ("PoolSvc", name),
+    #m_h_metaDataTool("IOVDbMetaDataTool"),
+    #m_h_tagInfoMgr("TagInfoMgr", name),
+
+    isMC=inputFlags.get("AthenaConfiguration.GlobalConfigFlags.isMC")
+
+    # Set up IOVDbSvc
+    iovDbSvc=IOVDbSvc()
+    dbname=inputFlags.get("IOVDbSvc.IOVDbConfigFlags.DatabaseInstance")
+
+    localfile="sqlite://;schema=mycool.db;dbname="
+    iovDbSvc.dbConnection=localfile+dbname
+    # setup knowledge of dbinstance in IOVDbSvc, for global tag x-check
+    iovDbSvc.DBInstance=dbname
+
+    if 'FRONTIER_SERVER' in os.environ.keys() and os.environ['FRONTIER_SERVER']!="":
+        iovDbSvc.CacheAlign=3
+
+
+    iovDbSvc.GlobalTag=inputFlags.get("IOVDbSvc.IOVDbConfigFlags.GlobalTag")
+
+    result.addService(iovDbSvc)
+
+
+    # Set up POOLSvc with appropriate catalogs
+    
+    from PoolSvc.PoolSvcConf import PoolSvc
+    poolSvc=PoolSvc()
+    poolSvc.ReadCatalog=["apcfile:poolcond/PoolFileCatalog.xml",
+                         "prfile:poolcond/PoolCat_oflcond.xml",
+                         "apcfile:poolcond/PoolCat_oflcond.xml",
+                         ]
+
+    if not isMC:
+         poolSvc.ReadCatalog+=["prfile:poolcond/PoolCat_comcond.xml",
+                               "apcfile:poolcond/PoolCat_comcond.xml",
+                               ]
+    result.addService(poolSvc)
+    result.addService(CondSvc())
+    result.addService(ProxyProviderSvc(ProviderNames=["IOVDbSvc",]))
+
+
+    from DBReplicaSvc.DBReplicaSvcConf import DBReplicaSvc
+    if not isMC:
+        result.addService(DBReplicaSvc(COOLSQLiteVetoPattern="/DBRelease/"))
+
+    
+    return result
+
+
+#Convenience method to add folders:
+
+def addFolders(inputFlags,folderstrings,detDb=None):
+
+    #result=IOVDbSvcCfg(inputFlags)
+    result=ComponentAccumulator()
+    result.executeModule(IOVDbSvcCfg,inputFlags)
+
+    
+    
+    iovDbSvc=result.getService("IOVDbSvc")
+    
+    if detDb is not None:
+        dbname=inputFlags.get("IOVDbSvc.IOVDbConfigFlags.DatabaseInstance")
+        if not detDb in _dblist.keys():
+            raise ConfigurationError("Error, db shorthand %s not known")
+        dbstr="<db>"+_dblist[detDb]+"/"+dbname+"</db>"
+    else:
+        dbstr=""
+    
+    #Convenince hack: Allow a single string as parameter:
+    if isinstance(folderstrings,str):
+        folderstrings=[folderstrings,]
+
+    
+    for fs in folderstrings:
+        if fs.find("<db>")==-1:
+            iovDbSvc.Folders.append(fs+dbstr)
+        else:
+            iovDbSvc.Folders.append(fs)
+
+
+    return result
+
+
+_dblist={
+    'INDET':'COOLONL_INDET',
+    'INDET_ONL':'COOLONL_INDET',
+    'PIXEL':'COOLONL_PIXEL',
+    'PIXEL_ONL':'COOLONL_PIXEL',
+    'SCT':'COOLONL_SCT',
+    'SCT_ONL':'COOLONL_SCT',
+    'TRT':'COOLONL_TRT',
+    'TRT_ONL':'COOLONL_TRT',
+    'LAR':'COOLONL_LAR',
+    'LAR_ONL':'COOLONL_LAR',
+    'TILE':'COOLONL_TILE',
+    'TILE_ONL':'COOLONL_TILE',
+    'MUON':'COOLONL_MUON',
+    'MUON_ONL':'COOLONL_MUON',
+    'MUONALIGN':'COOLONL_MUONALIGN',
+    'MUONALIGN_ONL':'COOLONL_MUONALIGN',
+    'MDT':'COOLONL_MDT',
+    'MDT_ONL':'COOLONL_MDT',
+    'RPC':'COOLONL_RPC',
+    'RPC_ONL':'COOLONL_RPC',
+    'TGC':'COOLONL_TGC',
+    'TGC_ONL':'COOLONL_TGC',
+    'CSC':'COOLONL_CSC',
+    'CSC_ONL':'COOLONL_CSC',
+    'TDAQ':'COOLONL_TDAQ',
+    'TDAQ_ONL':'COOLONL_TDAQ',
+    'GLOBAL':'COOLONL_GLOBAL',
+    'GLOBAL_ONL':'COOLONL_GLOBAL',
+    'TRIGGER':'COOLONL_TRIGGER',
+    'TRIGGER_ONL':'COOLONL_TRIGGER',
+    'CALO':'COOLONL_CALO',
+    'CALO_ONL':'COOLONL_CALO',
+    'FWD':'COOLONL_FWD',
+    'FWD_ONL':'COOLONL_FWD',            
+    'INDET_OFL':'COOLOFL_INDET',
+    'PIXEL_OFL':'COOLOFL_PIXEL',
+    'SCT_OFL':'COOLOFL_SCT',
+    'TRT_OFL':'COOLOFL_TRT',
+    'LAR_OFL':'COOLOFL_LAR',
+    'TILE_OFL':'COOLOFL_TILE',
+    'MUON_OFL':'COOLOFL_MUON',
+    'MUONALIGN_OFL':'COOLOFL_MUONALIGN',
+    'MDT_OFL':'COOLOFL_MDT',
+    'RPC_OFL':'COOLOFL_RPC',
+    'TGC_OFL':'COOLOFL_TGC',
+    'CSC_OFL':'COOLOFL_CSC',
+    'TDAQ_OFL':'COOLOFL_TDAQ',
+    'DCS_OFL':'COOLOFL_DCS',
+    'GLOBAL_OFL':'COOLOFL_GLOBAL',
+    'TRIGGER_OFL':'COOLOFL_TRIGGER',
+    '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 66ff21936ad15074b58a830217942ccdd9658dcd..58f061e1595d0c08dbaf8e520d9dd108d277022f 100644
--- a/DetectorDescription/GeoModel/AtlasGeoModel/python/GeoModelConfig.py
+++ b/DetectorDescription/GeoModel/AtlasGeoModel/python/GeoModelConfig.py
@@ -1,23 +1,26 @@
 from AthenaConfiguration.ComponentAccumulator import ComponentAccumulator
-import GaudiSvc.GaudiSvcConf as GaudiSvcConf
 
+def GeoModelCfg(ConfigFlagContainer):
+    version=ConfigFlagContainer.get("AtlasGeoModel.GeoModelFlags.AtlasVersion")
 
+    from AthenaCommon.AppMgr import release_metadata
+    rel_metadata = release_metadata()
+    relversion = rel_metadata['release'].split('.')
+    if len(relversion) < 3:
+        relversion = rel_metadata['base release'].split('.')
 
 
-def GeoModelCfg():
     result=ComponentAccumulator()
     from GeoModelSvc.GeoModelSvcConf import GeoModelSvc
-    theGeoSvc=GeoModelSvc()
-    result.addService(GeoModelSvc())
+    result.addService(GeoModelSvc(AtlasVersion=version,
+                                  SupportedGeometry = int(relversion[0])))
     
     from DetDescrCnvSvc.DetDescrCnvSvcConf import DetDescrCnvSvc
-    
+    from GaudiSvc.GaudiSvcConf import EvtPersistencySvc
+
     # Specify primary Identifier dictionary to be used
-    result.addService(DetDescrCnvSvc(IdDictName = "IdDictParser/ATLAS_IDS.xml"))
-    
-    evtPersSvc=GaudiSvcConf.EvtPersistencySvc( "EventPersistencySvc" )
-    evtPersSvc.CnvServices += [ "DetDescrCnvSvc" ]
-    result.addService(evtPersSvc)
+    detDescrCnvSvc=DetDescrCnvSvc(IdDictName = "IdDictParser/ATLAS_IDS.xml",IdDictFromRDB = True)
+    result.addService(detDescrCnvSvc)
+    result.addService(EvtPersistencySvc("EventPersistencySvc",CnvServices=[detDescrCnvSvc.getName(),])) #No service handle yet???
 
     return result
-
diff --git a/DetectorDescription/GeoModel/AtlasGeoModel/python/GeoModelFlags.py b/DetectorDescription/GeoModel/AtlasGeoModel/python/GeoModelFlags.py
new file mode 100644
index 0000000000000000000000000000000000000000..926e779849b0b8d86962a53a47a6184351827da1
--- /dev/null
+++ b/DetectorDescription/GeoModel/AtlasGeoModel/python/GeoModelFlags.py
@@ -0,0 +1,6 @@
+from AthenaConfiguration.ConfigFlags import ConfigFlag
+
+class AtlasVersion(ConfigFlag):
+    @staticmethod
+    def getDefault(prevFlags):
+        return "ATLAS-R2-2016-01-00-01" 
diff --git a/LArCalorimeter/LArGeoModel/LArGeoAlgsNV/CMakeLists.txt b/LArCalorimeter/LArGeoModel/LArGeoAlgsNV/CMakeLists.txt
index 75774c27a72c72f0b3f6ee80f3b3f341000e9c9c..967f47ae7e3eaf8e1eb22f2df4e0905c6a9a811a 100644
--- a/LArCalorimeter/LArGeoModel/LArGeoAlgsNV/CMakeLists.txt
+++ b/LArCalorimeter/LArGeoModel/LArGeoAlgsNV/CMakeLists.txt
@@ -40,4 +40,4 @@ atlas_add_component( LArGeoAlgsNV
 
 # Install files from the package:
 atlas_install_headers( LArGeoAlgsNV )
-
+atlas_install_python_modules( python/*.py )
diff --git a/LArCalorimeter/LArGeoModel/LArGeoAlgsNV/python/LArGMConfig.py b/LArCalorimeter/LArGeoModel/LArGeoAlgsNV/python/LArGMConfig.py
new file mode 100644
index 0000000000000000000000000000000000000000..85bc1c706c313fe77df0ed3382e089b1a8b98294
--- /dev/null
+++ b/LArCalorimeter/LArGeoModel/LArGeoAlgsNV/python/LArGMConfig.py
@@ -0,0 +1,24 @@
+from AthenaConfiguration.ComponentAccumulator import ComponentAccumulator
+from AtlasGeoModel.GeoModelConfig import GeoModelCfg
+from IOVDbSvc.IOVDbSvcConfig import addFolders
+
+def LArGMCfg(ConfigFlags):
+    result=ComponentAccumulator()
+    
+    result.executeModule(GeoModelCfg,ConfigFlags)
+
+    doAlignment=ConfigFlags.get("LArGeoAlgsNV.LArGeoModelFlags.doAlign")
+    
+    from LArGeoAlgsNV.LArGeoAlgsNVConf import LArDetectorToolNV
+    result.getService("GeoModelSvc").DetectorTools += [ LArDetectorToolNV(ApplyAlignments=doAlignment) ]
+
+    if doAlignment:
+        if ConfigFlags.get("AthenaConfiguration.GlobalConfigFlags.isMC"):
+            #Monte Carlo case:
+            result.executeModule(addFolders,ConfigFlags,["/LAR/Align","/LAR/LArCellPositionShift"],"LAR_OFL")
+        else:
+            #Regular offline data processing
+            result.executeModule(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
new file mode 100644
index 0000000000000000000000000000000000000000..5b90168db536f0c299db2780bca421fee28f41df
--- /dev/null
+++ b/LArCalorimeter/LArGeoModel/LArGeoAlgsNV/python/LArGeoModelFlags.py
@@ -0,0 +1,8 @@
+from AthenaConfiguration.ConfigFlags import ConfigFlag
+
+class doAlign(ConfigFlag):
+    """ Flag to activate LAr Alignment
+    """  
+    @staticmethod
+    def getDefault(prevFlags):
+        return prevFlags.get("AthenaConfiguration.GlobalConfigFlags.GeoLayout")=="atlas"
diff --git a/TileCalorimeter/TileGeoModel/CMakeLists.txt b/TileCalorimeter/TileGeoModel/CMakeLists.txt
index c6579b5092424b7bee89d6ffa4f213cd29aefa45..c545c92f323f1b173684eff0373a42ca4fcca445 100644
--- a/TileCalorimeter/TileGeoModel/CMakeLists.txt
+++ b/TileCalorimeter/TileGeoModel/CMakeLists.txt
@@ -44,4 +44,6 @@ atlas_add_component( TileGeoModel
 
 # Install files from the package:
 atlas_install_joboptions( share/*.py )
+atlas_install_python_modules( python/*.py )
+
 
diff --git a/TileCalorimeter/TileGeoModel/python/TileGMConfig.py b/TileCalorimeter/TileGeoModel/python/TileGMConfig.py
new file mode 100644
index 0000000000000000000000000000000000000000..3fbee8787186abf6a72183d1e74c06b4c9032986
--- /dev/null
+++ b/TileCalorimeter/TileGeoModel/python/TileGMConfig.py
@@ -0,0 +1,12 @@
+from AthenaConfiguration.ComponentAccumulator import ComponentAccumulator
+from AtlasGeoModel.GeoModelConfig import GeoModelCfg
+
+def TileGMCfg(ConfigFlags):
+    result=ComponentAccumulator()
+    
+    result.executeModule(GeoModelCfg,ConfigFlags)
+
+    from TileGeoModel.TileGeoModelConf import TileDetectorTool
+    result.getService("GeoModelSvc").DetectorTools += [ TileDetectorTool() ]
+
+    return result