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  from AtlasGeoModel import CommonGeoDB
57  CommonGeoDB.SetupLocalSqliteGeometryDb(args.sqlitefile,args.geometrytag)
58 
59 from AthenaConfiguration.DetectorConfigFlags import setupDetectorFlags
60 setupDetectorFlags(flags, args.detectors, toggle_geometry=True)
61 
62 flags.lock()
63 
64 # Construct our accumulator to run
65 from AthenaConfiguration.MainServicesConfig import MainServicesCfg
66 acc = MainServicesCfg(flags)
67 from AthenaConfiguration.ComponentFactory import CompFactory
68 
69 # ITk Pixel
70 if flags.Detector.EnableITkPixel:
71  from PixelGeoModelXml.ITkPixelGeoModelConfig import ITkPixelReadoutGeometryCfg
72  acc.merge(ITkPixelReadoutGeometryCfg(flags))
73 
74  ReadPixelDetElements = CompFactory.ReadSiDetectorElements('ReadPixelDetElements')
75  ReadPixelDetElements.ManagerName = "ITkPixel"
76  ReadPixelDetElements.DetEleCollKey = "ITkPixelDetectorElementCollection"
77  ReadPixelDetElements.UseConditionsTools = False
78  acc.addEventAlgo(ReadPixelDetElements)
79 
80  PrintPixelDetElements = CompFactory.PrintSiElements('PrintPixelDetElements')
81  PrintPixelDetElements.OutputLevel = 5
82  PrintPixelDetElements.DetectorManagerNames = ["ITkPixel"]
83  PrintPixelDetElements.OutputFile = "PixelGeometry.dat"
84  acc.addEventAlgo(PrintPixelDetElements)
85 
86 
87 # ITk Strip
88 if flags.Detector.EnableITkStrip:
89  from StripGeoModelXml.ITkStripGeoModelConfig import ITkStripReadoutGeometryCfg
90  acc.merge(ITkStripReadoutGeometryCfg(flags))
91 
92  ReadStripDetElements = CompFactory.ReadSiDetectorElements('ReadStripDetElements')
93  ReadStripDetElements.ManagerName = "ITkStrip"
94  ReadStripDetElements.DetEleCollKey = "ITkStripDetectorElementCollection"
95  ReadStripDetElements.UseConditionsTools = False
96  acc.addEventAlgo(ReadStripDetElements)
97 
98  PrintStripDetElements = CompFactory.PrintSiElements('PrintStripDetElements')
99  PrintStripDetElements.OutputLevel = 5
100  PrintStripDetElements.DetectorManagerNames = ["ITkStrip"]
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
python.MainServicesConfig.MainServicesCfg
def MainServicesCfg(flags, LoopMgr='AthenaEventLoopMgr')
Definition: MainServicesConfig.py:260
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
ITkPixelGeoModelConfig.ITkPixelReadoutGeometryCfg
def ITkPixelReadoutGeometryCfg(flags, setGeometryAlignable=False, setAlignmentFolderName="/Indet/Align")
Definition: ITkPixelGeoModelConfig.py:39
ITkStripGeoModelConfig.ITkStripReadoutGeometryCfg
def ITkStripReadoutGeometryCfg(flags, setGeometryAlignable=False, setAlignmentFolderName="/Indet/Align")
Definition: ITkStripGeoModelConfig.py:39
python.AllConfigFlags.initConfigFlags
def initConfigFlags()
Definition: AllConfigFlags.py:19
dbg::print
void print(std::FILE *stream, std::format_string< Args... > fmt, Args &&... args)
Definition: SGImplSvc.cxx:70