From 26a9b89b27d4c6809d79b3ba8243fcfd8761b83d Mon Sep 17 00:00:00 2001 From: Zach Marshall Date: Wed, 22 Jan 2020 16:43:38 +0100 Subject: [PATCH 1/2] Adding draft translator for trans to pers names To avoid warnings and reduce some code complexity, we want a translator from transient container name (e.g. with _v3 in, or with DataVectr<>) to persistent name (no _v3, or Container). This adds a little helper function to do the translation, and uses it in RecExCommon - successfully avoiding the warnings that are printed otherwise. --- .../xAODRootAccess/python/ClassNameManips.py | 26 +++++++++++++++++++ .../share/RecExCommon_topOptions.py | 4 ++- 2 files changed, 29 insertions(+), 1 deletion(-) create mode 100644 Control/xAODRootAccess/python/ClassNameManips.py diff --git a/Control/xAODRootAccess/python/ClassNameManips.py b/Control/xAODRootAccess/python/ClassNameManips.py new file mode 100644 index 00000000000..13d5478a2d9 --- /dev/null +++ b/Control/xAODRootAccess/python/ClassNameManips.py @@ -0,0 +1,26 @@ + +# Helper functions for class name manipulations + +# For some of the finding +import re + +# For logging errors and warnings +from AthenaCommon import Logging +cnm_log = Logging.logging.getLogger('ClassNameManips') + +def pers_to_trans_name(p): + # Baseline: transient name is identical + t = p + # Let's look for a version in the name + vers = re.findall('_v\d+',t) + if len(vers)>1: + cnm_log.warning('Input name '+p+' seems to have multiple version numbers: '+str(vers)+' - will wipe them all') + for v in vers: + # Wipe out the version + t = t.replace(v,'') + # Now convert data vectors + if 'DataVector<' in t: + t = t.replace('DataVector<','').replace('>','') + t = 'Container#'.join(t.split('#')) + cnm_log.debug('Translated '+p+' to '+t) + return t diff --git a/Reconstruction/RecExample/RecExCommon/share/RecExCommon_topOptions.py b/Reconstruction/RecExample/RecExCommon/share/RecExCommon_topOptions.py index a05093959a3..5fe6060df29 100755 --- a/Reconstruction/RecExample/RecExCommon/share/RecExCommon_topOptions.py +++ b/Reconstruction/RecExample/RecExCommon/share/RecExCommon_topOptions.py @@ -1369,7 +1369,9 @@ if rec.doDPD() and (rec.DPDMakerScripts()!=[] or rec.doDPD.passThroughMode): from RecExConfig.InputFilePeeker import inputFileSummary #Explicitely add file metadata from input and from transient store - MSMgr.AddMetaDataItemToAllStreams(inputFileSummary['metadata_itemsList']) + #Include translation of name from persistent format to transient format + from xAODRootAccess.ClassNameManips import pers_to_trans_name + MSMgr.AddMetaDataItemToAllStreams([pers_to_trans_name(x) for x in inputFileSummary['metadata_itemsList']]) MSMgr.AddMetaDataItemToAllStreams(dfMetadataItemList()) pass pass -- GitLab From 2e831a1baf8d3298b808def51191d1f05a683841 Mon Sep 17 00:00:00 2001 From: Zach Marshall Date: Thu, 23 Jan 2020 20:06:26 +0100 Subject: [PATCH 2/2] Adding copyright statement --- Control/xAODRootAccess/python/ClassNameManips.py | 1 + 1 file changed, 1 insertion(+) diff --git a/Control/xAODRootAccess/python/ClassNameManips.py b/Control/xAODRootAccess/python/ClassNameManips.py index 13d5478a2d9..356d92e9c66 100644 --- a/Control/xAODRootAccess/python/ClassNameManips.py +++ b/Control/xAODRootAccess/python/ClassNameManips.py @@ -1,3 +1,4 @@ +# Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration # Helper functions for class name manipulations -- GitLab