ATLAS Offline Software
Loading...
Searching...
No Matches
RunMaterialMapping.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"""
4Run material mapping
5"""
6
7from argparse import ArgumentParser
8from AthenaCommon.Logging import log
9from AthenaConfiguration.AllConfigFlags import initConfigFlags
10from AthenaConfiguration.MainServicesConfig import MainServicesCfg
11
12# Argument parsing
13parser = ArgumentParser("RunMaterialMapping.py")
14parser.add_argument("detectors", metavar="detectors", type=str, nargs="*",
15 help="Specify the list of detectors")
16parser.add_argument("--localgeo", default=False, action="store_true",
17 help="Use local geometry Xml files")
18parser.add_argument("--geoModelSqLiteFile", default = "", help="Read geometry from sqlite file")
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("--skipEvents",default=0, type=int,
28 help="The number of events to skip")
29parser.add_argument("--geometrytag",default="ATLAS-P2-RUN4-03-00-00", type=str,
30 help="The geometry tag to use")
31parser.add_argument("--inputFile",
32 required=True, type=str,
33 help="Input files to be used for the mapping procedure. They must contain the material track information, which was previously produced with the 'RunGeantinoMaterialTrackProduction.py'")
34args = parser.parse_args()
35
36
37# Some info about the job
38print("----RunMaterialMapping for ITk geometry----")
39print()
40print("Using Geometry Tag: "+args.geometrytag)
41if args.localgeo:
42 print("...overridden by local Geometry Xml files")
43print("Input material track file:"+args.inputFile)
44if not args.detectors:
45 print("Running complete detector")
46else:
47 print("Running with: {}".format(", ".join(args.detectors)))
48print()
49
50# Configure
51flags = initConfigFlags()
52if args.localgeo:
53 flags.ITk.Geometry.AllLocal = True
54
55flags.Input.Files = []
56flags.Input.isMC=True
57flags.GeoModel.AtlasVersion = args.geometrytag
58flags.IOVDb.GlobalTag = "OFLCOND-SIM-00-00-00"
59flags.GeoModel.Align.Dynamic = False
60
61# This should run serially
62flags.Concurrency.NumThreads = 1
63flags.Concurrency.NumConcurrentEvents = 1
64
65from AthenaConfiguration.DetectorConfigFlags import getEnabledDetectors ,setupDetectorFlags
66from AthenaConfiguration.AutoConfigFlags import getDefaultDetectors
67
68if args.geoModelSqLiteFile:
69 flags.GeoModel.SQLiteDB = True
70 flags.GeoModel.SQLiteDBFullPath = args.geoModelSqLiteFile
71 # hack to set Run4 for running on muon dead material geometry
72 from AthenaConfiguration.Enums import LHCPeriod
73 flags.GeoModel.Run = LHCPeriod.Run4
74else:
75 defaultDetectors = ['ITkPixel', 'ITkStrip']
76 detectors = args.detectors if 'detectors' in args and args.detectors else defaultDetectors
77 detectors.append('Bpipe') # always run with beam pipe
78 setupDetectorFlags(flags, detectors, toggle_geometry=True)
79
80flags.Acts.TrackingGeometry.UseBlueprint = True
81
82flags.Exec.SkipEvents = args.skipEvents
83
84log.debug('Lock config flags now.')
85flags.lock()
86
87# Construct our accumulator to run
88acc = MainServicesCfg(flags)
89
90
91if args.verboseAccumulators:
92 acc.printConfig(withDetails=True)
93if args.verboseStoreGate:
94 acc.getService("StoreGateSvc").Dump = True
95
96log.debug('Dumping of ConfigFlags now.')
97flags.dump()
98
99from ActsConfig.ActsMaterialConfig import MaterialTrackReaderCfg
100import glob
101acc.merge(MaterialTrackReaderCfg(flags,
102 FileNames=glob.glob(args.inputFile)))
103
104from ActsConfig.ActsMaterialConfig import MaterialMappingCfg
105acc.merge(MaterialMappingCfg(flags))
106
107from ActsConfig.ActsMaterialConfig import MaterialTrackWriterCfg
108acc.merge(MaterialTrackWriterCfg(flags, name="MappedMaterialTrackWriter", FileName="material-tracks-mapped.root",
109 MaterialTrackCollectionKey="OutputMappedMaterialTracks"))
110acc.merge(MaterialTrackWriterCfg(flags, name="UnmappedMaterialTrackWriter", FileName="material-tracks-unmapped.root",
111 MaterialTrackCollectionKey="OutputUnmappedMaterialTracks"))
112
113acc.printConfig(withDetails = True, summariseProps = True)
114
115acc.run(maxEvents=args.maxEvents)
116
117
void print(char *figname, TCanvas *c1)