1 """Define methods to construct a configured TRT R-t calibration algorithm
3 Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
5 from AthenaConfiguration.ComponentAccumulator
import ComponentAccumulator
6 from AthenaConfiguration.ComponentFactory
import CompFactory
9 def TRT_CalibrationMgrCfg(flags,name='TRT_CalibrationMgr',calibconstants='', Hittuple='', caltag='' ,**kwargs) :
12 kwargs.setdefault(
"DoCalibrate",
False)
13 kwargs.setdefault(
"DoRefit",
False)
15 if "AlignTrkTools" not in kwargs:
16 from TRT_CalibTools.TRTCalibToolsConfig
import (
17 FillAlignTrkInfoCfg, FillAlignTRTHitsCfg)
18 kwargs.setdefault(
"AlignTrkTools", [
22 if "FitTools" not in kwargs:
23 from TRT_CalibTools.TRTCalibToolsConfig
import FitToolCfg
24 kwargs.setdefault(
"FitTools", [acc.popToolsAndMerge(
FitToolCfg(flags))])
26 if "TrackFitter" not in kwargs:
27 from TrkConfig.CommonTrackFitterConfig
import InDetTrackFitterCfg
30 if "TrackSelectorTool" not in kwargs:
31 from InDetConfig.InDetTrackSelectorToolConfig
import TRT_InDetDetailedTrackSelectorToolCfg
34 if "TRTCalibrator" not in kwargs:
35 from TRT_CalibTools.TRTCalibratorConfig
import TRTCalibratorCfg
38 kwargs.setdefault(
"TRTCalibrator",[acc.addPublicTool(acc.popToolsAndMerge(
TRTCalibratorCfg(flags)))])
41 kwargs.setdefault(
"TRTCalibrator",[acc.addPublicTool(acc.popToolsAndMerge(
TRTCalibratorCfg(flags, Hittuple=Hittuple, calTag=caltag)))])
48 from TRT_ConditionsAlgs.TRT_ConditionsAlgsConfig
import TRTCondWriteCfg
52 acc.addEventAlgo(CompFactory.TRTCalibrationMgr(name, **kwargs))
61 from TRT_ConditionsServices.TRT_ConditionsServicesConfig
import TRT_StrawStatusSummaryToolCfg
64 from InDetConfig.TRT_TrackHoleSearchConfig
import TRTTrackHoleSearchToolCfg
67 from IOVDbSvc.IOVDbSvcConfig
import addOverride
68 acc.merge(
addOverride(flags,
'/TRT/Cond/Status',
'TRTCondStatus-empty-00-00'))
70 acc.addEventAlgo(CompFactory.InDet.TRT_StrawStatus(name,**kwargs))
76 from AthenaConfiguration.DetectorConfigFlags
import setupDetectorFlags
80 flags.Reco.EnableTau=
False
81 flags.Reco.EnableCombinedMuon=
False
82 flags.Reco.EnableMet=
False
83 flags.Reco.EnableTrigger =
False
84 flags.Reco.EnableEgamma=
False
85 flags.Reco.EnableCaloRinger=
False
86 flags.Reco.EnableCaloExtension=
False
89 flags.Detector.EnableMuon=
False
90 flags.Detector.EnableCalo=
False
93 flags.DQ.doMonitoring=
False
94 flags.DQ.Steering.InDet.doPerfMon=
False
95 flags.DQ.Steering.InDet.doGlobalMon=
False
96 flags.DQ.Steering.doPixelMon=
False
97 flags.DQ.Steering.doSCTMon=
False
100 flags.Tracking.doCaloSeededBrem=
False
101 flags.Tracking.doCaloSeededAmbi=
False
102 flags.Tracking.doTRTSegments=
False
103 flags.Tracking.doTRTStandalone=
False
104 flags.Tracking.doBackTracking=
False
110 if __name__ ==
'__main__':
112 import glob, argparse
113 parser = argparse.ArgumentParser(prog=
'python -m TRT_CalibAlgs.TRTCalibrationMgrConfig',
114 description=
"""Run R-t TRT calibration.\n\n
115 Example: python -m TRT_CalibAlgs.TRTCalibrationMgrConfig --filesInput "/path/to/files/data22*" --evtMax 10""")
117 parser.add_argument(
'--evtMax' ,type=int,default=1,help=
"Number of events.")
118 parser.add_argument(
'--filesInput' , nargs=
'+', default=[],help=
"Input files. RAW data")
119 parser.add_argument(
'--fileOutput' , default=
"basic.root" ,help=
"Output file name. Flat Ntuple")
120 parser.add_argument(
'--doCalibrator',action=
'store_true' ,help=
"Run the calibrator to obtain the constants")
121 args = parser.parse_args()
123 from AthenaConfiguration.AllConfigFlags
import initConfigFlags
126 from AthenaConfiguration.TestDefaults
import defaultGeometryTags, defaultTestFiles
127 if not args.filesInput:
128 flags.Input.Files = defaultTestFiles.RAW_RUN3
130 flags.Input.Files = [file
for x
in args.filesInput
for file
in glob.glob(x)]
132 flags.Output.HISTFileName = args.fileOutput
133 flags.Exec.MaxEvents = args.evtMax
135 flags.GeoModel.AtlasVersion = defaultGeometryTags.RUN3
136 flags.IOVDb.GlobalTag =
"CONDBR2-BLKPA-2024-03"
141 flags = flags.cloneAndReplace(
142 "Tracking.ActiveConfig",
143 f
"Tracking.{flags.Tracking.PrimaryPassConfig.value}Pass",
152 from AthenaConfiguration.MainServicesConfig
import MainServicesCfg
155 from ByteStreamCnvSvc.ByteStreamConfig
import ByteStreamReadCfg
158 from InDetConfig.TrackRecoConfig
import InDetTrackRecoCfg
167 with open(
"TRTCalibConfigCA.pkl",
"wb")
as f:
173 sys.exit(
not acc.run().isSuccess())