91def SetupVP1():
92 from AthenaConfiguration.Enums import Format
93 from AthenaCommon.Logging import logging
95
96
97 _logger = logging.getLogger("VP1")
98 _logger.setLevel(VERBOSE)
99
100 from AthenaConfiguration.AllConfigFlags import initConfigFlags
101
102 flags = initConfigFlags()
103 flags.Concurrency.NumThreads = 0
104
105
106
107
108
109
110
111 parser = flags.getArgumentParser()
112 parser.prog = "vp1"
113 parser.description = """
114 VP1, or Virtual Point 1, is the interactive 3D event display for the ATLAS experiment at CERN.
115 Detailed documentation can be found at the webpage: https://atlas-vp1.web.cern.ch/atlas-vp1
116 but below are the flags that can be used to configure VP1 (most are standard Athena flags, but some are VP1-specific).
117 """
118 parser.description = """
119 So for example, to run VP1 on a file: vp1 [options] myESD.pool.root"""
120
121 group = parser.add_argument_group("VP1 specific")
122 group.add_argument(
123 "Filename",
124 nargs='?',
125 help="Input file to pass to VP1 (i.e. vp1 myESD.pool.root as an alternative to vp1 --filesInput=[])",
126 metavar="File name",
127 )
128 group.add_argument(
129 "--config",
130 nargs="*",
131 help="Config file to use for VP1. If not specified, the default configuration will be used.",
132 )
133 group.add_argument(
134 "--verboseAthena",
135 action="store_true",
136 help="If false, tell Athena to suppress INFO messages and below.",
137 )
138 group.add_argument(
139 "--online", action="store_true", help="Use this flag for running VP1 at P1."
140 )
141 group.add_argument(
142 "--cruise",
143 type=int,
144 help="Start in cruise mode, changing events after N seconds.",
145 )
146
147 group.add_argument(
148 "--batch",
149 action="store_true",
150 help="Run VP1 in 'batch' mode with a given configuration file.",
151 )
152 group.add_argument(
153 "--batch-all-events",
154 action="store_true",
155 help="Process all events in the input data file in '-batch' mode. Use this together with '-batch'.",
156 )
157 group.add_argument(
158 "--batch-n-events",
159 type=int,
160 help="Process 'N' events in the input data file in '-batch' mode. Use this together with '-batch'.",
161 )
162 group.add_argument(
163 "--batch-output-folder",
164 help="Specify an output folder to store the event displays produced with the '-batch' option.",
165 )
166 group.add_argument(
167 "--batch-random-config",
168 action="store_true",
169 help="Run VP1 in 'batch' mode; for each single event a configuration file will be randomly picked out of the configuration files provided by the user. Use this together with '-batch'.",
170 )
171
172 group.add_argument(
173 "--live", action="store_true", help="Run on live events from point 1."
174 )
175 group.add_argument(
176 "--livelocal",
177 action="store_true",
178 help="Run on live events from point 1 in local directory.",
179 )
180 group.add_argument(
181 "--eventsrc",
182 help="Directory to take single event files from (do not specify input files in this case). To get files from a web server (i.e. live events), put instead the url to the file residing in the same directory (most users should just use the --live option instead).",
183 )
184 group.add_argument(
185 "--extraevtsrcdir",
186 help="Directory to take single event files from (do not specify input files in this case). To get files from a web server (i.e. live events), put instead the url to the file residing in the same directory (most users should just use the -live option instead).",
187 )
188 group.add_argument(
189 "--eventcpy",
190 help="Directory to keep local copies of processed event files. If --eventsrc is set, then -eventcpy will default to /tmp/emoyse/vp1events/6897 .",
191 )
192
193
194
195 args = flags.fillFromArgs(parser=parser)
196
197 if args.help:
199
200 import sys
201 sys.exit()
202
203
204 if args.Filename and (
205 flags.Input.Files == []
206 or flags.Input.Files == ["_ATHENA_GENERIC_INPUTFILE_NAME_"]
207 ):
208 flags.Input.Files = [args.Filename]
209
210 _logger.verbose("+ About to set flags related to the input")
211
212
213
214 vp1_empty_input = False
215
216
217 if flags.Input.Files == [] or flags.Input.Files == [
218 "_ATHENA_GENERIC_INPUTFILE_NAME_"
219 ]:
220 from Campaigns.Utils import Campaign
221 from AthenaConfiguration.TestDefaults import defaultGeometryTags
222
223 vp1_empty_input = True
224
225
226
227
228
229
230
231 flags.Input.ProjectName = "mc20_13TeV"
232 flags.Input.RunNumbers = [330000]
233 flags.Input.TimeStamps = [1]
234 flags.Input.TypedCollections = []
235
236
237 flags.IOVDb.GlobalTag = "OFLCOND-MC23-SDR-RUN3-02"
238 flags.Input.isMC = True
239 flags.Input.MCCampaign = Campaign.Unknown
240 flags.GeoModel.AtlasVersion = defaultGeometryTags.RUN3
241 else:
242
243 from os import path
244
245 for file in flags.Input.Files:
246 if not path.exists(flags.Input.Files[0]):
247 _logger.warning("Input file %s does not exist", file)
248 import sys
249 sys.exit(1)
250
251
252 if args.online:
253 flags.Common.isOnline = args.online
254 elif "HLTP" in flags.IOVDb.GlobalTag:
256 "HLTP detected in the global tag, but --online mode is not enabled. Enabling it now."
257 )
258 flags.Common.isOnline = True
259
260 _logger.verbose("+ ... Input flags done")
261
262 _logger.verbose("+ About to set the detector flags")
263
264 from AthenaConfiguration.DetectorConfigFlags import setupDetectorFlags
265
266 setupDetectorFlags(
267 flags,
268 None,
269 use_metadata=not vp1_empty_input,
270 toggle_geometry=True,
271 keep_beampipe=True,
272 )
273 _logger.verbose("+ ... Detector flags done")
274
275
276 flags.lock()
277
278
279 flags.dump()
280
281
282
283
284
285
286
287
288
289 _logger.verbose("+ Setup main services, and input file reading")
290
291 from AthenaConfiguration.MainServicesConfig import MainServicesCfg
292
293 cfg = MainServicesCfg(flags)
294
295 if not vp1_empty_input:
296
297
298 if flags.Input.Format is Format.POOL:
299 from AthenaPoolCnvSvc.PoolReadConfig import PoolReadCfg
300
301 cfg.merge(PoolReadCfg(flags))
302
303 if "EventInfo" not in flags.Input.Collections:
304 from xAODEventInfoCnv.xAODEventInfoCnvConfig import EventInfoCnvAlgCfg
305 cfg.merge(EventInfoCnvAlgCfg(flags))
306
307 from TrkConfig.TrackCollectionReadConfig import TrackCollectionReadCfg
308 cfg.merge(TrackCollectionReadCfg(flags, "Tracks"))
309
310 from TrkConfig.AtlasExtrapolationEngineConfig import AtlasExtrapolationEngineCfg
311 AtlasExtrapolationEngine = cfg.getPrimaryAndMerge(AtlasExtrapolationEngineCfg(flags))
312 cfg.addPublicTool(AtlasExtrapolationEngine)
313
314 from TrkEventCnvTools.TrkEventCnvToolsConfig import TrkEventCnvSuperToolCfg
315 cfg.merge(TrkEventCnvSuperToolCfg(flags))
316
317
318 if flags.Input.isMC and "xAOD::TruthEventContainer#TruthEvents" not in flags.Input.TypedCollections:
319
320 from xAODTruthCnv.xAODTruthCnvConfig import GEN_AOD2xAODCfg
321 cfg.merge(GEN_AOD2xAODCfg(flags))
322
323 _logger.verbose("+ ... Main services done")
324
325 _logger.verbose("+ About to setup geometry")
326 configureGeometry(flags, cfg)
327 _logger.verbose("+ ... Geometry done")
328
329
330 vp1config = {}
331 if not args.verboseAthena:
332
333 print(
"Suppressing most messages from Athena.")
334 print(
"To see more, set the --verboseAthena flag to true.")
335 msgService = cfg.getService("MessageSvc")
336 msgService.OutputLevel = 4
337
338 if args.cruise:
339 vp1config.setdefault("InitialCruiseMode", "EVENT")
340 vp1config.setdefault("InitialCruiseModePeriod", args.cruise)
341
342 if args.config:
343 print(
"Using config file", args.config)
344 vp1config.setdefault("InitialInputVP1Files", args.config)
345
346
347 if args.batch:
348 setup_batch_mode(args)
349
350
351 if args.eventsrc:
352 vp1config.setdefault("MultipleFilesON", True)
353
354 if args.live or args.livelocal:
355 setup_live_mode(args, vp1config)
356
357
358 cfg.merge(VP1AlgCfg(flags, **vp1config))
359 cfg.run()
360
361
void print(char *figname, TCanvas *c1)