EIC Software
Reference for
EIC
simulation and reconstruction software on GitHub
Home page
Related Pages
Modules
Namespaces
Classes
Files
External Links
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
Groups
Pages
FairGeoRotation.h
Go to the documentation of this file.
Or view
the newest version in sPHENIX GitHub for file FairGeoRotation.h
1
#ifndef FAIRGEOROTATION_H
2
#define FAIRGEOROTATION_H
3
4
#include "TObject.h"
5
6
#include "
FairGeoVector.h
"
7
8
#include "TRotMatrix.h"
9
10
#include <iostream>
11
12
17
class
FairGeoRotation
:
public
TObject
18
{
19
protected
:
20
Double_t
rot
[9];
21
public
:
22
inline
FairGeoRotation
();
23
inline
FairGeoRotation
(
const
FairGeoRotation
&);
24
inline
FairGeoRotation
(
const
Double_t*);
25
FairGeoRotation
(
const
Double_t,
const
Double_t,
const
Double_t);
26
~FairGeoRotation
() {}
27
inline
void
setMatrix
(
const
Double_t*);
28
inline
void
setMatrix
(
const
Float_t*);
29
void
setEulerAngles
(
const
Double_t,
const
Double_t,
const
Double_t);
30
inline
void
setElement
(
const
Double_t,
const
Int_t);
31
inline
Double_t
operator ()
(Int_t)
const
;
32
inline
FairGeoRotation
&
operator =
(
const
FairGeoRotation
&);
33
inline
Bool_t
operator ==
(
const
FairGeoRotation
&);
34
inline
Bool_t
operator !=
(
const
FairGeoRotation
&);
35
inline
FairGeoVector
operator *
(
const
FairGeoVector
&)
const
;
36
inline
FairGeoRotation
operator *
(
const
FairGeoRotation
&)
const
;
37
inline
FairGeoRotation
&
operator *=
(
const
FairGeoRotation
&);
38
inline
FairGeoRotation
&
transform
(
const
FairGeoRotation
&);
39
inline
Bool_t
isUnitMatrix
();
40
inline
FairGeoRotation
inverse
()
const
;
41
inline
FairGeoRotation
&
invert
();
42
inline
Double_t
determinant
()
const
;
43
Double_t
diff2
(
const
FairGeoRotation
&)
const
;
44
inline
Double_t
getElement
(Int_t i,Int_t j)
const
;
45
inline
void
setUnitMatrix
();
46
inline
void
setZero
();
47
inline
void
print
()
const
;
48
TRotMatrix*
createTRotMatrix
(
const
Text_t*
name
=
""
,
const
Text_t*
title
=
""
);
49
50
ClassDef(
FairGeoRotation
,1)
//
51
};
52
53
// -------------------- inlines ---------------------------
54
55
inline
FairGeoRotation::FairGeoRotation
()
56
:
TObject
()
57
{
58
rot
[0]=
rot
[4]=
rot
[8]=1.;
59
rot
[1]=
rot
[2]=
rot
[3]=
rot
[5]=
rot
[6]=
rot
[7]=0.;
60
}
61
62
inline
Double_t
FairGeoRotation::operator ()
(Int_t i)
const
63
{
64
if
(i>=0 && i<9) {
return
rot
[i]; }
65
Error(
"operator()"
,
"bad index"
);
66
return
0;
67
}
68
69
inline
FairGeoRotation::FairGeoRotation
(
const
FairGeoRotation
& r)
70
:
TObject
(r)
71
{
72
for
(Int_t i=0; i<9; i++) {
rot
[i]=r(i); }
73
}
74
75
inline
FairGeoRotation::FairGeoRotation
(
const
Double_t* a)
76
:
TObject
()
77
{
78
for
(Int_t i=0; i<9; i++) {
rot
[i]=a[i]; }
79
}
80
81
inline
void
FairGeoRotation::setMatrix
(
const
Double_t* a)
82
{
83
for
(Int_t i=0; i<9; i++) {
rot
[i]=a[i]; }
84
}
85
86
inline
void
FairGeoRotation::setMatrix
(
const
Float_t* a)
87
{
88
for
(Int_t i=0; i<9; i++) {
rot
[i]=a[i]; }
89
}
90
91
inline
void
FairGeoRotation::setElement
(
const
Double_t a,
const
Int_t i)
92
{
93
if
(i<9) {
rot
[i]=a; }
94
}
95
96
inline
Double_t
FairGeoRotation::getElement
(Int_t i,Int_t j)
const
97
{
98
return
rot
[i*3+j];
99
}
100
101
inline
FairGeoRotation
&
FairGeoRotation::operator =
(
const
FairGeoRotation
& r)
102
{
103
for
(Int_t i=0; i<9; i++) {
rot
[i]=r(i); }
104
return
*
this
;
105
}
106
107
inline
Bool_t
FairGeoRotation::operator ==
(
const
FairGeoRotation
& r)
108
{
109
Int_t i=0;
110
while
(i<9) {
111
if
(
rot
[i]!=r(i)) {
return
kFALSE; }
112
i++;
113
}
114
return
kTRUE;
115
}
116
117
inline
Bool_t
FairGeoRotation::operator !=
(
const
FairGeoRotation
& r)
118
{
119
Int_t i=0;
120
while
(i<9) {
121
if
(
rot
[i]!=r(i)) {
return
kTRUE; }
122
i++;
123
}
124
return
kFALSE;
125
}
126
127
inline
FairGeoVector
FairGeoRotation::operator *
(
const
FairGeoVector
&
v
)
const
128
{
129
return
FairGeoVector
(
rot
[0]*
v
(0)+
rot
[1]*
v
(1)+
rot
[2]*
v
(2),
130
rot
[3]*
v
(0)+
rot
[4]*
v
(1)+
rot
[5]*
v
(2),
131
rot
[6]*
v
(0)+
rot
[7]*
v
(1)+
rot
[8]*
v
(2));
132
}
133
134
inline
FairGeoRotation
FairGeoRotation::operator *
(
const
FairGeoRotation
& r)
const
135
{
136
Double_t a[9];
137
for
(Int_t kk=0; kk<9; kk++) { a[kk]=0; }
138
for
(Int_t i=0; i<3; i++) {
139
for
(Int_t j=0; j<3; j++) {
140
Int_t
n
=3*i+j;
141
for
(Int_t
k
=0;
k
<3;
k
++) { a[
n
]+=
rot
[3*i+
k
]*r(3*
k
+j); }
142
}
143
}
144
return
FairGeoRotation
(&a[0]);
145
}
146
147
inline
FairGeoRotation
&
FairGeoRotation::operator *=
(
const
FairGeoRotation
& r)
148
{
149
return
*
this
=
operator *
(r);
150
}
151
152
inline
FairGeoRotation
&
FairGeoRotation::transform
(
const
FairGeoRotation
& r)
153
{
154
return
*
this
=r*(*this);
155
}
156
157
inline
Bool_t
FairGeoRotation::isUnitMatrix
()
158
{
159
return
(
rot
[0]==1. &&
rot
[1]==0. &&
rot
[2]==0. &&
160
rot
[3]==0. &&
rot
[4]==1. &&
rot
[5]==0. &&
161
rot
[6]==0. &&
rot
[7]==0. &&
rot
[8]==1.) ? kTRUE : kFALSE;
162
}
163
164
inline
FairGeoRotation
FairGeoRotation::inverse
()
const
165
{
166
Double_t a[9];
167
for
(Int_t i=0; i<3; i++) {
168
for
(Int_t j=0; j<3; j++) { a[j+3*i]=
rot
[i+3*j]; }
169
}
170
return
FairGeoRotation
(a);
171
}
172
173
inline
FairGeoRotation
&
FairGeoRotation::invert
()
174
{
175
return
*
this
=
inverse
();
176
}
177
178
inline
Double_t
FairGeoRotation::determinant
()
const
179
{
180
return
rot
[0]*(
rot
[4]*
rot
[8]-
rot
[7]*
rot
[5])
181
-
rot
[3]*(
rot
[1]*
rot
[8]-
rot
[7]*
rot
[2])
182
+rot[6]*(rot[1]*rot[5]-rot[4]*rot[2]);
183
}
184
185
inline
void
FairGeoRotation::setUnitMatrix
()
186
{
187
rot
[0]=
rot
[4]=
rot
[8]=1.;
188
rot
[1]=
rot
[2]=
rot
[3]=
rot
[5]=
rot
[6]=
rot
[7]=0.;
189
}
190
191
inline
void
FairGeoRotation::setZero
()
192
{
193
for
(Int_t i=0; i<9; i++) {
rot
[i]=0.; }
194
}
195
196
inline
void
FairGeoRotation::print
()
const
197
{
198
for
(Int_t i=0; i<9; i++) { std::cout<<
rot
[i]<<
" "
; }
199
std::cout<<
'\n'
;
200
}
201
202
#endif
/* !FAIRGEOROTATION_H */
EicRoot
blob
master
geobase
FairGeoRotation.h
Built by
Jin Huang
. updated:
Mon Jan 22 2024 12:43:36
using
1.8.2 with
EIC GitHub integration