ATLAS Offline Software
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 
3 def 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  # Add PerfMon
113  if flags.PerfMon.doFastMonMT or flags.PerfMon.doFullMonMT:
114  from PerfMonComps.PerfMonCompsConfig import PerfMonMTSvcCfg
115  cfg.merge(PerfMonMTSvcCfg(flags))
116 
117  # Post-include
118  log.info('**** Processing postInclude')
119  processPostInclude(runArgs, flags, cfg)
120 
121  # Post-exec
122  log.info('**** Processing postExec')
123  processPostExec(runArgs, flags, cfg)
124 
125  # Now run the job and exit accordingly
126  sc = cfg.run()
127  import sys
128  sys.exit(not sc.isSuccess())
python.TransformUtils.processPreExec
def processPreExec(runArgs, flags)
Definition: Tools/PyJobTransforms/python/TransformUtils.py:41
python.TransformUtils.processPostExec
def processPostExec(runArgs, flags, cfg)
Definition: Tools/PyJobTransforms/python/TransformUtils.py:50
ESDtoNTUP_FCS_Skeleton.fromRunArgs
def fromRunArgs(runArgs)
Definition: ESDtoNTUP_FCS_Skeleton.py:3
python.TransformUtils.processPostInclude
def processPostInclude(runArgs, flags, cfg)
Definition: Tools/PyJobTransforms/python/TransformUtils.py:69
python.TransformUtils.processPreInclude
def processPreInclude(runArgs, flags)
Definition: Tools/PyJobTransforms/python/TransformUtils.py:62
python.PerfMonCompsConfig.PerfMonMTSvcCfg
def PerfMonMTSvcCfg(flags, **kwargs)
A minimal new-style configuration for PerfMonMTSvc.
Definition: PerfMonCompsConfig.py:10
python.PerfMonConfigHelpers.setPerfmonFlagsFromRunArgs
def setPerfmonFlagsFromRunArgs(flags, runArgs)
Definition: PerfMonConfigHelpers.py:3
python.MainServicesConfig.MainServicesCfg
def MainServicesCfg(flags, LoopMgr='AthenaEventLoopMgr')
Definition: MainServicesConfig.py:256
python.CommonRunArgsToFlags.commonRunArgsToFlags
def commonRunArgsToFlags(runArgs, configFlags)
Definition: CommonRunArgsToFlags.py:12
python.DetectorConfigFlags.setupDetectorFlags
def setupDetectorFlags(flags, custom_list=None, use_metadata=False, toggle_geometry=False, validate_only=False, keep_beampipe=False)
Definition: DetectorConfigFlags.py:286
ISF_FastCaloSimParametrizationConfig.ISF_HitAnalysisCfg
def ISF_HitAnalysisCfg(flags, name="ISF_HitAnalysis", NTruthParticles=1, saveAllBranches=False, doG4Hits=False, doClusterInfo=False, outputGeoFileName=None, **kwargs)
Definition: ISF_FastCaloSimParametrizationConfig.py:9
python.AllConfigFlags.initConfigFlags
def initConfigFlags()
Definition: AllConfigFlags.py:19
str
Definition: BTagTrackIpAccessor.cxx:11
python.PoolReadConfig.PoolReadCfg
def PoolReadCfg(flags)
Definition: PoolReadConfig.py:69