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