ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
HighGranularityTimingDetector
HGTD_AlignAlgs
HGTD_AlignGenAlgs
share
HGTD_CreateMisalignment.py
Go to the documentation of this file.
1
#!/usr/bin/env python
2
3
# Copyright (C) 2002-2026 CERN
4
#
5
# ----------------------------------------------------------
6
# Output files produced by this job:
7
#
8
# - HGTD_CreateMisalignment.root
9
# Validation ROOT tree (THistSvc)
10
#
11
# - HGTD_Misalignment.pool.root
12
# POOL conditions payload
13
#
14
# - HGTD_MisalignmentModeX.db
15
# SQLite COOL database
16
# ----------------------------------------------------------
17
18
# --------------------------------------------------------------
19
# Flags
20
# --------------------------------------------------------------
21
def
getFlags
(**kwargs):
22
from
AthenaConfiguration.AllConfigFlags
import
initConfigFlags
23
from
AthenaConfiguration.DetectorConfigFlags
import
setupDetectorFlags
24
from
AthenaConfiguration.TestDefaults
import
(
25
defaultGeometryTags,
26
defaultConditionsTags,
27
)
28
29
flags = initConfigFlags()
30
31
flags.Input.isMC =
True
32
flags.Input.Files = []
33
34
flags.GeoModel.AtlasVersion = defaultGeometryTags.RUN4
35
flags.GeoModel.Align.Dynamic =
False
36
37
# HGTD geometry
38
flags.HGTD.Geometry.isAlignable =
True
39
flags.HGTD.Geometry.useGeoModelXml =
True
40
flags.HGTD.Geometry.isLocal =
True
41
42
flags.HGTD.Geometry.Filename = kwargs.get(
43
"GeometryFile"
,
44
"HGTD_Detector/HGTD.gmx"
45
)
46
47
setupDetectorFlags(
48
flags,
49
custom_list=[
"HGTD"
],
50
toggle_geometry=
True
51
)
52
53
#----------------------------------------------------------
54
# Output SQLite database
55
#----------------------------------------------------------
56
57
MisalignMode = int(kwargs.get(
"MisalignMode"
, 1))
58
59
databaseFilename = f
"HGTD_MisalignmentMode{MisalignMode}.db"
60
61
flags.IOVDb.DBConnection = (
62
f
"sqlite://;schema={databaseFilename};dbname=OFLCOND"
63
)
64
65
flags.IOVDb.GlobalTag = defaultConditionsTags.RUN4_MC
66
flags.Exec.OutputLevel = 2
67
flags.Concurrency.NumThreads = 1
68
flags.Concurrency.NumConcurrentEvents = 1
69
70
flags.lock()
71
return
flags
72
73
# --------------------------------------------------------------
74
# Build job
75
# --------------------------------------------------------------
76
def
CreateMis
(flags, **kwargs):
77
78
from
AthenaConfiguration.MainServicesConfig
import
MainServicesCfg
79
from
AthenaConfiguration.ComponentFactory
import
CompFactory
80
from
HGTD_AlignGenTools.HGTD_AlignGenToolsConfig
import
HGTD_AlignDBToolCfg
81
from
IOVDbSvc.IOVDbSvcConfig
import
IOVDbSvcCfg
82
83
acc = MainServicesCfg(flags)
84
acc.merge(IOVDbSvcCfg(flags))
85
86
# ----------------------------------------------------------
87
# ROOT output for validation
88
# Creates HGTD_CreateMisalignment.root containing one entry
89
# per HGTD detector element with the applied misalignment.
90
# ----------------------------------------------------------
91
92
histoSvc = CompFactory.THistSvc(
93
Output=[
94
"CREATEMISALIGN DATAFILE='HGTD_CreateMisalignment.root' "
"TYPE='ROOT' OPT='RECREATE'"
95
]
96
)
97
98
acc.addService(histoSvc)
99
acc.setAppProperty(
"HistogramPersistency"
,
"ROOT"
)
100
101
# ----------------------------------------------------------
102
# Configure HGTD alignment DB tool
103
# ----------------------------------------------------------
104
105
kargsTool = {}
106
kargsTool.setdefault(
"DBRoot"
,
"/HGTD/Align"
)
107
108
HGTDCondStream = CompFactory.AthenaOutputStreamTool(
109
"CondStream_write"
,
110
OutputFile=
"HGTD_Misalignment.pool.root"
111
)
112
113
HGTDCondStream.PoolContainerPrefix =
"<type>"
114
HGTDCondStream.TopLevelContainerName =
""
115
HGTDCondStream.SubLevelBranchName =
"<key>"
116
117
kargsTool.setdefault(
"CondStream"
, HGTDCondStream)
118
119
dbTool = acc.popToolsAndMerge(
120
HGTD_AlignDBToolCfg(flags, **kargsTool)
121
)
122
123
MisalignMode = int(kwargs.get(
"MisalignMode"
, 1))
124
createFreshDB =
True
125
outFile = f
"HGTD_MisalignmentMode{MisalignMode}"
126
127
print
()
128
print
(
"=============================================="
)
129
print
(f
" HGTD Misalignment Mode {MisalignMode}"
)
130
print
(
"=============================================="
)
131
print
()
132
133
# ----------------------------------------------------------
134
# Convert command-line strings to the correct property types
135
# ----------------------------------------------------------
136
137
kwargs[
"MisalignMode"
] = int(kwargs.get(
"MisalignMode"
, 1))
138
kwargs[
"ApplyTranslation"
] = (str(kwargs.get(
"ApplyTranslation"
,
"True"
)).lower()
in
(
"true"
,
"1"
,
"yes"
))
139
kwargs[
"ApplyRotation"
] = (str(kwargs.get(
"ApplyRotation"
,
"False"
)).lower()
in
(
"true"
,
"1"
,
"yes"
))
140
141
kwargs[
"ShiftX"
] = float(kwargs.get(
"ShiftX"
, 0.05))
142
kwargs[
"ShiftY"
] = float(kwargs.get(
"ShiftY"
, 0.0))
143
kwargs[
"ShiftZ"
] = float(kwargs.get(
"ShiftZ"
, 0.0))
144
145
kwargs[
"SigmaX"
] = float(kwargs.get(
"SigmaX"
, 0.01))
146
kwargs[
"SigmaY"
] = float(kwargs.get(
"SigmaY"
, 0.01))
147
kwargs[
"SigmaZ"
] = float(kwargs.get(
"SigmaZ"
, 0.01))
148
149
kwargs[
"MaxModules"
] = int(kwargs.get(
"MaxModules"
, -1))
150
kwargs[
"TestHash"
] = int(kwargs.get(
"TestHash"
, -1))
151
152
kwargs[
"DoDebugPrint"
] =
True
153
kwargs[
"WriteToDB"
] =
True
154
kwargs[
"CreateFreshDB"
] = createFreshDB
155
kwargs[
"SQLiteTag"
] = f
"HGTD_MisalignmentMode_{MisalignMode}"
156
kwargs[
"OutputFile"
] = outFile +
".txt"
157
158
alg_kwargs = dict(kwargs)
159
alg_kwargs.pop(
"GeometryFile"
,
None
)
160
161
alg_kwargs[
"RandomStream"
] = kwargs.get(
162
"RandomStream"
,
163
"HGTDMisalignment"
164
)
165
166
# ----------------------------------------------------------
167
# Add HGTD misalignment algorithm
168
# ----------------------------------------------------------
169
170
from
HGTD_AlignGenAlgs.HGTD_AlignAlgsConfig
import
(
171
HGTD_CreateMisalignAlgCfg
172
)
173
174
alg_kwargs[
"AlignDBTool"
] = dbTool
175
176
acc.merge(
177
HGTD_CreateMisalignAlgCfg(
178
flags,
179
**alg_kwargs
180
)
181
)
182
183
return
acc
184
185
# --------------------------------------------------------------
186
# Main
187
# --------------------------------------------------------------
188
if
__name__ ==
"__main__"
:
189
import
sys
190
191
if
len(sys.argv[1:]):
192
193
kwargs = dict(
194
arg.split(
"="
)
195
for
arg
in
sys.argv[1:]
196
)
197
print
(kwargs)
198
199
else
:
200
201
kwargs = {}
202
print
(
"No command-line arguments"
)
203
204
flags =
getFlags
(**kwargs)
205
flags.dump()
206
207
acc =
CreateMis
(flags, **kwargs)
208
209
iovdb = acc.getService(
"IOVDbSvc"
)
210
print
(
"======================================"
)
211
print
(
"IOVDbSvc.dbConnection ="
, iovdb.dbConnection)
212
print
(
"======================================"
)
213
214
acc.printConfig(
215
withDetails=
True
,
216
summariseProps=
True
217
)
218
219
sc = acc.run(1)
220
221
if
sc.isFailure():
222
223
print
(
"Failed to run HGTD Misalignment Algorithm"
)
224
sys.exit(-1)
225
226
print
(
"HGTD Misalignment finished successfully."
)
print
void print(char *figname, TCanvas *c1)
Definition
TRTCalib_StrawStatusPlots.cxx:26
HGTD_CreateMisalignment.getFlags
getFlags(**kwargs)
Definition
HGTD_CreateMisalignment.py:21
HGTD_CreateMisalignment.CreateMis
CreateMis(flags, **kwargs)
Definition
HGTD_CreateMisalignment.py:76
Generated on
for ATLAS Offline Software by
1.17.0