ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
InnerDetector
InDetGraphics
InDetAlignVisual
InDetSimpleVisual
src
GetDetectorLocalFrames.cxx
Go to the documentation of this file.
1
/*
2
Copyright (C) 2002-2026 CERN for the benefit of the ATLAS collaboration
3
*/
4
14
15
#include "
InDetSimpleVisual/GetDetectorLocalFrames.h
"
16
17
#include "GaudiKernel/MsgStream.h"
18
19
#include "Identifier/Identifier.h"
20
#include "
Identifier/IdentifierHash.h
"
21
#include "
TRT_ReadoutGeometry/TRT_Numerology.h
"
22
#include "
InDetReadoutGeometry/SiDetectorElement.h
"
23
24
#include "
InDetIdentifier/TRT_ID.h
"
25
#include "
TRT_ReadoutGeometry/TRT_DetectorManager.h
"
26
27
#include "
EventPrimitives/EventPrimitives.h
"
28
29
#include "
StoreGate/ReadCondHandle.h
"
30
31
#include <cstdlib>
32
#include <cstring>
33
#include <vector>
34
35
37
GetDetectorLocalFrames::GetDetectorLocalFrames
(std::string
const
&
name
, ISvcLocator* pSvcLocator) :
38
AthAlgorithm
(
name
, pSvcLocator),
39
m_outputFileName
(
"IDLocalFrames.txt"
),
40
42
m_trt_barrel_ec
(0),
43
m_trt_layer_or_wheel
(0),
44
m_trt_phi_module
(0),
45
m_trt_straw_layer
(0),
46
m_trt_straw
(0),
47
49
m_TRTHelper
(nullptr),
50
m_TRTDetectorManager
(nullptr)
51
52
{
53
declareProperty
(
"OutputTextFile"
,
m_outputFileName
);
54
}
55
57
StatusCode
GetDetectorLocalFrames::initialize
(){
58
if
(
msgLvl
(MSG::VERBOSE))
msg
(MSG::VERBOSE) <<
"initialize()"
<<
endmsg
;
59
61
if
(
detStore
()->retrieve(
m_TRTHelper
,
"TRT_ID"
).isFailure()) {
62
msg
(MSG::FATAL) <<
"Could not get TRT ID helper"
<<
endmsg
;
63
return
StatusCode::FAILURE;
64
}
65
if
(
msgLvl
(MSG::VERBOSE))
msg
(MSG::VERBOSE) <<
"got the TRT ID"
<<
endmsg
;
66
67
if
((
detStore
()->retrieve(
m_TRTDetectorManager
)).isFailure()) {
68
if
(
msgLvl
(MSG::FATAL))
msg
(MSG::FATAL) <<
"Problem retrieving TRT_DetectorManager"
<<
endmsg
;
69
return
StatusCode::FAILURE;
70
}
71
73
ATH_CHECK
(
m_SCTDetEleCollKey
.initialize());
74
76
ATH_CHECK
(
m_pixelDetEleCollKey
.initialize());
77
79
m_outputFile
.open((
m_outputFileName
).c_str());
80
81
return
StatusCode::SUCCESS;
82
}
83
85
StatusCode
GetDetectorLocalFrames::execute
(
const
EventContext&
/*ctx*/
) {
86
87
if
(
msgLvl
(MSG::VERBOSE))
msg
(MSG::VERBOSE) <<
"execute() check global position"
<<
endmsg
;
88
89
StatusCode
sc
= StatusCode::SUCCESS;
90
m_eventCount
++;
91
93
if
(
m_eventCount
!=0)
94
return
sc
;
95
96
std::cout <<
"========================================================================================"
<<std::endl;
97
std::cout <<
"==================== Getting the Inner Detector Local Frames ==========================="
<<std::endl;
98
std::cout <<
"========================================================================================"
<<std::endl;
99
100
//Write pixel positions
101
writePixelFames
();
102
103
//Write SCT positions
104
writeSCTFrames
();
105
106
//Write SCT positions
107
writeTRTFrames
();
108
109
return
StatusCode::SUCCESS;
110
}
111
113
StatusCode
GetDetectorLocalFrames::finalize
() {
114
if
(
msgLvl
(MSG::VERBOSE))
msg
(MSG::VERBOSE) <<
"finalize()"
<<
endmsg
;
115
117
m_outputFile
.close();
118
119
return
StatusCode::SUCCESS;
120
}
121
123
void
GetDetectorLocalFrames::writePixelFames
(){
124
if
(
msgLvl
(MSG::VERBOSE))
msg
(MSG::VERBOSE) <<
"In writePixelFames()"
<<
endmsg
;
125
126
SG::ReadCondHandle<InDetDD::SiDetectorElementCollection>
pixelDetEleHandle(
m_pixelDetEleCollKey
);
127
const
InDetDD::SiDetectorElementCollection
* elements{*pixelDetEleHandle};
128
if
(not pixelDetEleHandle.
isValid
() or elements==
nullptr
) {
129
ATH_MSG_ERROR
(
m_pixelDetEleCollKey
.fullKey() <<
" is not available."
);
130
return
;
131
}
132
//Loop over pixel elements
133
// for (const InDetDD::SiDetectorElement* element: *elements) {
134
// Get local Frame
135
// }
136
137
if
(
msgLvl
(MSG::VERBOSE))
msg
(MSG::VERBOSE) <<
"Leaving writePixelFames()"
<<
endmsg
;
138
return
;
139
}
140
142
void
GetDetectorLocalFrames::writeSCTFrames
(){
143
if
(
msgLvl
(MSG::VERBOSE))
msg
(MSG::VERBOSE) <<
"In writeSCTFrames()"
<<
endmsg
;
144
145
SG::ReadCondHandle<InDetDD::SiDetectorElementCollection>
sctDetEleHandle(
m_SCTDetEleCollKey
);
146
const
InDetDD::SiDetectorElementCollection
* elements{*sctDetEleHandle};
147
if
(not sctDetEleHandle.
isValid
() or elements==
nullptr
) {
148
ATH_MSG_ERROR
(
m_SCTDetEleCollKey
.fullKey() <<
" is not available."
);
149
return
;
150
}
151
//Loop over SCT elements
152
// for (const InDetDD::SiDetectorElement* element: *elements) {
153
// Get local Frame
154
// }
155
156
if
(
msgLvl
(MSG::VERBOSE))
msg
(MSG::VERBOSE) <<
"Leaving writeSCTFrames()"
<<
endmsg
;
157
return
;
158
}
159
161
void
GetDetectorLocalFrames::writeTRTFrames
(){
162
if
(
msgLvl
(MSG::VERBOSE))
msg
(MSG::VERBOSE) <<
"In writeTRTFrames()"
<<
endmsg
;
163
164
TRT_ID::const_expanded_id_iterator
trtStrawIt =
m_TRTHelper
->straw_begin();
165
TRT_ID::const_expanded_id_iterator
trtStrawItE =
m_TRTHelper
->straw_end();
166
167
for
(; trtStrawIt != trtStrawItE; ++trtStrawIt) {
168
const
ExpandedIdentifier
& expId = (*trtStrawIt);
169
170
Identifier
trtId =
m_TRTHelper
->straw_id(expId[2],
171
expId[3],
172
expId[4],
173
expId[5],
174
expId[6]);
175
176
m_trt_barrel_ec
=
m_TRTHelper
->barrel_ec(trtId);
177
m_trt_layer_or_wheel
=
m_TRTHelper
->layer_or_wheel(trtId);
178
m_trt_phi_module
=
m_TRTHelper
->phi_module(trtId);
179
m_trt_straw_layer
=
m_TRTHelper
->straw_layer(trtId);
180
m_trt_straw
=
m_TRTHelper
->straw(trtId);
181
182
m_outputFile
<< 3 <<
" "
183
<<
m_trt_barrel_ec
<<
" "
184
<<
m_trt_layer_or_wheel
<<
" "
185
<<
m_trt_phi_module
<<
" "
186
<<
m_trt_straw_layer
<<
" "
187
<<
m_trt_straw
<<
" "
;
188
m_outputFile
<< std::endl;
189
190
//const HepGeom::Transform3D& localTransform = m_TRTDetectorManager->getElement( trtId )->transform(trtId);
191
Amg::Vector3D
xaxis(1,0,0);
192
Amg::Vector3D
yaxis(0,1,0);
193
Amg::Vector3D
zaxis(0,0,1);
194
const
Amg::Vector3D
strawXAxis =
m_TRTDetectorManager
->getElement( trtId )->strawTransform(
m_trt_straw
) * xaxis *
m_TRTDetectorManager
->getElement( trtId )->strawDirection();
195
const
Amg::Vector3D
strawYAxis =
m_TRTDetectorManager
->getElement( trtId )->strawTransform(
m_trt_straw
) * yaxis *
m_TRTDetectorManager
->getElement( trtId )->strawDirection();
196
const
Amg::Vector3D
strawZAxis =
m_TRTDetectorManager
->getElement( trtId )->strawTransform(
m_trt_straw
) * zaxis *
m_TRTDetectorManager
->getElement( trtId )->strawDirection();
197
198
const
Amg::Vector3D
strawXAxis_NoSign =
m_TRTDetectorManager
->getElement( trtId )->strawTransform(
m_trt_straw
) * xaxis;
199
const
Amg::Vector3D
strawYAxis_NoSign =
m_TRTDetectorManager
->getElement( trtId )->strawTransform(
m_trt_straw
) * yaxis;
200
const
Amg::Vector3D
strawZAxis_NoSign =
m_TRTDetectorManager
->getElement( trtId )->strawTransform(
m_trt_straw
) * zaxis;
201
//const HepGeom::Vector3D<double> theStrawAxis = m_TRTDetectorManager->getElement( trtId )->strawAxis(m_trt_straw);
202
203
//writeTransForm(localTransform);
204
writeVector
(
"straw x-axis"
,strawXAxis);
205
writeVector
(
"straw y-axis"
,strawYAxis);
206
writeVector
(
"straw z-axis"
,strawZAxis);
207
m_outputFile
<< std::endl;
208
writeVector
(
"straw x-axis (No sign)"
,strawXAxis_NoSign);
209
writeVector
(
"straw y-axis (No sign)"
,strawYAxis_NoSign);
210
writeVector
(
"straw z-axis (No sign)"
,strawZAxis_NoSign);
211
m_outputFile
<< std::endl;
212
}
213
214
if
(
msgLvl
(MSG::VERBOSE))
msg
(MSG::VERBOSE) <<
"Leaving writeTRTFrames()"
<<
endmsg
;
215
return
;
216
}
217
218
void
GetDetectorLocalFrames::writeVector
(std::string_view
name
,
const
Amg::Vector3D
&
vector
){
219
if
(
msgLvl
(MSG::VERBOSE))
msg
(MSG::VERBOSE) <<
"In writeVector()"
<<
endmsg
;
220
m_outputFile
<<
name
<<
" "
<<
vector
.x() <<
" "
<<
vector
.y() <<
" "
<<
vector
.z() <<
"\n"
;
221
if
(
msgLvl
(MSG::VERBOSE))
msg
(MSG::VERBOSE) <<
"Leaving writeVector()"
<<
endmsg
;
222
return
;
223
}
224
225
void
GetDetectorLocalFrames::writeTransForm
(
const
HepGeom::Transform3D& transform){
226
if
(
msgLvl
(MSG::VERBOSE))
msg
(MSG::VERBOSE) <<
"In writeTransForm()"
<<
endmsg
;
227
228
m_outputFile
<<
" Trans(x,y,z): "
<< transform.dx() <<
" "
<< transform.dy() <<
" "
<< transform.dz() << std::endl;
229
m_outputFile
<<
" Rotation Matrix "
<< std::endl;
230
m_outputFile
<< transform.xx() <<
" "
<< transform.xy() <<
" "
<< transform.xz() << std::endl;
231
m_outputFile
<< transform.yx() <<
" "
<< transform.yy() <<
" "
<< transform.yz() << std::endl;
232
m_outputFile
<< transform.zx() <<
" "
<< transform.zy() <<
" "
<< transform.zz() << std::endl;
233
234
if
(
msgLvl
(MSG::VERBOSE))
msg
(MSG::VERBOSE) <<
"Leaving writeTransForm()"
<<
endmsg
;
235
return
;
236
}
237
endmsg
#define endmsg
Definition
AnalysisConfig_Ntuple.cxx:54
ATH_CHECK
#define ATH_CHECK
Evaluate an expression and check for errors.
Definition
AthCheckMacros.h:40
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition
AthMsgStreamMacros.h:33
EventPrimitives.h
GetDetectorLocalFrames.h
IdentifierHash.h
sc
static Double_t sc
Definition
LArPhysWaveHECTool.cxx:37
ReadCondHandle.h
SiDetectorElement.h
TRT_DetectorManager.h
TRT_ID.h
This is an Identifier helper class for the TRT subdetector.
TRT_Numerology.h
AthAlgorithm::AthAlgorithm
AthAlgorithm(const std::string &name, ISvcLocator *pSvcLocator)
Constructor.
Definition
AthAlgorithm.cxx:10
AthCommonAlgorithm< Gaudi::Algorithm >::declareProperty
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T, V, H > &t)
Definition
AthCommonDataStore.h:145
AthCommonAlgorithm< Gaudi::Algorithm >::detStore
const ServiceHandle< StoreGateSvc > & detStore() const
Definition
AthCommonDataStore.h:95
AthCommonAlgorithm< Gaudi::Algorithm >::msgLvl
bool msgLvl(const MSG::Level lvl) const
Definition
AthCommonMsg.h:30
ExpandedIdentifier
Definition
DetectorDescription/Identifier/Identifier/ExpandedIdentifier.h:105
GetDetectorLocalFrames::m_pixelDetEleCollKey
SG::ReadCondHandleKey< InDetDD::SiDetectorElementCollection > m_pixelDetEleCollKey
Pixel Data.
Definition
GetDetectorLocalFrames.h:58
GetDetectorLocalFrames::m_TRTDetectorManager
const InDetDD::TRT_DetectorManager * m_TRTDetectorManager
Definition
GetDetectorLocalFrames.h:72
GetDetectorLocalFrames::GetDetectorLocalFrames
GetDetectorLocalFrames(const std::string &name, ISvcLocator *pSvcLocator)
Authors: John Alison johnda@hep.upenn.edu.
Definition
GetDetectorLocalFrames.cxx:37
GetDetectorLocalFrames::m_TRTHelper
const TRT_ID * m_TRTHelper
Tools.
Definition
GetDetectorLocalFrames.h:71
GetDetectorLocalFrames::writeVector
void writeVector(std::string_view name, const Amg::Vector3D &vector)
Definition
GetDetectorLocalFrames.cxx:218
GetDetectorLocalFrames::m_trt_barrel_ec
int m_trt_barrel_ec
TRT Data.
Definition
GetDetectorLocalFrames.h:64
GetDetectorLocalFrames::writeSCTFrames
void writeSCTFrames()
Writing the SCT Positions.
Definition
GetDetectorLocalFrames.cxx:142
GetDetectorLocalFrames::execute
StatusCode execute(const EventContext &ctx)
execute
Definition
GetDetectorLocalFrames.cxx:85
GetDetectorLocalFrames::m_trt_straw_layer
int m_trt_straw_layer
Definition
GetDetectorLocalFrames.h:67
GetDetectorLocalFrames::m_SCTDetEleCollKey
SG::ReadCondHandleKey< InDetDD::SiDetectorElementCollection > m_SCTDetEleCollKey
SCT Data.
Definition
GetDetectorLocalFrames.h:61
GetDetectorLocalFrames::m_trt_phi_module
int m_trt_phi_module
Definition
GetDetectorLocalFrames.h:66
GetDetectorLocalFrames.name
name
Definition
GetDetectorLocalFrames.py:11
GetDetectorLocalFrames::m_trt_straw
int m_trt_straw
Definition
GetDetectorLocalFrames.h:68
GetDetectorLocalFrames::writeTRTFrames
void writeTRTFrames()
Writing the Detailed (all straws) TRT Positions.
Definition
GetDetectorLocalFrames.cxx:161
GetDetectorLocalFrames::m_trt_layer_or_wheel
int m_trt_layer_or_wheel
Definition
GetDetectorLocalFrames.h:65
GetDetectorLocalFrames::m_eventCount
int m_eventCount
Counter.
Definition
GetDetectorLocalFrames.h:75
GetDetectorLocalFrames::finalize
StatusCode finalize()
Finalize.
Definition
GetDetectorLocalFrames.cxx:113
GetDetectorLocalFrames::m_outputFileName
std::string m_outputFileName
Name of the Output file.
Definition
GetDetectorLocalFrames.h:54
GetDetectorLocalFrames::writePixelFames
void writePixelFames()
Functions to write the data.
Definition
GetDetectorLocalFrames.cxx:123
GetDetectorLocalFrames::writeTransForm
void writeTransForm(const HepGeom::Transform3D &transform)
Definition
GetDetectorLocalFrames.cxx:225
GetDetectorLocalFrames::initialize
StatusCode initialize()
initialize
Definition
GetDetectorLocalFrames.cxx:57
GetDetectorLocalFrames::m_outputFile
std::ofstream m_outputFile
Definition
GetDetectorLocalFrames.h:55
InDetDD::SiDetectorElementCollection
Class to hold the SiDetectorElement objects to be put in the detector store.
Definition
SiDetectorElementCollection.h:27
SG::ReadCondHandle
Definition
ReadCondHandle.h:40
SG::ReadCondHandle::isValid
bool isValid()
Definition
ReadCondHandle.h:205
TRT_ID::const_expanded_id_iterator
MultiRange::const_identifier_factory const_expanded_id_iterator
Definition
TRT_ID.h:90
vector
Definition
MultiHisto.h:13
Amg::Vector3D
Eigen::Matrix< double, 3, 1 > Vector3D
Definition
GeoPrimitives.h:47
Identifier
Definition
IdentifierFieldParser.cxx:14
msg
MsgStream & msg
Definition
testRead.cxx:32
Generated on
for ATLAS Offline Software by
1.17.0