ATLAS Offline Software
Loading...
Searching...
No Matches
runEgammaOnlyESD.py
Go to the documentation of this file.
1# Copyright (C) 2002-2023 CERN for the benefit of the ATLAS collaboration
2
3# authors:
4# Asim Mohammed Aslam <asim.mohammed.aslam@cern.ch>
5# Fernando Monticelli <Fernando.Monticelli@cern.ch>
6# Jean-Baptiste De Vivie <devivie@lpsc.in2p3.fr>
7# Christos Anastopoulos <Christos.Anastopoulos@cern.ch>
8
9# Simple script to run a
10# Egamma job from ESD
11#
12# python runEgammaOnlyESD.py
13# or
14# pythong -m egammaConfig.runEgammaOnlyESD
15
16import sys
17
18
19def _run(args):
20 from AthenaConfiguration.AllConfigFlags import initConfigFlags
21
22 flags = initConfigFlags()
23 # input
24 from AthenaConfiguration.TestDefaults import defaultTestFiles
25
26 flags.Exec.MaxEvents = args.maxEvents
27 if not args.inputFileList:
28 flags.Input.Files = defaultTestFiles.ESD_RUN3_MC
29 else:
30 flags.Input.Files = args.inputFileList
31
32 from AthenaConfiguration.Enums import ProductionStep
33
34 flags.Common.ProductionStep = ProductionStep.Reconstruction
35 # Disable detectors we do not need
36 flags.Detector.GeometryMuon = False
37 flags.Detector.EnableAFP = False
38 flags.Detector.EnableLucid = False
39 flags.Detector.EnableZDC = False
40 flags.Input.isMC = True
41
42 # output
43 flags.Output.AODFileName = args.outputAODFile
44
45 #
46 flags.Egamma.Keys.Output.CaloClusters = "new_egammaClusters"
47 flags.Egamma.Keys.Output.Electrons = "new_Electrons"
48 flags.Egamma.Keys.Output.Photons = "new_Photons"
49
50 # Setup detector flags
51 from AthenaConfiguration.DetectorConfigFlags import setupDetectorFlags
52
53 setupDetectorFlags(
54 flags, None, use_metadata=True, toggle_geometry=True, keep_beampipe=True
55 )
56
57 flags.lock()
58
59 from AthenaConfiguration.MainServicesConfig import MainServicesCfg
60
61 acc = MainServicesCfg(flags)
62
63 from AtlasGeoModel.GeoModelConfig import GeoModelCfg
64
65 acc.merge(GeoModelCfg(flags))
66
67 from AthenaPoolCnvSvc.PoolReadConfig import PoolReadCfg
68
69 acc.merge(PoolReadCfg(flags))
70
71 if flags.Detector.EnablePixel:
72 from PixelGeoModel.PixelGeoModelConfig import PixelReadoutGeometryCfg
73
74 acc.merge(PixelReadoutGeometryCfg(flags))
75 if flags.Detector.EnableSCT:
76 from SCT_GeoModel.SCT_GeoModelConfig import SCT_ReadoutGeometryCfg
77
78 acc.merge(SCT_ReadoutGeometryCfg(flags))
79 if flags.Detector.EnableTRT:
80 from TRT_GeoModel.TRT_GeoModelConfig import TRT_ReadoutGeometryCfg
81
82 acc.merge(TRT_ReadoutGeometryCfg(flags))
83
84 if flags.Detector.EnableLAr:
85 from LArBadChannelTool.LArBadChannelConfig import LArBadFebCfg
86
87 acc.merge(LArBadFebCfg(flags))
88
89 # Special message service configuration
90 from DigitizationConfig.DigitizationSteering import DigitizationMessageSvcCfg
91
92 acc.merge(DigitizationMessageSvcCfg(flags))
93
94 # Algorithms to run
95
96 # For being able to read pre Run-3 data w/ Trk objects
97 from TrkEventCnvTools.TrkEventCnvToolsConfig import TrkEventCnvSuperToolCfg
98
99 acc.merge(TrkEventCnvSuperToolCfg(flags))
100
101 # Redo topo
102 from CaloRec.CaloTopoClusterConfig import CaloTopoClusterCfg
103
104 acc.merge(CaloTopoClusterCfg(flags))
105
106 from egammaAlgs.egammaTopoClusterCopierConfig import egammaTopoClusterCopierCfg
107
108 acc.merge(egammaTopoClusterCopierCfg(flags))
109
110 from egammaAlgs.egammaRecBuilderConfig import egammaRecBuilderCfg
111
112 acc.merge(egammaRecBuilderCfg(flags))
113
114 from egammaAlgs.egammaSuperClusterBuilderConfig import (
115 electronSuperClusterBuilderCfg,
116 photonSuperClusterBuilderCfg,
117 )
118
119 acc.merge(electronSuperClusterBuilderCfg(flags))
120 acc.merge(photonSuperClusterBuilderCfg(flags))
121
122 from egammaAlgs.xAODEgammaBuilderConfig import xAODEgammaBuilderCfg
123
124 acc.merge(xAODEgammaBuilderCfg(flags, name="xAODEgammaBuilder", sequenceName=None))
125
126 from egammaConfig.egammaOutputConfig import egammaOutputCfg
127
128 acc.merge(egammaOutputCfg(flags))
129
130 from AthenaConfiguration.Utils import setupLoggingLevels
131
132 setupLoggingLevels(flags, acc)
133
134 if args.doCopyOriginalCollections:
135 from OutputStreamAthenaPool.OutputStreamConfig import addToAOD
136
137 toAOD = [
138 "xAOD::PhotonContainer#Photons",
139 "xAOD::PhotonAuxContainer#Photons"
140 f"Aux.{flags.Egamma.Keys.Output.PhotonsSuppAOD}",
141 "xAOD::ElectronContainer#Electrons",
142 "xAOD::ElectronAuxContainer#Electrons"
143 f"Aux.{flags.Egamma.Keys.Output.ElectronsSuppAOD}",
144 ]
145 acc.merge(addToAOD(flags, toAOD))
146
147 # running
148 statusCode = acc.run()
149 return statusCode
150
151
152if __name__ == "__main__":
153 statusCode = None
154
155 # Argument parsing
156 from argparse import ArgumentParser
157
158 parser = ArgumentParser("egammaFromESD")
159 parser.add_argument(
160 "-m",
161 "--maxEvents",
162 default=100,
163 type=int,
164 help="The number of events to run. -1 runs all events.",
165 )
166 parser.add_argument(
167 "-i", "--inputFileList", nargs="*", help="list of input ESD files"
168 )
169 parser.add_argument(
170 "-o", "--outputAODFile", default="myAOD.pool.root", help="Output file name"
171 )
172 parser.add_argument(
173 "--doCopyOriginalCollections",
174 default=False,
175 action="store_true",
176 help="store original electron and photon collections",
177 )
178 args = parser.parse_args()
179
180 statusCode = _run(args)
181 assert statusCode is not None, "Issue while running"
182 sys.exit(not statusCode.isSuccess())