ATLAS Offline Software
Loading...
Searching...
No Matches
GetDetectorLocalFrames.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2025 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
42
44
50 m_trt_straw(0),
51
53 m_TRTHelper(nullptr),
55
56{
57 declareProperty("OutputTextFile",m_outputFileName);
58}
59
62 if (msgLvl(MSG::VERBOSE)) msg(MSG::VERBOSE) << "initialize()" << endmsg;
63
65 if (detStore()->retrieve(m_TRTHelper, "TRT_ID").isFailure()) {
66 msg(MSG::FATAL) << "Could not get TRT ID helper" << endmsg;
67 return StatusCode::FAILURE;
68 }
69 if (msgLvl(MSG::VERBOSE)) msg(MSG::VERBOSE) << "got the TRT ID" << endmsg;
70
71 if ((detStore()->retrieve(m_TRTDetectorManager)).isFailure()) {
72 if(msgLvl(MSG::FATAL)) msg(MSG::FATAL) << "Problem retrieving TRT_DetectorManager" << endmsg;
73 return StatusCode::FAILURE;
74 }
75
77 ATH_CHECK(m_SCTDetEleCollKey.initialize());
78
80 ATH_CHECK(m_pixelDetEleCollKey.initialize());
81
83 m_outputFile.open((m_outputFileName).c_str());
84
85 return StatusCode::SUCCESS;
86}
87
90
91 if (msgLvl(MSG::VERBOSE)) msg(MSG::VERBOSE) << "execute() check global position" << endmsg;
92
93 StatusCode sc = StatusCode::SUCCESS;
95
97 if (m_eventCount!=0)
98 return sc;
99
100 std::cout << "========================================================================================" <<std::endl;
101 std::cout << "==================== Getting the Inner Detector Local Frames ===========================" <<std::endl;
102 std::cout << "========================================================================================" <<std::endl;
103
104 //Write pixel positions
106
107 //Write SCT positions
109
110 //Write SCT positions
112
113 return StatusCode::SUCCESS;
114}
115
118 if (msgLvl(MSG::VERBOSE)) msg(MSG::VERBOSE) << "finalize()" << endmsg;
119
121 m_outputFile.close();
122
123 return StatusCode::SUCCESS;
124}
125
128 if (msgLvl(MSG::VERBOSE)) msg(MSG::VERBOSE) << "In writePixelFames()" << endmsg;
129
131 const InDetDD::SiDetectorElementCollection* elements{*pixelDetEleHandle};
132 if (not pixelDetEleHandle.isValid() or elements==nullptr) {
133 ATH_MSG_ERROR(m_pixelDetEleCollKey.fullKey() << " is not available.");
134 return;
135 }
136 //Loop over pixel elements
137 // for (const InDetDD::SiDetectorElement* element: *elements) {
138 // Get local Frame
139 // }
140
141 if (msgLvl(MSG::VERBOSE)) msg(MSG::VERBOSE) << "Leaving writePixelFames()" << endmsg;
142 return;
143}
144
147 if (msgLvl(MSG::VERBOSE)) msg(MSG::VERBOSE) << "In writeSCTFrames()" << endmsg;
148
150 const InDetDD::SiDetectorElementCollection* elements{*sctDetEleHandle};
151 if (not sctDetEleHandle.isValid() or elements==nullptr) {
152 ATH_MSG_ERROR(m_SCTDetEleCollKey.fullKey() << " is not available.");
153 return;
154 }
155 //Loop over SCT elements
156 // for (const InDetDD::SiDetectorElement* element: *elements) {
157 // Get local Frame
158 // }
159
160 if (msgLvl(MSG::VERBOSE)) msg(MSG::VERBOSE) << "Leaving writeSCTFrames()" << endmsg;
161 return;
162}
163
166 if (msgLvl(MSG::VERBOSE)) msg(MSG::VERBOSE) << "In writeTRTFrames()" << endmsg;
167
168 TRT_ID::const_expanded_id_iterator trtStrawIt = m_TRTHelper->straw_begin();
169 TRT_ID::const_expanded_id_iterator trtStrawItE = m_TRTHelper->straw_end();
170
171 for (; trtStrawIt != trtStrawItE; ++trtStrawIt) {
172 const ExpandedIdentifier& expId = (*trtStrawIt);
173
174 Identifier trtId = m_TRTHelper->straw_id(expId[2],
175 expId[3],
176 expId[4],
177 expId[5],
178 expId[6]);
179
180 m_trt_barrel_ec = m_TRTHelper->barrel_ec(trtId);
181 m_trt_layer_or_wheel = m_TRTHelper->layer_or_wheel(trtId);
182 m_trt_phi_module = m_TRTHelper->phi_module(trtId);
183 m_trt_straw_layer = m_TRTHelper->straw_layer(trtId);
184 m_trt_straw = m_TRTHelper->straw(trtId);
185
186 m_outputFile << 3 << " "
187 << m_trt_barrel_ec << " "
188 << m_trt_layer_or_wheel << " "
189 << m_trt_phi_module << " "
190 << m_trt_straw_layer << " "
191 << m_trt_straw << " ";
192 m_outputFile << std::endl;
193
194 //const HepGeom::Transform3D& localTransform = m_TRTDetectorManager->getElement( trtId )->transform(trtId);
195 Amg::Vector3D xaxis(1,0,0);
196 Amg::Vector3D yaxis(0,1,0);
197 Amg::Vector3D zaxis(0,0,1);
198 const Amg::Vector3D strawXAxis = m_TRTDetectorManager->getElement( trtId )->strawTransform(m_trt_straw) * xaxis * m_TRTDetectorManager->getElement( trtId )->strawDirection();
199 const Amg::Vector3D strawYAxis = m_TRTDetectorManager->getElement( trtId )->strawTransform(m_trt_straw) * yaxis * m_TRTDetectorManager->getElement( trtId )->strawDirection();
200 const Amg::Vector3D strawZAxis = m_TRTDetectorManager->getElement( trtId )->strawTransform(m_trt_straw) * zaxis * m_TRTDetectorManager->getElement( trtId )->strawDirection();
201
202 const Amg::Vector3D strawXAxis_NoSign = m_TRTDetectorManager->getElement( trtId )->strawTransform(m_trt_straw) * xaxis;
203 const Amg::Vector3D strawYAxis_NoSign = m_TRTDetectorManager->getElement( trtId )->strawTransform(m_trt_straw) * yaxis;
204 const Amg::Vector3D strawZAxis_NoSign = m_TRTDetectorManager->getElement( trtId )->strawTransform(m_trt_straw) * zaxis;
205 //const HepGeom::Vector3D<double> theStrawAxis = m_TRTDetectorManager->getElement( trtId )->strawAxis(m_trt_straw);
206
207 //writeTransForm(localTransform);
208 writeVector("straw x-axis",strawXAxis);
209 writeVector("straw y-axis",strawYAxis);
210 writeVector("straw z-axis",strawZAxis);
211 m_outputFile << std::endl;
212 writeVector("straw x-axis (No sign)",strawXAxis_NoSign);
213 writeVector("straw y-axis (No sign)",strawYAxis_NoSign);
214 writeVector("straw z-axis (No sign)",strawZAxis_NoSign);
215 m_outputFile << std::endl;
216 }
217
218 if (msgLvl(MSG::VERBOSE)) msg(MSG::VERBOSE) << "Leaving writeTRTFrames()" << endmsg;
219 return;
220}
221
223 if (msgLvl(MSG::VERBOSE)) msg(MSG::VERBOSE) << "In writeVector()" << endmsg;
224
225 m_outputFile << name << " " << vector.x() << " " << vector.y() << " " << vector.z() << std::endl;
226
227 if (msgLvl(MSG::VERBOSE)) msg(MSG::VERBOSE) << "Leaving writeVector()" << endmsg;
228 return;
229}
230
231void GetDetectorLocalFrames::writeTransForm(const HepGeom::Transform3D& transform){
232 if (msgLvl(MSG::VERBOSE)) msg(MSG::VERBOSE) << "In writeTransForm()" << endmsg;
233
234 m_outputFile << " Trans(x,y,z): " << transform.dx() << " " << transform.dy() << " " << transform.dz() << std::endl;
235 m_outputFile << " Rotation Matrix " << std::endl;
236 m_outputFile << transform.xx() << " " << transform.xy() << " " << transform.xz() << std::endl;
237 m_outputFile << transform.yx() << " " << transform.yy() << " " << transform.yz() << std::endl;
238 m_outputFile << transform.zx() << " " << transform.zy() << " " << transform.zz() << std::endl;
239
240 if (msgLvl(MSG::VERBOSE)) msg(MSG::VERBOSE) << "Leaving writeTransForm()" << endmsg;
241 return;
242}
243
#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 with parameters:
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(const std::string &name, const Amg::Vector3D &vector)
void writeSCTFrames()
Writing the SCT Positions.
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:88
Eigen::Matrix< double, 3, 1 > Vector3D
MsgStream & msg
Definition testRead.cxx:32