ATLAS Offline Software
Loading...
Searching...
No Matches
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
16
17#include "GaudiKernel/MsgStream.h"
18
19#include "Identifier/Identifier.h"
23
26
28
30
31#include <cstdlib>
32#include <cstring>
33#include <vector>
34
35
37GetDetectorLocalFrames::GetDetectorLocalFrames(std::string const& name, ISvcLocator* pSvcLocator) :
38 AthAlgorithm(name, pSvcLocator),
39 m_outputFileName("IDLocalFrames.txt"),
40
46 m_trt_straw(0),
47
49 m_TRTHelper(nullptr),
51
52{
53 declareProperty("OutputTextFile",m_outputFileName);
54}
55
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
85StatusCode 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;
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
102
103 //Write SCT positions
105
106 //Write SCT positions
108
109 return StatusCode::SUCCESS;
110}
111
114 if (msgLvl(MSG::VERBOSE)) msg(MSG::VERBOSE) << "finalize()" << endmsg;
115
117 m_outputFile.close();
118
119 return StatusCode::SUCCESS;
120}
121
124 if (msgLvl(MSG::VERBOSE)) msg(MSG::VERBOSE) << "In writePixelFames()" << endmsg;
125
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
143 if (msgLvl(MSG::VERBOSE)) msg(MSG::VERBOSE) << "In writeSCTFrames()" << endmsg;
144
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
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
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
225void 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
#define endmsg
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_ERROR(x)
static Double_t sc
This is an Identifier helper class for the TRT subdetector.
AthAlgorithm(const std::string &name, ISvcLocator *pSvcLocator)
Constructor.
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T, V, H > &t)
const ServiceHandle< StoreGateSvc > & detStore() const
bool msgLvl(const MSG::Level lvl) const
SG::ReadCondHandleKey< InDetDD::SiDetectorElementCollection > m_pixelDetEleCollKey
Pixel Data.
const InDetDD::TRT_DetectorManager * m_TRTDetectorManager
GetDetectorLocalFrames(const std::string &name, ISvcLocator *pSvcLocator)
Authors: John Alison johnda@hep.upenn.edu.
const TRT_ID * m_TRTHelper
Tools.
void writeVector(std::string_view name, const Amg::Vector3D &vector)
void writeSCTFrames()
Writing the SCT Positions.
StatusCode execute(const EventContext &ctx)
execute
SG::ReadCondHandleKey< InDetDD::SiDetectorElementCollection > m_SCTDetEleCollKey
SCT Data.
void writeTRTFrames()
Writing the Detailed (all straws) TRT Positions.
std::string m_outputFileName
Name of the Output file.
void writePixelFames()
Functions to write the data.
void writeTransForm(const HepGeom::Transform3D &transform)
StatusCode initialize()
initialize
Class to hold the SiDetectorElement objects to be put in the detector store.
MultiRange::const_identifier_factory const_expanded_id_iterator
Definition TRT_ID.h:90
Eigen::Matrix< double, 3, 1 > Vector3D
MsgStream & msg
Definition testRead.cxx:32