test
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 (DeltaOutArr2 Dout)
 
std::vector< std::vector
< BTrack > > 
BestTracks_Hold (DeltaOutArr3 Dout)
 

Function Documentation

std::vector<BTrack> BestTracks ( DeltaOutArr2  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, gather_cfg::cout, ztail::d, DeltaOutput::Deltas(), BTrack::deltas, cond::serialization::equal(), DeltaOutput::GetMatchOut(), DeltaOutput::GetWinner(), i, ConvertedHit::Id(), j, relval_2017::k, cmsLHEtoEOSManager::l, universalConfigTemplate::mode, gen::n, convertSQLitetoXML_cfg::output, AlCaHLTBitMon_ParallelJobs::p, ConvertedHit::Pattern(), ConvertedHit::Phi(), phi(), DeltaOutput::Phi(), BTrack::phi, MatchingOutput::PhiMatch(), lumiQueryAPI::q, alignCSCRings::r, Winner::Rank(), alignCSCRings::s, relativeConstraints::station, t, ConvertedHit::Theta(), DeltaOutput::Theta(), BTrack::theta, tmp, BTrack::winner, x(), PhOutput::x, and DeltaOutArr2::x.

Referenced by BestTracks_Hold().

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.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 }
int i
Definition: DBlmapReader.cc:9
MatchingOutput GetMatchOut()
int Rank()
ConvertedHit x[4][3][4]
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
Winner GetWinner()
DeltaOutput x[4][3]
Geom::Phi< T > phi() const
std::vector< std::vector< double > > tmp
Definition: MVATrainer.cc:100
PhOutput PhiMatch()
std::vector< std::vector< int > > Deltas()
int clctpattern
tuple cout
Definition: gather_cfg.py:145
std::vector<std::vector<BTrack> > BestTracks_Hold ( DeltaOutArr3  Dout)

Definition at line 198 of file BestTracks.h.

References BestTracks(), convertSQLitetoXML_cfg::output, tmp, DeltaOutArr2::x, and DeltaOutArr3::x.

Referenced by L1TMuonEndCapTrackProducer::produce().

198  {
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 }
std::vector< BTrack > BestTracks(DeltaOutArr2 Dout)
Definition: BestTracks.h:13
DeltaOutput x[3][4][3]
DeltaOutput x[4][3]
std::vector< std::vector< double > > tmp
Definition: MVATrainer.cc:100