ATLAS Offline Software
RunPrintSiDetElements.py
Go to the documentation of this file.
1 #!/usr/bin/env python
2 """Run PrintSiDetectorElements
3 
4 Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
5 """
6 import sys
7 from argparse import ArgumentParser
8 
9 from AthenaConfiguration.AllConfigFlags import initConfigFlags
10 from AthenaConfiguration.TestDefaults import defaultConditionsTags
11 
12 # Argument parsing
13 parser = ArgumentParser("PrintSiDetectorElements.py")
14 parser.add_argument("detectors", metavar="detectors", type=str, nargs="*",
15  help="Specify the list of detectors")
16 parser.add_argument("--localgeo", default=False, action="store_true",
17  help="Use local geometry XML files")
18 parser.add_argument("--geometrytag",default="ATLAS-P2-RUN4-03-00-00", type=str,
19  help="The geometry tag to use")
20 parser.add_argument("--sqlitefile",default="", type=str,
21  help="SQLite input file to use")
22 args = parser.parse_args()
23 
24 
25 # Some info about the job
26 print("----PrintSiDetectorElements----")
27 print()
28 if args.localgeo:
29  print("Using local Geometry XML files")
30 if not args.detectors:
31  print("Running complete detector")
32 else:
33  print("Running with: {}".format(", ".join(args.detectors)))
34 print()
35 
36 # Configure
37 flags = initConfigFlags()
38 flags.Concurrency.NumThreads = 1
39 if flags.Concurrency.NumThreads > 0:
40  flags.Scheduler.ShowDataDeps = True
41  flags.Scheduler.ShowDataFlow = True
42  flags.Scheduler.ShowControlFlow = True
43 
44 flags.GeoModel.Align.Dynamic = False
45 flags.GeoModel.AtlasVersion = args.geometrytag
46 flags.Input.isMC = True
47 flags.IOVDb.GlobalTag = defaultConditionsTags.RUN4_MC
48 flags.Input.Files = []
49 
50 if args.localgeo:
51  flags.ITk.Geometry.AllLocal = True
52 
53 elif args.sqlitefile:
54  print("Using SQLite input")
55  flags.GeoModel.SQLiteDB = True
56  flags.GeoModel.SQLiteDBFullPath = args.sqlitefile
57 
58 from AthenaConfiguration.DetectorConfigFlags import setupDetectorFlags
59 setupDetectorFlags(flags, args.detectors, toggle_geometry=True)
60 
61 flags.lock()
62 
63 # Construct our accumulator to run
64 from AthenaConfiguration.MainServicesConfig import MainServicesCfg
65 acc = MainServicesCfg(flags)
66 from AthenaConfiguration.ComponentFactory import CompFactory
67 
68 # ITk Pixel
69 if flags.Detector.EnableITkPixel:
70  from PixelGeoModelXml.ITkPixelGeoModelConfig import ITkPixelReadoutGeometryCfg
71  acc.merge(ITkPixelReadoutGeometryCfg(flags))
72 
73  ReadPixelDetElements = CompFactory.ReadSiDetectorElements('ReadPixelDetElements')
74  ReadPixelDetElements.ManagerName = "ITkPixel"
75  ReadPixelDetElements.DetEleCollKey = "ITkPixelDetectorElementCollection"
76  ReadPixelDetElements.UseConditionsTools = False
77  acc.addEventAlgo(ReadPixelDetElements)
78 
79  PrintPixelDetElements = CompFactory.PrintSiElements('PrintPixelDetElements')
80  PrintPixelDetElements.OutputLevel = 5
81  PrintPixelDetElements.DetectorManagerNames = ["ITkPixel"]
82  PrintPixelDetElements.OutputFile = "PixelGeometry.dat"
83  acc.addEventAlgo(PrintPixelDetElements)
84 
85 
86 # ITk Strip
87 if flags.Detector.EnableITkStrip:
88  from StripGeoModelXml.ITkStripGeoModelConfig import ITkStripReadoutGeometryCfg
89  acc.merge(ITkStripReadoutGeometryCfg(flags))
90 
91  ReadStripDetElements = CompFactory.ReadSiDetectorElements('ReadStripDetElements')
92  ReadStripDetElements.ManagerName = "ITkStrip"
93  ReadStripDetElements.DetEleCollKey = "ITkStripDetectorElementCollection"
94  ReadStripDetElements.UseConditionsTools = False
95  acc.addEventAlgo(ReadStripDetElements)
96 
97  PrintStripDetElements = CompFactory.PrintSiElements('PrintStripDetElements')
98  PrintStripDetElements.OutputLevel = 5
99  PrintStripDetElements.DetectorManagerNames = ["ITkStrip"]
100  PrintStripDetElements.ModulesOnly = False
101  PrintStripDetElements.OutputFile = "StripGeometry.dat"
102  acc.addEventAlgo(PrintStripDetElements)
103 
104 # Execute and finish
105 sc = acc.run(maxEvents=1)
106 
107 # Success should be 0
108 sys.exit(not sc.isSuccess())
vtune_athena.format
format
Definition: vtune_athena.py:14
ITkStripGeoModelConfig.ITkStripReadoutGeometryCfg
def ITkStripReadoutGeometryCfg(flags)
Definition: ITkStripGeoModelConfig.py:39
ITkPixelGeoModelConfig.ITkPixelReadoutGeometryCfg
def ITkPixelReadoutGeometryCfg(flags)
Definition: ITkPixelGeoModelConfig.py:39
python.MainServicesConfig.MainServicesCfg
def MainServicesCfg(flags, LoopMgr='AthenaEventLoopMgr')
Definition: MainServicesConfig.py:260
print
void print(char *figname, TCanvas *c1)
Definition: TRTCalib_StrawStatusPlots.cxx:25
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:289
python.AllConfigFlags.initConfigFlags
def initConfigFlags()
Definition: AllConfigFlags.py:19