ATLAS Offline Software
Loading...
Searching...
No Matches
TagInfoMgrConfig.py
Go to the documentation of this file.
1# Copyright (C) 2002-2023 CERN for the benefit of the ATLAS collaboration
2from AthenaConfiguration.ComponentAccumulator import ComponentAccumulator, ConfigurationError
3from AthenaConfiguration.ComponentFactory import CompFactory
4
5
6def TagInfoMgrCfg(flags, tagValuePairs={}):
7 # Sanity check:
8 if not isinstance(tagValuePairs, dict):
9 raise ConfigurationError("Parameter extraTagValuePairs is supposed to be a dictionary")
10
11 # Build project-version string for the TagInfoMgr
12 from os import getenv
13 project = getenv("AtlasProject", "Unknown")
14 version = getenv("AtlasVersion", "Unknown")
15 atlasRelease=project+"-"+version
16
17 tagValuePairs.update({"AtlasRelease" : atlasRelease})
18
19 from Campaigns.Utils import Campaign
20 if flags.Input.isMC and flags.Input.MCCampaign is not Campaign.Unknown:
21 tagValuePairs.update({"mc_campaign" : flags.Input.MCCampaign.value})
22
23 result = ComponentAccumulator()
24 result.addService(CompFactory.TagInfoMgr(ExtraTagValuePairs=tagValuePairs), primary=True)
25 return result
26
27
28if __name__ == "__main__":
29 from AthenaConfiguration.AllConfigFlags import initConfigFlags
30 from AthenaConfiguration.TestDefaults import defaultTestFiles
31 flags = initConfigFlags()
32 flags.Input.Files = defaultTestFiles.RDO_RUN2
33 flags.lock()
34
35 acc = TagInfoMgrCfg( flags, {"SomeKey": "SomeValue"} )
36 acc2 = TagInfoMgrCfg( flags, {"OtherKey": "OtherValue", "SomeKey": "SomeValue"} )
37 acc.merge(acc2)
38
39 assert "SomeKey" in acc.getService("TagInfoMgr").ExtraTagValuePairs
40 assert "OtherKey" in acc.getService("TagInfoMgr").ExtraTagValuePairs
41 acc.store( open( "test.pkl", "wb" ) )
42 print("All OK")
void print(char *figname, TCanvas *c1)
TagInfoMgrCfg(flags, tagValuePairs={})