1 """Define functions to configure Pixel conditions algorithms
3 Copyright (C) 2002-2023 CERN for the benefit of the ATLAS collaboration
5 from AthenaConfiguration.AccumulatorCache
import AccumulatorCache
6 from AthenaConfiguration.ComponentAccumulator
import ComponentAccumulator
7 from AthenaConfiguration.ComponentFactory
import CompFactory
8 from AthenaConfiguration.Enums
import BeamType, LHCPeriod, Format
9 from IOVDbSvc.IOVDbSvcConfig
import addFolders,addFoldersSplitOnline
12 """Return a ComponentAccumulator with configured PixelConfigCondAlg"""
17 if flags.Beam.Type
is BeamType.Cosmics:
19 BarrelTimeJitter=[25.0,25.0,25.0,25.0],
20 EndcapTimeJitter=[25.0,25.0,25.0],
21 DBMTimeJitter=[25.0,25.0,25.0],
22 BarrelNumberOfBCID=[8,8,8,8],
23 EndcapNumberOfBCID=[8,8,8],
24 DBMNumberOfBCID=[8,8,8],
25 BarrelTimeOffset=[100.0,100.0,100.0,100.0],
26 EndcapTimeOffset=[100.0,100.0,100.0],
27 DBMTimeOffset=[100.0,100.0,100.0]
31 PixelParameterConditionsFolder=flags.InDet.PixelConfig.version,
32 UsePrivateFileName=flags.InDet.PixelConfig.UserInputFileName
36 IdMappingDat=
"PixelCabling/Pixels_Atlas_IdMapping_2016.dat"
39 if flags.GeoModel.Run >= LHCPeriod.Run4:
40 IdMappingDat =
"ITk_Atlas_IdMapping.dat"
41 elif flags.GeoModel.Run
in [LHCPeriod.Run2, LHCPeriod.Run3]:
43 if flags.GeoModel.IBLLayout ==
"planar":
44 if flags.GeoModel.Run
is LHCPeriod.Run2:
45 IdMappingDat=
"PixelCabling/Pixels_Atlas_IdMapping_inclIBL_DBM.dat"
47 IdMappingDat=
"PixelCabling/Pixels_Atlas_IdMapping_inclIBL.dat"
49 elif flags.GeoModel.IBLLayout ==
"3D":
50 IdMappingDat=
"PixelCabling/Pixels_Atlas_IdMapping_Run2.dat"
52 IdMappingDat=
"PixelCabling/Pixels_Atlas_IdMapping.dat"
53 elif not flags.Input.RunNumbers:
54 IdMappingDat=
"PixelCabling/Pixels_Atlas_IdMapping_344494.dat"
56 runNum = flags.Input.RunNumbers[0]
58 IdMappingDat=
"PixelCabling/Pixels_Atlas_IdMapping_May08.dat"
61 if (runNum >= 344494):
62 IdMappingDat=
"PixelCabling/Pixels_Atlas_IdMapping_344494.dat"
63 elif (runNum >= 314940
and runNum < 344494):
64 IdMappingDat=
"PixelCabling/Pixels_Atlas_IdMapping_314940.dat"
65 elif (runNum >= 289350
and runNum < 314940):
66 IdMappingDat=
"PixelCabling/Pixels_Atlas_IdMapping_2016.dat"
67 elif (runNum >= 222222
and runNum < 289350):
68 IdMappingDat=
"PixelCabling/Pixels_Atlas_IdMapping_Run2.dat"
70 IdMappingDat=
"PixelCabling/Pixels_Atlas_IdMapping_344494.dat"
73 CablingMapFileName=IdMappingDat
77 CondArgs.update(kwargs)
78 acc.addCondAlgo(CompFactory.PixelConfigCondAlg(name, **CondArgs))
83 """Return a ComponentAccumulator with configured PixelAlignCondAlg"""
84 from PixelGeoModel.PixelGeoModelConfig
import PixelGeoModelCfg
87 if flags.GeoModel.Align.Dynamic:
89 [
"/Indet/Onl/AlignL1/ID",
"/Indet/Onl/AlignL2/PIX"],
90 [
"/Indet/AlignL1/ID",
"/Indet/AlignL2/PIX"],
91 className=
"CondAttrListCollection"))
92 acc.merge(
addFoldersSplitOnline(flags,
"INDET",
"/Indet/Onl/AlignL3",
"/Indet/AlignL3",className=
"AlignableTransformContainer"))
94 acc.merge(
addFoldersSplitOnline(flags,
"INDET",
"/Indet/Onl/Align",
"/Indet/Align",className=
"AlignableTransformContainer"))
96 acc.merge(
addFoldersSplitOnline(flags,
"INDET",
"/Indet/Onl/IBLDist",
"/Indet/IBLDist",className=
"CondAttrListCollection"))
98 kwargs.setdefault(
"UseDynamicAlignFolders", flags.GeoModel.Align.Dynamic)
99 kwargs.setdefault(
"ReadKeyStatic",
"/Indet/Align")
100 kwargs.setdefault(
"ReadKeyDynamicL1",
"/Indet/AlignL1/ID")
101 kwargs.setdefault(
"ReadKeyDynamicL2",
"/Indet/AlignL2/PIX")
102 kwargs.setdefault(
"ReadKeyDynamicL3",
"/Indet/AlignL3")
103 kwargs.setdefault(
"ReadKeyIBLDist",
"/Indet/IBLDist")
104 kwargs.setdefault(
"WriteKey",
"PixelAlignmentStore")
106 acc.addCondAlgo(CompFactory.PixelAlignCondAlg(name, **kwargs))
110 """Return a ComponentAccumulator with configured PixelCablingCondAlg"""
115 from AthenaConfiguration.Enums
import LHCPeriod
117 if not flags.Input.isMC
and not flags.Overlay.DataOverlay
and not flags.GeoModel.Run < LHCPeriod.Run2 :
118 acc.merge(
addFoldersSplitOnline(flags,
"PIXEL",
"/PIXEL/Onl/CablingMap",
"/PIXEL/CablingMap", className=
"AthenaAttributeList"))
119 kwargs.setdefault(
"ReadKey",
"/PIXEL/CablingMap")
120 if flags.Input.RunNumbers
and flags.Input.RunNumbers[0]<222222:
121 kwargs.setdefault(
"ReadKey",
"")
123 kwargs.setdefault(
"ReadKey",
"")
124 kwargs.setdefault(
"PixelModuleData",
"PixelModuleData")
125 kwargs.setdefault(
"PixelReadoutSpeedData",
"PixelReadoutSpeedData")
126 kwargs.setdefault(
"WriteKey",
"PixelCablingCondData")
127 acc.addCondAlgo(CompFactory.PixelCablingCondAlg(name, **kwargs))
131 """Return a ComponentAccumulator with configured PixelChargeCalibCondAlg"""
134 PixCalibFolder =
'ChargeCalibration'
135 from PixelGeoModel.PixelGeoModelConfig
import PixelReadoutGeometryCfg
137 kwargs.setdefault(
"PixelDetEleCollKey",
"PixelDetectorElementCollection")
138 kwargs.setdefault(
"PixelModuleData",
"PixelModuleData")
139 if flags.GeoModel.Run
is LHCPeriod.Run2:
140 acc.merge(
addFoldersSplitOnline(flags,
"PIXEL",
"/PIXEL/Onl/"+PixCalibFolder,
"/PIXEL/"+PixCalibFolder, className=
"CondAttrListCollection"))
141 kwargs.setdefault(
"ReadKey",
"/PIXEL/"+PixCalibFolder)
143 kwargs.setdefault(
"ReadKey",
"")
144 kwargs.setdefault(
"WriteKey",
"PixelChargeCalibCondData")
145 acc.addCondAlgo(CompFactory.PixelChargeCalibCondAlg(name, **kwargs))
149 """Return a ComponentAccumulator with configured PixelChargeLUTCalibCondAlg"""
152 acc.merge(
addFoldersSplitOnline(flags,
"PIXEL",
"/PIXEL/Onl/ChargeCalibration",
"/PIXEL/ChargeCalibration", className=
"CondAttrListCollection"))
153 from PixelGeoModel.PixelGeoModelConfig
import PixelReadoutGeometryCfg
155 kwargs.setdefault(
"PixelDetEleCollKey",
"PixelDetectorElementCollection")
156 kwargs.setdefault(
"PixelModuleData",
"PixelModuleData")
157 kwargs.setdefault(
"ReadKey",
"/PIXEL/ChargeCalibration")
158 kwargs.setdefault(
"WriteKey",
"PixelChargeCalibCondData")
159 acc.addCondAlgo(CompFactory.PixelChargeLUTCalibCondAlg(name, **kwargs))
163 """Return a ComponentAccumulator with configured PixelDCSCondHVAlg"""
166 if flags.Common.isOnline:
167 kwargs.update( ReadKey=
"/PIXEL/HLT/DCS/HV")
168 acc.merge(
addFolders(flags, kwargs[
"ReadKey"],
"PIXEL_ONL", className=
"CondAttrListCollection"))
170 kwargs.update( ReadKey=
"/PIXEL/DCS/HV")
171 acc.merge(
addFolders(flags, kwargs[
"ReadKey"],
"DCS_OFL", className=
"CondAttrListCollection"))
173 kwargs.setdefault(
"WriteKey",
"PixelDCSHVCondData")
174 acc.addCondAlgo(CompFactory.PixelDCSCondHVAlg(name, **kwargs))
178 """Return a ComponentAccumulator with configured PixelDCSCondStateAlg"""
180 if not flags.Input.isMC
and not flags.Overlay.DataOverlay
and flags.InDet.usePixelDCS:
181 acc.merge(
addFolders(flags,
"/PIXEL/DCS/FSMSTATE",
"DCS_OFL", className=
"CondAttrListCollection"))
182 kwargs.setdefault(
"ReadKeyState",
"/PIXEL/DCS/FSMSTATE")
184 kwargs.setdefault(
"ReadKeyState",
"")
185 kwargs.setdefault(
"WriteKeyState",
"PixelDCSStateCondData")
186 acc.addCondAlgo(CompFactory.PixelDCSCondStateAlg(name, **kwargs))
190 """Return a ComponentAccumulator with configured PixelDCSCondStatusAlg"""
192 if not flags.Input.isMC
and not flags.Overlay.DataOverlay
and flags.InDet.usePixelDCS:
193 acc.merge(
addFolders(flags,
"/PIXEL/DCS/FSMSTATUS",
"DCS_OFL", className=
"CondAttrListCollection"))
194 kwargs.setdefault(
"ReadKeyStatus",
"/PIXEL/DCS/FSMSTATUS")
196 kwargs.setdefault(
"ReadKeyStatus",
"")
197 kwargs.setdefault(
"WriteKeyStatus",
"PixelDCSStatusCondData")
198 acc.addCondAlgo(CompFactory.PixelDCSCondStatusAlg(name, **kwargs))
202 """Return a ComponentAccumulator with configured PixelDCSCondTempAlg"""
205 if flags.Common.isOnline:
206 kwargs.setdefault(
"ReadKey",
"/PIXEL/HLT/DCS/TEMPERATURE")
207 acc.merge(
addFolders(flags, kwargs[
"ReadKey"],
"PIXEL_ONL", className=
"CondAttrListCollection"))
209 kwargs.setdefault(
"ReadKey",
"/PIXEL/DCS/TEMPERATURE")
210 acc.merge(
addFolders(flags, kwargs[
"ReadKey"],
"DCS_OFL", className=
"CondAttrListCollection"))
211 kwargs.setdefault(
"WriteKey",
"PixelDCSTempCondData")
212 acc.addCondAlgo(CompFactory.PixelDCSCondTempAlg(name, **kwargs))
216 """Return a ComponentAccumulator with configured PixelDeadMapCondAlg"""
219 if flags.GeoModel.Run
is LHCPeriod.Run1:
220 kwargs.setdefault(
"ReadKey",
"")
222 kwargs.setdefault(
"ReadKey",
"/PIXEL/PixelModuleFeMask")
223 acc.merge(
addFoldersSplitOnline(flags,
"PIXEL",
"/PIXEL/Onl/PixelModuleFeMask",
"/PIXEL/PixelModuleFeMask", className=
"CondAttrListCollection"))
224 kwargs.setdefault(
"WriteKey",
"PixelDeadMapCondData")
225 acc.addCondAlgo(CompFactory.PixelDeadMapCondAlg(name, **kwargs))
229 """Return a ComponentAccumulator with configured PixelDetectorElementCondAlg"""
233 kwargs.setdefault(
"PixelAlignmentStore",
"PixelAlignmentStore")
234 kwargs.setdefault(
"WriteKey",
"PixelDetectorElementCollection")
240 if flags.Detector.GeometryMuon
and flags.Muon.enableAlignment:
241 from MuonConfig.MuonGeometryConfig
import MuonGeoModelCfg
243 kwargs.setdefault(
"MuonManagerKey",
"MuonDetectorManager")
244 if flags.Detector.GeometryTRT:
245 from TRT_GeoModel.TRT_GeoModelConfig
import TRT_ReadoutGeometryCfg
247 kwargs.setdefault(
"TRT_DetEltContKey",
"TRT_DetElementContainer")
248 if not flags.GeoModel.Align.LegacyConditionsAccess
and flags.Detector.GeometrySCT:
249 from SCT_GeoModel.SCT_GeoModelConfig
import SCT_AlignmentCfg
251 kwargs.setdefault(
"SCTAlignmentStore",
"SCTAlignmentStore")
254 acc.addCondAlgo(CompFactory.PixelDetectorElementCondAlg(name, **kwargs))
258 """Return a ComponentAccumulator with configured PixelDistortionAlg"""
261 acc.merge(
addFoldersSplitOnline(flags,
"INDET",
"/Indet/Onl/PixelDist",
"/Indet/PixelDist",className=
"DetCondCFloat"))
262 kwargs.setdefault(
"ReadKey",
"/Indet/PixelDist")
263 kwargs.setdefault(
"WriteKey",
"PixelDistortionData")
264 from RngComps.RngCompsConfig
import AthRNGSvcCfg
265 kwargs.setdefault(
"RndmSvc", acc.getPrimaryAndMerge(
AthRNGSvcCfg(flags)).name)
266 acc.addCondAlgo(CompFactory.PixelDistortionAlg(name, **kwargs))
270 """Return a ComponentAccumulator with configured PixelHitDiscCnfgAlg"""
274 if flags.GeoModel.IBLLayout
in (
"noIBL",
"UNDEFINED"):
276 if flags.IOVDb.DatabaseInstance ==
"CONDBR2":
277 acc.merge(
addFolders(flags,
"/PIXEL/HitDiscCnfg",
"PIXEL", className=
"AthenaAttributeList"))
278 elif flags.Input.isMC
and flags.GeoModel.Run
in [LHCPeriod.Run2, LHCPeriod.Run3]:
279 acc.merge(
addFoldersSplitOnline(flags,
"PIXEL",
"/PIXEL/HitDiscCnfg",
"/PIXEL/HitDiscCnfg", className=
"AthenaAttributeList"))
280 kwargs.setdefault(
"ReadKey",
"/PIXEL/HitDiscCnfg")
281 kwargs.setdefault(
"WriteKey",
"PixelHitDiscCnfgData")
282 acc.addCondAlgo(CompFactory.PixelHitDiscCnfgAlg(name, **kwargs))
286 """Return a ComponentAccumulator with configured PixelOfflineCalibCondAlg"""
288 acc.merge(
addFoldersSplitOnline(flags,
"PIXEL",
"/PIXEL/Onl/PixReco",
"/PIXEL/PixReco", className=
"DetCondCFloat"))
289 kwargs.setdefault(
"InputSource", 2)
290 kwargs.setdefault(
"PixelClusterErrorDataFile",
"PixelClusterErrorData.txt")
291 kwargs.setdefault(
"PixelClusterOnTrackErrorDataFile",
"PixelClusterOnTrackErrorData.txt")
292 kwargs.setdefault(
"PixelChargeInterpolationDataFile",
"PixelChargeInterpolationData.txt")
293 kwargs.setdefault(
"DumpConstants", 0)
294 kwargs.setdefault(
"ReadKey",
"/PIXEL/PixReco")
295 kwargs.setdefault(
"WriteKey",
"PixelOfflineCalibData")
296 acc.addCondAlgo(CompFactory.PixelOfflineCalibCondAlg(name, **kwargs))
300 """Return a ComponentAccumulator with configured PixelReadoutSpeedAlg"""
302 if not flags.Input.isMC:
303 acc.merge(
addFolders(flags,
"/PIXEL/ReadoutSpeed",
"PIXEL", className=
"AthenaAttributeList"))
305 acc.merge(
addFoldersSplitOnline(flags,
"PIXEL",
"/PIXEL/ReadoutSpeed",
"/PIXEL/ReadoutSpeed", className=
"AthenaAttributeList"))
306 kwargs.setdefault(
"ReadKey",
"/PIXEL/ReadoutSpeed")
307 kwargs.setdefault(
"WriteKey",
"PixelReadoutSpeedData")
308 acc.addCondAlgo(CompFactory.PixelReadoutSpeedAlg(name, **kwargs))
312 """Return a ComponentAccumulator with configured PixelRadSimFluenceMapAlg"""
315 kwargs.setdefault(
"PixelModuleData",
"PixelModuleData")
316 kwargs.setdefault(
"WriteRadiationFluenceMapKey",
"PixelRadiationDamageFluenceMapData")
317 acc.addCondAlgo(CompFactory.PixelRadSimFluenceMapAlg(name, **kwargs))
321 """Return a ComponentAccumulator with configured PixeldEdxAlg"""
323 acc.merge(
addFoldersSplitOnline(flags,
"PIXEL",
"/PIXEL/Onl/PixdEdx",
"/PIXEL/PixdEdx", className=
'AthenaAttributeList'))
324 acc.addCondAlgo(CompFactory.PixeldEdxAlg(name, ReadFromCOOL =
True, **kwargs))
328 """Return a ComponentAccumulator with configured PixelSiliconConditionsTestAlg"""
334 from SiLorentzAngleTool.PixelLorentzAngleConfig
import PixelLorentzAngleToolCfg
336 acc.addEventAlgo(CompFactory.PixelSiliconConditionsTestAlg(name, **kwargs))
341 Condition alg to precompute the pixel detector element status.
342 this algo does not consider the DCS status (and the byte stream errors which are event data)
345 if 'ConditionsSummaryTool' not in kwargs :
346 from PixelConditionsTools.PixelConditionsSummaryConfig
import PixelConditionsSummaryToolNoByteStreamErrorsActiveOnlyCfg
348 kwargs.setdefault(
"WriteKey",
"PixelDetectorElementStatusNoByteStreamActiveOnly")
349 acc.addCondAlgo( CompFactory.InDet.SiDetectorElementStatusCondAlg(name, **kwargs) )
354 Condition alg to precompute the create pixel detector element status which includes the DCS status
355 this algo does not consider the byte stream errors which are event data
358 if 'ConditionsSummaryTool' not in kwargs :
360 from PixelConditionsTools.PixelConditionsSummaryConfig
import PixelActiveDetectorElementStatusToolCfg
362 PixelDetElStatusCondDataBaseKey=
"PixelDetectorElementStatusNoByteStreamActiveOnly")) )
363 kwargs.setdefault(
"WriteKey",
"PixelDetectorElementStatusNoByteStream")
364 acc.addCondAlgo( CompFactory.InDet.SiDetectorElementStatusCondAlg(name, **kwargs) )
369 Event alg which extends the pixel detector element status conditions data which does not consider the DCS status by the bytestream errors.
370 This alg however does only consider errors concerning the module activity, not general errors.
373 active_only = kwargs.pop(
"ActiveOnly",
False)
374 if 'ConditionsSummaryTool' not in kwargs
and not active_only :
375 element_status_input=
None
376 if flags.InDet.usePixelDCS:
378 element_status_input=
"PixelDetectorElementStatusNoByteStream"
383 element_status_input=
"PixelDetectorElementStatusNoByteStreamActiveOnly"
384 from PixelConditionsTools.PixelConditionsSummaryConfig
import PixelByteStreamErrorDetectorElementStatusToolCfg
385 kwargs.setdefault(
"ConditionsSummaryTool",
388 elif 'ConditionsSummaryTool' not in kwargs
and active_only :
390 from PixelConditionsTools.PixelConditionsSummaryConfig
import PixelByteStreamErrorDetectorElementStatusToolActiveOnlyCfg
391 kwargs.setdefault(
"ConditionsSummaryTool",
394 kwargs.setdefault(
"WriteKey",
"PixelDetectorElementStatus")
397 if flags.Input.Format
is Format.BS:
398 from PixelRawDataByteStreamCnv.PixelRawDataByteStreamCnvConfig
import (
399 PixelRawDataProviderAlgCfg)
402 acc.addEventAlgo( CompFactory.InDet.SiDetectorElementStatusAlg(name, **kwargs) )
407 Event alg which extends the pixel detector element status conditions data which does not consider the DCS status by the bytestream errors.
408 This alg however does only consider errors concerning the module activity, not general errors.
411 WriteKey =
"PixelDetectorElementStatusActiveOnly",
416 if flags.GeoModel.Run >= LHCPeriod.Run4:
417 from PixelConditionsAlgorithms.ITkPixelConditionsConfig
import (
418 ITkPixelChargeCalibCondAlgCfg)
420 elif flags.GeoModel.Run == LHCPeriod.Run3:
425 """Force the job to use the Pixel Module-level mask implemented via the
426 FE-level masking code. See https://gitlab.cern.ch/atlas/athena/-/merge_requests/45356"""
427 from IOVDbSvc.IOVDbSvcConfig
import addOverride
428 if (
not flags.Input.isMC
and flags.IOVDb.DatabaseInstance ==
'CONDBR2'):
429 cfg.merge(
addOverride(flags,
'/PIXEL/PixelModuleFeMask',
'PixelModuleFeMask-RUN2-DATA-UPD4-05'))
431 cfg.merge(
addOverride(flags,
'/PIXEL/PixelModuleFeMask',
'PixelModuleFeMask-SIM-MC16-000-03'))
435 if __name__ ==
'__main__':
436 from AthenaConfiguration.MainServicesConfig
import MainServicesCfg
437 from AthenaConfiguration.AllConfigFlags
import initConfigFlags
441 from AthenaConfiguration.TestDefaults
import defaultTestFiles
442 flags.Input.Files = defaultTestFiles.RAW_RUN2
443 flags.Exec.MaxEvents=5
449 acc.printConfig(withDetails=
True)
450 with open(
"PixelConditions.pkl",
"wb")
as file: