ATLAS Offline Software
MuonVertexValidationRun.py
Go to the documentation of this file.
1 #
2 # Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
3 #
4 
5 from AthenaConfiguration.ComponentAccumulator import ComponentAccumulator
6 from AthenaConfiguration.ComponentFactory import CompFactory
7 
8 
10  from argparse import ArgumentParser
11 
12  parser = ArgumentParser()
13  parser.add_argument( "-i", "--inputFile", required=True, help="Input file to run on ", nargs="+") # flexible number of arguments, gathered into a list
14  parser.add_argument( "-o", "--outputFile", default="MSVtxVal_out.root", help="output root file")
15  parser.add_argument("--maxEvents", default=-1, type=int, help="How many events shall be run maximally")
16  parser.add_argument("--skipEvents", default=0, type=int, help="How many events shall be skipped")
17  parser.add_argument("--threads", default=1, type=int, help="number of threads")
18 
19  return parser
20 
21 
22 def setupHistSvcCfg(flags, out_file="out.root", out_stream="MSVtxValidation"):
23  result = ComponentAccumulator()
24  if len(out_file) == 0: return result
25  histSvc = CompFactory.THistSvc(Output=[f"{out_stream} DATAFILE='{out_file}', OPT='RECREATE'"])
26  result.addService(histSvc, primary=True)
27  return result
28 
29 
30 def MSVtxValidationCfg(flags, name="MSVertexValidationAlg", outStream="MSVtxValidation", outFile="out.root", **kwargs):
31  # outStream defines the steam to place the tree and histograms
32  result = ComponentAccumulator()
33  # setting algorithm properties here via kwargs.setdefault("<property name>", <property value>)
34  alg = CompFactory.MSVtxValidationAlg(name, **kwargs)
35  result.merge(setupHistSvcCfg(flags,out_file=outFile, out_stream=outStream))
36  result.addEventAlgo(alg)
37 
38  return result
39 
40 
41 def execute(cfg):
42  cfg.printConfig(withDetails=True, summariseProps=True)
43  if not cfg.run().isSuccess(): exit(1)
44 
45 
46 if __name__ == "__main__":
47  from AthenaConfiguration.AllConfigFlags import initConfigFlags
48  from MuonCondTest.MdtCablingTester import setupServicesCfg
49 
51  flags = initConfigFlags()
52  flags.Concurrency.NumThreads = args.threads
53  flags.Exec.MaxEvents = args.maxEvents
54  flags.Exec.SkipEvents = args.skipEvents
55  flags.Concurrency.NumConcurrentEvents = args.threads
56  flags.Input.Files = args.inputFile
57  flags.Scheduler.ShowDataDeps = True
58  flags.Scheduler.ShowDataFlow = True
59  flags.lock()
60  cfg = setupServicesCfg(flags)
61  cfg.merge(MSVtxValidationCfg(flags, outFile=args.outputFile))
62  execute(cfg)
MuonVertexValidationRun.execute
def execute(cfg)
Definition: MuonVertexValidationRun.py:41
MuonVertexValidationRun.SetupArgParser
def SetupArgParser()
Definition: MuonVertexValidationRun.py:9
python.JetAnalysisCommon.ComponentAccumulator
ComponentAccumulator
Definition: JetAnalysisCommon.py:302
python.MdtCablingTester.setupServicesCfg
def setupServicesCfg(flags)
Definition: MdtCablingTester.py:17
MuonVertexValidationRun.setupHistSvcCfg
def setupHistSvcCfg(flags, out_file="out.root", out_stream="MSVtxValidation")
Definition: MuonVertexValidationRun.py:22
calibdata.exit
exit
Definition: calibdata.py:236
MuonVertexValidationRun.MSVtxValidationCfg
def MSVtxValidationCfg(flags, name="MSVertexValidationAlg", outStream="MSVtxValidation", outFile="out.root", **kwargs)
Definition: MuonVertexValidationRun.py:30
python.AllConfigFlags.initConfigFlags
def initConfigFlags()
Definition: AllConfigFlags.py:19
confTool.parse_args
def parse_args()
Definition: confTool.py:35