ATLAS Offline Software
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 
5 Run material mapping for tracking geometry.
6 Uses as MaterialStepsCollections as input.
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("RunMaterialMappingITk.py")
15 parser.add_argument("detectors", metavar="detectors", type=str, nargs="*",
16  help="Specify the list of detectors")
17 parser.add_argument("--localgeo", default=False, action="store_true",
18  help="Use local geometry Xml files")
19 parser.add_argument("-V", "--verboseAccumulators", default=False,
20  action="store_true",
21  help="Print full details of the AlgSequence")
22 parser.add_argument("-S", "--verboseStoreGate", default=False,
23  action="store_true",
24  help="Dump the StoreGate(s) each event iteration")
25 parser.add_argument("--maxEvents",default=10, type=int,
26  help="The number of events to run. 0 skips execution")
27 parser.add_argument("--geometrytag",default="ATLAS-P2-RUN4-03-00-00", type=str,
28  help="The geometry tag to use")
29 parser.add_argument("--inputfile",
30  default="MaterialStepCollection.root",
31  help="The input material step file to use")
32 args = parser.parse_args()
33 
34 # Some info about the job
35 print("----MaterialMapping for ITk geometry----")
36 print()
37 print("Using Geometry Tag: "+args.geometrytag)
38 if args.localgeo:
39  print("...overridden by local Geometry Xml files")
40 print("Input File:"+args.inputfile)
41 if not args.detectors:
42  print("Running complete detector")
43 else:
44  print("Running with: {}".format(", ".join(args.detectors)))
45 print()
46 
47 flags = initConfigFlags()
48 flags.IOVDb.DBConnection = f'sqlite://;schema={flags.ITk.trackingGeometry.localDatabaseName};dbname=OFLP200'
49 
50 # necessity to create a new PoolFileCatalog
51 import os
52 if 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 
57 flags.Input.isMC = True
58 
59 import glob
60 flags.Input.Files = glob.glob(args.inputfile)
61 
62 if args.localgeo:
63  flags.ITk.Geometry.AllLocal = True
64 
65 from AthenaConfiguration.DetectorConfigFlags import setupDetectorFlags
66 detectors = args.detectors if 'detectors' in args and args.detectors else ['ITkPixel', 'ITkStrip', 'HGTD']
67 detectors.append('Bpipe') # always run with beam pipe
68 setupDetectorFlags(flags, detectors, toggle_geometry=True)
69 
70 flags.GeoModel.AtlasVersion = args.geometrytag
71 flags.IOVDb.GlobalTag = "OFLCOND-SIM-00-00-00"
72 flags.GeoModel.Align.Dynamic = False
73 flags.TrackingGeometry.MaterialSource = "None"
74 
75 flags.Detector.GeometryCalo = False
76 flags.Detector.GeometryMuon = False
77 
78 # This should run serially for the moment.
79 flags.Concurrency.NumThreads = 1
80 flags.Concurrency.NumConcurrentEvents = 1
81 
82 log.debug('Lock config flags now.')
83 flags.lock()
84 
85 from AthenaConfiguration.MainServicesConfig import MainServicesCfg
86 cfg=MainServicesCfg(flags)
87 
88 
89 if args.verboseAccumulators:
90  cfg.printConfig(withDetails=True)
91 if args.verboseStoreGate:
92  cfg.getService("StoreGateSvc").Dump = True
93 
94 log.debug('Dumping of ConfigFlags now.')
95 flags.dump()
96 
97 from AthenaPoolCnvSvc.PoolReadConfig import PoolReadCfg
98 cfg.merge(PoolReadCfg(flags))
99 
100 from TrkDetDescrAlgs.TrkDetDescrAlgsConfig import ITkMaterialMappingCfg
101 cfg.merge(ITkMaterialMappingCfg(flags,
102  name="ITkMaterialMapping"))
103 
104 cfg.printConfig(withDetails = True, summariseProps = True)
105 
106 events = args.maxEvents
107 if events<=0:
108  events = 10000000000
109 cfg.run(maxEvents=events)
110 
vtune_athena.format
format
Definition: vtune_athena.py:14
python.MainServicesConfig.MainServicesCfg
def MainServicesCfg(flags, LoopMgr='AthenaEventLoopMgr')
Definition: MainServicesConfig.py:256
TCS::join
std::string join(const std::vector< std::string > &v, const char c=',')
Definition: Trigger/TrigT1/L1Topo/L1TopoCommon/Root/StringUtils.cxx:10
python.DetectorConfigFlags.setupDetectorFlags
def setupDetectorFlags(flags, custom_list=None, use_metadata=False, toggle_geometry=False, validate_only=False, keep_beampipe=False)
Definition: DetectorConfigFlags.py:286
python.AllConfigFlags.initConfigFlags
def initConfigFlags()
Definition: AllConfigFlags.py:19
Muon::print
std::string print(const MuPatSegment &)
Definition: MuonTrackSteering.cxx:28
TrkDetDescrAlgsConfig.ITkMaterialMappingCfg
def ITkMaterialMappingCfg(flags, name="ITkMaterialMapping", **kwargs)
Definition: TrkDetDescrAlgsConfig.py:9
python.PoolReadConfig.PoolReadCfg
def PoolReadCfg(flags)
Definition: PoolReadConfig.py:69