ATLAS Offline Software
Loading...
Searching...
No Matches
ZdcPhysRecConfig.py
Go to the documentation of this file.
1#!/usr/bin/env python
2#
3# Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
4#
5
6from AthenaConfiguration.ComponentFactory import CompFactory
7from AthenaConfiguration.ComponentAccumulator import ComponentAccumulator
8
9from ZdcNtuple.ZdcNtupleConfig import ZdcNtupleCfg
10from ZdcRecConfig import ZdcGenericFlagSetting, ZdcStreamDependentFlagSetting
11
12# -------------------------------- Configuration function for calorimeter & HIGlocal reconstructions --------------------------------
14 """additional flag settings in possible scenarios we may need FCal info"""
15
16 # turn necessary trigger inputs on if need ZDC triggers (ZdcCalib or UCC stream)
17
18 IsPhysicsStream = "physics_" in flags.Input.TriggerStream or flags.Input.TriggerStream == "express_express"
19
20 if flags.Input.TriggerStream == "calibration_ZDCCalib" or IsPhysicsStream:
21 flags.Trigger.L1.doCTP = True
22
23 if IsPhysicsStream:
24 flags.Trigger.L1.doCaloInputs = True
25
26 flags.Detector.EnableCalo = IsPhysicsStream
27
28def FCalRecCfg(flags):
29 """Calorimeter and HIGlobal reconstruction config for ZDC-FCal correlations"""
30
31 acc = ComponentAccumulator()
32
33 from CaloRec.CaloRecoConfig import CaloRecoCfg
34 acc.merge(CaloRecoCfg(flags))
35 from HIGlobal.HIGlobalConfig import HIGlobalRecCfg
36 acc.merge(HIGlobalRecCfg(flags))
37
38 return acc
39
40
41def ZdcNtupleWithCaloRun3Cfg(flags, outputlevel = 3, **kwargs):
42 """ZDC Ntuple configuration for run3 data potential with Calorimeter-info retrieving & writing
43 Depends on the flag Detector.EnableCalo to be correctly set
44 Retrieves and writes calorimeter info in ZdcNTuple if and only if Detector.EnableCalo is true"""
45
46 acc = ComponentAccumulator()
47 ZdcNtupleAcc = ZdcNtupleCfg(flags,
48 useGRL = False,
49 zdcOnly = not flags.Detector.EnableCalo,
50 lhcf2022 = False,
51 lhcf2022zdc = False,
52 lhcf2022afp = False,
53 isMC = flags.Input.isMC,
54 enableTrigger = not flags.Input.isMC,
55 enableOutputSamples = True,
56 enableOutputTree = True,
57 writeOnlyTriggers = False,
58 enableRPD = flags.Detector.EnableZDC_RPD,
59 enableRPDAmp = flags.Detector.EnableZDC_RPD,
60 enableCentroid = flags.Detector.EnableZDC_RPD,
61 enableCalo = flags.Detector.EnableCalo,
62 reprocZdc = False,
63 **kwargs)
64 ZdcNtupleAcc.getEventAlgo('ZdcNtuple').OutputLevel = outputlevel # turn on DEBUG messages
65 acc.merge(ZdcNtupleAcc)
66
67 acc.addService(CompFactory.THistSvc(Output = ["ANALYSIS DATAFILE='NTUP.root' OPT='RECREATE'"]))
68 return acc
69
70
71if __name__ == '__main__':
72
73 import time
74 start_time = time.time()
75
76 """ This is selftest & ZDC calibration transform at the same time"""
77 from AthenaConfiguration.AllConfigFlags import initConfigFlags
78 from AthenaConfiguration.MainServicesConfig import MainServicesCfg
79
80 flags = initConfigFlags()
81
82 ZdcGenericFlagSetting(flags) # set generic (stream-independent) ZDC flags
83
85
86 flags.Output.AODFileName="AOD.pool.root"
87 flags.Output.HISTFileName="HIST.root"
88 flags.Output.doWriteAOD=True
89
90 isLED, isInj, isCalib, pn = ZdcStreamDependentFlagSetting(flags) # set stream-dependent ZDC flags & get return values
91
92 from ZdcRecConfig import SetConfigTag
93 config = SetConfigTag(flags)
94
95 #decode HLT for when HLT trigger selections are needed (OO/pO/NeNe - adjust if needed)
96 flags.Trigger.decodeHLT = ('pO' in config or 'OO' in config) and flags.DQ.useTrigger and flags.Input.TriggerStream == 'physics_MinBias'
97
98 flags.lock()
99 flags.dump(evaluate=True) # uncomment this line if needed for testing
100
101 acc=MainServicesCfg(flags)
102
103 from AtlasGeoModel.ForDetGeoModelConfig import ForDetGeometryCfg
104 acc.merge(ForDetGeometryCfg(flags))
105
106 if not flags.Input.isMC and pn != 'data_test': # trigger reco config not existing for MC or standalone
107 from TriggerJobOpts.TriggerRecoConfig import TriggerRecoCfgData
108 acc.merge(TriggerRecoCfgData(flags))
109
110 if isLED:
111 from ZdcRecConfig import ZdcLEDRecCfg
112 acc.merge(ZdcLEDRecCfg(flags))
113 if isCalib: # should be able to run both if in standalone data
114 from ZdcRecConfig import ZdcRecCfg
115 acc.merge(ZdcRecCfg(flags))
116 if isInj: # should be able to run both if in standalone data
117 from ZdcRecConfig import ZdcRecCfg
118 acc.merge(ZdcRecCfg(flags))
119
120 if ("physics_" in flags.Input.TriggerStream or flags.Input.TriggerStream == "express_express"):
121 acc.merge(FCalRecCfg(flags))
122
123 if not flags.Input.isMC:
124 if (isLED):
125 from ZdcMonitoring.ZdcLEDMonitorAlgorithm import ZdcLEDMonitoringConfig
126 acc.merge(ZdcLEDMonitoringConfig(flags,'ppPbPb2023'))
127 from ZdcRecConfig import ZdcLEDNtupleCfg
128 acc.merge(ZdcLEDNtupleCfg(flags))
129
130 if (isCalib):
131 from ZdcMonitoring.ZdcMonitorAlgorithm import ZdcMonitoringConfig
132 zdcMonitorAcc = ZdcMonitoringConfig(flags)
133 acc.merge(zdcMonitorAcc)
134 acc.merge(ZdcNtupleWithCaloRun3Cfg(flags))
135
136 if (isInj):
137 from ZdcMonitoring.ZdcMonitorAlgorithm import ZdcMonitoringConfig
138 zdcMonitorAcc = ZdcMonitoringConfig(flags)
139 acc.merge(zdcMonitorAcc)
140 from ZdcRecConfig import ZdcInjNtupleCfg
141 acc.merge(ZdcInjNtupleCfg(flags))
142 else:
143 from ZdcRecConfig import ZdcRecCfg, ZdcNtupleLocalCfg
144 acc.merge(ZdcRecCfg(flags))
145 acc.merge(ZdcNtupleLocalCfg(flags))
146
147 acc.printConfig(withDetails=True)
148 # acc.foreach_component("*Zdc*").OutputLevel=DEBUG #uncomment to turn on DEBUG messages for ZDC applications
149
150 with open("config.pkl", "wb") as f:
151 acc.store(f)
152 status = acc.run()
153 if status.isFailure():
154 import sys
155 sys.exit(-1)
156
157 end_time = time.time()
158
159 # If number of events is known from runArgs or input configuration
160 # Use an explicit number if known, or get it from athena configuration if possible
161 n_events = int(flags.Exec.MaxEvents) if 'flags' in locals() and flags.hasFlag("Exec.MaxEvents") else -1
162
163 print(f"Total time: {end_time - start_time:.2f} seconds")
164 if n_events > 0:
165 print(f"Average time per event: {(end_time - start_time)/n_events:.4f} seconds/event")
166 else:
167 print("Number of events unknown, cannot compute per-event timing.")
void print(char *figname, TCanvas *c1)
ZdcNtupleWithCaloRun3Cfg(flags, outputlevel=3, **kwargs)