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-2024 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")
27parser.add_argument("--geometrytag",default="ATLAS-P2-RUN4-03-00-00", type=str,
28 help="The geometry tag to use")
29parser.add_argument("--inputfile",
30 default="MaterialStepCollection.root",
31 help="The input material step file to use")
32args = parser.parse_args()
33
34# Some info about the job
35print("----MaterialMapping for ITk geometry----")
36print()
37print("Using Geometry Tag: "+args.geometrytag)
38if args.localgeo:
39 print("...overridden by local Geometry Xml files")
40print("Input File:"+args.inputfile)
41if not args.detectors:
42 print("Running complete detector")
43else:
44 print("Running with: {}".format(", ".join(args.detectors)))
45print()
46
47flags = initConfigFlags()
48flags.IOVDb.DBConnection = f'sqlite://;schema={flags.ITk.trackingGeometry.localDatabaseName};dbname=OFLP200'
49
50# necessity to create a new PoolFileCatalog
51import os
52if os.path.exists('./PoolFileCatalog.xml') :
53 print('[!] PoolFileCatalog exists in the run directory (may use old PFN!)')
54 print('[>] Deleting it now !')
55 os.remove('./PoolFileCatalog.xml')
56
57flags.Input.isMC = True
58
59import glob
60flags.Input.Files = glob.glob(args.inputfile)
61
62if args.localgeo:
63 flags.ITk.Geometry.AllLocal = True
64
65from AthenaConfiguration.DetectorConfigFlags import setupDetectorFlags
66detectors = args.detectors if 'detectors' in args and args.detectors else ['ITkPixel', 'ITkStrip', 'HGTD']
67detectors.append('Bpipe') # always run with beam pipe
68setupDetectorFlags(flags, detectors, toggle_geometry=True)
69
70flags.GeoModel.AtlasVersion = args.geometrytag
71flags.IOVDb.GlobalTag = "OFLCOND-SIM-00-00-00"
72flags.GeoModel.Align.Dynamic = False
73flags.TrackingGeometry.MaterialSource = "None"
74
75flags.Detector.GeometryCalo = False
76flags.Detector.GeometryMuon = False
77
78# This should run serially for the moment.
79flags.Concurrency.NumThreads = 1
80flags.Concurrency.NumConcurrentEvents = 1
81
82log.debug('Lock config flags now.')
83flags.lock()
84
85from AthenaConfiguration.MainServicesConfig import MainServicesCfg
86cfg=MainServicesCfg(flags)
87
88
89if args.verboseAccumulators:
90 cfg.printConfig(withDetails=True)
91if args.verboseStoreGate:
92 cfg.getService("StoreGateSvc").Dump = True
93
94log.debug('Dumping of ConfigFlags now.')
95flags.dump()
96
97from AthenaPoolCnvSvc.PoolReadConfig import PoolReadCfg
98cfg.merge(PoolReadCfg(flags))
99
100from TrkDetDescrAlgs.TrkDetDescrAlgsConfig import ITkMaterialMappingCfg
101cfg.merge(ITkMaterialMappingCfg(flags,
102 name="ITkMaterialMapping"))
103
104cfg.printConfig(withDetails = True, summariseProps = True)
105
106events = args.maxEvents
107if events<=0:
108 events = 10000000000
109cfg.run(maxEvents=events)
110
void print(char *figname, TCanvas *c1)