From d51cd20780105553577e7f456ab8acc2d3ac9bc3 Mon Sep 17 00:00:00 2001 From: Walter Lampl <Walter.Lampl@cern.ch> Date: Mon, 28 May 2018 11:51:45 +0200 Subject: [PATCH] squashed version of CaloCellMakerConfig Former-commit-id: ad721ff95fed26c9cfd298614133d496ca79c815 --- .../CaloRec/python/CaloCellMakerConfig.py | 51 ++++++++++++ .../python/ComponentAccumulator.py | 4 +- Database/IOVDbSvc/python/IOVDbSvcConfig.py | 55 ++++++++++--- .../python/LArBadChannelConfig.py | 79 +++++++++++++++++++ .../LArCabling/python/LArCablingConfig.py | 39 +++++++++ .../LArCellRec/python/LArCellBuilderConfig.py | 57 +++++++++++++ .../LArCellRec/python/LArConfigFlags.py | 2 + .../src/LArCellNoiseMaskingTool.cxx | 4 +- 8 files changed, 277 insertions(+), 14 deletions(-) create mode 100644 Calorimeter/CaloRec/python/CaloCellMakerConfig.py create mode 100644 LArCalorimeter/LArBadChannelTool/python/LArBadChannelConfig.py create mode 100644 LArCalorimeter/LArCabling/python/LArCablingConfig.py create mode 100644 LArCalorimeter/LArCellRec/python/LArCellBuilderConfig.py diff --git a/Calorimeter/CaloRec/python/CaloCellMakerConfig.py b/Calorimeter/CaloRec/python/CaloCellMakerConfig.py new file mode 100644 index 000000000000..bc2f3b1aa3ed --- /dev/null +++ b/Calorimeter/CaloRec/python/CaloCellMakerConfig.py @@ -0,0 +1,51 @@ +# Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration + +from AthenaConfiguration.ComponentAccumulator import ComponentAccumulator +#from LArCellRec.LArCellRecConf import LArCellBuilderFromLArRawChannelTool +from CaloRec.CaloRecConf import CaloCellMaker, CaloCellContainerFinalizerTool +from LArCellRec.LArCellBuilderConfig import LArCellBuilderCfg,LArCellCorrectorCfg +from TileRecUtils.TileRecUtilsConf import TileCellBuilder + +def CaloCellMakerCfg(configFlags): + result=ComponentAccumulator() + + from LArGeoAlgsNV.LArGMConfig import LArGMCfg + from TileGeoModel.TileGMConfig import TileGMCfg + result.addConfig(LArGMCfg,configFlags) + result.addConfig(TileGMCfg,configFlags) + + theLArCellMaker=result.addConfig(LArCellBuilderCfg,configFlags) + + theLArCellCorrectors=result.addConfig(LArCellCorrectorCfg,configFlags) + + theTileCellBuilder = TileCellBuilder() + result.addEventAlgo(CaloCellMaker(CaloCellMakerToolNames=theLArCellMaker+ + [CaloCellContainerFinalizerTool()]+theLArCellCorrectors, + CaloCellsOutputName="AllCalo")) + return result + + + +if __name__=="__main__": + from AthenaCommon.Logging import log + from AthenaCommon.Constants import DEBUG + + log.setLevel(DEBUG) + from AthenaConfiguration.AllConfigFlags import ConfigFlags + + ConfigFlags.set("global.InputFiles",["myRDO.pool.root"]) + ConfigFlags.lock() + + cfg=ComponentAccumulator() + + from AthenaPoolCnvSvc.PoolReadConfig import PoolReadCfg + cfg.addConfig(PoolReadCfg,ConfigFlags) + + cfg.addConfig(CaloCellMakerCfg,ConfigFlags) + cfg.getEventAlgo("CaloCellMaker").CaloCellsOutputName="AllCaloNew" + + f=open("CaloCellMaker.pkl","w") + cfg.store(f) + f.close() + + #ConfigFlags.dump() diff --git a/Control/AthenaConfiguration/python/ComponentAccumulator.py b/Control/AthenaConfiguration/python/ComponentAccumulator.py index 3d35b2e5a8b8..0073c98f3bd5 100644 --- a/Control/AthenaConfiguration/python/ComponentAccumulator.py +++ b/Control/AthenaConfiguration/python/ComponentAccumulator.py @@ -208,7 +208,7 @@ class ComponentAccumulator(object): else: #self._msg.error("component '%s' defined multiple times with mismatching configuration", svcs[i].getJobOptName()) raise DeduplicationFailed("component '%s' defined multiple times with mismatching property %s" % \ - comp.getJobOptName(),prop) + (comp.getJobOptName(),str(prop))) pass #end if prop-mismatch pass @@ -369,7 +369,7 @@ class ComponentAccumulator(object): #The client is supposed to grab the private tools and attach #them to their parent component self._privateTools=retval._privateTools - return + return self._privateTools def appendConfigurable(self,confElem): diff --git a/Database/IOVDbSvc/python/IOVDbSvcConfig.py b/Database/IOVDbSvc/python/IOVDbSvcConfig.py index b472ff7c0af0..a7c98165833c 100644 --- a/Database/IOVDbSvc/python/IOVDbSvcConfig.py +++ b/Database/IOVDbSvc/python/IOVDbSvcConfig.py @@ -1,15 +1,18 @@ # Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration from AthenaConfiguration.ComponentAccumulator import ComponentAccumulator, ConfigurationError +from IOVSvc.IOVSvcConf import CondInputLoader import os def IOVDbSvcCfg(configFlags): result=ComponentAccumulator() + #Add the conditions loader, must be the first in the sequence + result.addCondAlgo(CondInputLoader()) + 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: @@ -50,6 +53,7 @@ def IOVDbSvcCfg(configFlags): from PoolSvc.PoolSvcConf import PoolSvc poolSvc=PoolSvc() + poolSvc.MaxFilesOpen=0 poolSvc.ReadCatalog=["apcfile:poolcond/PoolFileCatalog.xml", "prfile:poolcond/PoolCat_oflcond.xml", "apcfile:poolcond/PoolCat_oflcond.xml", @@ -63,7 +67,6 @@ def IOVDbSvcCfg(configFlags): result.addService(CondSvc()) result.addService(ProxyProviderSvc(ProviderNames=["IOVDbSvc",])) - from DBReplicaSvc.DBReplicaSvcConf import DBReplicaSvc if not isMC: result.addService(DBReplicaSvc(COOLSQLiteVetoPattern="/DBRelease/")) @@ -74,12 +77,24 @@ def IOVDbSvcCfg(configFlags): #Convenience method to add folders: -def addFolders(configFlags,folderstrings,detDb=None): +def addFolders(configFlags,folderstrings,detDb=None,className=None): + + #Convenince hack: Allow a single string as parameter: + if isinstance(folderstrings,str): + folderstrings=[folderstrings,] + result=ComponentAccumulator() result.addConfig(IOVDbSvcCfg,configFlags) - - + #Add class-name to CondInputLoader (if reqired) + if className is not None: + loadFolders=[] + for fs in folderstrings: + loadFolders.append((className, _extractFolder(fs))); + result.getCondAlgo("CondInputLoader").Load+=loadFolders + #result.addCondAlgo(CondInputLoader(Load=loadFolders)) + + iovDbSvc=result.getService("IOVDbSvc") if detDb is not None: @@ -90,10 +105,6 @@ def addFolders(configFlags,folderstrings,detDb=None): 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: @@ -101,7 +112,6 @@ def addFolders(configFlags,folderstrings,detDb=None): else: iovDbSvc.Folders.append(fs) - return result @@ -162,3 +172,28 @@ _dblist={ +def _extractFolder(folderstr): + "Extract the folder name (non-XML text) from a IOVDbSvc.Folders entry" + fname="" + xmltag="" + ix=0 + while ix<len(folderstr): + if (folderstr[ix]=='<' and xmltag==""): + ix2=folderstr.find('>',ix) + if (ix2!=-1): + xmltag=(folderstr[ix+1:ix2]).strip() + ix=ix2+1 + elif (folderstr[ix:ix+2]=='</' and xmltag!=""): + ix2=folderstr.find('>',ix) + if (ix2!=-1): + xmltag="" + ix=ix2+1 + else: + ix2=folderstr.find('<',ix) + if ix2==-1: ix2=len(folderstr) + if (xmltag==""): fname=fname+folderstr[ix:ix2] + ix=ix2 + return fname.strip() + + + diff --git a/LArCalorimeter/LArBadChannelTool/python/LArBadChannelConfig.py b/LArCalorimeter/LArBadChannelTool/python/LArBadChannelConfig.py new file mode 100644 index 000000000000..0829ab9ae170 --- /dev/null +++ b/LArCalorimeter/LArBadChannelTool/python/LArBadChannelConfig.py @@ -0,0 +1,79 @@ +from AthenaConfiguration.ComponentAccumulator import ComponentAccumulator +from LArBadChannelTool.LArBadChannelToolConf import LArBadChannelCondAlg, LArBadFebCondAlg, LArBadChannelMasker +from LArCabling.LArCablingConfig import LArOnOffIdMappingCfg +from IOVDbSvc.IOVDbSvcConfig import addFolders + +def LArBadChannelCfg(configFlags): + result=ComponentAccumulator() + + result.addConfig(LArOnOffIdMappingCfg,configFlags) + + if configFlags.get("global.isOnline") or configFlags.get("global.isMC"): + foldername="/LAR/BadChannels/BadChannels" + else: + foldername="/LAR/BadChannelsOfl/BadChannels" + pass + + if configFlags.get("global.isOnline"): + dbname="LAR" + else: + dbname="LAR_OFL" + + result.addConfig(addFolders,configFlags,foldername,detDb=dbname,className="CondAttrListCollection") + + result.addCondAlgo(LArBadChannelCondAlg(ReadKey=foldername)) + return result + + +def LArBadFebCfg(configFlags): + result=ComponentAccumulator() + + if configFlags.get("global.isOnline") or configFlags.get("global.isMC"): + foldername="/LAR/BadChannels/MissingFEBs" + else: + foldername="/LAR/BadChannelsOfl/MissingFEBs" + pass + + if configFlags.get("global.isOnline"): + dbname="LAR" + else: + dbname="LAR_OFL" + + result.addConfig(addFolders,configFlags,foldername,detDb=dbname,className="AthenaAttributeList") + + result.addCondAlgo(LArBadFebCondAlg(ReadKey=foldername)) + return result + + +def LArBadChannelMaskerCfg(configFlags,problemsToMask,doMasking=True, + ToolName="LArBadChannelMasker"): + result=ComponentAccumulator() + result.addConfig(LArBadChannelCfg,configFlags) + + result.addAlgTool(LArBadChannelMasker(ToolName,ProblemsToMask=problemsToMask, + DoMasking=doMasking)) + + return result + + + +if __name__=="__main__": + + from AthenaConfiguration.AllConfigFlags import ConfigFlags + from AthenaCommon.Logging import log + from AthenaCommon.Constants import DEBUG + log.setLevel(DEBUG) + + ConfigFlags.set("global.isMC",False) + ConfigFlags.set("global.InputFiles",["/cvmfs/atlas-nightlies.cern.ch/repo/data/data-art/Tier0ChainTests/data17_13TeV.00330470.physics_Main.daq.RAW._lb0310._SFO-1._0001.data"]) + ConfigFlags.lock() + + cfg=ComponentAccumulator() + + cfg.addConfig(LArBadChannelCfg,ConfigFlags) + cfg.addConfig(LArBadFebCfg,ConfigFlags) + cfg.addConfig(LArBadChannelMaskerCfg,ConfigFlags,["allDead",]) + f=open("LArBCCondAlgos.pkl","w") + cfg.store(f) + f.close() + diff --git a/LArCalorimeter/LArCabling/python/LArCablingConfig.py b/LArCalorimeter/LArCabling/python/LArCablingConfig.py new file mode 100644 index 000000000000..bd7c08478821 --- /dev/null +++ b/LArCalorimeter/LArCabling/python/LArCablingConfig.py @@ -0,0 +1,39 @@ +# Copyright (C) 2002-2018 CERN for the benefit of the ATLAS collaboration + +from AthenaConfiguration.ComponentAccumulator import ComponentAccumulator +from IOVDbSvc.IOVDbSvcConfig import addFolders +from LArRecUtils.LArRecUtilsConf import LArOnOffMappingAlg, LArFebRodMappingAlg, LArCalibLineMappingAlg + +def _larCablingCfg(configFlags,algo,folder): + result=ComponentAccumulator() + + #MC folder-tag hack (See also ATCONDDB-49) + tagsperFolder={"/LAR/Identifier/OnOffIdMap":"LARIdentifierOnOffIdMap-012", + "/LAR/Identifier/FebRodMap":"LARIdentifierFebRodMap-005", + "/LAR/Identifier/CalibIdMap":"LARIdentifierCalibIdMap-012" + } + + if configFlags.get("global.isMC"): + db='LAR_OFL' + if folder in tagsperFolder: + ft=tagsperFolder[folder] + folderwithtag=folder+"<tag>"+ft+"</tag>" + else: + db='LAR' + folderwithtag=folder + + result.addCondAlgo(algo(ReadKey=folder)) + result.addConfig(addFolders,configFlags,folderwithtag,className="AthenaAttributeList",detDb=db) + return result + + +def LArOnOffIdMappingCfg(configFlags): + return _larCablingCfg(configFlags,LArOnOffMappingAlg,"/LAR/Identifier/OnOffIdMap") + +def LArFebRodMappingCfg(configFlags): + return _larCablingCfg(configFlags,LArFebRodMappingAlg,"/LAR/Identifier/FebRodMap") + +def LArCalibIdMappingCfg(configFlags): + return _larCablingCfg(configFlags,LArCalibLineMappingAlg,"/LAR/Identifier/CalibIdMap") + + diff --git a/LArCalorimeter/LArCellRec/python/LArCellBuilderConfig.py b/LArCalorimeter/LArCellRec/python/LArCellBuilderConfig.py new file mode 100644 index 000000000000..5833ee4b0461 --- /dev/null +++ b/LArCalorimeter/LArCellRec/python/LArCellBuilderConfig.py @@ -0,0 +1,57 @@ +# Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration + +from AthenaConfiguration.ComponentAccumulator import ComponentAccumulator +from LArCellRec.LArCellRecConf import LArCellBuilderFromLArRawChannelTool, LArCellMerger, LArCellNoiseMaskingTool +from LArCabling.LArCablingConfig import LArOnOffIdMappingCfg + +def LArCellBuilderCfg(configFlags): + result=ComponentAccumulator() + result.addConfig(LArOnOffIdMappingCfg,configFlags) + theLArCellBuilder = LArCellBuilderFromLArRawChannelTool() + + theLArCellBuilder.addDeadOTX = False #Create flag? Requires bad-feb DB access + result.addAlgTool(theLArCellBuilder) + + + return result + + + +def LArCellCorrectorCfg(configFlags): + result=ComponentAccumulator() + + correctionTools=[] + + if configFlags.get("LAr.RawChannelSource")=="both": + theMerger=result.addConfig(LArCellMerger,configFlags,RawChannelsName="LArRawChannels_FromDigits") + correctionTools.append(theMerger[0]) + + if configFlags.get("LAr.doCellNoiseMasking") or configFlags.get("LAr.doCellSporadicNoiseMasking"): + from LArBadChannelTool.LArBadChannelConfig import LArBadChannelMaskerCfg + theNoiseMasker=LArCellNoiseMaskingTool() + if configFlags.get("LAr.doCellNoiseMasking"): + cellNoiseMaskingTool=result.addConfig(LArBadChannelMaskerCfg,configFlags, + problemsToMask=["highNoiseHG","highNoiseMG","highNoiseLG","deadReadout","deadPhys"], + ToolName="CellNoiseMask") + theNoiseMasker.MaskingTool=cellNoiseMaskingTool[0] + pass + if configFlags.get("LAr.doCellSporadicNoiseMasking"): + sporadicNoiseMaskingTool=result.addConfig(LArBadChannelMaskerCfg,configFlags, + problemsToMask=["sporadicBurstNoise",], + ToolName="SporadicNoiseMask") + theNoiseMasker.MaskingSporadicTool=sporadicNoiseMaskingTool[0] + pass + correctionTools.append(theNoiseMasker) + pass + + #Many more tools to be added, eg HV correction + + + result.clearAlgTools() + for t in correctionTools: + result.addAlgTool(t) + + return result + + + diff --git a/LArCalorimeter/LArCellRec/python/LArConfigFlags.py b/LArCalorimeter/LArCellRec/python/LArConfigFlags.py index 004476873ce6..b408df9c8ac6 100644 --- a/LArCalorimeter/LArCellRec/python/LArConfigFlags.py +++ b/LArCalorimeter/LArCellRec/python/LArConfigFlags.py @@ -15,6 +15,8 @@ def createLArConfigFlags(): # "calculated": re-computed by the offline LArRawChannelBuilder # "both": overwrite the digits computed + lcf.addFlag("LAr.doCellNoiseMasking",True) + lcf.addFlag("LAr.doCellSporadicNoiseMasking",True) return lcf diff --git a/LArCalorimeter/LArCellRec/src/LArCellNoiseMaskingTool.cxx b/LArCalorimeter/LArCellRec/src/LArCellNoiseMaskingTool.cxx index 8703ff13ca48..c90107b48ec6 100755 --- a/LArCalorimeter/LArCellRec/src/LArCellNoiseMaskingTool.cxx +++ b/LArCalorimeter/LArCellRec/src/LArCellNoiseMaskingTool.cxx @@ -34,8 +34,8 @@ LArCellNoiseMaskingTool::LArCellNoiseMaskingTool( const std::string& name, const IInterface* parent) :AthAlgTool(type, name, parent), - m_maskingTool(""), - m_maskingSporadicTool(""), + m_maskingTool(this), + m_maskingSporadicTool(this), m_qualityCut(65536), m_maskNoise(true), m_maskSporadic(true) -- GitLab