ATLAS Offline Software
Loading...
Searching...
No Matches
RunActsMaterialMapping.py
Go to the documentation of this file.
1# Copyright (C) 2002-2023 CERN for the benefit of the ATLAS collaboration
2
3#!/usr/bin/env python
4"""
5
6Run material mapping for ACTS tracking geometry
7
8"""
9from AthenaCommon.Logging import log
10from argparse import ArgumentParser
11from AthenaConfiguration.AllConfigFlags import initConfigFlags
12
13# Argument parsing
14parser = ArgumentParser("RunActsMaterialMapping.py")
15parser.add_argument("detectors", metavar="detectors", type=str, nargs="*",
16 help="Specify the list of detectors")
17parser.add_argument("-M", "--material", required=True, type=str,
18 help="The geometry file material source. It is expected to be a path to a valid json file. You can produce one running RunActsWriteTrackingGeometry.py for the specific geometry tag")
19parser.add_argument("--localgeo", default=False, action="store_true",
20 help="Use local geometry Xml files")
21parser.add_argument("-V", "--verboseAccumulators", default=False,
22 action="store_true",
23 help="Print full details of the AlgSequence")
24parser.add_argument("-S", "--verboseStoreGate", default=False,
25 action="store_true",
26 help="Dump the StoreGate(s) each event iteration")
27parser.add_argument("--maxEvents",default=10, type=int,
28 help="The number of events to run. 0 skips execution")
29parser.add_argument("--geometrytag",default="ATLAS-P2-RUN4-04-00-00", type=str,
30 help="The geometry tag to use")
31parser.add_argument("--inputfile",
32 default="MaterialStepCollection.root",
33 help="The input material step file to use")
34args = parser.parse_args()
35
36# Some info about the job
37print("----Material Mapping for ACTS Tracking Geometry----")
38print()
39print("Using Geometry Tag: "+args.geometrytag)
40if args.localgeo:
41 print("...overridden by local Geometry Xml files")
42if not args.detectors:
43 print("Running complete detector")
44else:
45 print("Running with: {}".format(", ".join(args.detectors)))
46print()
47
48flags = initConfigFlags()
49
50flags.Input.isMC = True
51flags.Input.Files = []
52
53if args.localgeo:
54 flags.ITk.Geometry.AllLocal = True
55
56flags.GeoModel.AtlasVersion = args.geometrytag
57from AthenaConfiguration.DetectorConfigFlags import setupDetectorsFromList
58detectors = args.detectors if 'detectors' in args and args.detectors else ['ITkPixel', 'ITkStrip', 'HGTD']
59detectors.append('Bpipe') # always run with beam pipe
60setupDetectorsFromList(flags, detectors, toggle_geometry=True)
61
62flags.IOVDb.GlobalTag = "OFLCOND-SIM-00-00-00"
63flags.GeoModel.Align.Dynamic = False
64if args.material.find(".json") == -1:
65 from AthenaConfiguration.ComponentAccumulator import ConfigurationError
66 raise ConfigurationError("Invalid material source. It must be a json file!")
67flags.Acts.TrackingGeometry.MaterialSource = args.material
68flags.Acts.TrackingGeometry.MaterialCalibrationFolder = "."
69
70flags.Detector.GeometryCalo = False
71flags.Detector.GeometryMuon = False
72
73# This should run serially for the moment.
74flags.Concurrency.NumThreads = 1
75flags.Concurrency.NumConcurrentEvents = 1
76
77import glob
78FileList = glob.glob(args.inputfile)
79flags.Input.Files = FileList
80
81log.debug('Lock config flags now.')
82flags.lock()
83
84from AthenaConfiguration.MainServicesConfig import MainServicesCfg
85cfg=MainServicesCfg(flags)
86
87
88if args.verboseAccumulators:
89 cfg.printConfig(withDetails=True)
90if args.verboseStoreGate:
91 cfg.getService("StoreGateSvc").Dump = True
92
93log.debug('Dumping of ConfigFlags now.')
94flags.dump()
95
96from ActsConfig.ActsGeometryConfig import ActsMaterialTrackWriterSvcCfg
97cfg.merge(ActsMaterialTrackWriterSvcCfg(flags,
98 "ActsMaterialTrackWriterSvc",
99 FilePath="MaterialTracks_mapping.root",
100 TreeName="material-tracks"))
101
102from AthenaPoolCnvSvc.PoolReadConfig import PoolReadCfg
103cfg.merge(PoolReadCfg(flags))
104
105from ActsConfig.ActsGeometryConfig import ActsMaterialMappingCfg
106cfg.merge(ActsMaterialMappingCfg(flags, "ActsMaterialMappingCfg",
107 mapSurfaces = True,
108 mapVolumes = True))
109
110from AthenaConfiguration.FPEAndCoreDumpConfig import FPEAndCoreDumpCfg
111cfg.merge(FPEAndCoreDumpCfg(flags))
112
113cfg.printConfig(withDetails = True, summariseProps = True)
114
115events = args.maxEvents
116if events<=0:
117 events = 100000000000
118cfg.run(maxEvents=events)
119
120
121
void print(char *figname, TCanvas *c1)