ATLAS Offline Software
Loading...
Searching...
No Matches
ESDtoNTUP_FCS_Skeleton.py
Go to the documentation of this file.
1# Copyright (C) 2002-2023 CERN for the benefit of the ATLAS collaboration
2
3def fromRunArgs(runArgs):
4
5 """ This is the main skeleton for creating FCS_NTUP from ESD files.
6 """
7
8 # Setup logging
9 from AthenaCommon.Logging import logging
10 log = logging.getLogger('FCS_Ntup_tf')
11 log.info( '****************** STARTING Ntuple Production *****************' )
12
13 # Print arguments
14 log.info('**** Transformation run arguments')
15 log.info(str(runArgs))
16
17 # Setup configuration flags
18 log.info('**** Setting up configuration flags')
19
20 from PyJobTransforms.CommonRunArgsToFlags import commonRunArgsToFlags
21 from AthenaConfiguration.AllConfigFlags import initConfigFlags
22 flags = initConfigFlags()
23 flags.Exec.EventPrintoutInterval = 100
24 commonRunArgsToFlags(runArgs, flags)
25
26 # First let's find the input/output files
27 if hasattr(runArgs,"inputESDFile"):
28 flags.Input.Files = runArgs.inputESDFile
29 else:
30 raise RuntimeError('Could NOT determine the input files!')
31
32 # Now set the input files before we attempt to read the processing tags
33 if hasattr(runArgs,"outputNTUP_FCSFile"):
34 log.info("Output is")
35 flags.Output.HISTFileName = runArgs.outputNTUP_FCSFile
36 else:
37 log.warning('No output file set! Using output.NTUP_FCS.root')
38 flags.Output.HISTFileName = 'output.NTUP_FCS.root'
39
40
41 outputGeoFileName = None
42 if hasattr(runArgs,"outputGeoFileName"):
43 outputGeoFileName = runArgs.outputGeoFileName
44
45 # Autoconfigure enabled subdetectors
46 if hasattr(runArgs, 'detectors'):
47 detectors = runArgs.detectors
48 else:
49 detectors = None
50 # Setup detector flags
51 from AthenaConfiguration.DetectorConfigFlags import setupDetectorFlags
52 setupDetectorFlags(flags, detectors, use_metadata=True, toggle_geometry=True, keep_beampipe=True)
53
54
55 doG4HitsArg = False
56 if hasattr(runArgs,"doG4Hits"):
57 doG4HitsArg = runArgs.doG4Hits
58
59
60 doClusterInfoArg = False
61 if hasattr(runArgs,"doClusterInfo"):
62 doClusterInfoArg = runArgs.doClusterInfo
63
64
65 saveAllBranchesArg = False
66 if hasattr(runArgs, "saveAllBranches"):
67 saveAllBranchesArg = runArgs.saveAllBranches
68
69
70 NTruthParticlesArg = 1
71 if hasattr(runArgs, "NTruthParticles"):
72 NTruthParticlesArg = runArgs.NTruthParticles
73
74 # Setup perfmon flags from runargs
75 from PerfMonComps.PerfMonConfigHelpers import setPerfmonFlagsFromRunArgs
76 setPerfmonFlagsFromRunArgs(flags, runArgs)
77
78 # Pre-include
79 from PyJobTransforms.TransformUtils import processPreExec, processPreInclude, processPostExec, processPostInclude
80 log.info('**** Processing preInclude')
81 processPreInclude(runArgs, flags)
82
83 # Pre-exec
84 log.info('**** Processing preExec')
85 processPreExec(runArgs, flags)
86
87 # To respect --athenaopts
88 log.info('**** Processing athenaopts')
89 flags.fillFromArgs()
90
91 # Lock configuration flags
92 log.info('**** Locking configuration flags')
93 flags.lock()
94
95 # Set up necessary job components
96 log.info('**** Setting up job components')
97
98 # Main services
99 from AthenaConfiguration.MainServicesConfig import MainServicesCfg
100 cfg = MainServicesCfg(flags)
101
102 # Input reading
103 from AthenaPoolCnvSvc.PoolReadConfig import PoolReadCfg
104 cfg.merge(PoolReadCfg(flags))
105
106 from ISF_FastCaloSimParametrization.ISF_FastCaloSimParametrizationConfig import ISF_HitAnalysisCfg
107 cfg.merge(ISF_HitAnalysisCfg(flags,
108 NTruthParticles=NTruthParticlesArg, saveAllBranches=saveAllBranchesArg,
109 doG4Hits=doG4HitsArg, doClusterInfo=doClusterInfoArg, outputGeoFileName=outputGeoFileName))
110 # TODO! FCS config here
111
112 # Post-include
113 log.info('**** Processing postInclude')
114 processPostInclude(runArgs, flags, cfg)
115
116 # Post-exec
117 log.info('**** Processing postExec')
118 processPostExec(runArgs, flags, cfg)
119
120 # Now run the job and exit accordingly
121 sc = cfg.run()
122 import sys
123 sys.exit(not sc.isSuccess())