6 from AthenaConfiguration.ComponentFactory
import CompFactory
7 from AthenaConfiguration.ComponentAccumulator
import ComponentAccumulator
8 from AthenaConfiguration.Enums
import Format
9 from AthenaConfiguration.Enums
import LHCPeriod
11 from OutputStreamAthenaPool.OutputStreamConfig
import addToAOD
12 from OutputStreamAthenaPool.OutputStreamConfig
import addToESD
14 from TriggerJobOpts.TriggerByteStreamConfig
import ByteStreamReadCfg
16 from ZdcNtuple.ZdcNtupleConfig
import ZdcNtupleCfg
19 from TrigConfigSvc.TriggerConfigAccess
import getL1MenuAccess
21 from TrigDecisionTool.TrigDecisionToolConfig
import TrigDecisionToolCfg, getRun3NavigationContainerFromInput
27 zdcConfigMap[
'data15_hi'] = {}
28 zdcConfigMap[
'data16_hip'] = {}
29 zdcConfigMap[
'data17_13TeV'] = {}
30 zdcConfigMap[
'data18_hi'] = {}
31 zdcConfigMap[
'data22_13p6TeV'] = {}
32 zdcConfigMap[
'data23_5p36TeV'] = {}
33 zdcConfigMap[
'data23_13p6TeV'] = {}
34 zdcConfigMap[
'data23_hi'] = {}
35 zdcConfigMap[
'data23_comm'] = {}
36 zdcConfigMap[
'data23_5p36TeV'] = {}
37 zdcConfigMap[
'data24_900GeV'] = {}
39 zdcConfigMap[
'data24_13p6TeV'] = {}
40 zdcConfigMap[
'data24_13p6TeV'][
'default'] =
'pp2024'
42 zdcConfigMap[
'data24_refcomm'] = {}
43 zdcConfigMap[
'data24_refcomm'][
'default'] =
'pp2024'
44 zdcConfigMap[
'data24_refcomm'][
'calibration_ZdcInjCalib'] =
'Injectorpp2024'
46 zdcConfigMap[
'data24_hicomm'] = {}
47 zdcConfigMap[
'data24_hicomm'][
'default'] =
'PbPb2024'
48 zdcConfigMap[
'data24_hicomm'][
'calibration_ZdcInjCalib'] =
'InjectorPbPb2024'
50 zdcConfigMap[
'data24_hi'] = {}
51 zdcConfigMap[
'data24_hi'][
'default']=
"PbPb2024"
52 zdcConfigMap[
'data24_hi'][
'calibration_ZdcInjCalib']=
"InjectorPbPb2024"
56 if flags.Input.TriggerStream ==
"calibration_ZDCInjCalib" or flags.Input.TriggerStream ==
"calibration_DcmDummyProcessor":
57 config =
"Injectorpp2024"
59 if flags.Input.ProjectName ==
"data24_hi" or flags.Input.ProjectName ==
"data24_hicomm":
60 config =
"InjectorPbPb2024"
64 run = flags.GeoModel.Run
65 if (run == LHCPeriod.Run3):
67 config =
"MonteCarloPbPb2023"
68 elif flags.Input.ProjectName ==
"data22_13p6TeV":
70 elif flags.Input.ProjectName ==
"data23_5p36TeV" or flags.Input.ProjectName ==
"data23_900GeV" or flags.Input.ProjectName ==
"data23_13p6TeV":
72 elif flags.Input.ProjectName ==
"data23_hi" or flags.Input.ProjectName ==
"data23_comm":
74 elif flags.Input.ProjectName ==
"data24_5p36TeV" or flags.Input.ProjectName ==
"data24_900GeV" or flags.Input.ProjectName ==
"data24_13p6TeV" or flags.Input.ProjectName ==
"data24_refcomm":
76 elif flags.Input.ProjectName ==
"data24_hi" or flags.Input.ProjectName ==
"data24_hicomm":
78 elif (run == LHCPeriod.Run2):
79 if flags.Input.ProjectName ==
"data15_hi":
81 elif flags.Input.ProjectName ==
"data17_13TeV":
83 elif flags.Input.ProjectName ==
"data16_hip":
85 elif flags.Input.ProjectName ==
"data18_hi":
95 if flags.Input.Format
is Format.BS:
96 ZDC_ItemList.append(
"xAOD::ZdcModuleContainer#ZdcModules")
97 ZDC_ItemList.append(
"xAOD::ZdcModuleAuxContainer#ZdcModulesAux.")
98 ZDC_ItemList.append(
"xAOD::ZdcModuleContainer#ZdcSums")
99 ZDC_ItemList.append(
"xAOD::ZdcModuleAuxContainer#ZdcSumsAux.")
101 acc.merge(
addToESD(flags,ZDC_ItemList))
102 acc.merge(
addToAOD(flags,ZDC_ItemList))
104 from xAODMetaDataCnv.InfileMetaDataConfig
import SetupMetaDataForStreamCfg
111 def ZdcAnalysisToolCfg(flags, run, config="PbPb2023", DoCalib=False, DoFADCCorr=False, DoNonLinCorr=False, DoTimeCalib=False, DoTrigEff=False, ForceCalibRun=-1, ForceCalibLB=814):
114 print(
'ZdcAnalysisToolCfg: setting up ZdcAnalysisTool with config='+config)
116 acc.setPrivateTools(CompFactory.ZDC.ZdcAnalysisTool(
117 name =
'ZdcAnalysisTool'+config,
118 Configuration = config,
120 DoFADCCorr = DoFADCCorr,
121 DoNonLinCorr = DoNonLinCorr,
122 DoTimeCalib = DoTimeCalib,
123 DoTrigEff = DoTrigEff,
124 ForceCalibRun = ForceCalibRun,
125 ForceCalibLB = ForceCalibLB,
132 print(
'ZdcAnalysisToolCfg: setting up ZdcAnalysisTool with config='+config)
133 acc.setPrivateTools(CompFactory.ZDC.ZdcLEDAnalysisTool(name =
'ZdcLEDAnalysisTool'+config,
134 Configuration = config,
135 DoFADCCorr = DoFADCCorr))
144 trigValTool = CompFactory.ZDC.ZdcTrigValidTool(
145 name =
'ZdcTrigValTool',
148 filepath_LUT =
'TrigT1ZDC/zdc_json_PbPb5.36TeV_2023.json')
150 trigValTool.TrigDecisionTool = acc.getPublicTool(
'TrigDecisionTool')
152 trigValTool.triggerList = [c
for c
in getL1MenuAccess(flags)
if 'L1_ZDC_BIT' in c]
154 acc.setPrivateTools(trigValTool)
161 CompFactory.ZDC.RPDAnalysisTool(
162 name=
"RPDAnalysisTool",
171 CompFactory.ZDC.RpdSubtractCentroidTool(
172 name=
"RpdSubtractCentroidTool",
181 print (
'ZdcRecConfig.py: Running with config tag ', config)
189 if flags.Input.ProjectName ==
"data15_hi":
193 elif flags.Input.ProjectName ==
"data17_13TeV":
197 elif flags.Input.ProjectName ==
"data16_hip":
201 elif flags.Input.ProjectName ==
"data18_hi":
206 acc.merge(
ByteStreamReadCfg(flags, type_names=[
'xAOD::TriggerTowerContainer/ZdcTriggerTowers',
207 'xAOD::TriggerTowerAuxContainer/ZdcTriggerTowersAux.']))
209 acc.addEventAlgo(CompFactory.ZdcByteStreamRawDataV2())
210 acc.addEventAlgo(CompFactory.ZdcRecV3Decode())
212 anaTool = acc.popToolsAndMerge(
ZdcAnalysisToolCfg(flags,2,config,doCalib,doFADCCorr,doNonLinCorr,doTimeCalib,doTrigEff))
214 acc.addEventAlgo(CompFactory.ZdcRecV3(
"ZdcRecV3",ZdcAnalysisTool=anaTool))
222 print (
'ZdcRecConfig.py: Running with config tag ', config)
232 if flags.Input.TriggerStream !=
"calibration_ZDCInjCalib" and flags.Input.TriggerStream !=
"calibration_DcmDummyProcessor":
233 if flags.Common.isOnline:
236 if flags.Input.ProjectName ==
"data24_5p36TeV" or flags.Input.ProjectName ==
"data24_refcomm":
237 ForceCalibRun = 488239
239 elif flags.Input.ProjectName ==
"data24_hi" or flags.Input.ProjectName ==
"data24_hicomm":
240 ForceCalibRun = 488980
245 elif flags.Input.ProjectName ==
"data23_comm":
247 elif flags.Input.ProjectName ==
"data23_hi":
250 elif flags.Input.ProjectName ==
"data24_hi":
256 doRPD = flags.Detector.EnableZDC_RPD
258 print(
'ZdcRecRun3Cfg: doCalib = '+
str(doCalib)+
' for project '+flags.Input.ProjectName)
259 print(
'RPD enable flag is '+
str(doRPD))
261 anaTool = acc.popToolsAndMerge(
ZdcAnalysisToolCfg(flags,3,config,doCalib,doFADCCorr,doNonLinCorr,doTimeCalib,doTrigEff,ForceCalibRun,ForceCalibLB))
267 if ( flags.Input.isMC ):
270 zdcTools += [rpdAnaTool,centroidTool]
271 elif ( flags.Trigger.doZDC ):
273 elif flags.Input.TriggerStream ==
"calibration_ZDCInjCalib" or flags.Input.TriggerStream ==
"calibration_DcmDummyProcessor":
275 elif (flags.Common.isOnline):
278 zdcTools += [rpdAnaTool,centroidTool]
281 zdcTools = [anaTool,trigTool]
283 zdcTools += [rpdAnaTool,centroidTool]
285 if flags.Input.Format
is Format.BS:
286 acc.addEventAlgo(CompFactory.ZdcByteStreamLucrodData())
287 acc.addEventAlgo(CompFactory.ZdcRecRun3Decode())
289 from AthenaPoolCnvSvc.PoolReadConfig
import PoolReadCfg
291 acc.addEventAlgo(CompFactory.ZdcMCTruthAlg())
293 zdcAlg = CompFactory.ZdcRecRun3(
"ZdcRecRun3",ZdcAnalysisTools=zdcTools)
294 acc.addEventAlgo(zdcAlg, primary=
True)
301 run = flags.GeoModel.Run
303 if (run == LHCPeriod.Run2):
304 print (
'ZdcRecConfig.py: setting up Run 2 ntuple!')
306 elif (run == LHCPeriod.Run3):
307 print (
'ZdcRecConfig.py: setting up Run 3 ntuples!')
310 print (
'ZdcRecConfig.py: setting up no ntuple!')
320 enableTrigger =
False,
321 enableOutputSamples =
True,
322 enableOutputTree =
True,
323 writeOnlyTriggers =
False,
327 acc.addService(CompFactory.THistSvc(Output = [
"ANALYSIS DATAFILE='zdctree.root' OPT='RECREATE'"]))
340 enableTrigger =
not flags.Input.isMC,
341 enableOutputSamples =
True,
342 enableOutputTree =
True,
343 writeOnlyTriggers =
False,
344 enableRPD = flags.Detector.EnableZDC_RPD,
345 enableCentroid = flags.Detector.EnableZDC_RPD,
349 acc.addService(CompFactory.THistSvc(Output = [
"ANALYSIS DATAFILE='NTUP.root' OPT='RECREATE'"]))
363 enableTrigger =
False,
364 enableOutputSamples =
True,
365 enableOutputTree =
True,
366 writeOnlyTriggers =
False,
368 enableCentroid =
False,
372 acc.addService(CompFactory.THistSvc(Output = [
"ANALYSIS DATAFILE='NTUP.root' OPT='RECREATE'"]))
378 zdcLEDNtuple = CompFactory.ZdcLEDNtuple(
"ZdcLEDNtuple")
379 zdcLEDNtuple.enableOutputTree =
True
380 acc.addEventAlgo(zdcLEDNtuple)
381 acc.addService(CompFactory.THistSvc(Output = [
"ANALYSIS DATAFILE='NTUP.root' OPT='RECREATE'"]))
388 if flags.Input.Format
is Format.BS:
389 run = flags.GeoModel.Run
392 print (
"ZdcRecConfig.py: run = "+run.name)
394 config =
'ppPbPb2023'
398 if (flags.GeoModel.Run == LHCPeriod.Run3):
401 acc.addEventAlgo(CompFactory.ZdcByteStreamLucrodData())
402 acc.addEventAlgo(CompFactory.ZdcRecRun3Decode())
407 zdcTools += [anaTool]
410 zdcAlg = CompFactory.ZdcRecRun3(
"ZdcRecRun3",DAQMode=2, ForcedEventType=2, ZdcAnalysisTools=zdcTools)
411 acc.addEventAlgo(zdcAlg, primary=
True)
413 if flags.Output.doWriteESD
or flags.Output.doWriteAOD:
423 tdmv = CompFactory.TrigDec.TrigDecisionMakerValidator()
424 tdmv.errorOnFailure =
True
427 acc.addEventAlgo( tdmv )
432 """Configure Zdc analysis alg
433 Additional arguments are useful in calibration runs
438 run = flags.GeoModel.Run
441 print (
"ZdcRecConfig.py: run = "+run.name)
443 if (run == LHCPeriod.Run2):
444 print (
'ZdcRecConfig.py: setting up Run 2!')
446 elif (run == LHCPeriod.Run3):
447 print (
'ZdcRecConfig.py: setting up Run 3!')
450 print (
'ZdcRecConfig.py: setting up nothing (problem)!')
452 if flags.Output.doWriteESD
or flags.Output.doWriteAOD:
458 if __name__ ==
'__main__':
460 """ This is selftest & ZDC calibration transform at the same time"""
461 from AthenaConfiguration.AllConfigFlags
import initConfigFlags
462 from AthenaConfiguration.MainServicesConfig
import MainServicesCfg
463 from AthenaConfiguration.TestDefaults
import defaultConditionsTags, defaultGeometryTags
467 flags.Scheduler.CheckDependencies =
True
468 flags.Scheduler.ShowDataDeps =
True
469 flags.Scheduler.ShowDataFlow =
True
470 flags.Scheduler.ShowControlFlow =
True
471 flags.Scheduler.EnableVerboseViews =
True
473 flags.Detector.GeometryZDC=
True
474 flags.Detector.GeometryAFP=
False
475 flags.Detector.GeometryALFA=
False
476 flags.Detector.GeometryLucid=
False
477 flags.Detector.GeometryMDT=
False
478 flags.Detector.GeometryMM=
False
479 flags.Detector.GeometryMuon=
False
480 flags.Trigger.decodeHLT=
False
481 flags.Trigger.enableL1MuonPhase1=
False
482 flags.Trigger.L1.doMuon=
False
483 flags.Trigger.L1.doCalo=
False
484 flags.Trigger.L1.doTopo=
False
491 flags.Output.AODFileName=
"AOD.pool.root"
492 flags.Output.HISTFileName=
"HIST.root"
493 flags.Output.doWriteAOD=
True
495 parser = flags.getArgumentParser()
496 parser.add_argument(
'--runCalibForStandaloneData',default=
"Calib",help=
"indicate if we run calib/LED reconstruction for standalone data: Calib (default) --> run calib reconstruction for injector-pulse events; LED --> run LED reconstruction for LED events")
497 args = flags.fillFromArgs(parser=parser)
500 isLED = (flags.Input.TriggerStream ==
"calibration_ZDCLEDCalib")
501 isInj = (flags.Input.TriggerStream ==
"calibration_ZDCInjCalib")
502 isCalib = (flags.Input.TriggerStream ==
"calibration_ZDCCalib" or flags.Input.TriggerStream ==
"physics_MinBias" or flags.Input.TriggerStream ==
"express_express" or flags.Input.TriggerStream ==
"physics_UCC")
503 if flags.Input.TriggerStream ==
"calibration_DcmDummyProcessor":
504 if args.runCalibForStandaloneData ==
"Calib" or args.runCalibForStandaloneData ==
"calib":
506 elif args.runCalibForStandaloneData ==
"LED" or args.runCalibForStandaloneData ==
"led":
509 print(
'WARNING: The value for the argument runCalibForStandaloneData is invalid')
510 print(
'Running nominal reconstruction (injector-pulse) by default')
514 print(
'ZdcRecConfig: Running LED data!')
516 print(
'ZdcRecConfig: Running Injected pulse data!')
518 print(
'ZdcRecConfig: Running ZDC calibration data!')
519 if (flags.Input.isMC):
520 print(
'ZdcRecConfig: Running over MC Samples')
521 flags.Input.ProjectName =
"data23_hi"
524 pn = flags.Input.ProjectName
526 raise ValueError(
'Unknown project name')
528 if (isInj
or isLED
or isInj
or pn ==
'data_test'):
529 flags.Trigger.EDMVersion=3
530 flags.GeoModel.Run = LHCPeriod.Run3
531 flags.GeoModel.AtlasVersion=defaultGeometryTags.RUN3
532 flags.IOVDb.GlobalTag=defaultConditionsTags.RUN3_DATA
536 flags.Trigger.EDMVersion=2
537 flags.GeoModel.Run = LHCPeriod.Run2
538 flags.IOVDb.GlobalTag=defaultConditionsTags.RUN2_DATA
540 flags.Trigger.EDMVersion=3
541 flags.GeoModel.Run = LHCPeriod.Run3
542 flags.GeoModel.AtlasVersion=defaultGeometryTags.RUN3
543 flags.IOVDb.GlobalTag=defaultConditionsTags.RUN3_DATA
545 if (flags.Input.isMC):
546 print(
'ZdcRecConfig: Overriding MC run to be Run 3!')
547 flags.GeoModel.Run = LHCPeriod.Run3
550 or flags.Input.TriggerStream ==
"calibration_DcmDummyProcessor"
551 or pn ==
"data22_13p6TeV"):
552 flags.Detector.EnableZDC_RPD =
False
554 if flags.Input.TriggerStream ==
"calibration_DcmDummyProcessor":
555 flags.DQ.useTrigger =
False
556 flags.DQ.triggerDataAvailable =
False
563 from AtlasGeoModel.ForDetGeoModelConfig
import ForDetGeometryCfg
566 if not flags.Input.isMC
and pn !=
'data_test':
567 from TriggerJobOpts.TriggerRecoConfig
import TriggerRecoCfgData
578 if not flags.Input.isMC:
580 from ZdcMonitoring.ZdcLEDMonitorAlgorithm
import ZdcLEDMonitoringConfig
585 from ZdcMonitoring.ZdcMonitorAlgorithm
import ZdcMonitoringConfig
587 acc.merge(zdcMonitorAcc)
589 if (flags.Input.TriggerStream !=
"calibration_DcmDummyProcessor"):
593 from ZdcMonitoring.ZdcMonitorAlgorithm
import ZdcMonitoringConfig
595 acc.merge(zdcMonitorAcc)
601 acc.printConfig(withDetails=
True)
603 with open(
"config.pkl",
"wb")
as f:
606 if status.isFailure():