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