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 "--phaseII", action="store_true", help="Launch VP1 with the current default Run4 geometry tag for Phase-II [that is, it sets 'flags.GeoModel.AtlasVersion = defaultGeometryTags.RUN4']. It cannot be used when running VP1 on a data file, otherwise it interferes with the auto-configuration from the metadata stored in the file."
149 )
150
151 group.add_argument(
152 "--batch",
153 action="store_true",
154 help="Run VP1 in 'batch' mode with a given configuration file.",
155 )
156 group.add_argument(
157 "--batch-all-events",
158 action="store_true",
159 help="Process all events in the input data file in '-batch' mode. Use this together with '-batch'.",
160 )
161 group.add_argument(
162 "--batch-n-events",
163 type=int,
164 help="Process 'N' events in the input data file in '-batch' mode. Use this together with '-batch'.",
165 )
166 group.add_argument(
167 "--batch-output-folder",
168 help="Specify an output folder to store the event displays produced with the '-batch' option.",
169 )
170 group.add_argument(
171 "--batch-random-config",
172 action="store_true",
173 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'.",
174 )
175
176 group.add_argument(
177 "--live", action="store_true", help="Run on live events from point 1."
178 )
179 group.add_argument(
180 "--livelocal",
181 action="store_true",
182 help="Run on live events from point 1 in local directory.",
183 )
184 group.add_argument(
185 "--eventsrc",
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 "--extraevtsrcdir",
190 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).",
191 )
192 group.add_argument(
193 "--eventcpy",
194 help="Directory to keep local copies of processed event files. If --eventsrc is set, then -eventcpy will default to /tmp/emoyse/vp1events/6897 .",
195 )
196
197
198
199 args = flags.fillFromArgs(parser=parser)
200
201 if args.help:
203
204 import sys
205 sys.exit()
206
207
208 if args.Filename and (
209 flags.Input.Files == []
210 or flags.Input.Files == ["_ATHENA_GENERIC_INPUTFILE_NAME_"]
211 ):
212 flags.Input.Files = [args.Filename]
213
214 _logger.verbose("+ About to set flags related to the input")
215
216
217
218 vp1_empty_input = False
219
220
221 if (flags.Input.Files == [] or flags.Input.Files == ["_ATHENA_GENERIC_INPUTFILE_NAME_"]):
222 if not args.phaseII:
223 from Campaigns.Utils import Campaign
224 from AthenaConfiguration.TestDefaults import defaultGeometryTags
225
226 vp1_empty_input = True
227
228
229
230
231
232
233
234 flags.Input.ProjectName = "mc20_13TeV"
235 flags.Input.RunNumbers = [330000]
236 flags.Input.TimeStamps = [1]
237 flags.Input.TypedCollections = []
238
239
240 flags.IOVDb.GlobalTag = "OFLCOND-MC23-SDR-RUN3-02"
241 flags.Input.isMC = True
242 flags.Input.MCCampaign = Campaign.Unknown
243 flags.GeoModel.AtlasVersion = defaultGeometryTags.RUN3
244 elif args.phaseII:
245 _logger.verbose("Phase-II mode!")
246 from Campaigns.Utils import Campaign
247 from AthenaConfiguration.TestDefaults import defaultGeometryTags
248 vp1_empty_input = True
249 flags.Input.ProjectName = "mc21_14TeV"
250 flags.Input.RunNumbers = [601229]
251 flags.Input.TimeStamps = [1]
252 flags.Input.TypedCollections = []
253
254
255 flags.IOVDb.GlobalTag = "OFLCOND-MC16-SDR-15"
256 flags.Input.isMC = True
257 flags.Input.MCCampaign = Campaign.Unknown
258 flags.GeoModel.AtlasVersion = defaultGeometryTags.RUN4
259
260
261
262
263
264 else:
265
266 if args.phaseII:
267 _logger.error("VP1: The use of the `--phaseII` flag with input data file is not supported. When you run VP1 on input data file, metadata are taken from the data file itself. Please remove `--phaseII` and relaunch. However, if needed, you can still steer Athena by using the standard Athena flags and options. Exiting...\n")
268 import sys
269 sys.exit(2)
270
271
272 from os import path
273
274 for file in flags.Input.Files:
275 if not path.exists(flags.Input.Files[0]):
276 _logger.warning("Input file '%s' does not exist", file)
277 import sys
278 sys.exit(1)
279
280
281 if args.online:
282 flags.Common.isOnline = args.online
283 elif "HLTP" in flags.IOVDb.GlobalTag:
285 "HLTP detected in the global tag, but --online mode is not enabled. Enabling it now."
286 )
287 flags.Common.isOnline = True
288
289 _logger.verbose("+ ... Input flags done")
290
291 _logger.verbose("+ About to set the detector flags")
292
293 from AthenaConfiguration.DetectorConfigFlags import setupDetectorFlags
294
295 setupDetectorFlags(
296 flags,
297 None,
298 use_metadata=not vp1_empty_input,
299 toggle_geometry=True,
300 keep_beampipe=True,
301 )
302 _logger.verbose("+ ... Detector flags done")
303
304
305 flags.lock()
306
307
308 flags.dump()
309
310
311
312
313
314
315
316
317
318 _logger.verbose("+ Setup main services, and input file reading")
319
320 from AthenaConfiguration.MainServicesConfig import MainServicesCfg
321
322 cfg = MainServicesCfg(flags)
323
324 if not vp1_empty_input:
325
326
327 if flags.Input.Format is Format.POOL:
328 from AthenaPoolCnvSvc.PoolReadConfig import PoolReadCfg
329
330 cfg.merge(PoolReadCfg(flags))
331
332 if "EventInfo" not in flags.Input.Collections:
333 from xAODEventInfoCnv.xAODEventInfoCnvConfig import EventInfoCnvAlgCfg
334 cfg.merge(EventInfoCnvAlgCfg(flags))
335
336 from TrkConfig.TrackCollectionReadConfig import TrackCollectionReadCfg
337 cfg.merge(TrackCollectionReadCfg(flags, "Tracks"))
338
339 from TrkConfig.AtlasExtrapolationEngineConfig import AtlasExtrapolationEngineCfg
340 AtlasExtrapolationEngine = cfg.getPrimaryAndMerge(AtlasExtrapolationEngineCfg(flags))
341 cfg.addPublicTool(AtlasExtrapolationEngine)
342
343 from TrkEventCnvTools.TrkEventCnvToolsConfig import TrkEventCnvSuperToolCfg
344 cfg.merge(TrkEventCnvSuperToolCfg(flags))
345
346
347 if flags.Input.isMC and "xAOD::TruthEventContainer#TruthEvents" not in flags.Input.TypedCollections:
348
349 from xAODTruthCnv.xAODTruthCnvConfig import GEN_AOD2xAODCfg
350 cfg.merge(GEN_AOD2xAODCfg(flags))
351
352 _logger.verbose("+ ... Main services done")
353
354 _logger.verbose("+ About to setup geometry")
355 configureGeometry(flags, cfg)
356 _logger.verbose("+ ... Geometry done")
357
358
359 vp1config = {}
360 if not args.verboseAthena:
361
362 print(
"Suppressing most messages from Athena.")
363 print(
"To see more, set the --verboseAthena flag to true.")
364 msgService = cfg.getService("MessageSvc")
365 msgService.OutputLevel = 4
366
367 if args.cruise:
368 vp1config.setdefault("InitialCruiseMode", "EVENT")
369 vp1config.setdefault("InitialCruiseModePeriod", args.cruise)
370
371 if args.config:
372 print(
"Using config file", args.config)
373 vp1config.setdefault("InitialInputVP1Files", args.config)
374
375
376 if args.batch:
377 setup_batch_mode(args)
378
379
380 if args.eventsrc:
381 vp1config.setdefault("MultipleFilesON", True)
382
383 if args.live or args.livelocal:
384 setup_live_mode(args, vp1config)
385
386
387 cfg.merge(VP1AlgCfg(flags, **vp1config))
388 cfg.run()
389
390
void print(char *figname, TCanvas *c1)