ATLAS Offline Software
RunHitAnalysis.py
Go to the documentation of this file.
1 #!/usr/bin/env python
2 """Run HitAnalysis
3 
4 Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
5 """
6 import sys
7 from argparse import ArgumentParser
8 
9 # Argument parsing
10 parser = ArgumentParser("HitAnalysis.py")
11 parser.add_argument("detectors", metavar="detectors", type=str, nargs="*",
12  help="Specify the list of detectors")
13 parser.add_argument("--localgeo", default=False, action="store_true",
14  help="Use local geometry XML files")
15 parser.add_argument("-n", "--maxEvents", default=-1, type=int,
16  help="The number of events to run. -1 runs all events.")
17 parser.add_argument("-i", "--input",
18  help="The input HITS file to use")
19 args = parser.parse_args()
20 
21 
22 # Some info about the job
23 print("----HitAnalysis----")
24 print()
25 if args.localgeo:
26  print("Using local Geometry XML files")
27 print(f"Input file: {args.input}")
28 if not args.detectors:
29  print("Running complete detector")
30 else:
31  print("Running with: {}".format(", ".join(args.detectors)))
32 print()
33 
34 # Configure
35 from AthenaConfiguration.AllConfigFlags import initConfigFlags
36 from AthenaConfiguration.Enums import ProductionStep
37 flags = initConfigFlags()
38 flags.Common.ProductionStep = ProductionStep.Simulation
39 flags.Input.Files = [args.input]
40 if args.localgeo:
41  flags.ITk.Geometry.AllLocal = True
42 flags.Output.HISTFileName = 'SiHitAnalysis.root'
43 from AthenaConfiguration.DetectorConfigFlags import setupDetectorFlags
44 setupDetectorFlags(flags, args.detectors, use_metadata=True, toggle_geometry=True)
45 flags.lock()
46 
47 # Construct our accumulator to run
48 from AthenaConfiguration.MainServicesConfig import MainServicesCfg
49 acc = MainServicesCfg(flags)
50 from AthenaPoolCnvSvc.PoolReadConfig import PoolReadCfg
51 acc.merge(PoolReadCfg(flags))
52 from HitAnalysis.HitAnalysisConfig import SiHitAnalysisCfg
53 acc.merge(SiHitAnalysisCfg(flags))
54 
55 # Execute and finish
56 sc = acc.run(maxEvents=args.maxEvents)
57 
58 # Success should be 0
59 sys.exit(not sc.isSuccess())
vtune_athena.format
format
Definition: vtune_athena.py:14
python.MainServicesConfig.MainServicesCfg
def MainServicesCfg(flags, LoopMgr='AthenaEventLoopMgr')
Definition: MainServicesConfig.py:260
print
void print(char *figname, TCanvas *c1)
Definition: TRTCalib_StrawStatusPlots.cxx:25
TCS::join
std::string join(const std::vector< std::string > &v, const char c=',')
Definition: Trigger/TrigT1/L1Topo/L1TopoCommon/Root/StringUtils.cxx:10
python.DetectorConfigFlags.setupDetectorFlags
def setupDetectorFlags(flags, custom_list=None, use_metadata=False, toggle_geometry=False, validate_only=False, keep_beampipe=False)
Definition: DetectorConfigFlags.py:289
python.AllConfigFlags.initConfigFlags
def initConfigFlags()
Definition: AllConfigFlags.py:19
python.HitAnalysisConfig.SiHitAnalysisCfg
def SiHitAnalysisCfg(flags)
Definition: HitAnalysisConfig.py:154
python.PoolReadConfig.PoolReadCfg
def PoolReadCfg(flags)
Definition: PoolReadConfig.py:69