ATLAS Offline Software
Loading...
Searching...
No Matches
MuonVertexValidationRun.py
Go to the documentation of this file.
2# Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
3#
4
5from AthenaConfiguration.ComponentAccumulator import ComponentAccumulator
6from AthenaConfiguration.ComponentFactory import CompFactory
7
8
9def splitOnComma(inputs):
10 files = []
11 for item in inputs: files.extend(item.split(','))
12
13 return files
14
15
17 from argparse import ArgumentParser
18
19 parser = ArgumentParser()
20 parser.add_argument( "-i", "--inputFile", required=True, help="Input files to run on. Files can be comma or space separated", nargs="+")
21 parser.add_argument( "-o", "--outputFile", default="MSVtxVal_out.NTUP.root", help="output root file")
22 parser.add_argument("--triggers", action="store_true", help="Configure the trigger tools")
23 parser.add_argument("--data", action="store_true", help="run on a data file")
24 parser.add_argument("--maxEvents", default=-1, type=int, help="How many events shall be run maximally")
25 parser.add_argument("--skipEvents", default=0, type=int, help="How many events shall be skipped")
26 parser.add_argument("--threads", default=1, type=int, help="number of threads")
27
28 args = parser.parse_args()
29 args.inputFile = splitOnComma(args.inputFile) # to support comma separated input files
30
31 return args
32
33def MSVtxValidationCfg(flags, name="MSVertexValidationAlg", outStream="MSVtxValidation", outFile="out.root", **kwargs):
34 # outStream defines the steam to place the tree and histograms
35 from TriggerMatchingTool.TriggerMatchingToolConfig import TriggerMatchingToolCfg
36 result = ComponentAccumulator()
37 # setting algorithm properties here via kwargs.setdefault("<property name>", <property value>)
38 alg = CompFactory.MSVtxValidationAlg(name, **kwargs)
39 from MuonConfig.MuonConfigUtils import setupHistSvcCfg
40 result.merge(setupHistSvcCfg(flags,outFile=outFile, outStream=outStream))
41 if kwargs.get("readTriggers", False): result.getPrimaryAndMerge(TriggerMatchingToolCfg(flags, name='R3MatchingTool'))
42 result.addEventAlgo(alg)
43
44 return result
45
46
47def execute(cfg):
48 cfg.printConfig(withDetails=True, summariseProps=True)
49 if not cfg.run().isSuccess(): exit(1)
50
51
52if __name__ == "__main__":
53 from AthenaConfiguration.AllConfigFlags import initConfigFlags
54 from MuonConfig.MuonConfigUtils import SetupMuonStandaloneCA
55
57 flags = initConfigFlags()
58 flags.Concurrency.NumThreads = args.threads
59 flags.Exec.MaxEvents = args.maxEvents
60 flags.Exec.SkipEvents = args.skipEvents
61 flags.Concurrency.NumConcurrentEvents = args.threads
62 flags.Input.Files = args.inputFile
63 flags.Scheduler.ShowDataDeps = True
64 flags.Scheduler.ShowDataFlow = True
65 flags.lock()
66 cfg = SetupMuonStandaloneCA(flags)
67 cfg.merge(MSVtxValidationCfg(flags, outFile=args.outputFile, readTriggers=args.triggers, isMC=not args.data))
68 execute(cfg)
MSVtxValidationCfg(flags, name="MSVertexValidationAlg", outStream="MSVtxValidation", outFile="out.root", **kwargs)