ATLAS Offline Software
Loading...
Searching...
No Matches
VP1AlgConfig Namespace Reference

Functions

 configureGeometry (flags, cfg)
 getATLASVersion ()
 VP1AlgCfg (flags, name="VP1AlgCA", **kwargs)
 SetupVP1 ()
 setup_live_mode (args, vp1config)
 setup_batch_mode (args)

Function Documentation

◆ configureGeometry()

configureGeometry ( flags,
cfg )

Definition at line 9 of file VP1AlgConfig.py.

9def configureGeometry(flags, cfg):
10 if flags.Detector.GeometryBpipe:
11 from BeamPipeGeoModel.BeamPipeGMConfig import BeamPipeGeometryCfg
12
13 cfg.merge(BeamPipeGeometryCfg(flags))
14
15 if flags.Detector.GeometryPixel:
16 from PixelGeoModel.PixelGeoModelConfig import PixelReadoutGeometryCfg
17
18 cfg.merge(PixelReadoutGeometryCfg(flags))
19
20 if flags.Detector.GeometrySCT:
21 from SCT_GeoModel.SCT_GeoModelConfig import SCT_ReadoutGeometryCfg
22
23 cfg.merge(SCT_ReadoutGeometryCfg(flags))
24
25 if flags.Detector.GeometryTRT:
26 from TRT_GeoModel.TRT_GeoModelConfig import TRT_ReadoutGeometryCfg
27
28 cfg.merge(TRT_ReadoutGeometryCfg(flags))
29
30 if flags.Detector.GeometryITkPixel:
31 from PixelGeoModelXml.ITkPixelGeoModelConfig import ITkPixelReadoutGeometryCfg
32
33 cfg.merge(ITkPixelReadoutGeometryCfg(flags))
34
35 if flags.Detector.GeometryITkStrip:
36 from StripGeoModelXml.ITkStripGeoModelConfig import ITkStripReadoutGeometryCfg
37
38 cfg.merge(ITkStripReadoutGeometryCfg(flags))
39
40 if flags.Detector.GeometryHGTD:
41 from HGTD_GeoModelXml.HGTD_GeoModelConfig import HGTD_ReadoutGeometryCfg
42
43 cfg.merge(HGTD_ReadoutGeometryCfg(flags))
44
45 if flags.Detector.GeometryLAr:
46 from LArGeoAlgsNV.LArGMConfig import LArGMCfg
47
48 cfg.merge(LArGMCfg(flags))
49
50 if flags.Detector.GeometryTile:
51 from TileGeoModel.TileGMConfig import TileGMCfg
52
53 cfg.merge(TileGMCfg(flags))
54
55 if flags.Detector.GeometryMuon:
56 from MuonConfig.MuonGeometryConfig import MuonGeoModelCfg
57
58 cfg.merge(MuonGeoModelCfg(flags))
59
60 # Trigger the build of the InDetServMat geometry
61 # if any ID subsystems have been enabled
62 if flags.Detector.GeometryID:
63 from InDetServMatGeoModel.InDetServMatGeoModelConfig import (
64 InDetServiceMaterialCfg)
65 cfg.merge(InDetServiceMaterialCfg(flags))
66
67
68

◆ getATLASVersion()

getATLASVersion ( )

Definition at line 69 of file VP1AlgConfig.py.

69def getATLASVersion():
70 import os
71
72 if "AtlasVersion" in os.environ:
73 return os.environ["AtlasVersion"]
74 if "AtlasBaseVersion" in os.environ:
75 return os.environ["AtlasBaseVersion"]
76 return "Unknown"
77
78

◆ setup_batch_mode()

setup_batch_mode ( args)

Definition at line 424 of file VP1AlgConfig.py.

424def setup_batch_mode(args):
425 # BATCH-MODE
426 # If "--batch" is True, then set the corresponding env var.
427 # The GUI of VP1 will not be shown, but the config file will be taken
428 # and in the end a render of the 3D window will be saved as PNG file.
429 import os
430
431 if args.batch:
432 os.putenv("VP1_BATCHMODE", "1")
433 if args.batch_all_events:
434 os.putenv("VP1_BATCHMODE_ALLEVENTS", "1")
435 if args.batch_n_events:
436 os.putenv("VP1_BATCHMODE_NEVENTS", str(args.batch_n_events))
437 if args.batch_output_folder:
438 os.putenv("VP1_BATCHMODE_OUT_FOLDER", args.batch_output_folder)
439 if args.batch_random_config:
440 os.putenv("VP1_BATCHMODE_RANDOMCONFIG", "1")
441
442

◆ setup_live_mode()

setup_live_mode ( args,
vp1config )

Definition at line 409 of file VP1AlgConfig.py.

409def setup_live_mode(args, vp1config):
410 vp1config.setdefault("MultipleFilesON", True)
411 if args.eventcpy:
412 vp1config.setdefault("vp1Alg.MFLocalCopyDir", args.eventcpy)
413 if args.extraevtsrcdir:
414 vp1config.setdefault("MFAvailableLocalInputDirectories", args.extraevtsrcdir)
415 if args.live:
416 vp1config.setdefault(
417 "MFSourceDir",
418 "https://atlas-live.cern.ch/event_files/L1MinBias/vp1fileinfo.txt",
419 )
420 elif args.livelocal:
421 vp1config.setdefault("MFSourceDir", "/VP1_events/")
422
423

◆ SetupVP1()

SetupVP1 ( )

Definition at line 95 of file VP1AlgConfig.py.

95def SetupVP1():
96 from AthenaConfiguration.Enums import Format
97 from AthenaCommon.Logging import logging
98 from AthenaCommon.Constants import VERBOSE
99
100 # ++++ Firstly we setup flags ++++
101 _logger = logging.getLogger("VP1")
102 _logger.setLevel(VERBOSE)
103
104 from AthenaConfiguration.AllConfigFlags import initConfigFlags
105
106 flags = initConfigFlags()
107 flags.Concurrency.NumThreads = 0
108
109 # ^ VP1 will not work with the scheduler, since its condition/data dependencies are not known in advance
110 # More in details: the scheduler needs to know BEFORE the event, what the dependencies of each Alg are.
111 # So for VP1, no dependencies are declared, which means the conditions data is not there.
112 # So when I load tracks, the geometry is missing and it crashes.
113 # Turning off the scheduler (with NumThreads=0) fixes this.
114
115 parser = flags.getArgumentParser()
116 parser.prog = "vp1"
117 parser.description = """
118 VP1, or Virtual Point 1, is the interactive 3D event display for the ATLAS experiment at CERN.
119 Detailed documentation can be found at the webpage: https://atlas-vp1.web.cern.ch/atlas-vp1
120 but below are the flags that can be used to configure VP1 (most are standard Athena flags, but some are VP1-specific).
121 """
122 parser.description = """
123 So for example, to run VP1 on a file: vp1 [options] myESD.pool.root"""
124 # Add VP1-specific arguments here, but remember you can also directly pass flags in form <flagName>=<value>.
125 group = parser.add_argument_group("VP1 specific")
126 group.add_argument(
127 "--fix-snapshots", action="store_true",
128 help="Enable the temporary Linux GLX zero pixel-limit workaround (requires a C compiler).",
129 )
130 group.add_argument(
131 "Filename",
132 nargs='?',
133 help="Input file to pass to VP1 (i.e. vp1 myESD.pool.root as an alternative to vp1 --filesInput=[])",
134 metavar="File name",
135 )
136 group.add_argument(
137 "--config",
138 nargs="*",
139 help="Config file to use for VP1. If not specified, the default configuration will be used.",
140 )
141 group.add_argument(
142 "--verboseAthena",
143 action="store_true",
144 help="If false, tell Athena to suppress INFO messages and below.",
145 )
146 group.add_argument(
147 "--online", action="store_true", help="Use this flag for running VP1 at P1."
148 )
149 group.add_argument(
150 "--cruise",
151 type=int,
152 help="Start in cruise mode, changing events after N seconds.",
153 )
154 # Phase-II
155 group.add_argument(
156 "--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."
157 )
158 # Batch
159 group.add_argument(
160 "--batch",
161 action="store_true",
162 help="Run VP1 in 'batch' mode with a given configuration file.",
163 )
164 group.add_argument(
165 "--batch-all-events",
166 action="store_true",
167 help="Process all events in the input data file in '-batch' mode. Use this together with '-batch'.",
168 )
169 group.add_argument(
170 "--batch-n-events",
171 type=int,
172 help="Process 'N' events in the input data file in '-batch' mode. Use this together with '-batch'.",
173 )
174 group.add_argument(
175 "--batch-output-folder",
176 help="Specify an output folder to store the event displays produced with the '-batch' option.",
177 )
178 group.add_argument(
179 "--batch-random-config",
180 action="store_true",
181 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'.",
182 )
183 # Live / Livelocal
184 group.add_argument(
185 "--live", action="store_true", help="Run on live events from point 1."
186 )
187 group.add_argument(
188 "--livelocal",
189 action="store_true",
190 help="Run on live events from point 1 in local directory.",
191 )
192 group.add_argument(
193 "--eventsrc",
194 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).",
195 )
196 group.add_argument(
197 "--extraevtsrcdir",
198 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).",
199 )
200 group.add_argument(
201 "--eventcpy",
202 help="Directory to keep local copies of processed event files. If --eventsrc is set, then -eventcpy will default to /tmp/emoyse/vp1events/6897 .",
203 )
204 # group.add_argument('--nocleanupeventcpy', action='store_true', help="Prevent removal of eventcpy directory after athena process finishes.")
205 # Commented, because I'm not sure how to implement this safely, yet -- TODO.
206
207 args = flags.fillFromArgs(parser=parser)
208
209 if args.help:
210 print(args)
211 # No point doing more here, since we just want to print the help.
212 import sys
213 sys.exit()
214
215 # Support the positional version of passing file name e.g. vp1 myESD.pool.root
216 if args.Filename and (
217 flags.Input.Files == []
218 or flags.Input.Files == ["_ATHENA_GENERIC_INPUTFILE_NAME_"]
219 ):
220 flags.Input.Files = [args.Filename]
221
222 _logger.verbose("+ About to set flags related to the input")
223
224
225 # This dict stores the variables to set the VP1Alg properties
226 vp1config = {}
227
228
229 # Empty input is not normal for Athena, so we will need to check
230 # this repeatedly below
231 vp1_empty_input = False
232 # This covers the use case where we launch VP1
233 # without input files; e.g., to check the detector description
234 if (flags.Input.Files == [] or flags.Input.Files == ["_ATHENA_GENERIC_INPUTFILE_NAME_"]):
235 if not args.phaseII:
236 from Campaigns.Utils import Campaign
237 from AthenaConfiguration.TestDefaults import defaultGeometryTags
238
239 vp1_empty_input = True
240
241 # NB Must set e.g. ConfigFlags.Input.Runparse_args() Number and
242 # ConfigFlags.Input.TimeStamp before calling the
243 # MainServicesCfg to avoid it attempting auto-configuration
244 # from an input file, which is empty in this use case.
245 # If you don't have it, it (and/or other Cfg routines) complains and crashes.
246 # See also:
247 # https://acode-browser1.usatlas.bnl.gov/lxr/source/athena/InnerDetector/InDetConditions/SCT_ConditionsAlgorithms/python/SCT_DCSConditionsTestAlgConfig.py#0023
248 flags.Input.ProjectName = "mc20_13TeV"
249 flags.Input.RunNumbers = [330000]
250 flags.Input.TimeStamps = [1]
251 flags.Input.TypedCollections = []
252
253 # set default CondDB and Geometry version
254 flags.IOVDb.GlobalTag = "OFLCOND-MC23-SDR-RUN3-02"
255 flags.Input.isMC = True
256 flags.Input.MCCampaign = Campaign.Unknown
257 flags.GeoModel.AtlasVersion = defaultGeometryTags.RUN3
258 elif args.phaseII:
259 _logger.verbose("Phase-II mode!")
260 from Campaigns.Utils import Campaign
261 from AthenaConfiguration.TestDefaults import defaultConditionsTags, defaultGeometryTags
262 vp1_empty_input = True
263 flags.Input.ProjectName = "mc21_14TeV"
264 flags.Input.RunNumbers = [601229]
265 flags.Input.TimeStamps = [1]
266 flags.Input.TypedCollections = []
267
268 # set default CondDB and Geometry version
269 flags.IOVDb.GlobalTag = defaultConditionsTags.RUN4_MC
270 flags.Input.isMC = True
271 flags.Input.MCCampaign = Campaign.Unknown
272 flags.GeoModel.AtlasVersion = defaultGeometryTags.RUN4
273
274
275 # Here we consider the use case where we launch VP1
276 # with input data files
277 # (such as ESD, HITS, RDO, or any other pool.root file)
278 else:
279
280 if args.phaseII:
281 _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")
282 import sys
283 sys.exit(2)
284
285 # Now just check file exists, or fail gracefully
286 from os import path
287
288 for file in flags.Input.Files:
289 if not path.exists(flags.Input.Files[0]):
290 _logger.warning("Input file '%s' does not exist", file)
291 import sys
292 sys.exit(1)
293
294 vp1config.setdefault("EmptyInput", vp1_empty_input)
295
296 # Set the online flag if we are running at P1
297 if args.online:
298 flags.Common.isOnline = args.online
299 elif "HLTP" in flags.IOVDb.GlobalTag:
300 print(
301 "HLTP detected in the global tag, but --online mode is not enabled. Enabling it now."
302 )
303 flags.Common.isOnline = True
304
305 _logger.verbose("+ ... Input flags done")
306
307 _logger.verbose("+ About to set the detector flags")
308 # So we can now set up the geometry flags from the input
309 from AthenaConfiguration.DetectorConfigFlags import setupDetectorFlags
310
311 setupDetectorFlags(
312 flags,
313 None,
314 use_metadata=not vp1_empty_input,
315 toggle_geometry=True,
316 keep_beampipe=True,
317 )
318 _logger.verbose("+ ... Detector flags done")
319
320 # finalize setting flags: lock them.
321 flags.lock()
322
323 # DEBUG -- inspect the flags
324 flags.dump()
325 # flags._loadDynaFlags('GeoModel')
326 # flags._loadDynaFlags('Detector')
327 # flags.dump('Detector.(Geometry|Enable)', True)
328
329 # ++++ Now we setup the actual configuration ++++
330
331 # NB Must have set ConfigFlags.Input.RunNumber and
332 # ConfigFlags.Input.TimeStamp before calling to avoid
333 # attempted auto-configuration from an input file.
334 _logger.verbose("+ Setup main services, and input file reading")
335
336 from AthenaConfiguration.MainServicesConfig import MainServicesCfg
337
338 cfg = MainServicesCfg(flags)
339
340 if not vp1_empty_input:
341 # Only do this if we have input files, otherwise flags will try to read metadata
342 # Check if we are reading from POOL and setupo convertors if so
343 if flags.Input.Format is Format.POOL:
344 from AthenaPoolCnvSvc.PoolReadConfig import PoolReadCfg
345
346 cfg.merge(PoolReadCfg(flags))
347 # Check if running on legacy inputs
348 if "EventInfo" not in flags.Input.Collections:
349 from xAODEventInfoCnv.xAODEventInfoCnvConfig import EventInfoCnvAlgCfg
350 cfg.merge(EventInfoCnvAlgCfg(flags))
351
352 from TrkConfig.TrackCollectionReadConfig import TrackCollectionReadCfg
353 cfg.merge(TrackCollectionReadCfg(flags, "Tracks"))
354
355
356 from TrkConfig.AtlasExtrapolatorConfig import AtlasExtrapolatorCfg
357 toolAtlasExtrapolator = cfg.popToolsAndMerge(AtlasExtrapolatorCfg(flags))
358 cfg.addPublicTool(toolAtlasExtrapolator)
359 vp1config.setdefault("ExtrapolatorTool", toolAtlasExtrapolator)
360
361
362 from TrkEventCnvTools.TrkEventCnvToolsConfig import TrkEventCnvSuperToolCfg
363 cfg.merge(TrkEventCnvSuperToolCfg(flags))
364
365
366 if flags.Input.isMC and "xAOD::TruthEventContainer#TruthEvents" not in flags.Input.TypedCollections:
367 # AOD2xAOD Truth conversion
368 from xAODTruthCnv.xAODTruthCnvConfig import GEN_AOD2xAODCfg
369 cfg.merge(GEN_AOD2xAODCfg(flags))
370
371 _logger.verbose("+ ... Main services done")
372
373 _logger.verbose("+ About to setup geometry")
374 configureGeometry(flags, cfg)
375 _logger.verbose("+ ... Geometry done")
376
377 # Setup some VP1 specific stuff
378 if not args.verboseAthena:
379 # Suppress the output from Athena
380 _logger.warning("From here, we are suppressing most messages from Athena.")
381 _logger.info("To see more, use the --verboseAthena flag; e.g., 'vp1 myESD.root --verboseAthena'")
382 msgService = cfg.getService("MessageSvc")
383 msgService.OutputLevel = 4
384
385 if args.cruise:
386 vp1config.setdefault("InitialCruiseMode", "EVENT")
387 vp1config.setdefault("InitialCruiseModePeriod", args.cruise)
388
389 if args.config:
390 print("Using config file", args.config)
391 vp1config.setdefault("InitialInputVP1Files", args.config)
392
393 # Batch mode
394 if args.batch:
395 setup_batch_mode(args)
396
397 # Event copying and live
398 if args.eventsrc:
399 vp1config.setdefault("MultipleFilesON", True)
400
401 if args.live or args.livelocal:
402 setup_live_mode(args, vp1config)
403
404 # configure VP1
405 cfg.merge(VP1AlgCfg(flags, **vp1config))
406 cfg.run()
407
408
void print(char *figname, TCanvas *c1)

◆ VP1AlgCfg()

VP1AlgCfg ( flags,
name = "VP1AlgCA",
** kwargs )

Definition at line 79 of file VP1AlgConfig.py.

79def VP1AlgCfg(flags, name="VP1AlgCA", **kwargs):
80 # This is based on a few old-style configuation files:
81 # JiveXML_RecEx_config.py
82 # JiveXML_jobOptionBase.py
83 result = ComponentAccumulator()
84
85 kwargs.setdefault("AtlasRelease", getATLASVersion())
86 if kwargs.get("EmptyInput", False):
87 # Disable the default tool handle: the framework also retrieves tools
88 # after initialize(), even when VP1 skips its explicit retrieval.
89 kwargs.setdefault("ExtrapolatorTool", "")
90 the_alg = CompFactory.VP1Alg(name="VP1EventDisplayAlg", **kwargs)
91 result.addEventAlgo(the_alg, primary=True)
92 return result
93
94