2 """Overlay test helpers
4 Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
7 from argparse
import ArgumentParser
8 from AthenaCommon.Debugging
import DbgStage
9 from AthenaConfiguration.AutoConfigFlags
import GetFileMD
10 from AthenaConfiguration.Enums
import LHCPeriod
11 from AthenaConfiguration.JobOptsDumper
import JobOptsDumperCfg
15 """Configure event loop for overlay"""
20 """Common overlay test argument parser"""
21 parser = ArgumentParser(prog=prog)
22 parser.add_argument(
"-d",
"--data", default=
False,
23 action=
"store_true", help=
"Run data overlay")
24 parser.add_argument(
"-n",
"--maxEvents", default=3, type=int,
25 help=
"The number of events to run. 0 skips execution")
26 parser.add_argument(
"-t",
"--threads", default=1, type=int,
27 help=
"The number of concurrent threads to run. 0 uses serial Athena.")
28 parser.add_argument(
"-p",
"--processes", default=0, type=int,
29 help=
"The number of concurrent processes to run. 0 uses serial Athena.")
30 parser.add_argument(
"-c",
"--concurrent", default=0, type=int,
31 help=
"The number of concurrent events to run. 0 uses the same as number of threads.")
32 parser.add_argument(
"-V",
"--verboseAccumulators", default=
False, action=
"store_true",
33 help=
"Print full details of the AlgSequence for each accumulator")
34 parser.add_argument(
"-S",
"--verboseStoreGate", default=
False, action=
"store_true",
35 help=
"Dump the StoreGate(s) each event iteration")
36 parser.add_argument(
"-o",
"--output", default=
'', type=str,
37 help=
"Output RDO file")
38 parser.add_argument(
"-s",
"--outputSig", default=
'', type=str,
39 help=
"Output RDO_SGNL file")
40 parser.add_argument(
"-r",
"--run", default=LHCPeriod.Run2,
41 type=LHCPeriod, choices=
list(LHCPeriod))
42 parser.add_argument(
"--disableTruth", default=
False, action=
"store_true",
43 help=
"Disable truth overlay")
44 parser.add_argument(
"--debug", default=
'', type=str,
45 choices=DbgStage.allowed_values,
46 help=
"Debugging flag: " +
','.join (DbgStage.allowed_values))
51 """Fill default overlay flags for testing"""
53 flags.Digitization.EnableTruth =
False
55 from AthenaConfiguration.TestDefaults
import defaultTestFiles, defaultConditionsTags
56 from AthenaConfiguration.Enums
import ProductionStep
57 flags.Common.ProductionStep = ProductionStep.Overlay
59 flags.Input.isMC =
False
60 flags.Input.Files = defaultTestFiles.HITS_DATA_OVERLAY
61 flags.Input.SecondaryFiles = defaultTestFiles.RAW_BKG
62 flags.Output.RDOFileName =
"dataOverlayRDO.pool.root"
63 flags.IOVDb.GlobalTag = defaultConditionsTags.RUN2_DATA
64 flags.IOVDb.DatabaseInstance =
"CONDBR2"
65 flags.Overlay.DataOverlay =
True
66 from Campaigns
import DataOverlayPPTest
69 if args.run
is LHCPeriod.Run2:
70 flags.Input.Files = defaultTestFiles.RDO_BKG_RUN2
71 flags.Input.SecondaryFiles = defaultTestFiles.HITS_RUN2
72 flags.IOVDb.GlobalTag = defaultConditionsTags.RUN2_MC
73 from Campaigns
import MC20e
75 elif args.run
is LHCPeriod.Run3:
76 flags.Input.Files = defaultTestFiles.RDO_BKG_RUN3
77 flags.Input.SecondaryFiles = defaultTestFiles.HITS_RUN3
78 flags.IOVDb.GlobalTag = defaultConditionsTags.RUN3_MC
79 from Campaigns
import MC23a
81 elif args.run
is LHCPeriod.Run4:
82 flags.Input.Files = defaultTestFiles.RDO_BKG_RUN4
83 flags.Input.SecondaryFiles = defaultTestFiles.HITS_RUN4
84 flags.IOVDb.GlobalTag = defaultConditionsTags.RUN4_MC
85 from Campaigns
import PhaseIIPileUp200
88 raise ValueError(
"Run not supported")
89 flags.Input.MCChannelNumber =
GetFileMD(flags.Input.SecondaryFiles, allowEmpty=
False).
get(
"mc_channel_number", 0)
90 flags.Output.RDOFileName =
"mcOverlayRDO.pool.root"
91 flags.Overlay.DataOverlay =
False
94 if args.output ==
'None':
95 flags.Output.RDOFileName =
''
97 flags.Output.RDOFileName = args.output
100 flags.Output.RDO_SGNLFileName = args.outputSig
102 if 'detectors' in args
and args.detectors:
103 detectors = args.detectors
107 from AthenaConfiguration.DetectorConfigFlags
import setupDetectorFlags
112 from OverlayConfiguration.OverlayMetadata
import overlayMetadataCheck
118 """Postprocess and lock config flags for overlay"""
119 flags.Concurrency.NumThreads = args.threads
120 flags.Concurrency.NumProcs = args.processes
122 flags.Scheduler.ShowDataDeps =
True
123 flags.Scheduler.ShowDataFlow =
True
124 flags.Scheduler.ShowControlFlow =
True
125 flags.Concurrency.NumConcurrentEvents = args.concurrent
if args.concurrent > 0
else args.threads
131 """Common debugging and execution for overlay tests"""
133 accessor.printConfig(withDetails=args.verboseAccumulators)
134 if args.verboseStoreGate:
135 accessor.getService(
"StoreGateSvc").Dump =
True
139 accessor.setDebugStage (args.debug)
142 sc = accessor.run(maxEvents=args.maxEvents)
145 return not sc.isSuccess()