ATLAS Offline Software
LArCablingConfig.py
Go to the documentation of this file.
1 # Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
2 
3 from AthenaConfiguration.ComponentFactory import CompFactory
4 from AthenaConfiguration.ComponentAccumulator import ComponentAccumulator
5 from IOVDbSvc.IOVDbSvcConfig import IOVDbSvcCfg, addFolders
6 LArOnOffMappingAlg, LArFebRodMappingAlg, LArCalibLineMappingAlg,LArLATOMEMappingAlg=CompFactory.getComps("LArOnOffMappingAlg","LArFebRodMappingAlg","LArCalibLineMappingAlg","LArLATOMEMappingAlg")
7 
8 def _larCablingCfg(configFlags,algo,folder,algName=None):
9  result=ComponentAccumulator()
10 
11  result.merge(IOVDbSvcCfg(configFlags))
12 
13  #MC folder-tag hack (See also ATCONDDB-49)
14  tagsperFolder={"/LAR/Identifier/OnOffIdMap":"LARIdentifierOnOffIdMap-012",
15  "/LAR/Identifier/FebRodMap":"LARIdentifierFebRodMap-005",
16  "/LAR/Identifier/CalibIdMap":"LARIdentifierCalibIdMap-012",
17  }
18 
19  if configFlags.Input.isMC:
20  db='LAR_OFL'
21  if folder in tagsperFolder:
22  ft=tagsperFolder[folder]
23  folderwithtag=folder+"<tag>"+ft+"</tag>"
24  else:
25  folderwithtag=folder
26  else:
27  db='LAR_ONL'
28  folderwithtag=folder
29 
30  if algName is None:
31  result.addCondAlgo(algo(ReadKey=folder),primary=True)
32  else:
33  result.addCondAlgo(algo(name=algName, ReadKey=folder),primary=True)
34  result.merge(addFolders(configFlags,folderwithtag,className="AthenaAttributeList",detDb=db))
35  return result
36 
37 def _larLatomeCfg(configFlags,algo,folder,outkey):
38  result=ComponentAccumulator()
39 
40  result.merge(IOVDbSvcCfg(configFlags))
41 
42  #MC folder-tag hack
43  tagsperFolder={"/LAR/IdentifierSC/LatomeMapping":"LARIdentifierSCLatomeMapping-UPD1-00"
44  }
45 
46  if configFlags.Input.isMC:
47  db='LAR_OFL'
48  if folder in tagsperFolder:
49  ft=tagsperFolder[folder]
50  folderwithtag=folder+"<tag>"+ft+"</tag>"
51  else:
52  folderwithtag=folder
53  else:
54  db='LAR_ONL'
55  folderwithtag=folder
56 
57  result.addCondAlgo(algo(ReadKey=folder,WriteKey=outkey),primary=True)
58  result.merge(addFolders(configFlags,folderwithtag,className="CondAttrListCollection",detDb=db))
59  #print (result)
60  return result
61 
62 def LArOnOffIdMappingCfg(configFlags):
63  return _larCablingCfg(configFlags,LArOnOffMappingAlg,"/LAR/Identifier/OnOffIdMap")
64 
65 def LArOnOffIdMappingSCCfg(configFlags):
66  result = ComponentAccumulator()
67  # mapping requires the geometry to be loaded
68  from LArGeoAlgsNV.LArGMConfig import LArGMCfg
69  result.merge(LArGMCfg(configFlags))
70  if configFlags.Input.isMC:
71  result.merge(_larCablingCfg(configFlags,LArOnOffMappingAlg,"/LAR/IdentifierOfl/OnOffIdMap_SC","LArOnOffMappingAlgSC"))
72  from IOVDbSvc.IOVDbSvcConfig import addOverride
73  result.merge(addOverride(configFlags, "/LAR/IdentifierOfl/OnOffIdMap_SC", "LARIdentifierOflOnOffIdMap_SC-000")) # FIXME temporary?
74  else:
75  result.merge(_larCablingCfg(configFlags,LArOnOffMappingAlg,"/LAR/Identifier/OnOffIdMap_SC","LArOnOffMappingAlgSC"))
76  result.getCondAlgo("LArOnOffMappingAlgSC").WriteKey = "LArOnOffIdMapSC"
77  result.getCondAlgo("LArOnOffMappingAlgSC").isSuperCell = True
78  return result
79 
80 def LArFebRodMappingCfg(configFlags):
81  return _larCablingCfg(configFlags,LArFebRodMappingAlg,"/LAR/Identifier/FebRodMap")
82 
83 def LArCalibIdMappingCfg(configFlags):
84  return _larCablingCfg(configFlags,LArCalibLineMappingAlg,"/LAR/Identifier/CalibIdMap")
85 
86 def LArCalibIdMappingSCCfg(configFlags):
87  result = ComponentAccumulator()
88  if not configFlags.Input.isMC:
89  result.merge(_larCablingCfg(configFlags,LArCalibLineMappingAlg,"/LAR/Identifier/CalibIdMap_SC","LArCalibLineMappingAlgSC"))
90  result.getCondAlgo("LArCalibLineMappingAlgSC").WriteKey="LArCalibIdMapSC"
91  result.getCondAlgo("LArCalibLineMappingAlgSC").isSuperCell=True
92  result.getCondAlgo("LArCalibLineMappingAlgSC").MaxCL=16
93  return result
94 
95 def LArLATOMEMappingCfg(configFlags):
96  if not configFlags.Input.isMC:
97  return _larLatomeCfg(configFlags,LArLATOMEMappingAlg,"/LAR/Identifier/LatomeMapping","LArLATOMEMap")
98 
99 def LArIdMapCfg(configFlags):
100  """Return ComponentAccumulator configured with Identifier Map in POOL/COOL"""
101  # replaces LArIdMap_MC_jobOptions.py or LArIdMap_comm_jobOptions.py
102  result = LArOnOffIdMappingCfg(configFlags)
103  result.merge(LArFebRodMappingCfg(configFlags))
104  result.merge(LArCalibIdMappingCfg(configFlags))
105  return result
106 
107 
108 if __name__ == "__main__":
109  from AthenaConfiguration.AllConfigFlags import initConfigFlags
110  from AthenaConfiguration.TestDefaults import defaultTestFiles
111 
113  flags.Input.Files = defaultTestFiles.RAW_RUN2
114  flags.lock()
115 
116  acc = LArOnOffIdMappingCfg( flags )
117  acc.merge(LArFebRodMappingCfg(flags))
118  acc.merge(LArCalibIdMappingCfg(flags))
119  acc.store( open( "test.pkl", "wb" ) )
120  print ("All OK")
LArCablingConfig.LArOnOffIdMappingSCCfg
def LArOnOffIdMappingSCCfg(configFlags)
Definition: LArCablingConfig.py:65
python.JetAnalysisCommon.ComponentAccumulator
ComponentAccumulator
Definition: JetAnalysisCommon.py:302
LArCablingConfig._larLatomeCfg
def _larLatomeCfg(configFlags, algo, folder, outkey)
Definition: LArCablingConfig.py:37
LArCablingConfig.LArFebRodMappingCfg
def LArFebRodMappingCfg(configFlags)
Definition: LArCablingConfig.py:80
LArCablingConfig._larCablingCfg
def _larCablingCfg(configFlags, algo, folder, algName=None)
Definition: LArCablingConfig.py:8
LArCablingConfig.LArLATOMEMappingCfg
def LArLATOMEMappingCfg(configFlags)
Definition: LArCablingConfig.py:95
python.IOVDbSvcConfig.addOverride
def addOverride(flags, folder, tag, db=None)
Definition: IOVDbSvcConfig.py:224
python.IOVDbSvcConfig.addFolders
def addFolders(flags, folderStrings, detDb=None, className=None, extensible=False, tag=None, db=None, modifiers='')
Definition: IOVDbSvcConfig.py:72
python.IOVDbSvcConfig.IOVDbSvcCfg
def IOVDbSvcCfg(flags, **kwargs)
Definition: IOVDbSvcConfig.py:19
LArCablingConfig.LArOnOffIdMappingCfg
def LArOnOffIdMappingCfg(configFlags)
Definition: LArCablingConfig.py:62
LArGMConfig.LArGMCfg
def LArGMCfg(flags)
Definition: LArGMConfig.py:8
Trk::open
@ open
Definition: BinningType.h:40
LArCablingConfig.LArCalibIdMappingSCCfg
def LArCalibIdMappingSCCfg(configFlags)
Definition: LArCablingConfig.py:86
python.AllConfigFlags.initConfigFlags
def initConfigFlags()
Definition: AllConfigFlags.py:19
LArCablingConfig.LArIdMapCfg
def LArIdMapCfg(configFlags)
Definition: LArCablingConfig.py:99
LArCablingConfig.LArCalibIdMappingCfg
def LArCalibIdMappingCfg(configFlags)
Definition: LArCablingConfig.py:83