test
Main Page
Namespaces
Classes
Package Documentation
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Properties
Friends
Macros
Pages
L1Trigger
L1TMuonEndCap
interface
BestTracks.h
Go to the documentation of this file.
1
/*
2
Takes in the output of Deltas module and sorts to find
3
three best tracks per given sector.
4
5
6
Author: Matthew R. Carver
7
Date: 7/29/13
8
*/
9
10
#include "
L1Trigger/L1TMuonEndCap/interface/EmulatorClasses.h
"
11
12
13
std::vector<BTrack>
BestTracks
(
DeltaOutArr2
Dout){
14
15
bool
verbose
=
false
;
16
17
int
larger[12][12] = {{0},{0}}, kill[12] = {0};
18
int
exists[12] = {0};
19
int
winner[3][12] = {{0,0,0,0,0,0,0,0,0,0,0,0},{0,0,0,0,0,0,0,0,0,0,0,0},{0,0,0,0,0,0,0,0,0,0,0,0}};
20
int
phi
[4][3][4],
id
[4][3][4];
21
22
for
(
int
r
=0;
r
<4;
r
++){
23
for
(
int
t
=0;
t
<3;
t
++){
24
for
(
int
d
=0;
d
<4;
d
++){
25
26
phi[
r
][
t
][
d
] = Dout.
x
[
r
][
t
].
GetMatchOut
().
PhiMatch
().
x
[
r
][
t
][
d
].
Phi
();
27
//if(phi[r][t][d] != -999) std::cout<<"phi = "<<phi[r][t][d]<<"\n";
28
id
[
r
][
t
][
d
] = Dout.
x
[
r
][
t
].
GetMatchOut
().
PhiMatch
().
x
[
r
][
t
][
d
].
Id
();
29
}
30
}
31
}
32
33
BTrack
tmp
;
34
std::vector<BTrack>
output
(3,tmp);
35
36
for
(
int
zone=0;zone<4;zone++){
37
for
(
int
winner=0;winner<3;winner++){
38
for
(
int
station
=0;
station
<4;
station
++){
39
40
int
cham
= Dout.
x
[zone][winner].
GetMatchOut
().
PhiMatch
().
x
[zone][winner][
station
].
Id
();
41
//int relst = 0;
42
int
relch = 0;
43
44
if
(
station
== 0){
45
46
//relst = (cham < 3) ? 0 : 1;
47
relch = cham%3;
48
if
(zone == 2)
49
relch += 3;
50
if
(zone == 3)
51
relch += 6;
52
}
53
else
if
(
station
== 1){
54
55
//relst = station + 1;
56
relch =
cham
;
57
if
(zone > 1)
58
relch += 3;
59
}
60
else
{
61
62
//relst = station + 1;
63
relch =
cham
;
64
if
(zone > 0)
65
relch += 3;
66
}
67
68
//phi[zone][winner][relst] = phi[zone][winner][station];
69
//id[zone][winner][relst] = id[zone][winner][station];
70
71
//if(phi[zone][winner][relst] != -999 && verbose)
72
// std::cout<<"st:"<<relst<<"::real phi = "<<phi[zone][winner][relst]<<" and id = "<<id[zone][winner][relst]<<std::endl;
73
}
74
}
75
}
76
78
for
(
int
i
=0;
i
<12;
i
++){
79
80
larger[
i
][
i
] = 1;
//result of comparison with itself
81
int
ranki = Dout.
x
[
i
%4][
i
/4].
GetWinner
().
Rank
();
//the zone loops faster such that each is given equal priority
82
83
for
(
int
j
=0;
j
<12;
j
++){
84
85
int
rankj = Dout.
x
[
j
%4][
j
/4].
GetWinner
().
Rank
();
86
bool
greater = (ranki > rankj);
87
bool
equal
= (ranki == rankj);
88
89
if
(((
i
<
j
) && (greater ||
equal
)) || ((
i
>
j
) && greater))
90
larger[
i
][
j
] = 1;
91
}
92
93
exists[
i
] = (ranki != 0);
94
}
95
96
// ghost cancelltion. only in current BX so far(as in firmware as well)
97
int
vmask[4] = {32,8,2,1};
98
for
(
int
k
=0;
k
<12;
k
++){
99
for
(
int
l
=0;
l
<12;
l
++){
100
int
sh_seg = 0;
101
for
(
int
s
=0;
s
<4;
s
++){
102
103
//if(id[k%4][k/4][s] && (k != l) && ((phi[k%4][k/4][s] != -999) && (phi[l%4][l/4][s] != -999)) && verbose)
104
// std::cout<<"id1 = "<<id[k%4][k/4][s]<<", id2 = "<<id[l%4][l/4][s]<<"\nphi1 = "<<phi[k%4][k/4][s]<<", phi1 = "<<phi[l%4][l/4][s]<<".\n";
105
106
if
((
id
[
k
%4][
k
/4][
s
] ==
id
[
l
%4][
l
/4][
s
])
107
&& ((phi[
k
%4][
k
/4][
s
] != -999) || (phi[
l
%4][
l
/4][
s
] != -999))
108
&& (phi[
k
%4][
k
/4][
s
] == phi[
l
%4][
l
/4][
s
])
109
&& (
k
!=
l
)
110
&& (Dout.
x
[
k
%4][
k
/4].
GetWinner
().
Rank
() & vmask[
s
])
//station from track one is valid after deltas
111
&& (Dout.
x
[
l
%4][
l
/4].
GetWinner
().
Rank
() & vmask[
s
])
//station from track two is valid after deltas
112
){
113
114
sh_seg++;
115
}
116
}
117
118
if
(sh_seg){
119
//kill candidate that has lower rank
120
if
(larger[
k
][
l
]){kill[
l
] = 1;}
121
else
{kill[
k
] = 1;}
122
}
123
}
124
}
125
126
//remove ghosts according to kill array
127
for
(
int
q
=0;
q
<12;
q
++){
128
if
(kill[
q
]){exists[
q
] = 0;}
129
}
130
131
for
(
int
p
=0;
p
<12;
p
++){
132
if
(exists[
p
]){
133
for
(
int
x
=0;
x
<12;
x
++){
134
if
(!exists[
x
]){larger[
p
][
x
] = 1;}
135
}
136
}
137
else
{
138
for
(
int
x
=0;
x
<12;
x
++){
139
larger[
p
][
x
] = 0;
140
}
141
}
142
143
int
sum = 0;
144
for
(
int
j
=0;
j
<12;
j
++){
145
if
(!larger[p][
j
]){sum++;}
146
}
147
148
if
(sum < 3){winner[sum][
p
] = 1;}
149
}
150
151
for
(
int
n
=0;
n
<3;
n
++){
152
for
(
int
i
=0;
i
<12;
i
++){
153
if
(winner[
n
][
i
]){
154
155
BTrack
bests;
156
int
mode
= 0;
157
if
(Dout.
x
[i%4][i/4].
GetWinner
().
Rank
() & 32)
158
mode |= 8;
159
if
(Dout.
x
[i%4][i/4].
GetWinner
().
Rank
() & 8)
160
mode |= 4;
161
if
(Dout.
x
[i%4][i/4].
GetWinner
().
Rank
() & 2)
162
mode |= 2;
163
if
(Dout.
x
[i%4][i/4].
GetWinner
().
Rank
() & 1)
164
mode |= 1;
165
166
if
(verbose)
std::cout
<<
"Best Rank "
<<
n
<<
" = "
<<Dout.
x
[i%4][i/4].
GetWinner
().
Rank
()<<
" and mode = "
<<mode<<
"\n\n"
;
167
if
(verbose)
std::cout
<<
"Phi = "
<<Dout.
x
[i%4][i/4].
Phi
()<<
" and Theta = "
<<Dout.
x
[i%4][i/4].
Theta
()<<
"\n\n"
;
168
if
(verbose)
std::cout
<<
"Ph Deltas: "
<<Dout.
x
[i%4][i/4].
Deltas
()[0][0]<<
" "
<<Dout.
x
[i%4][i/4].
Deltas
()[0][1]<<
" "
<<Dout.
x
[i%4][i/4].
Deltas
()[0][2]<<
" "
<<Dout.
x
[i%4][i/4].
Deltas
()[0][3]
169
<<
" "
<<Dout.
x
[i%4][i/4].
Deltas
()[0][4]<<
" "
<<Dout.
x
[i%4][i/4].
Deltas
()[0][5]<<
" \nTh Deltas: "
<<Dout.
x
[i%4][i/4].
Deltas
()[1][0]
170
<<
" "
<<Dout.
x
[i%4][i/4].
Deltas
()[1][1]<<
" "
<<Dout.
x
[i%4][i/4].
Deltas
()[1][2]<<
" "
<<Dout.
x
[i%4][i/4].
Deltas
()[1][3]
171
<<
" "
<<Dout.
x
[i%4][i/4].
Deltas
()[1][4]<<
" "
<<Dout.
x
[i%4][i/4].
Deltas
()[1][5]<<
"\n\n"
;
172
173
bests.
winner
= Dout.
x
[i%4][i/4].
GetWinner
();
174
bests.
phi
= Dout.
x
[i%4][i/4].
Phi
();
175
bests.
theta
= Dout.
x
[i%4][i/4].
Theta
();
176
bests.
deltas
= Dout.
x
[i%4][i/4].
Deltas
();
177
bests.
clctpattern
= Dout.
x
[i%4][i/4].
GetMatchOut
().
PhiMatch
().
x
[i%4][i/4][0].
Pattern
();
178
bests.
AHits
.clear();
179
for
(
int
iPh = 0; iPh < 4; iPh++) {
180
if
( Dout.
x
[i%4][i/4].
GetMatchOut
().
PhiMatch
().
x
[i%4][i/4][iPh].
Theta
() != -999 &&
181
Dout.
x
[i%4][i/4].
GetMatchOut
().
PhiMatch
().
x
[i%4][i/4][iPh].
Phi
() > 0 )
182
bests.
AHits
.push_back( Dout.
x
[i%4][i/4].
GetMatchOut
().
PhiMatch
().
x
[i%4][i/4][iPh] );
183
}
184
185
if
(bests.
phi
!= 0 && bests.
theta
== 0)
186
std::cout
<<
"In BestTracks.h, phi = "
<< bests.
phi
<<
" and theta = "
<< bests.
theta
<< std::endl;
187
188
output[
n
] = bests;
189
190
}
191
}
192
}
193
194
return
output
;
195
196
}
197
198
std::vector<std::vector<BTrack>>
BestTracks_Hold
(
DeltaOutArr3
Dout){
199
200
BTrack
tmp
;
201
std::vector<BTrack>
output
(3,tmp);
202
std::vector<std::vector<BTrack>> full_output (3,output);
203
204
for
(
int
bx=0;bx<3;bx++){
205
DeltaOutArr2
Dout2;
206
for
(
int
zone=0;zone<4;zone++){
207
for
(
int
winner=0;winner<3;winner++){
208
Dout2.
x
[zone][winner] = Dout.
x
[bx][zone][winner];
209
}
210
}
211
full_output[bx] =
BestTracks
(Dout2);
212
}
213
214
return
full_output;
215
216
}
217
i
int i
Definition:
DBlmapReader.cc:9
DeltaOutput::GetMatchOut
MatchingOutput GetMatchOut()
Definition:
EmulatorClasses.h:181
Winner::Rank
int Rank()
Definition:
EmulatorClasses.h:96
DeltaOutArr2
Definition:
EmulatorClasses.h:195
BestTracks
std::vector< BTrack > BestTracks(DeltaOutArr2 Dout)
Definition:
BestTracks.h:13
verbose
Definition:
MagVerbosity.h:13
PhOutput::x
ConvertedHit x[4][3][4]
Definition:
EmulatorClasses.h:135
relval_2017.k
list k
Definition:
relval_2017.py:21
DeltaOutArr3::x
DeltaOutput x[3][4][3]
Definition:
EmulatorClasses.h:196
lumiQueryAPI.q
tuple q
Definition:
lumiQueryAPI.py:1839
ConvertedHit::Phi
int Phi()
Definition:
EmulatorClasses.h:45
BTrack::winner
Winner winner
Definition:
EmulatorClasses.h:202
cmsLHEtoEOSManager.l
tuple l
Definition:
cmsLHEtoEOSManager.py:192
cond::serialization::equal
bool equal(const T &first, const T &second)
Definition:
Equal.h:34
BTrack::deltas
std::vector< std::vector< int > > deltas
Definition:
EmulatorClasses.h:206
universalConfigTemplate.mode
mode
Definition:
universalConfigTemplate.py:80
ztail.d
tuple d
Definition:
ztail.py:151
BTrack::phi
int phi
Definition:
EmulatorClasses.h:203
x
T x() const
Cartesian x coordinate.
Definition:
Basic3DVectorLD.h:127
ConvertedHit::Id
int Id()
Definition:
EmulatorClasses.h:52
relativeConstraints.station
tuple station
Definition:
relativeConstraints.py:66
BTrack::AHits
std::vector< ConvertedHit > AHits
Definition:
EmulatorClasses.h:207
DeltaOutput::Theta
int Theta()
Definition:
EmulatorClasses.h:184
ConvertedHit::Theta
int Theta()
Definition:
EmulatorClasses.h:46
j
int j
Definition:
DBlmapReader.cc:9
EmulatorClasses.h
BTrack
Definition:
EmulatorClasses.h:198
DeltaOutput::GetWinner
Winner GetWinner()
Definition:
EmulatorClasses.h:185
BTrack::theta
int theta
Definition:
EmulatorClasses.h:204
convertSQLitetoXML_cfg.output
tuple output
Definition:
convertSQLitetoXML_cfg.py:32
relativeConstraints.cham
tuple cham
Definition:
relativeConstraints.py:68
DeltaOutArr2::x
DeltaOutput x[4][3]
Definition:
EmulatorClasses.h:195
alignCSCRings.s
list s
Definition:
alignCSCRings.py:91
gen::n
int n
Definition:
Cascade2Hadronizer.cc:79
phi
Geom::Phi< T > phi() const
Definition:
Basic3DVectorLD.h:163
t
t
Definition:
TrackingNtuple.cc:717
AlCaHLTBitMon_ParallelJobs.p
tuple p
Definition:
AlCaHLTBitMon_ParallelJobs.py:152
tmp
std::vector< std::vector< double > > tmp
Definition:
MVATrainer.cc:100
MatchingOutput::PhiMatch
PhOutput PhiMatch()
Definition:
EmulatorClasses.h:160
BestTracks_Hold
std::vector< std::vector< BTrack > > BestTracks_Hold(DeltaOutArr3 Dout)
Definition:
BestTracks.h:198
alignCSCRings.r
list r
Definition:
alignCSCRings.py:92
DeltaOutput::Deltas
std::vector< std::vector< int > > Deltas()
Definition:
EmulatorClasses.h:182
BTrack::clctpattern
int clctpattern
Definition:
EmulatorClasses.h:205
gather_cfg.cout
tuple cout
Definition:
gather_cfg.py:145
ConvertedHit::Pattern
int Pattern()
Definition:
EmulatorClasses.h:54
DeltaOutArr3
Definition:
EmulatorClasses.h:196
DeltaOutput::Phi
int Phi()
Definition:
EmulatorClasses.h:183
Generated for CMSSW Reference Manual by
1.8.5