ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
Trigger
TrigAlgorithms
TrigL2MuonSA
src
CscRegUtils.cxx
Go to the documentation of this file.
1
/*
2
Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
3
*/
4
5
6
#include "
CscRegUtils.h
"
7
8
#include "
AthenaBaseComps/AthMsgStreamMacros.h
"
9
10
#include <cmath>
11
12
13
namespace
TrigL2MuonSA
{
14
15
16
CscRegDict :: CscRegDict(
const
std::string &
type
,
const
std::string &name,
const
IInterface *parent)
17
:
AthAlgTool
(
type
,name,parent),
18
m_util
()
19
{
20
}
21
22
23
StatusCode CscRegDict :: initialize(){
24
25
int
i=0;
26
27
//small sector
28
const
double
SPwid = 0.32369;
29
const
double
Setamin = 1.97667;
30
const
double
Setamax = 2.76781;
31
const
double
SDisplace = (7441.+7518.)/2.;
//7428.3;
32
const
double
SAtanNormal = 0.20223129856437;
33
34
//Cside Small
35
for
(
int
phi
=0;
phi
<8; ++
phi
) {
36
m_reg_dict
[i].etaMin=(-1)*Setamax;
37
m_reg_dict
[i].etaMax=(-1)*Setamin;
38
m_reg_dict
[i].phiMin=
PhiConv
( 0.125*
M_PI
+
phi
*0.25*
M_PI
- 0.5*SPwid );
39
m_reg_dict
[i].phiMax=
PhiConv
( 0.125*
M_PI
+
phi
*0.25*
M_PI
+ 0.5*SPwid );
40
m_reg_dict
[i].phiCen=
m_reg_dict
[i].phiMod =
PhiConv
( 0.125*
M_PI
+
phi
*0.25*
M_PI
);
41
m_reg_dict
[i].Displacement=SDisplace;
42
m_reg_dict
[i].idealAtanNormal=
m_reg_dict
[i].actualAtanNormal =
M_PI
-SAtanNormal;
43
m_reg_dict
[i].posCorrectionMinusR=0.;
44
m_reg_dict
[i].posCorrectionPlusR=0.;
45
ATH_MSG_DEBUG
(
"CscRegDict: hash= "
<< i <<
" StationName="
<<
stationName
(i) <<
" StationEta="
<<
stationEta
(i) <<
" StationPhi="
<<
stationPhi
(i)
46
<<
" eta:["
<<
m_reg_dict
[i].etaMin <<
","
<<
m_reg_dict
[i].etaMax <<
"]"
47
<<
" phi:["
<<
m_reg_dict
[i].phiMin <<
","
<<
m_reg_dict
[i].phiMax <<
"]"
48
<<
" theta:["
<<
m_util
.calc_theta(
m_reg_dict
[i].etaMin) <<
","
<<
m_util
.calc_theta(
m_reg_dict
[i].etaMax) <<
"]"
);
49
++i;
50
}
51
//Aside Small
52
for
(
int
phi
=0;
phi
<8; ++
phi
) {
53
m_reg_dict
[i].etaMin=Setamin;
54
m_reg_dict
[i].etaMax=Setamax;
55
m_reg_dict
[i].phiMin=
PhiConv
( 0.125*
M_PI
+
phi
*0.25*
M_PI
- 0.5*SPwid );
56
m_reg_dict
[i].phiMax=
PhiConv
( 0.125*
M_PI
+
phi
*0.25*
M_PI
+ 0.5*SPwid );
57
m_reg_dict
[i].phiCen=
m_reg_dict
[i].phiMod =
PhiConv
( 0.125*
M_PI
+
phi
*0.25*
M_PI
);
58
m_reg_dict
[i].Displacement=SDisplace;
59
m_reg_dict
[i].idealAtanNormal=
m_reg_dict
[i].actualAtanNormal =SAtanNormal;
60
m_reg_dict
[i].posCorrectionMinusR=0.;
61
m_reg_dict
[i].posCorrectionPlusR=0.;
62
ATH_MSG_DEBUG
(
"CscRegDict: hash= "
<< i <<
" StationName="
<<
stationName
(i) <<
" StationEta="
<<
stationEta
(i) <<
" StationPhi="
<<
stationPhi
(i)
63
<<
" eta:["
<<
m_reg_dict
[i].etaMin <<
","
<<
m_reg_dict
[i].etaMax <<
"]"
64
<<
" phi:["
<<
m_reg_dict
[i].phiMin <<
","
<<
m_reg_dict
[i].phiMax <<
"]"
65
<<
" theta:["
<<
m_util
.calc_theta(
m_reg_dict
[i].etaMin) <<
","
<<
m_util
.calc_theta(
m_reg_dict
[i].etaMax) <<
"]"
);
66
++i;
67
}
68
69
70
//large sector
71
const
double
LPwid = 0.514507;
72
const
double
Letamin = 2.01471;
73
const
double
Letamax = 2.75914;
74
const
double
LDisplace = (7800.+7880.)/2.;
//7789.6;
75
const
double
LAtanNormal = 0.20223129856437;
76
77
//Cside Large
78
for
(
int
phi
=0;
phi
<8; ++
phi
) {
79
m_reg_dict
[i].etaMin=(-1)*Letamax;
80
m_reg_dict
[i].etaMax=(-1)*Letamin;
81
m_reg_dict
[i].phiMin=
PhiConv
(
phi
*0.25*
M_PI
- 0.5*LPwid );
82
m_reg_dict
[i].phiMax=
PhiConv
(
phi
*0.25*
M_PI
+ 0.5*LPwid );
83
m_reg_dict
[i].phiCen=
m_reg_dict
[i].phiMod =
PhiConv
(
phi
*0.25*
M_PI
);
84
m_reg_dict
[i].Displacement=LDisplace;
85
m_reg_dict
[i].idealAtanNormal=
m_reg_dict
[i].actualAtanNormal =
M_PI
-LAtanNormal;
86
m_reg_dict
[i].posCorrectionMinusR=0.;
87
m_reg_dict
[i].posCorrectionPlusR=0.;
88
ATH_MSG_DEBUG
(
"CscRegDict: hash= "
<< i <<
" StationName="
<<
stationName
(i) <<
" StationEta="
<<
stationEta
(i) <<
" StationPhi="
<<
stationPhi
(i)
89
<<
" eta:["
<<
m_reg_dict
[i].etaMin <<
","
<<
m_reg_dict
[i].etaMax <<
"]"
90
<<
" phi:["
<<
m_reg_dict
[i].phiMin <<
","
<<
m_reg_dict
[i].phiMax <<
"]"
91
<<
" theta:["
<<
m_util
.calc_theta(
m_reg_dict
[i].etaMin) <<
","
<<
m_util
.calc_theta(
m_reg_dict
[i].etaMax) <<
"]"
);
92
++i;
93
}
94
//Aside Large
95
for
(
int
phi
=0;
phi
<8; ++
phi
) {
96
m_reg_dict
[i].etaMin=Letamin;
97
m_reg_dict
[i].etaMax=Letamax;
98
m_reg_dict
[i].phiMin=
PhiConv
(
phi
*0.25*
M_PI
- 0.5*LPwid );
99
m_reg_dict
[i].phiMax=
PhiConv
(
phi
*0.25*
M_PI
+ 0.5*LPwid );
100
m_reg_dict
[i].phiCen=
m_reg_dict
[i].phiMod =
PhiConv
(
phi
*0.25*
M_PI
);
101
m_reg_dict
[i].Displacement=LDisplace;
102
m_reg_dict
[i].idealAtanNormal=
m_reg_dict
[i].actualAtanNormal =LAtanNormal;
103
m_reg_dict
[i].posCorrectionMinusR=0.;
104
m_reg_dict
[i].posCorrectionPlusR=0.;
105
ATH_MSG_DEBUG
(
"CscRegDict: hash= "
<< i <<
" StationName="
<<
stationName
(i) <<
" StationEta="
<<
stationEta
(i) <<
" StationPhi="
<<
stationPhi
(i)
106
<<
" eta:["
<<
m_reg_dict
[i].etaMin <<
","
<<
m_reg_dict
[i].etaMax <<
"]"
107
<<
" phi:["
<<
m_reg_dict
[i].phiMin <<
","
<<
m_reg_dict
[i].phiMax <<
"]"
108
<<
" theta:["
<<
m_util
.calc_theta(
m_reg_dict
[i].etaMin) <<
","
<<
m_util
.calc_theta(
m_reg_dict
[i].etaMax) <<
"]"
);
109
++i;
110
}
111
/*
112
ATH_MSG_DEBUG( "m_isMC=" << m_isMC );
113
if (!m_isMC){
114
initializePosCorrectionParameters();
115
initializeDictionaryForData();
116
}
117
*/
118
initializeHashDictionary
();
119
120
121
return
StatusCode::SUCCESS;
122
}
123
124
125
int
CscRegDict :: get_hash(
int
stationname,
int
stationeta,
int
stationphi)
const
{
126
127
int
sname, seta, sphi;
128
if
(stationname == 50 || stationname == 51) sname = stationname-50;
129
else
{
ATH_MSG_DEBUG
(
"stationname is out of [50,51]"
);
130
return
999;
131
}
132
if
(stationeta == 1 || stationeta ==-1) seta = ((stationeta == 1)? 1:0);
133
else
{
ATH_MSG_DEBUG
(
"stationeta is not 1 nor -1"
);
134
return
999;
135
}
136
if
(stationphi >=1 || stationeta <=8) sphi = stationphi-1;
137
else
{
ATH_MSG_DEBUG
(
"stationeta is out of [1,8]"
);
138
return
999;
139
}
140
141
return
m_module_hashes
[sname][seta][sphi];
142
}
143
144
145
146
147
double
CscRegDict :: PhiConv(
double
phi
){
148
149
if
(
phi
>
M_PI
) {
150
phi
-= 2*
M_PI
;
151
}
152
153
return
phi
;
154
}
155
156
157
ReturnCode
CscRegDict :: initializeHashDictionary(){
158
159
int
hash = 0;
160
for
(
int
sname=0; sname<2; ++sname) {
161
for
(
int
seta=0; seta<2; ++seta) {
162
for
(
int
sphi=0; sphi<8; ++sphi) {
163
m_module_hashes
[sname][seta][sphi] = hash;
164
ATH_MSG_DEBUG
(
"module_hash:"
<< hash <<
" StationName:"
<< sname+50 <<
" StationEta:"
<< (seta ? 1 : -1) <<
" StationPhi:"
<< sphi+1 );
165
++hash;
166
}
167
}
168
}
169
return
0;
170
}
171
172
173
174
Amg::Vector3D
CscRegDict::nomalVector
(
int
module)
const
{
175
176
double
phi
=
m_reg_dict
[module].phiCen;
177
double
theta
=
m_reg_dict
[module].idealAtanNormal;
178
Amg::Vector3D
nomvec( std::sin(
theta
)*std::cos(
phi
), std::sin(
theta
)*std::sin(
phi
), std::cos(
theta
));
179
180
return
nomvec;
181
182
}
183
184
185
double
CscRegDict :: posCorrectionR(
int
module,
int
charge
/*0 or 1*/
){
186
187
if
(0==
charge
)
return
m_reg_dict
[module].posCorrectionMinusR;
188
if
(1==
charge
)
return
m_reg_dict
[module].posCorrectionPlusR;
189
190
return
0.0;
191
}
192
193
194
double
CscRegDict :: posCorrectionZ(
int
module,
int
charge
/*0 or 1*/
){
195
196
double
tan = this->
idealAtanNormal
(module);
197
198
if
(0==
charge
)
return
(-1)*tan*(
m_reg_dict
[module].posCorrectionMinusR );
199
if
(1==
charge
)
return
(-1)*tan*(
m_reg_dict
[module].posCorrectionPlusR );
200
201
return
0.0;
202
}
203
204
205
206
207
double
UtilTools :: calc_phi(
double
x
,
double
y
)
const
{
208
209
double
/*abs_x=std::abs(x),*/
abs_y=std::abs(
y
);
210
double
abs_sine=abs_y/std::sqrt(
x
*
x
+
y
*
y
);
211
//std::cout << "convert " << ASin(abssin) << std::endl;
212
213
if
(
x
>0 &&
y
>=0) {
214
return
std::asin(abs_sine);
215
}
else
if
(
x<=0 && y>
0){
216
return
M_PI
-std::asin(abs_sine);
217
}
else
if
(
x
<0 &&
y
<=0){
218
return
M_PI
+std::asin(abs_sine)-2*
M_PI
;
219
}
else
if
(
x
>=0 &&
y
<0){
220
return
2*
M_PI
-std::asin(abs_sine)-2*
M_PI
;
221
}
else
{
222
//std::cout<< "UtilTools::calc_phi, sin=cos=0" << std::endl;
223
return
0.;
224
}
225
226
}
227
228
229
double
UtilTools :: calc_dphi(
double
phi1,
double
phi2)
const
230
{
231
double
dphi=phi1-phi2;
232
233
if
(dphi >
M_PI
) {
234
dphi -= 2*
M_PI
;
235
}
else
if
(dphi < (-1)*
M_PI
){
236
dphi += 2*
M_PI
;
237
}
238
239
return
dphi;
240
}
241
242
243
double
UtilTools :: average_phi(
double
phi1,
double
phi2)
const
244
{
245
double
phi
= 0.;
246
247
if
(phi1*phi2<0. && std::abs(phi1)>
M_PI
/2.){
248
249
double
tmp1 = (phi1>0.) ? phi1 -
M_PI
: phi1 +
M_PI
;
250
double
tmp2 = (phi2>0.) ? phi2 -
M_PI
: phi2 +
M_PI
;
251
252
double
tmp = (tmp1+tmp2)/2.;
253
254
phi
= (tmp>0.) ? tmp -
M_PI
: tmp +
M_PI
;
255
256
}
else
{
257
258
phi
= (phi1+phi2)/2.;
259
260
}
261
262
return
phi
;
263
}
264
265
266
267
ReturnCode
CscRegDict :: initializeDictionaryForData(){
268
269
return
ReturnCode::SUCCESS
;
270
}
271
272
273
274
ReturnCode
CscRegDict :: initializePosCorrectionParameters(){
275
276
277
return
ReturnCode::SUCCESS
;
278
}
279
280
281
}
//namespace TrigL2MuonSA
M_PI
#define M_PI
Definition
ActiveFraction.h:14
phi
Scalar phi() const
phi method
Definition
AmgMatrixBasePlugin.h:67
theta
Scalar theta() const
theta method
Definition
AmgMatrixBasePlugin.h:75
AthMsgStreamMacros.h
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition
AthMsgStreamMacros.h:29
charge
double charge(const T &p)
Definition
AtlasPID.h:1003
CscRegUtils.h
y
#define y
x
#define x
AthAlgTool::AthAlgTool
AthAlgTool(const std::string &type, const std::string &name, const IInterface *parent)
Constructor with parameters:
Definition
AthAlgTool.cxx:16
TrigL2MuonSA::CscRegDict::stationEta
int stationEta(int hash) const
Definition
CscRegUtils.h:110
TrigL2MuonSA::CscRegDict::nomalVector
Amg::Vector3D nomalVector(int module) const
Definition
CscRegUtils.cxx:174
TrigL2MuonSA::CscRegDict::initializeHashDictionary
ReturnCode initializeHashDictionary()
Definition
CscRegUtils.cxx:157
TrigL2MuonSA::CscRegDict::idealAtanNormal
double idealAtanNormal(int module) const
Definition
CscRegUtils.h:76
TrigL2MuonSA::CscRegDict::PhiConv
double PhiConv(double phi)
Definition
CscRegUtils.cxx:147
TrigL2MuonSA::CscRegDict::m_util
TrigL2MuonSA::UtilTools m_util
Definition
CscRegUtils.h:94
TrigL2MuonSA::CscRegDict::stationPhi
int stationPhi(int hash) const
Definition
CscRegUtils.h:119
TrigL2MuonSA::CscRegDict::m_reg_dict
CscRegion m_reg_dict[32]
Definition
CscRegUtils.h:84
TrigL2MuonSA::CscRegDict::m_module_hashes
int m_module_hashes[2][2][8]
Definition
CscRegUtils.h:85
TrigL2MuonSA::CscRegDict::stationName
int stationName(int hash) const
Definition
CscRegUtils.h:104
TrigL2MuonSA::ReturnCode
Definition
CscRegUtils.h:126
TrigL2MuonSA::ReturnCode::SUCCESS
@ SUCCESS
Definition
CscRegUtils.h:134
Amg::Vector3D
Eigen::Matrix< double, 3, 1 > Vector3D
Definition
GeoPrimitives.h:47
TrigL2MuonSA
Definition
AlignmentBarrelLUT.h:13
type
Generated on
for ATLAS Offline Software by
1.17.0