diff --git a/Calorimeter/CaloRec/python/CaloTopoClusterConfig.py b/Calorimeter/CaloRec/python/CaloTopoClusterConfig.py index dc0cfdacee61449f64d4577f43fbdbf47c5da635..dcbaa23121a61648d4de0d0b83890f2ff2a6e10a 100644 --- a/Calorimeter/CaloRec/python/CaloTopoClusterConfig.py +++ b/Calorimeter/CaloRec/python/CaloTopoClusterConfig.py @@ -6,8 +6,7 @@ from AthenaCommon.Constants import VERBOSE def caloTopoCoolFolderCfg(configFlags): result=ComponentAccumulator() - from IOVDbSvc.IOVDbSvcConfig import addFolders, IOVDbSvcCfg - result.mergeAll(IOVDbSvcCfg(configFlags)) + from IOVDbSvc.IOVDbSvcConfig import addFolders # rely on global tag for both MC and data; do not specify folder tags # use CALO_OFL only for GEO>=18 hadCalibFolders = [ @@ -239,8 +238,7 @@ def getTopoCalibMoments(configFlags): def caloTopoCoolFolderCfg(configFlags): result=ComponentAccumulator() - from IOVDbSvc.IOVDbSvcConfig import addFolders, IOVDbSvcCfg - result.mergeAll(IOVDbSvcCfg(configFlags)) + from IOVDbSvc.IOVDbSvcConfig import addFolders # rely on global tag for both MC and data; do not specify folder tags # use CALO_OFL only for GEO>=18 hadCalibFolders = [ diff --git a/Control/AthenaConfiguration/python/ArgsToFlags.py b/Control/AthenaConfiguration/python/ArgsToFlags.py new file mode 100644 index 0000000000000000000000000000000000000000..d74d2b0627f386bb6aaec7fb6d4e0a94938e55ed --- /dev/null +++ b/Control/AthenaConfiguration/python/ArgsToFlags.py @@ -0,0 +1,40 @@ + + +def argsToFlags(configFlags=None, listOfArgs=None): + + if configFlags is None: + from AthenaConfiguration.AllConfigFlags import ConfigFlags + configFlags=ConfigFlags + + if listOfArgs is None: + import sys + listOfArgs=sys.argv[1:] + + + for arg in listOfArgs: + #Safety check on arg: Contains exactly one '=' and left side is a valid flag + argsplit=arg.split("=") + if len(argsplit)!=2: + raise ValueError("Can't interpret argument %s, expected a key=value format" % arg) + + key=argsplit[0].strip() + if not configFlags.hasFlag(key): + raise KeyError("%s is not a known configuration flag" % key) + + #Arg looks good enough, just exec it: + argToExec="configFlags."+arg + + exec(argToExec) + + return configFlags + + +if __name__=="__main__": + + from AthenaConfiguration.AllConfigFlags import ConfigFlags + ConfigFlags.Input.Files=["yourfile",] + + #Overwrite flags from the command-line + argsToFlags() + ConfigFlags.dump() + diff --git a/Control/AthenaConfiguration/python/ComponentAccumulator.py b/Control/AthenaConfiguration/python/ComponentAccumulator.py index d19fb3834de2c536dc52cfad70dbb276ce9df157..e964ef8902f0480748feadfc210313d8bf8380fd 100644 --- a/Control/AthenaConfiguration/python/ComponentAccumulator.py +++ b/Control/AthenaConfiguration/python/ComponentAccumulator.py @@ -464,43 +464,11 @@ class ComponentAccumulator(object): pass - - def mergeAll(self,others, sequenceName=None): - if isinstance(others,ComponentAccumulator): - return self.merge(others) - - elif isinstance(others,collections.Sequence): - for other in others: - if isinstance (other,ComponentAccumulator): - self.merge(other) - elif isinstance (other,ConfigurableService): - self.addService(other) - elif isinstance(other,ConfigurableAlgorithm): - self.addEventAlgorithm(other, sequenceName=sequenceName) - #FIXME: At this point we can't distingush event algos from conditions algos. - #Might become possible with new Gaudi configurables - elif isinstance(other,ConfigurableAlgTool): - self.addPublicTool(other) - else: - raise RuntimeError("mergeAll called with unexpected parameter of type %s" % type(other)) - - else: - raise RuntimeError("mergeAll called with unexpected parameter") - def merge(self,other, sequenceName=None): """ Merging in the other accumulator """ if other is None: raise RuntimeError("merge called on object of type None: did you forget to return a CA from a config function?") - if isinstance(other,collections.Sequence): - self._msg.error("Merge called with a: %s " % str(type(other)) + " of length: %d " % len(other)) - self._msg.error("where elements are of type : " + ", ".join([ str(type(x).__name__) for x in other]) ) - if len(other) > 1 and isinstance(other[0], ComponentAccumulator): - self._msg.error("Try calling mergeAll") - raise RuntimeError("Merge can not handle a sequence: " + ", ".join([ str(type(x).__name__) for x in other]) +", call mergeAll instead" ) - else: - raise RuntimeError("Merge can not handle a sequence: " + ", ".join([ str(type(x).__name__) for x in other]) +"" ) - if not isinstance(other,ComponentAccumulator): raise TypeError("Attempt merge wrong type %s. Only instances of ComponentAccumulator can be added" % type(other).__name__) diff --git a/Control/AthenaConfiguration/python/ComponentAccumulatorTest.py b/Control/AthenaConfiguration/python/ComponentAccumulatorTest.py index fc72853a8f32f3cd70947b48ac3a228277f70bb0..af1bab63dde04ba7c7c66b3871349f082980f8b1 100644 --- a/Control/AthenaConfiguration/python/ComponentAccumulatorTest.py +++ b/Control/AthenaConfiguration/python/ComponentAccumulatorTest.py @@ -260,7 +260,7 @@ class FailedMerging( unittest.TestCase ): def badMerge(): someCA = ComponentAccumulator() topCA.merge( (someCA, 1, "hello") ) - self.assertRaises(RuntimeError, badMerge ) + self.assertRaises(TypeError, badMerge ) topCA.wasMerged() diff --git a/InnerDetector/InDetDigitization/SCT_Digitization/python/SCT_DigitizationConfigNew.py b/InnerDetector/InDetDigitization/SCT_Digitization/python/SCT_DigitizationConfigNew.py index 8bdea12c61bd9910d28a4f03a3b42d4b03d31b8f..1af3cb765b61d9283ca03434bbf8ecbb1f88ab47 100644 --- a/InnerDetector/InDetDigitization/SCT_Digitization/python/SCT_DigitizationConfigNew.py +++ b/InnerDetector/InDetDigitization/SCT_Digitization/python/SCT_DigitizationConfigNew.py @@ -53,8 +53,9 @@ def SCT_DigitizationCommonCfg(flags, name="SCT_DigitizationToolCommon", **kwargs surfAcc = SCT_SurfaceChargesGeneratorCfg(flags) tool.SurfaceChargesGenerator = surfAcc.popPrivateTools() tool.RandomDisabledCellGenerator = SCT_RandomDisabledCellGeneratorCfg(flags) - acc.mergeAll([frontAcc, surfAcc]) acc.setPrivateTools(tool) + acc.merge(frontAcc) + acc.merge(surfAcc) return acc def SCT_DigitizationToolCfg(flags, name="SCT_DigitizationTool", **kwargs): @@ -153,8 +154,11 @@ def SCT_SurfaceChargesGeneratorCfg(flags, name="SCT_SurfaceChargesGenerator", ** tool.SiConditionsTool = SiliCondTool tool.SiPropertiesTool = SiliPropsAcc.popPrivateTools() tool.LorentzAngleTool = LorentzAcc.popPrivateTools() - acc.mergeAll([DCSCondAcc, SiliCondAcc, SiliPropsAcc, LorentzAcc]) acc.setPrivateTools(tool) + acc.merge(DCSCondAcc) + acc.merge(SiliCondAcc) + acc.merge(SiliPropsAcc) + acc.merge(LorentzAcc) return acc def SCT_FrontEndCfg(flags, name="SCT_FrontEnd", **kwargs): diff --git a/MuonSpectrometer/MuonConfig/python/MuonBytestreamDecodeConfig.py b/MuonSpectrometer/MuonConfig/python/MuonBytestreamDecodeConfig.py index c91b6879b4f72ff6874e6d17956e95277faa20ed..6ac90ed1f8ab0660139fa6e141ab91e9f51a3f01 100644 --- a/MuonSpectrometer/MuonConfig/python/MuonBytestreamDecodeConfig.py +++ b/MuonSpectrometer/MuonConfig/python/MuonBytestreamDecodeConfig.py @@ -229,20 +229,20 @@ if __name__=="__main__": from ByteStreamCnvSvc.ByteStreamConfig import TrigBSReadCfg cfg.merge(TrigBSReadCfg(ConfigFlags )) - # Schedule Rpc data decoding - once mergeAll is working can simplify these lines + # Schedule Rpc data decoding rpcdecodingAcc = RpcBytestreamDecodeCfg( ConfigFlags ) cfg.merge( rpcdecodingAcc ) - # Schedule Tgc data decoding - once mergeAll is working can simplify these lines + # Schedule Tgc data decoding tgcdecodingAcc = TgcBytestreamDecodeCfg( ConfigFlags ) cfg.merge( tgcdecodingAcc ) - # Schedule Mdt data decoding - once mergeAll is working can simplify these lines + # Schedule Mdt data decoding mdtdecodingAcc = MdtBytestreamDecodeCfg( ConfigFlags , True) cfg.merge( mdtdecodingAcc ) - # Schedule Csc data decoding - once mergeAll is working can simplify these lines + # Schedule Csc data decoding cscdecodingAcc = CscBytestreamDecodeCfg( ConfigFlags , True) cfg.merge( cscdecodingAcc ) diff --git a/MuonSpectrometer/MuonConfig/python/MuonRdoDecodeConfig.py b/MuonSpectrometer/MuonConfig/python/MuonRdoDecodeConfig.py index 90b84499d644711ec94d0aa132dd8172220e25f1..507b9d596a2df844bd45f2367833c46c9d2847e9 100644 --- a/MuonSpectrometer/MuonConfig/python/MuonRdoDecodeConfig.py +++ b/MuonSpectrometer/MuonConfig/python/MuonRdoDecodeConfig.py @@ -186,7 +186,7 @@ def muonRdoDecodeTestData( forTrigger = False ): from MuonConfig.MuonBytestreamDecodeConfig import MuonCacheCfg cfg.merge( MuonCacheCfg() ) - # Schedule Rpc bytestream data decoding - once mergeAll is working can simplify these lines + # Schedule Rpc bytestream data decoding from MuonConfig.MuonBytestreamDecodeConfig import RpcBytestreamDecodeCfg rpcdecodingAcc = RpcBytestreamDecodeCfg( ConfigFlags ) @@ -272,7 +272,7 @@ def muonRdoDecodeTestMC(): from AthenaPoolCnvSvc.PoolReadConfig import PoolReadCfg cfg.merge(PoolReadCfg(ConfigFlags)) - # Schedule RDO conversion - can replace this with cfg.mergeAll once that is working + # Schedule RDO conversion # RPC decoding rpcdecodingAcc = RpcRDODecodeCfg( ConfigFlags ) cfg.merge(rpcdecodingAcc) diff --git a/PhysicsAnalysis/JetTagging/JetTagAlgs/BTagging/python/BTagRun3Config.py b/PhysicsAnalysis/JetTagging/JetTagAlgs/BTagging/python/BTagRun3Config.py index 883cbf4a689b3dc4e394eda3367e14ed0b17afa5..76d60b2cf1925cdac1fe2a6658e7b0c1f3473cdc 100644 --- a/PhysicsAnalysis/JetTagging/JetTagAlgs/BTagging/python/BTagRun3Config.py +++ b/PhysicsAnalysis/JetTagging/JetTagAlgs/BTagging/python/BTagRun3Config.py @@ -349,12 +349,6 @@ def BTagCfg(inputFlags,**kwargs): #Some such items may be best placed elsewehere (e.g. put magnetic field setup in magnetic field git folder etc) result=ComponentAccumulator() - from StoreGate.StoreGateConf import StoreGateSvc - result.addService(StoreGateSvc("DetectorStore")) - - from AtlasGeoModel.GeoModelConfig import GeoModelCfg - result.mergeAll(GeoModelCfg(inputFlags)) - from TrkDetDescrSvc.AtlasTrackingGeometrySvcConfig import TrackingGeometrySvcCfg acc, geom_svc = TrackingGeometrySvcCfg(inputFlags) result.merge(acc) diff --git a/Reconstruction/eflowRec/python/PFRun3Config.py b/Reconstruction/eflowRec/python/PFRun3Config.py index 3ed129b48a9e2eb0d06a2f8c85dae286889ab90e..001dac680058d50c5d5f8168815296fa9c7d7b04 100644 --- a/Reconstruction/eflowRec/python/PFRun3Config.py +++ b/Reconstruction/eflowRec/python/PFRun3Config.py @@ -8,12 +8,6 @@ def PFCfg(inputFlags,**kwargs): #Some such items may be best placed elsewehere (e.g. put magnetic field setup in magnetic field git folder etc) result=ComponentAccumulator() - from StoreGate.StoreGateConf import StoreGateSvc - result.addService(StoreGateSvc("DetectorStore")) - - from AtlasGeoModel.GeoModelConfig import GeoModelCfg - result.mergeAll(GeoModelCfg(inputFlags)) - from TrkDetDescrSvc.AtlasTrackingGeometrySvcConfig import TrackingGeometrySvcCfg acc, geom_svc = TrackingGeometrySvcCfg(inputFlags) result.merge(acc) diff --git a/Trigger/TrigAlgorithms/TrigT2CaloCommon/python/TrigCaloDataAccessConfig.py b/Trigger/TrigAlgorithms/TrigT2CaloCommon/python/TrigCaloDataAccessConfig.py index 18778580b17bc098e5f0eaaf5857afef99682ea2..124eb6d42750e2e9b2d7c5e9a0719233c2714ab4 100644 --- a/Trigger/TrigAlgorithms/TrigT2CaloCommon/python/TrigCaloDataAccessConfig.py +++ b/Trigger/TrigAlgorithms/TrigT2CaloCommon/python/TrigCaloDataAccessConfig.py @@ -45,7 +45,7 @@ def trigCaloDataAccessSvcCfg( flags ): acc.getService('GeoModelSvc').DetectorTools['TileDetectorTool'].GeometryConfig = 'RECO' from RegionSelector.RegSelConfig import regSelCfg - acc.mergeAll( regSelCfg( flags ) ) + acc.merge( regSelCfg( flags ) ) acc.merge( createLArRoI_Map( flags ) ) diff --git a/Trigger/TrigSteer/L1Decoder/python/L1DecoderConfig.py b/Trigger/TrigSteer/L1Decoder/python/L1DecoderConfig.py index 019c415cda5dc5e2dbf5074a4bc537565050fd26..1479f43e618e8d248e249a411640785b1d3fae5b 100644 --- a/Trigger/TrigSteer/L1Decoder/python/L1DecoderConfig.py +++ b/Trigger/TrigSteer/L1Decoder/python/L1DecoderConfig.py @@ -30,8 +30,8 @@ def L1DecoderCfg(flags): from MuonConfig.MuonCablingConfig import RPCCablingConfigCfg, TGCCablingConfigCfg - acc.mergeAll( TGCCablingConfigCfg( flags ) ) - acc.mergeAll( RPCCablingConfigCfg( flags ) ) + acc.merge( TGCCablingConfigCfg( flags ) ) + acc.merge( RPCCablingConfigCfg( flags ) ) decoderAlg.roiUnpackers += [ MURoIsUnpackingTool( Decisions = recordable("L1MU"), OutputTrigRoIs = recordable("MURoIs"), MonTool = RoIsUnpackingMonitoring( prefix="MU", maxCount=20 ) ) ]