ATLAS Offline Software
Loading...
Searching...
No Matches
RunMaterialMappingITk.py
Go to the documentation of this file.
1#!/usr/bin/env python
2# Copyright (C) 2002-2026 CERN for the benefit of the ATLAS collaboration
3"""
4
5Run material mapping for tracking geometry.
6Uses as MaterialStepsCollections as input.
7
8"""
9from AthenaCommon.Logging import log
10from argparse import ArgumentParser
11from AthenaConfiguration.AllConfigFlags import initConfigFlags
12
13# Argument parsing
14parser = ArgumentParser("RunMaterialMappingITk.py")
15parser.add_argument("detectors", metavar="detectors", type=str, nargs="*",
16 help="Specify the list of detectors")
17parser.add_argument("--localgeo", default=False, action="store_true",
18 help="Use local geometry Xml files")
19parser.add_argument("-V", "--verboseAccumulators", default=False,
20 action="store_true",
21 help="Print full details of the AlgSequence")
22parser.add_argument("-S", "--verboseStoreGate", default=False,
23 action="store_true",
24 help="Dump the StoreGate(s) each event iteration")
25parser.add_argument("--maxEvents",default=10, type=int,
26 help="The number of events to run. 0 skips execution")
27from AthenaConfiguration.TestDefaults import defaultGeometryTags
28parser.add_argument("--geometrytag",default=defaultGeometryTags.RUN4, type=str,
29 help="The geometry tag to use")
30parser.add_argument("--inputfile",
31 default="MaterialStepCollection.root",
32 help="The input material step file to use")
33args = parser.parse_args()
34
35# Some info about the job
36print("----MaterialMapping for ITk geometry----")
37print()
38print("Using Geometry Tag: "+args.geometrytag)
39if args.localgeo:
40 print("...overridden by local Geometry Xml files")
41print("Input File:"+args.inputfile)
42if not args.detectors:
43 print("Running complete detector")
44else:
45 print("Running with: {}".format(", ".join(args.detectors)))
46print()
47
48flags = initConfigFlags()
49flags.IOVDb.DBConnection = f'sqlite://;schema={flags.ITk.trackingGeometry.localDatabaseName};dbname=OFLP200'
50
51# necessity to create a new PoolFileCatalog
52import os
53if os.path.exists('./PoolFileCatalog.xml') :
54 print('[!] PoolFileCatalog exists in the run directory (may use old PFN!)')
55 print('[>] Deleting it now !')
56 os.remove('./PoolFileCatalog.xml')
57
58flags.Input.isMC = True
59
60import glob
61flags.Input.Files = glob.glob(args.inputfile)
62
63if args.localgeo:
64 flags.ITk.Geometry.AllLocal = True
65
66from AthenaConfiguration.DetectorConfigFlags import setupDetectorFlags
67detectors = args.detectors if 'detectors' in args and args.detectors else ['ITkPixel', 'ITkStrip', 'HGTD']
68detectors.append('Bpipe') # always run with beam pipe
69setupDetectorFlags(flags, detectors, toggle_geometry=True)
70
71flags.GeoModel.AtlasVersion = args.geometrytag
72flags.IOVDb.GlobalTag = "OFLCOND-SIM-00-00-00"
73flags.GeoModel.Align.Dynamic = False
74flags.TrackingGeometry.MaterialSource = "None"
75
76flags.Detector.GeometryCalo = False
77flags.Detector.GeometryMuon = False
78
79# This should run serially for the moment.
80flags.Concurrency.NumThreads = 1
81flags.Concurrency.NumConcurrentEvents = 1
82
83log.debug('Lock config flags now.')
84flags.lock()
85
86from AthenaConfiguration.MainServicesConfig import MainServicesCfg
87cfg=MainServicesCfg(flags)
88
89
90if args.verboseAccumulators:
91 cfg.printConfig(withDetails=True)
92if args.verboseStoreGate:
93 cfg.getService("StoreGateSvc").Dump = True
94
95log.debug('Dumping of ConfigFlags now.')
96flags.dump()
97
98from AthenaPoolCnvSvc.PoolReadConfig import PoolReadCfg
99cfg.merge(PoolReadCfg(flags))
100
101from TrkDetDescrAlgs.TrkDetDescrAlgsConfig import ITkMaterialMappingCfg
102cfg.merge(ITkMaterialMappingCfg(flags,
103 name="ITkMaterialMapping"))
104
105cfg.printConfig(withDetails = True, summariseProps = True)
106
107events = args.maxEvents
108if events<=0:
109 events = 10000000000
110cfg.run(maxEvents=events)
111
void print(char *figname, TCanvas *c1)