ATLAS Offline Software
RAWtoALL_Skeleton.py
Go to the documentation of this file.
1 # Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
2 
3 from PyJobTransforms.CommonRunArgsToFlags import commonRunArgsToFlags
4 from PyJobTransforms.TransformUtils import processPreExec, processPreInclude, processPostExec, processPostInclude
5 
6 from AthenaCommon import SystemOfUnits as Units
7 
8 # force no legacy job properties
9 from AthenaCommon import JobProperties
10 JobProperties.jobPropertiesDisallowed = True
11 
12 
13 
14 def fromRunArgs(runArgs):
15  from AthenaCommon.Logging import logging
16  log = logging.getLogger('RAWtoALL')
17  log.info('****************** STARTING Reconstruction (RAWtoALL) *****************')
18 
19  log.info('**** Transformation run arguments')
20  log.info(str(runArgs))
21 
22  import time
23  timeStart = time.time()
24 
25  log.info('**** executing ROOT6Setup')
26  from PyUtils.Helpers import ROOT6Setup
27  ROOT6Setup(batch=True)
28 
29  log.info('**** Setting-up configuration flags')
30  from AthenaConfiguration.AllConfigFlags import initConfigFlags
31  flags = initConfigFlags()
32  # set per-event timeout (in ns)
33  flags.Exec.EventTimeOut = 3600*Units.second
34 
35  commonRunArgsToFlags(runArgs, flags)
36 
37  # Autoconfigure enabled subdetectors
38  if hasattr(runArgs, 'detectors'):
39  detectors = runArgs.detectors
40  else:
41  detectors = None
42 
43  # TODO: event service?
44 
45 
47  inputsDRAW = [prop for prop in dir(runArgs) if prop.startswith('inputDRAW') and prop.endswith('File')]
48  if hasattr(runArgs, 'inputBSFile'):
49  if inputsDRAW:
50  raise RuntimeError('Impossible to run RAWtoALL with input BS and DRAW files (one input type only!)')
51  flags.Input.Files = runArgs.inputBSFile
52  if len(inputsDRAW) == 1:
53  flags.Input.Files = getattr(runArgs, inputsDRAW[0])
54  elif len(inputsDRAW) > 1:
55  raise RuntimeError('Impossible to run RAWtoALL with multiple input DRAW files (viz.: {0})'.format(inputsDRAW))
56 
57  # RDO
58  if hasattr(runArgs, 'inputRDOFile'):
59  flags.Input.Files = runArgs.inputRDOFile
60  if hasattr(runArgs, 'inputRDO_TRIGFile'):
61  flags.Input.Files = runArgs.inputRDO_TRIGFile
62  # TODO: trigger setup
63 
64  # TODO: EVNT?
65 
66 
67  if hasattr(runArgs, 'outputESDFile'):
68  flags.Output.ESDFileName = runArgs.outputESDFile
69  log.info("---------- Configured ESD output")
70 
71  if hasattr(runArgs, 'outputAODFile'):
72  flags.Output.AODFileName = runArgs.outputAODFile
73  log.info("---------- Configured AOD output")
74 
75  if hasattr(runArgs, 'outputHISTFile'):
76  flags.Output.HISTFileName = runArgs.outputHISTFile
77  flags.DQ.doMonitoring = True
78  log.info("---------- Configured HIST output")
79 
80  if hasattr(runArgs, 'outputHIST_R2AFile'):
81  flags.Output.HISTFileName = runArgs.outputHIST_R2AFile
82  flags.DQ.doMonitoring = True
83  log.info("---------- Configured HIST_R2A output")
84 
85  if hasattr(runArgs, 'outputDAOD_IDTIDEFile'):
86  flagString = 'Output.DAOD_IDTIDEFileName'
87  flags.addFlag(flagString, runArgs.outputDAOD_IDTIDEFile)
88  flags.Output.doWriteDAOD = True
89  flags.addFlag('Output.doWriteDAOD_IDTIDE', True)
90  log.info("---------- Configured DAOD_IDTIDE output")
91 
92  if hasattr(runArgs, 'outputDAOD_PIXELVALIDFile'):
93  flagString = 'Output.DAOD_PIXELVALIDFileName'
94  flags.addFlag(flagString, runArgs.outputDAOD_PIXELVALIDFile)
95  flags.Output.doWriteDAOD = True
96  flags.addFlag('Output.doWriteDAOD_PIXELVALID', True)
97  log.info("---------- Configured DAOD_PIXELVALID output")
98 
99  if hasattr(runArgs, 'outputDAOD_IDTRKVALIDFile'):
100  flagString = 'Output.DAOD_IDTRKVALIDFileName'
101  flags.addFlag(flagString, runArgs.outputDAOD_IDTRKVALIDFile)
102  flags.Output.doWriteDAOD = True
103  flags.addFlag('Output.doWriteDAOD_IDTRKVALID', True)
104  log.info("---------- Configured DAOD_IDTRKVALID output")
105 
106  if hasattr(runArgs, 'outputDAOD_SCTVALIDFile'):
107  flagString = 'Output.DAOD_SCTVALIDFileName'
108  flags.addFlag(flagString, runArgs.outputDAOD_SCTVALIDFile)
109  flags.Output.doWriteDAOD = True
110  flags.addFlag('Output.doWriteDAOD_SCTVALID', True)
111  log.info("---------- Configured DAOD_SCTVALID output")
112 
113  if hasattr(runArgs, 'outputDESDM_MCPFile'):
114  flagString = 'Output.DESDM_MCPFileName'
115  flags.addFlag(flagString, runArgs.outputDESDM_MCPFile)
116  flags.Output.doWriteDAOD = True
117  flags.addFlag('Output.doWriteDESDM_MCP', True)
118  log.info("---------- Configured DESDM_MCP output")
119 
120  if hasattr(runArgs, 'outputDESDM_EXOTHIPFile'):
121  flagString = 'Output.DESDM_EXOTHIPFileName'
122  flags.addFlag(flagString, runArgs.outputDESDM_EXOTHIPFile)
123  flags.Output.doWriteDAOD = True
124  flags.addFlag('Output.doWriteDESDM_EXOTHIP', True)
125  log.info("---------- Configured DESDM_EXOTHIP output")
126 
127  if hasattr(runArgs, 'outputDRAW_ZMUMUFile'):
128  flagString = 'Output.DRAW_ZmumuFileName'
129  flags.addFlag(flagString, runArgs.outputDRAW_ZMUMUFile)
130  flags.Output.doWriteBS = True
131  log.info("---------- Configured DRAW ZMUMU output")
132 
133  if hasattr(runArgs, 'outputDRAW_EGZFile'):
134  flagString = 'Output.DRAW_EGZFileName'
135  flags.addFlag(flagString, runArgs.outputDRAW_EGZFile)
136  flags.Output.doWriteBS = True
137  log.info("---------- Configured DRAW_EGZ output")
138 
139  if hasattr(runArgs, 'outputDRAW_TAULHFile'):
140  flagString = 'Output.DRAW_TAULHFileName'
141  flags.addFlag(flagString, runArgs.outputDRAW_TAULHFile)
142  flags.Output.doWriteBS = True
143  log.info("---------- Configured DRAW_TAULH output")
144 
145  if hasattr(runArgs, 'outputDRAW_JETFile'):
146  flagString = 'Output.DRAW_JETFileName'
147  flags.addFlag(flagString, runArgs.outputDRAW_JETFile)
148  flags.Output.doWriteBS = True
149  log.info("---------- Configured DRAW_JET output")
150 
151  if hasattr(runArgs, 'outputDAOD_L1CALO1File'):
152  flagString = 'Output.DAOD_L1CALO1FileName'
153  flags.addFlag(flagString, runArgs.outputDAOD_L1CALO1File)
154  flags.Output.doWriteDAOD = True
155  flags.addFlag('Output.doWriteDAOD_L1CALO1', True)
156  log.info("---------- Configured DAOD_L1CALO1 output")
157 
158  if hasattr(runArgs, 'outputDAOD_L1CALO2File'):
159  flagString = 'Output.DAOD_L1CALO2FileName'
160  flags.addFlag(flagString, runArgs.outputDAOD_L1CALO2File)
161  flags.Output.doWriteDAOD = True
162  flags.addFlag('Output.doWriteDAOD_L1CALO2', True)
163  log.info("---------- Configured DAOD_L1CALO2 output")
164 
165  if hasattr(runArgs, 'outputDESDM_PHOJETFile'):
166  flagString = 'Output.DESDM_PHOJETFileName'
167  flags.addFlag(flagString, runArgs.outputDESDM_PHOJETFile)
168  flags.Output.doWriteDAOD = True
169  flags.addFlag('Output.doWriteDESDM_PHOJET', True)
170  log.info("---------- Configured DESDM_PHOJET output")
171 
172  if hasattr(runArgs, 'outputDESDM_ALLCELLSFile'):
173  streamName = 'DESDM_ALLCELLS'
174  flags.addFlag(f'Output.{streamName}FileName', runArgs.outputDESDM_ALLCELLSFile)
175  flags.addFlag(f'Output.doWrite{streamName}', True)
176  log.info("---------- Configured "+streamName+" output")
177 
178  # Reconstruction flags should be parsed after inputs are set
179  from RecJobTransforms.RecoConfigFlags import recoRunArgsToFlags
180  recoRunArgsToFlags(runArgs, flags)
181 
182  from AthenaConfiguration.Enums import ProductionStep
183  flags.Common.ProductionStep=ProductionStep.Reconstruction
184 
185  # Setup detector flags
186  from AthenaConfiguration.DetectorConfigFlags import setupDetectorFlags
187  setupDetectorFlags(flags, detectors, use_metadata=True, toggle_geometry=True, keep_beampipe=True)
188  # Print reco domain status
189  from RecJobTransforms.RecoConfigFlags import printRecoFlags
190  printRecoFlags(flags)
191 
192  # TODO: DESD, DAOD and DRAW
193 
194  # outputHIST_R2AFile
195  # outputTAG_COMMFile
196  # outputTXT_FTKIPFile
197  # outputNTUP_MUONCALIBFile
198  # outputTXT_JIVEXMLTGZFile
199 
200  # Setup perfmon flags from runargs
201  from PerfMonComps.PerfMonConfigHelpers import setPerfmonFlagsFromRunArgs
202  setPerfmonFlagsFromRunArgs(flags, runArgs)
203 
204  # Pre-include
205  processPreInclude(runArgs, flags)
206 
207  # Pre-exec
208  processPreExec(runArgs, flags)
209 
210  # To respect --athenaopts
211  flags.fillFromArgs()
212 
213  # Lock flags
214  flags.lock()
215 
216  # Main reconstruction steering
217  from RecJobTransforms.RecoSteering import RecoSteering
218  cfg = RecoSteering(flags)
219 
220  # Performance DPDs
221  cfg.flagPerfmonDomain('PerfDPD')
222  # IDTIDE
223  for flag in [key for key in flags._flagdict.keys() if ("Output.DAOD_IDTIDEFileName" in key)]:
224  from DerivationFrameworkInDet.IDTIDE import IDTIDECfg
225  cfg.merge(IDTIDECfg(flags))
226  log.info("---------- Configured IDTIDE perfDPD")
227 
228  # PixelVALID
229  for flag in [key for key in flags._flagdict.keys() if ("Output.DAOD_PIXELVALIDFileName" in key)]:
230  from DerivationFrameworkInDet.PIXELVALID import PixelVALIDCfg
231  cfg.merge(PixelVALIDCfg(flags))
232  log.info("---------- Configured PixelVALID perfDPD")
233 
234  # SCTVALID
235  for flag in [key for key in flags._flagdict.keys() if ("Output.DAOD_SCTVALIDFileName" in key)]:
236  from InDetPrepRawDataToxAOD.SCTVALID import SCTVALIDCfg
237  cfg.merge(SCTVALIDCfg(flags))
238  log.info("---------- Configured SCTVALID perfDPD")
239 
240  # IDTRKVALID
241  for flag in [key for key in flags._flagdict.keys() if ("Output.DAOD_IDTRKVALIDFileName" in key)]:
242  from DerivationFrameworkInDet.IDTRKVALID import IDTRKVALIDCfg
243  cfg.merge(IDTRKVALIDCfg(flags))
244  log.info("---------- Configured IDTRKVALID perfDPD")
245 
246  # DESDM_MCP
247  for flag in [key for key in flags._flagdict.keys() if ("Output.DESDM_MCPFileName" in key)]:
248  from PrimaryDPDMaker.DESDM_MCP import DESDM_MCPCfg
249  cfg.merge(DESDM_MCPCfg(flags))
250  log.info("---------- Configured DESDM_MCP perfDPD")
251 
252  # DESDM_EXOTHIP
253  for flag in [key for key in flags._flagdict.keys() if ("Output.DESDM_EXOTHIPFileName" in key)]:
254  from PrimaryDPDMaker.DESDM_EXOTHIP import DESDM_EXOTHIPCfg
255  cfg.merge(DESDM_EXOTHIPCfg(flags))
256  log.info("---------- Configured DESDM_EXOTHIP perfDPD")
257 
258  # DRAW ZMUMU
259  for flag in [key for key in flags._flagdict.keys() if ("Output.DRAW_ZmumuFileName" in key)]:
260  from PrimaryDPDMaker.DRAW_ZMUMU import DRAW_ZmumuCfg
261  cfg.merge(DRAW_ZmumuCfg(flags))
262  log.info("---------- Configured DRAW_ZMUMU perfDPD")
263 
264  #DRAW_EGZ
265  for flag in [key for key in flags._flagdict.keys() if ("Output.DRAW_EGZFileName" in key)]:
266  from PrimaryDPDMaker.DRAW_EGZ import DRAW_EGZCfg
267  cfg.merge(DRAW_EGZCfg(flags))
268  log.info("---------- Configured DRAW_EGZ perfDPD")
269 
270  #DRAW_TAULH
271  for flag in [key for key in flags._flagdict.keys() if ("Output.DRAW_TAULHFileName" in key)]:
272  from PrimaryDPDMaker.DRAW_TAULH import DRAW_TAULHCfg
273  cfg.merge(DRAW_TAULHCfg(flags))
274  log.info("---------- Configured DRAW_TAULH perfDPD")
275 
276  #DRAW_JET
277  for flag in [key for key in flags._flagdict.keys() if ("Output.DRAW_JETFileName" in key)]:
278  from PrimaryDPDMaker.DRAW_JET import DRAW_JETCfg
279  cfg.merge(DRAW_JETCfg(flags))
280  log.info("---------- Configured DRAW_JET perfDPD")
281 
282  # L1CALO1/2
283  for flag in [key for key in flags._flagdict.keys() if ("Output.DAOD_L1CALO1FileName" in key)]:
284  from DerivationFrameworkL1Calo.L1CALO1 import L1CALO1Cfg
285  cfg.merge(L1CALO1Cfg(flags))
286  log.info("---------- Configured L1CALO1 perfDPD")
287 
288  for flag in [key for key in flags._flagdict.keys() if ("Output.DAOD_L1CALO2FileName" in key)]:
289  from DerivationFrameworkL1Calo.L1CALO2 import L1CALO2Cfg
290  cfg.merge(L1CALO2Cfg(flags))
291  log.info("---------- Configured L1CALO2 perfDPD")
292 
293  # DESDM PHOJET
294  for flag in [key for key in flags._flagdict.keys() if ("Output.DESDM_PHOJETFileName" in key)]:
295  from PrimaryDPDMaker.DESDM_PHOJET import DESDM_PHOJETCfg
296  cfg.merge(DESDM_PHOJETCfg(flags))
297  log.info("---------- Configured PHOJET perfDPD")
298 
299  # DESDM ALLCELLS
300  for flag in [key for key in flags._flagdict.keys() if ("Output.DESDM_ALLCELLSFileName" in key)]:
301  from PrimaryDPDMaker.DESDM_ALLCELLS import DESDM_ALLCELLSCfg
302  cfg.merge(DESDM_ALLCELLSCfg(flags))
303  log.info("---------- Configured ALLCELLS perfDPD")
304 
305  # Special message service configuration
306  from DigitizationConfig.DigitizationSteering import DigitizationMessageSvcCfg
307  cfg.merge(DigitizationMessageSvcCfg(flags))
308 
309  # Post-include
310  processPostInclude(runArgs, flags, cfg)
311 
312  # Post-exec
313  processPostExec(runArgs, flags, cfg)
314 
315  from AthenaConfiguration.Utils import setupLoggingLevels
316  setupLoggingLevels(flags, cfg)
317 
318  # Write some metadata into TagInfo
319  from EventInfoMgt.TagInfoMgrConfig import TagInfoMgrCfg
320  cfg.merge(
322  flags,
323  tagValuePairs={
324  "beam_type": flags.Beam.Type.value,
325  "beam_energy": str(int(flags.Beam.Energy)),
326  "triggerStreamOfFile": ""
327  if flags.Input.isMC
328  else flags.Input.TriggerStream,
329  "project_name": "IS_SIMULATION"
330  if flags.Input.isMC
331  else flags.Input.ProjectName,
332  f"AtlasRelease_{runArgs.trfSubstepName}": flags.Input.Release or "n/a",
333  },
334  )
335  )
336  if not flags.Input.isMC and flags.Input.DataYear > 0:
337  cfg.merge(TagInfoMgrCfg(flags, tagValuePairs={
338  "data_year": str(flags.Input.DataYear)
339  }))
340 
341  # Write AMI tag into in-file metadata
342  from PyUtils.AMITagHelperConfig import AMITagCfg
343  cfg.merge(AMITagCfg(flags, runArgs))
344 
345  # Print PerfMon domain information when running detailed monitoring
346  if flags.PerfMon.doFullMonMT:
347  cfg.printPerfmonDomains()
348 
349  timeConfig = time.time()
350  log.info("configured in %d seconds", timeConfig - timeStart)
351 
352  log.info("Configured according to flag values listed below")
353  flags.dump()
354 
355  # Print sum information about AccumulatorCache performance
356  from AthenaConfiguration.AccumulatorCache import AccumulatorDecorator
357  AccumulatorDecorator.printStats()
358 
359  # Run the final accumulator
360  sc = cfg.run()
361  timeFinal = time.time()
362  log.info("Run RAWtoALL_skeleton in %d seconds (running %d seconds)", timeFinal - timeStart, timeFinal - timeConfig)
363 
364  import sys
365  sys.exit(not sc.isSuccess())
python.RAWtoALL_Skeleton.fromRunArgs
def fromRunArgs(runArgs)
Definition: RAWtoALL_Skeleton.py:14
python.RecoSteering.RecoSteering
def RecoSteering(flags)
Definition: RecoSteering.py:6
python.DESDM_PHOJET.DESDM_PHOJETCfg
def DESDM_PHOJETCfg(configFlags)
Definition: DESDM_PHOJET.py:40
python.TransformUtils.processPreExec
def processPreExec(runArgs, flags)
Definition: Tools/PyJobTransforms/python/TransformUtils.py:41
vtune_athena.format
format
Definition: vtune_athena.py:14
python.TransformUtils.processPostExec
def processPostExec(runArgs, flags, cfg)
Definition: Tools/PyJobTransforms/python/TransformUtils.py:50
CaloCellPos2Ntuple.int
int
Definition: CaloCellPos2Ntuple.py:24
python.DESDM_MCP.DESDM_MCPCfg
def DESDM_MCPCfg(flags)
Definition: DESDM_MCP.py:353
python.DESDM_ALLCELLS.DESDM_ALLCELLSCfg
def DESDM_ALLCELLSCfg(configFlags)
Definition: DESDM_ALLCELLS.py:27
L1CALO1.L1CALO1Cfg
def L1CALO1Cfg(flags)
Definition: L1CALO1.py:14
python.RecoConfigFlags.printRecoFlags
def printRecoFlags(flags)
Definition: RecoConfigFlags.py:153
python.TransformUtils.processPostInclude
def processPostInclude(runArgs, flags, cfg)
Definition: Tools/PyJobTransforms/python/TransformUtils.py:69
python.RecoConfigFlags.recoRunArgsToFlags
def recoRunArgsToFlags(runArgs, flags)
Definition: RecoConfigFlags.py:196
python.TransformUtils.processPreInclude
def processPreInclude(runArgs, flags)
Definition: Tools/PyJobTransforms/python/TransformUtils.py:62
python.TagInfoMgrConfig.TagInfoMgrCfg
def TagInfoMgrCfg(flags, tagValuePairs={})
Definition: TagInfoMgrConfig.py:6
python.DigitizationSteering.DigitizationMessageSvcCfg
def DigitizationMessageSvcCfg(flags)
Definition: DigitizationSteering.py:217
python.DRAW_TAULH.DRAW_TAULHCfg
def DRAW_TAULHCfg(flags)
Definition: DRAW_TAULH.py:121
python.Utils.setupLoggingLevels
def setupLoggingLevels(flags, ca)
Definition: Control/AthenaConfiguration/python/Utils.py:46
python.SCTVALID.SCTVALIDCfg
def SCTVALIDCfg(flags)
Definition: SCTVALID.py:94
python.PerfMonConfigHelpers.setPerfmonFlagsFromRunArgs
def setPerfmonFlagsFromRunArgs(flags, runArgs)
Definition: PerfMonConfigHelpers.py:3
python.Helpers.ROOT6Setup
def ROOT6Setup(batch=False)
Definition: Tools/PyUtils/python/Helpers.py:19
python.CommonRunArgsToFlags.commonRunArgsToFlags
def commonRunArgsToFlags(runArgs, configFlags)
Definition: CommonRunArgsToFlags.py:12
python.PIXELVALID.PixelVALIDCfg
def PixelVALIDCfg(flags)
Definition: PIXELVALID.py:189
beamspotman.dir
string dir
Definition: beamspotman.py:623
python.DetectorConfigFlags.setupDetectorFlags
def setupDetectorFlags(flags, custom_list=None, use_metadata=False, toggle_geometry=False, validate_only=False, keep_beampipe=False)
Definition: DetectorConfigFlags.py:289
python.DRAW_JET.DRAW_JETCfg
def DRAW_JETCfg(flags)
Definition: DRAW_JET.py:64
python.AMITagHelperConfig.AMITagCfg
def AMITagCfg(flags, runArgs=None, fixBroken=False)
Definition: AMITagHelperConfig.py:77
python.DRAW_EGZ.DRAW_EGZCfg
def DRAW_EGZCfg(flags)
Definition: DRAW_EGZ.py:94
python.AllConfigFlags.initConfigFlags
def initConfigFlags()
Definition: AllConfigFlags.py:19
python.DESDM_EXOTHIP.DESDM_EXOTHIPCfg
def DESDM_EXOTHIPCfg(flags)
Definition: DESDM_EXOTHIP.py:40
python.IDTRKVALID.IDTRKVALIDCfg
def IDTRKVALIDCfg(flags)
Definition: IDTRKVALID.py:228
str
Definition: BTagTrackIpAccessor.cxx:11
python.IDTIDE.IDTIDECfg
def IDTIDECfg(flags)
Definition: IDTIDE.py:318
L1CALO2.L1CALO2Cfg
def L1CALO2Cfg(flags)
Definition: L1CALO2.py:14
python.DRAW_ZMUMU.DRAW_ZmumuCfg
def DRAW_ZmumuCfg(flags)
Definition: DRAW_ZMUMU.py:85