CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
Functions
BestTracks.h File Reference
#include "L1Trigger/L1TMuonEndCap/interface/EmulatorClasses.h"

Go to the source code of this file.

Functions

std::vector< BTrackBestTracks (std::vector< std::vector< DeltaOutput >> Dout)
 

Function Documentation

std::vector<BTrack> BestTracks ( std::vector< std::vector< DeltaOutput >>  Dout)

Here we compare the best three ranks from each zone with each other

Definition at line 13 of file BestTracks.h.

References BTrack::AHits, relativeConstraints::cham, BTrack::clctpattern, ztail::d, BTrack::deltas, cond::serialization::equal(), i, j, relval_2017::k, cmsLHEtoEOSManager::l, gen::n, convertSQLitetoXML_cfg::output, AlCaHLTBitMon_ParallelJobs::p, phi(), BTrack::phi, lumiQueryAPI::q, alignCSCRings::r, alignCSCRings::s, relativeConstraints::station, lumiQTWidget::t, BTrack::theta, tmp, BTrack::winner, and x().

Referenced by L1TMuonEndCapTrackProducer::produce().

13  {
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[r][t].GetMatchOut().PhiMatch()[r][t][d].Phi();
27  id[r][t][d] = Dout[r][t].GetMatchOut().PhiMatch()[r][t][d].Id();
28  }
29  }
30  }
31 
32  BTrack tmp;
33  std::vector<BTrack> output (3,tmp);
34 
35 
36 
37  for(int zone=0;zone<4;zone++){
38 
39  for(int winner=0;winner<3;winner++){
40 
41  for(int station=0;station<4;station++){
42 
43 
44  int cham = Dout[zone][winner].GetMatchOut().PhiMatch()[zone][winner][station].Id();
45  //int relst = 0;
46  int relch = 0;
47 
48  if(station == 0){
49 
50  //relst = (cham < 3) ? 0 : 1;
51  relch = cham%3;
52  if(zone == 2)
53  relch += 3;
54  if(zone == 3)
55  relch += 6;
56  }
57  else if(station == 1){
58 
59  //relst = station + 1;
60  relch = cham;
61  if(zone > 1)
62  relch += 3;
63  }
64  else{
65 
66  //relst = station + 1;
67  relch = cham;
68  if(zone > 0)
69  relch += 3;
70  }
71 
72  //phi[zone][winner][relst] = phi[zone][winner][station];
73  //id[zone][winner][relst] = id[zone][winner][station];
74 
75  //if(phi[zone][winner][relst] != -999 && verbose)
76  // std::cout<<"st:"<<relst<<"::real phi = "<<phi[zone][winner][relst]<<" and id = "<<id[zone][winner][relst]<<std::endl;
77 
78  }
79  }
80  }
81 
82 
83 
85  for(int i=0;i<12;i++){
86 
87  larger[i][i] = 1;//result of comparison with itself
88  int ranki = Dout[i%4][i/4].GetWinner().Rank();//the zone loops faster such that each is given equal priority
89 
90 
91  for(int j=0;j<12;j++){
92 
93  int rankj = Dout[j%4][j/4].GetWinner().Rank();
94  bool greater = (ranki > rankj);
95  bool equal = (ranki == rankj);
96 
97  if(((i<j) && (greater || equal)) || ((i>j) && greater))
98  larger[i][j] = 1;
99  }
100 
101  exists[i] = (ranki != 0);
102  }
103 
104 
105 
106  // ghost cancelltion. only in current BX so far(as in firmware as well)
107  for(int k=0;k<12;k++){
108 
109  for(int l=0;l<12;l++){
110 
111  int sh_seg = 0;
112 
113 
114  for(int s=0;s<4;s++){
115 
116  //if(id[k%4][k/4][s] && (k != l) && ((phi[k%4][k/4][s] != -999) && (phi[l%4][l/4][s] != -999)) && verbose)
117  // 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";
118 
119  if((id[k%4][k/4][s] == id[l%4][l/4][s])
120  && ((phi[k%4][k/4][s] != -999) || (phi[l%4][l/4][s] != -999))
121  && (phi[k%4][k/4][s] == phi[l%4][l/4][s])
122  && (k != l)
123  ){
124 
125  sh_seg++;
126  }
127 
128 
129  }
130 
131  if(sh_seg){
132 
133  //kill candidate that has lower rank
134  //if(verbose) std::cout<<"\nsh_seg != 0\nk = "<<k<<" and l = "<<l<<"\n";
135  if(larger[k][l]){kill[l] = 1;}
136  else{kill[k] = 1;}
137  }
138 
139  }
140  }
141 
142 
143  //remove ghosts according to kill array
144  for(int q=0;q<12;q++){
145 
146  if(kill[q]){exists[q] = 0;}
147  }
148 
149 
150  for(int p=0;p<12;p++){
151 
152  if(exists[p]){
153 
154  for(int x=0;x<12;x++){
155 
156  if(!exists[x]){larger[p][x] = 1;}
157  }
158  }
159  else{
160 
161  for(int x=0;x<12;x++){
162 
163  larger[p][x] = 0;
164  }
165  }
166 
167  int sum = 0;
168  for(int j=0;j<12;j++){
169 
170  if(!larger[p][j]){sum++;}
171  }
172 
173  if(sum < 3){winner[sum][p] = 1;}
174  }
175 
176  for(int n=0;n<3;n++){
177 
178  for(int i=0;i<12;i++){
179 
180  if(winner[n][i]){
181 
182  BTrack bests;
183 
184  //if(verbose) std::cout<<"Best Rank "<<n<<" = "<<Dout[i%4][i/4].GetWinner().Rank()<<"\n\n";
185  //if(verbose) std::cout<<"Phi = "<<Dout[i%4][i/4].Phi()<<" and Theta = "<<Dout[i%4][i/4].Theta()<<"\n\n";
186  //if(verbose) std::cout<<"Ph Deltas: "<<Dout[i%4][i/4].Deltas()[0][0]<<" "<<Dout[i%4][i/4].Deltas()[0][1]<<" Th Deltas: "<<Dout[i%4][i/4].Deltas()[1][0]
187  // <<" "<<Dout[i%4][i/4].Deltas()[1][1]<<"\n\n";
188 
189  bests.winner = Dout[i%4][i/4].GetWinner();
190  bests.phi = Dout[i%4][i/4].Phi();
191  bests.theta = Dout[i%4][i/4].Theta();
192  bests.deltas = Dout[i%4][i/4].Deltas();
193  bests.clctpattern = Dout[i%4][i/4].GetMatchOut().PhiMatch()[i%4][i/4][0].Pattern();
194  bests.AHits = Dout[i%4][i/4].GetMatchOut().PhiMatch()[i%4][i/4];
195 
196  output[n] = bests;
197 
198  }
199  }
200  }
201 
202 
203 
204 
205 
206  return output;
207 
208 
209 }
int i
Definition: DBlmapReader.cc:9
Winner winner
bool equal(const T &first, const T &second)
Definition: Equal.h:34
std::vector< std::vector< int > > deltas
tuple d
Definition: ztail.py:151
T x() const
Cartesian x coordinate.
std::vector< ConvertedHit > AHits
int j
Definition: DBlmapReader.cc:9
Geom::Phi< T > phi() const
std::vector< std::vector< double > > tmp
Definition: MVATrainer.cc:100
int clctpattern