ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
InnerDetector
InDetExample
InDetDetDescrExample
src
TestSiAlignment.cxx
Go to the documentation of this file.
1
/*
2
Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
3
*/
4
5
#include "
InDetDetDescrExample/TestSiAlignment.h
"
6
7
#include "CLHEP/Units/SystemOfUnits.h"
8
9
#include "
InDetReadoutGeometry/SiDetectorElement.h
"
10
#include "
InDetReadoutGeometry/SiDetectorManager.h
"
11
#include "
ReadoutGeometryBase/SiCellId.h
"
12
#include "
ReadoutGeometryBase/SiIntersect.h
"
13
#include "
ReadoutGeometryBase/SiLocalPosition.h
"
14
#include "
InDetIdentifier/PixelID.h
"
15
#include "
InDetIdentifier/SCT_ID.h
"
16
#include "Identifier/Identifier.h"
17
#include "
GeoPrimitives/CLHEPtoEigenConverter.h
"
18
#include "
StoreGate/ReadCondHandle.h
"
19
20
#include <iostream>
21
#include <vector>
22
#include <string>
23
24
using
std::cout;
25
using
std::endl;
26
27
using namespace
InDetDD
;
28
// or just the ones we need.
29
// using InDetDD::SiDetectorManager;
30
// using InDetDD::SiDetectorElement;
31
// using InDetDD::SiDetectorElementCollection;
32
// using InDetDD::SiLocalPosition;
33
// using InDetDD::SiCellId;
34
// using InDetDD::SiIntersect;
35
37
//
38
// Prints out SiDetectorElement positions and other info.
39
41
42
TestSiAlignment::TestSiAlignment
(
const
std::string& name, ISvcLocator* pSvcLocator) :
43
AthAlgorithm
(name, pSvcLocator),
44
m_manager
(nullptr),
45
m_managerName
(
""
)
46
{
47
// Get parameter values from jobOptions file
48
declareProperty
(
"ManagerName"
,
m_managerName
);
49
declareProperty
(
"LongPrintOut"
,
m_longPrintOut
=
false
);
50
declareProperty
(
"ErrorRotation"
,
m_errRot
= 1e-15);
// For testing if alignment changed
51
declareProperty
(
"ErrorTranslation"
,
m_errTrans
= 1e-12);
// For testing if alignment changed
52
}
53
54
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
55
56
StatusCode
TestSiAlignment::initialize
(){
57
58
ATH_MSG_INFO
(
"Algorithm Properties"
);
59
ATH_MSG_INFO
(
" ManagerName: "
<<
m_managerName
);
60
ATH_MSG_INFO
(
" LongPrintOut: "
<< (
m_longPrintOut
?
"true"
:
"false"
) );
61
ATH_MSG_INFO
(
" ErrorRotation: "
<<
m_errRot
);
62
ATH_MSG_INFO
(
" ErrorTranslation: "
<<
m_errTrans
);
63
// Retrieve Detector Manager
64
ATH_CHECK
(
detStore
()->retrieve(
m_manager
,
m_managerName
));
65
if
(
m_managerName
!=
"Pixel"
&&
m_managerName
!=
"SCT"
) {
66
ATH_MSG_FATAL
(
"m_managerName "
<<
m_managerName
<<
" is not appropriate name"
);
67
}
68
ATH_CHECK
(
m_detEleCollKey
.initialize(
m_managerName
==
"SCT"
));
69
printAlignmentShifts
(
true
);
70
return
StatusCode::SUCCESS;
71
}
72
73
74
void
75
TestSiAlignment::printAlignmentShifts
(
const
bool
accessDuringInitialization) {
76
const
bool
useConditionStore = (
m_managerName
==
"SCT"
and (not accessDuringInitialization));
77
static
const
Amg::Vector3D
zeroPoint(0., 0., 0.);
78
static
const
Amg::Vector3D
phiAxis(1, 0, 0);
79
static
const
Amg::Vector3D
etaAxis(0, 1, 0);
80
static
const
Amg::Vector3D
depAxis(0, 0, 1);
81
const
SiDetectorElementCollection
* elements =
nullptr
;
82
if
(useConditionStore) {
83
// Get SiDetectorElementCollection from ConditionStore
84
SG::ReadCondHandle<InDetDD::SiDetectorElementCollection>
detEle(
m_detEleCollKey
);
85
elements = detEle.
retrieve
();
86
if
(elements==
nullptr
) {
87
ATH_MSG_FATAL
(
m_detEleCollKey
.fullKey() <<
" could not be retrieved"
);
88
return
;
89
}
90
}
else
{
91
elements =
m_manager
->getDetectorElementCollection();
92
}
93
for
(
const
SiDetectorElement
* element: *elements) {
94
if
(element) {
95
// The id helper is available either through the manager or the elements
96
cout << element->getIdHelper()->show_to_string(element->identify());
97
// Get the default transform
98
Amg::Transform3D
elementDefXF = element->defTransform();
99
Amg::Transform3D
elementXF = element->transform();
100
Amg::Transform3D
localDelta = elementDefXF.inverse() * elementXF;
101
Amg::Transform3D
globalDelta = elementXF * elementDefXF.inverse();
102
Amg::Vector3D
globalShift = elementXF * zeroPoint - elementDefXF * zeroPoint;
103
double
alphaL,betaL,gammaL;
104
extractAlphaBetaGamma
(localDelta,alphaL,betaL,gammaL);
105
// test if it is the identity transform within some error
106
if
(
testIdentity
(localDelta,
m_errRot
,
m_errTrans
)) {
107
cout <<
" NO SHIFT"
<< endl;
108
}
else
{
109
if
(
m_longPrintOut
) {
110
double
alphaG,betaG,gammaG;
111
extractAlphaBetaGamma
(globalDelta,alphaG,betaG,gammaG);
112
cout << endl;
113
cout <<
" Local Shift"
<< endl;
114
cout <<
" delta trans "
<< localDelta * zeroPoint <<
" Rot: {"
<< alphaL <<
","
<< betaL <<
","
<< gammaL <<
"}"
<<endl;
115
cout <<
" phiAxis "
<< phiAxis <<
" -> "
<< localDelta * phiAxis << endl;
116
cout <<
" etaAxis "
<< etaAxis <<
" -> "
<< localDelta * etaAxis << endl;
117
cout <<
" depAxis "
<< depAxis <<
" -> "
<< localDelta * depAxis << endl;
118
cout <<
" Global Shift"
<< endl;
119
cout <<
" shift "
<< globalShift << endl;
120
cout <<
" delta trans "
<< globalDelta * zeroPoint <<
" Rot: {"
<< alphaG <<
","
<< betaG <<
","
<< gammaG <<
"}"
<<endl;
121
cout <<
" center "
<< elementDefXF * zeroPoint <<
" -> "
<< elementXF * zeroPoint << endl;
122
cout <<
" phiAxis "
<< elementDefXF * phiAxis <<
" -> "
<< elementXF * phiAxis << endl;
123
cout <<
" etaAxis "
<< elementDefXF * etaAxis <<
" -> "
<< elementXF * etaAxis << endl;
124
cout <<
" depAxis "
<< elementDefXF * depAxis <<
" -> "
<< elementXF * depAxis << endl;
125
}
else
{
126
cout <<
" Global shift: "
<< globalShift <<
" Local shift/Rot: "
<< localDelta * zeroPoint <<
" Rot: {"
127
<< alphaL <<
","
<< betaL <<
","
<< gammaL <<
"}"
<<endl;
128
}
129
}
130
}
else
{
131
cout <<
"Missing element!!!!!!!!!!!"
<< endl;
132
}
133
}
134
cout << endl;
135
}
136
137
bool
138
TestSiAlignment::testIdentity
(
const
Amg::Transform3D
& transform,
double
errRot,
double
errTrans) {
139
using
std::abs;
140
const
Amg::Transform3D
& t1 = transform;
141
Amg::Transform3D
t2;
142
t2.setIdentity();
143
// Rotation/Scale
144
for
(
int
i=0; i < 3; i++){
145
for
(
int
j=0; j < 3; j++){
146
double
diff
= abs(t1(i,j) - t2(i,j));
147
if
(
diff
> errRot)
return
false
;
148
}
149
}
150
151
// Translation
152
for
(
int
ii = 0; ii < 3; ii++){
153
double
diff
= abs(t1(ii,3) - t2(ii,3));
154
if
(
diff
> errTrans)
return
false
;
155
}
156
return
true
;
157
}
158
159
void
TestSiAlignment::extractAlphaBetaGamma
(
const
Amg::Transform3D
& trans,
double
& alpha,
double
& beta,
double
&gamma)
const
{
160
double
siny = trans(0,2);
161
beta = asin(siny);
162
// Check if cosy = 0. This requires special treatment.
163
// can check either element (1,2),(2,2) both equal zero
164
// or (0,1) and (0,0)
165
if
((trans(1,2) == 0) && (trans(2,2) == 0)) {
166
// alpha and gamma are degenerate. We arbitrarily choose
167
// gamma = 0.
168
gamma = 0;
169
alpha = atan2(trans(1,1),trans(2,1));
170
}
else
{
171
alpha = atan2(-trans(1,2),trans(2,2));
172
gamma = atan2(-trans(0,1),trans(0,0));
173
if
(alpha == 0) alpha = 0;
// convert -0 to 0
174
if
(gamma == 0) gamma = 0;
// convert -0 to 0
175
}
176
}
177
178
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
179
180
StatusCode
TestSiAlignment::execute
(
const
EventContext&
/*ctx*/
) {
181
printAlignmentShifts
(
false
);
182
return
StatusCode::SUCCESS;
183
}
184
185
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
186
187
StatusCode
TestSiAlignment::finalize
() {
188
return
StatusCode::SUCCESS;
189
}
190
191
192
193
ATH_CHECK
#define ATH_CHECK
Evaluate an expression and check for errors.
Definition
AthCheckMacros.h:40
ATH_MSG_INFO
#define ATH_MSG_INFO(x,...)
Definition
AthMsgStreamMacros.h:45
ATH_MSG_FATAL
#define ATH_MSG_FATAL(x,...)
Definition
AthMsgStreamMacros.h:48
CLHEPtoEigenConverter.h
PixelID.h
This is an Identifier helper class for the Pixel subdetector.
ReadCondHandle.h
diff
void diff(const Jet &rJet1, const Jet &rJet2, std::map< std::string, double > varDiff)
Difference between jets - Non-Class function required by trigger.
Definition
Jet.cxx:631
SCT_ID.h
This is an Identifier helper class for the SCT subdetector.
SiCellId.h
SiDetectorElement.h
SiDetectorManager.h
SiIntersect.h
SiLocalPosition.h
TestSiAlignment.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
InDetDD::SiDetectorElementCollection
Class to hold the SiDetectorElement objects to be put in the detector store.
Definition
SiDetectorElementCollection.h:27
InDetDD::SiDetectorElement
Class to hold geometrical description of a silicon detector element.
Definition
SiDetectorElement.h:109
SG::ReadCondHandle
Definition
ReadCondHandle.h:39
SG::ReadCondHandle::retrieve
const_pointer_type retrieve()
Definition
ReadCondHandle.h:160
TestSiAlignment::m_detEleCollKey
SG::ReadCondHandleKey< InDetDD::SiDetectorElementCollection > m_detEleCollKey
Definition
TestSiAlignment.h:43
TestSiAlignment::extractAlphaBetaGamma
void extractAlphaBetaGamma(const Amg::Transform3D &trans, double &alpha, double &beta, double &gamma) const
Definition
TestSiAlignment.cxx:159
TestSiAlignment::m_longPrintOut
bool m_longPrintOut
Definition
TestSiAlignment.h:40
TestSiAlignment::m_manager
const InDetDD::SiDetectorManager * m_manager
Definition
TestSiAlignment.h:38
TestSiAlignment::initialize
StatusCode initialize()
Definition
TestSiAlignment.cxx:56
TestSiAlignment::testIdentity
bool testIdentity(const Amg::Transform3D &transform, double errRot=0, double errTrans=0)
Definition
TestSiAlignment.cxx:138
TestSiAlignment::m_errRot
double m_errRot
Definition
TestSiAlignment.h:41
TestSiAlignment::finalize
StatusCode finalize()
Definition
TestSiAlignment.cxx:187
TestSiAlignment::execute
StatusCode execute(const EventContext &ctx)
Execute method.
Definition
TestSiAlignment.cxx:180
TestSiAlignment::printAlignmentShifts
void printAlignmentShifts(const bool accessDuringInitialization)
Definition
TestSiAlignment.cxx:75
TestSiAlignment::m_errTrans
double m_errTrans
Definition
TestSiAlignment.h:42
TestSiAlignment::m_managerName
std::string m_managerName
Definition
TestSiAlignment.h:39
TestSiAlignment::TestSiAlignment
TestSiAlignment(const std::string &name, ISvcLocator *pSvcLocator)
Definition
TestSiAlignment.cxx:42
Amg::Transform3D
Eigen::Affine3d Transform3D
Definition
GeoPrimitives.h:46
Amg::Vector3D
Eigen::Matrix< double, 3, 1 > Vector3D
Definition
GeoPrimitives.h:48
InDetDD
Message Stream Member.
Definition
FakeTrackBuilder.h:8
Generated on
for ATLAS Offline Software by
1.17.0