CMS 3D CMS Logo

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

Go to the source code of this file.

Functions

MatchingOutput PhiMatching (SortingOutput Sout)
 
std::vector< MatchingOutputPhiMatching_Hold (std::vector< SortingOutput > Sout)
 

Function Documentation

MatchingOutput PhiMatching ( SortingOutput  Sout)

Is the converted hit in the zone we're looking at now?

Definition at line 16 of file Matching.h.

References rpcdqm::BX, ConvertedHit::BX(), gather_cfg::cout, SortingOutput::Hits(), i, ConvertedHit::Id(), ConvertedHit::IsNeighbor(), convertSQLitetoXML_cfg::output, colinearityKinematic::Phi, ConvertedHit::Phi(), MatchingOutput::setM2(), ConvertedHit::SetNull(), MatchingOutput::SetValues(), align::Strip, groupFilesInBlocks::tt, w, SortingOutput::Winners(), ThOutput2::x, PhOutput::x, and detailsBasic3DVector::z.

Referenced by PhiMatching_Hold().

16  {
17 
18  bool verbose = false;
19 
20  std::vector<ConvertedHit> Thits = Sout.Hits();
21  std::vector<std::vector<Winner>> Winners = Sout.Winners();
22  std::vector<int> segment (4,0);
23  int phdiff[4] = {15,7,7,7};
24 
28  ConvertedHit tt; tt.SetNull();
29  PhOutput ph_output = { {{{tt}}} };
30  ThOutput2 th_output2 = { {{{{-999}}}} };
31  ThOutput th_output = { {{{{tt}}}} };
32 
36 
37  for(int z=0;z<4;z++){//zone loop
38 
39  for(int w=0;w<3;w++){//winner loop
40 
41  if(Winners[z][w].Rank()){//is there a winner present?
42 
43  if(verbose) std::cout<<"\n\nWinner position-"<<Winners[z][w].Strip()<<". Zone = "<<z<<std::endl;
44  if(verbose) std::cout<<"Number of possible hits to match = "<<Thits.size()<<"\n";
45 
46  //for(std::vector<ConvertedHit>::iterator i = Thits.begin();i != Thits.end();i++){//Possible associated hits
47  for(unsigned int i=0;i<Thits.size();i++){//Possible associated hits
48 
49  int zmask[4] {1,2,4,8};
50  bool inzone = false;
51  if(Thits[i].ZoneWord() & zmask[z]) inzone = true;
52 
53  bool inBXgroup = false;
54 
55  switch(Winners[z][w].BXGroup()){
56 
57  case 1: if(Thits[i].BX() > 3 && Thits[i].BX() < 7) inBXgroup = true;break;
58  case 2: if(Thits[i].BX() > 4 && Thits[i].BX() < 8) inBXgroup = true;break;
59  case 3: if(Thits[i].BX() > 5 && Thits[i].BX() < 9) inBXgroup = true;break;
60  default: inBXgroup = false;
61 
62  }
63 
67  int setstation = Thits[i].Station() - 1;
68  bool setphi = false;
69 
70  if(verbose)
71  std::cout<<"setstation = "<<setstation<<std::endl;
72 
73  //if(verbose){
74 
75  // std::cout<<"Winners[z][w].Strip(): "<<Winners[z][w].Strip()<<" + 1 - Thits[i].Zhit():"<<Thits[i].Zhit()<<" = "<<(Winners[z][w].Strip() + 1) - Thits[i].Zhit()<<". Thits[i].Phi()>>5 = "<<(Thits[i].Phi() >> 5)<<"\n";
76  //}
77 
78  if((fabs(Winners[z][w].Strip() - (Thits[i].Phi()>>5)) <= phdiff[setstation]) && inBXgroup && inzone){//is close to winner keystrip and in same zone?
79 
80  if(ph_output.x[z][w][setstation].Phi() == -999){//has this already been set? no
81 
82  if(verbose) std::cout<<"hasn't been set"<<std::endl;
83 
84  ph_output.x[z][w][setstation] = (Thits[i]);
85 
86  if(verbose) std::cout<<"set with strip-"<<Thits[i].Strip()<<", and wire-"<<Thits[i].Wire()<<std::endl;
87  setphi = true;
88  }
89  else{//if yes, find absolute difference between zhit of each hit and keystrip
90 
91  if(verbose) std::cout<<"has already been set"<<std::endl;
92 
93  int d1 = fabs((ph_output.x[z][w][setstation].Phi()>>5) - Winners[z][w].Strip());
94  int d2 = fabs((Thits[i].Phi()>>5) - Winners[z][w].Strip());
95 
96  if(verbose) std::cout<<"d1 = "<<d1<<" and d2 = "<<d2<<"\n";
97 
98  if(d2 < d1){//if new hit is closer then replace phi
99 
100  if(verbose) std::cout<<"this is closer strip-"<<Thits[i].Strip()<<", and wire-"<<Thits[i].Wire()<<std::endl;
101 
102  ph_output.x[z][w][setstation] = (Thits[i]);
103 
104  setphi = true;
105 
106  }
107 
108  if (d2 == d1) {
109  if (Thits[i].BX() < ph_output.x[z][w][setstation].BX()) {
110  ph_output.x[z][w][setstation] = (Thits[i]);
111  setphi = true;
112  }
113  else if (Thits[i].IsNeighbor() && !ph_output.x[z][w][setstation].IsNeighbor()) {
114  ph_output.x[z][w][setstation] = (Thits[i]);
115  setphi = true;
116  }
117  else if ((Thits[i].IsNeighbor() == ph_output.x[z][w][setstation].IsNeighbor()) && (Thits[i].Id() < ph_output.x[z][w][setstation].Id())) {
118  ph_output.x[z][w][setstation] = (Thits[i]);
119  setphi = true;
120  }
121  }
122  }
123 
127 
128  //if((th_output.x[z][w][setstation][0].Theta() != -999) && (th_output.x[z][w][setstation][0].Id() == Thits[i].Id())){//if same chamber take as well
129  // th_output.x[z][w][setstation][1] = (Thits[i]);
130  // if(verbose) std::cout<<"in here with set th = "<<th_output.x[z][w][setstation][0].Theta()<<" and new th = "<<Thits[i].Theta()<<"\n";
131  // }
132 
133  if(setphi){//only set if phi was also set
134 
135  th_output2.x[z][w][setstation][0] = Thits[i].Theta();
136 
137  /*if(th_output.x[z][w][setstation][0].Theta() == -999){
138  th_output.x[z][w][setstation][0] = (Thits[i]);
139  }
140  else if((th_output.x[z][w][setstation][0].Theta() != -999) && (th_output.x[z][w][setstation][0].Id() == Thits[i].Id())){//if same chamber take as well
141  th_output.x[z][w][setstation][1] = (Thits[i]);
142  if(verbose) std::cout<<"in here with set th = "<<th_output.x[z][w][setstation][0].Theta()<<" and new th = "<<Thits[i].Theta()<<"\n";
143  }*/
144 
145  //if((th_output.x[z][w][setstation][0].Theta() != -999) && (th_output.x[z][w][setstation][0].Id() == Thits[i].Id())){//if same chamber take as well
146  // th_output.x[z][w][setstation][1] = (Thits[i]);
147  // if(verbose) std::cout<<"in here with set th = "<<th_output.x[z][w][setstation][0].Theta()<<" and new th = "<<Thits[i].Theta()<<"\n";
148  //}
149  //else{
150  // th_output.x[z][w][setstation][0] = (Thits[i]);
151 
152  if(Thits[i].Theta2() != -999)
153  th_output2.x[z][w][setstation][1] = Thits[i].Theta2();
154  //}
155 
156  }
157 
158  }
159  }
160 
161  }
162 
163  }
164  }
165 
167  output.SetValues(th_output,ph_output,Thits,Winners,segment);
168  output.setM2(th_output2);
169 
170  return output;
171 }
int i
Definition: DBlmapReader.cc:9
const double w
Definition: UKUtility.cc:23
ConvertedHit x[4][3][4]
float float float z
std::vector< std::vector< Winner > > Winners()
void SetValues(ThOutput th_output, PhOutput ph_output, std::vector< ConvertedHit > hits, std::vector< std::vector< Winner >> winners, std::vector< int > segment)
void setM2(ThOutput2 t2)
int x[4][3][4][2]
tuple cout
Definition: gather_cfg.py:145
std::vector< ConvertedHit > Hits()
std::vector<MatchingOutput> PhiMatching_Hold ( std::vector< SortingOutput Sout)

Definition at line 173 of file Matching.h.

References gather_cfg::cout, i, convertSQLitetoXML_cfg::output, PhiMatching(), and tmp.

Referenced by L1TMuonEndCapTrackProducer::produce().

173  {
174 
176  std::vector<MatchingOutput> output (3,tmp);
177 
178  if(Sout.size() != 3)
179  std::cout<<"Incorrect BX window size for sorting output. Please check to see why.\n";
180 
181  for(int i=0;i<3;i++){
182  output[i] = PhiMatching(Sout[i]);
183  }
184 
185  return output;
186 }
int i
Definition: DBlmapReader.cc:9
MatchingOutput PhiMatching(SortingOutput Sout)
Definition: Matching.h:16
std::vector< std::vector< double > > tmp
Definition: MVATrainer.cc:100
tuple cout
Definition: gather_cfg.py:145