CMS 3D CMS Logo

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 17 of file BestTracks.h.

References BTrack::AHits, relativeConstraints::cham, BTrack::clctpattern, gather_cfg::cout, edmIntegrityCheck::d, DeltaOutput::Deltas(), BTrack::deltas, cond::serialization::equal(), DeltaOutput::GetMatchOut(), DeltaOutput::GetWinner(), mps_fire::i, ConvertedHit::Id(), gen::k, checklumidiff::l, ALCARECOPromptCalibProdSiPixelAli0T_cff::mode, gen::n, convertSQLitetoXML_cfg::output, AlCaHLTBitMon_ParallelJobs::p, ConvertedHit::Pattern(), stringResolutionProvider_cfi::phi, ConvertedHit::Phi(), DeltaOutput::Phi(), BTrack::phi, MatchingOutput::PhiMatch(), lumiQueryAPI::q, alignCSCRings::r, Winner::Rank(), alignCSCRings::s, relativeConstraints::station, lumiQTWidget::t, ConvertedHit::Theta(), DeltaOutput::Theta(), BTrack::theta, tmp, BTrack::winner, x(), PhOutput::x, and DeltaOutArr2::x.

Referenced by BestTracks_Hold().

17  {
18 
19  bool verbose = false;
20 
21  int larger[12][12] = {{0},{0}}, kill[12] = {0};
22  int exists[12] = {0};
23  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}};
24  int phi[4][3][4], id[4][3][4];
25 
26  for(int r=0;r<4;r++){
27  for(int t=0;t<3;t++){
28  for(int d=0;d<4;d++){
29 
30  phi[r][t][d] = Dout.x[r][t].GetMatchOut().PhiMatch().x[r][t][d].Phi();
31  //if(phi[r][t][d] != -999) std::cout<<"phi = "<<phi[r][t][d]<<"\n";
32  id[r][t][d] = Dout.x[r][t].GetMatchOut().PhiMatch().x[r][t][d].Id();
33  }
34  }
35  }
36 
37  BTrack tmp;
38  std::vector<BTrack> output (3,tmp);
39 
40  for(int zone=0;zone<4;zone++){
41  for(int winner=0;winner<3;winner++){
42  for(int station=0;station<4;station++){
43 
44  int cham = Dout.x[zone][winner].GetMatchOut().PhiMatch().x[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 
82  for(int i=0;i<12;i++){
83 
84  larger[i][i] = 1;//result of comparison with itself
85  int ranki = Dout.x[i%4][i/4].GetWinner().Rank();//the zone loops faster such that each is given equal priority
86 
87  for(int j=0;j<12;j++){
88 
89  int rankj = Dout.x[j%4][j/4].GetWinner().Rank();
90  bool greater = (ranki > rankj);
91  bool equal = (ranki == rankj);
92 
93  if(((i<j) && (greater || equal)) || ((i>j) && greater))
94  larger[i][j] = 1;
95  }
96 
97  exists[i] = (ranki != 0);
98  }
99 
100  // ghost cancelltion. only in current BX so far(as in firmware as well)
101  int vmask[4] = {32,8,2,1};
102  for(int k=0;k<12;k++){
103  for(int l=0;l<12;l++){
104  int sh_seg = 0;
105  for(int s=0;s<4;s++){
106 
107  //if(id[k%4][k/4][s] && (k != l) && ((phi[k%4][k/4][s] != -999) && (phi[l%4][l/4][s] != -999)) && verbose)
108  // 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";
109 
110  if((id[k%4][k/4][s] == id[l%4][l/4][s])
111  && ((phi[k%4][k/4][s] != -999) || (phi[l%4][l/4][s] != -999))
112  && (phi[k%4][k/4][s] == phi[l%4][l/4][s])
113  && (k != l)
114  && (Dout.x[k%4][k/4].GetWinner().Rank() & vmask[s]) //station from track one is valid after deltas
115  && (Dout.x[l%4][l/4].GetWinner().Rank() & vmask[s]) //station from track two is valid after deltas
116  ){
117 
118  sh_seg++;
119  }
120  }
121 
122  if(sh_seg){
123  //kill candidate that has lower rank
124  if(larger[k][l]){kill[l] = 1;}
125  else{kill[k] = 1;}
126  }
127  }
128  }
129 
130  //remove ghosts according to kill array
131  for(int q=0;q<12;q++){
132  if(kill[q]){exists[q] = 0;}
133  }
134 
135  for(int p=0;p<12;p++){
136  if(exists[p]){
137  for(int x=0;x<12;x++){
138  if(!exists[x]){larger[p][x] = 1;}
139  }
140  }
141  else{
142  for(int x=0;x<12;x++){
143  larger[p][x] = 0;
144  }
145  }
146 
147  int sum = 0;
148  for(int j=0;j<12;j++){
149  if(!larger[p][j]){sum++;}
150  }
151 
152  if(sum < 3){winner[sum][p] = 1;}
153  }
154 
155  for(int n=0;n<3;n++){
156  for(int i=0;i<12;i++){
157  if(winner[n][i]){
158 
159  BTrack bests;
160  int mode = 0;
161  if(Dout.x[i%4][i/4].GetWinner().Rank() & 32)
162  mode |= 8;
163  if(Dout.x[i%4][i/4].GetWinner().Rank() & 8)
164  mode |= 4;
165  if(Dout.x[i%4][i/4].GetWinner().Rank() & 2)
166  mode |= 2;
167  if(Dout.x[i%4][i/4].GetWinner().Rank() & 1)
168  mode |= 1;
169 
170  if(verbose) std::cout<<"Best Rank "<<n<<" = "<<Dout.x[i%4][i/4].GetWinner().Rank()<<" and mode = "<<mode<<"\n\n";
171  if(verbose) std::cout<<"Phi = "<<Dout.x[i%4][i/4].Phi()<<" and Theta = "<<Dout.x[i%4][i/4].Theta()<<"\n\n";
172  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]
173  <<" "<<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]
174  <<" "<<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]
175  <<" "<<Dout.x[i%4][i/4].Deltas()[1][4]<<" "<<Dout.x[i%4][i/4].Deltas()[1][5]<<"\n\n";
176 
177  bests.winner = Dout.x[i%4][i/4].GetWinner();
178  bests.phi = Dout.x[i%4][i/4].Phi();
179  bests.theta = Dout.x[i%4][i/4].Theta();
180  bests.deltas = Dout.x[i%4][i/4].Deltas();
181  bests.clctpattern = Dout.x[i%4][i/4].GetMatchOut().PhiMatch().x[i%4][i/4][0].Pattern();
182  bests.AHits.clear();
183  for (int iPh = 0; iPh < 4; iPh++) {
184  if ( Dout.x[i%4][i/4].GetMatchOut().PhiMatch().x[i%4][i/4][iPh].Theta() != -999 &&
185  Dout.x[i%4][i/4].GetMatchOut().PhiMatch().x[i%4][i/4][iPh].Phi() > 0 )
186  bests.AHits.push_back( Dout.x[i%4][i/4].GetMatchOut().PhiMatch().x[i%4][i/4][iPh] );
187  }
188 
189  if (bests.phi != 0 && bests.theta == 0)
190  std::cout << "In BestTracks.h, phi = " << bests.phi << " and theta = " << bests.theta << std::endl;
191 
192  output[n] = bests;
193 
194  }
195  }
196  }
197 
198  return output;
199 
200 }
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
T x() const
Cartesian x coordinate.
std::vector< ConvertedHit > AHits
Winner GetWinner()
int k[5][pyjets_maxn]
DeltaOutput x[4][3]
std::vector< std::vector< double > > tmp
Definition: MVATrainer.cc:100
PhOutput PhiMatch()
std::vector< std::vector< int > > Deltas()
int clctpattern
std::vector<std::vector<BTrack> > BestTracks_Hold ( DeltaOutArr3  Dout)

Definition at line 202 of file BestTracks.h.

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

Referenced by L1TMuonEndCapTrackProducer::produce().

202  {
203 
204  BTrack tmp;
205  std::vector<BTrack> output (3,tmp);
206  std::vector<std::vector<BTrack>> full_output (3,output);
207 
208  for(int bx=0;bx<3;bx++){
209  DeltaOutArr2 Dout2;
210  for(int zone=0;zone<4;zone++){
211  for(int winner=0;winner<3;winner++){
212  Dout2.x[zone][winner] = Dout.x[bx][zone][winner];
213  }
214  }
215  full_output[bx] = BestTracks(Dout2);
216  }
217 
218  return full_output;
219 
220 }
std::vector< BTrack > BestTracks(DeltaOutArr2 Dout)
Definition: BestTracks.h:17
DeltaOutput x[3][4][3]
DeltaOutput x[4][3]
std::vector< std::vector< double > > tmp
Definition: MVATrainer.cc:100