CMS 3D CMS Logo

L1TMuonBarrelKalmanSectorProcessor.cc
Go to the documentation of this file.
2 
3 
4 
6  verbose_(iConfig.getParameter<int>("verbose")),
7  sector_(sector)
8 {
9  std::vector<int> wheels = iConfig.getParameter<std::vector<int> >("wheelsToProcess");
10  for (const auto wheel : wheels)
11  regions_.push_back(L1TMuonBarrelKalmanRegionModule(iConfig.getParameter<edm::ParameterSet>("regionSettings"),wheel,sector));
12 }
13 
14 
15 
17 
19 
20 
21  L1MuKBMTrackCollection tracksM2;
22  L1MuKBMTrackCollection tracksM1;
23  L1MuKBMTrackCollection tracks0;
24  L1MuKBMTrackCollection tracksP1;
25  L1MuKBMTrackCollection tracksP2;
26 
27  for (auto& region: regions_) {
28  L1MuKBMTrackCollection tmp = region.process(trackMaker,stubsAll,bx);
29  if (region.wheel()==-2)
30  tracksM2.insert(tracksM2.end(),tmp.begin(),tmp.end());
31  if (region.wheel()==-1)
32  tracksM1.insert(tracksM1.end(),tmp.begin(),tmp.end());
33  if (region.wheel()==0)
34  tracks0.insert(tracks0.end(),tmp.begin(),tmp.end());
35  if (region.wheel()==1)
36  tracksP1.insert(tracksP1.end(),tmp.begin(),tmp.end());
37  if (region.wheel()==2)
38  tracksP2.insert(tracksP2.end(),tmp.begin(),tmp.end());
39 
40  }
41 
42  L1MuKBMTrackCollection out =wedgeSort(tracksM2,tracksM1,tracks0,tracksP1,tracksP2);
43  if (verbose_==1)
44  verbose(trackMaker,out);
45 
46  return out;
47 
48 }
49 
50 
51 
52 
55  out.pt_1=0;
56  out.qual_1=0;
57  out.eta_1=0;
58  out.HF_1=0;
59  out.phi_1=0;
60  out.bx0_1=0;
61  out.charge_1=0;
62  out.chargeValid_1=0;
63  out.dxy_1=0;
64  out.addr1_1=3;
65  out.addr2_1=15;
66  out.addr3_1=15;
67  out.addr4_1=15;
68  out.reserved_1=0;
69  out.wheel_1=0;
70  out.ptSTA_1=0;
71  out.SE_1=0;
72 
73  out.pt_2=0;
74  out.qual_2=0;
75  out.eta_2=0;
76  out.HF_2=0;
77  out.phi_2=0;
78  out.bx0_2=0;
79  out.charge_2=0;
80  out.chargeValid_2=0;
81  out.dxy_2=0;
82  out.addr1_2=3;
83  out.addr2_2=15;
84  out.addr3_2=15;
85  out.addr4_2=15;
86  out.reserved_2=0;
87  out.wheel_2=0;
88  out.ptSTA_2=0;
89  out.SE_2=0;
90 
91  out.pt_3=0;
92  out.qual_3=0;
93  out.eta_3=0;
94  out.HF_3=0;
95  out.phi_3=0;
96  out.bx0_3=0;
97  out.charge_3=0;
98  out.chargeValid_3=0;
99  out.dxy_3=0;
100  out.addr1_3=3;
101  out.addr2_3=15;
102  out.addr3_3=15;
103  out.addr4_3=15;
104  out.reserved_3=0;
105  out.wheel_3=0;
106  out.ptSTA_3=0;
107  out.SE_3=0;
108 
109  if (!tracks.empty()) {
110  l1t::RegionalMuonCand mu = trackMaker->convertToBMTF(tracks[0]);
111  out.pt_1=mu.hwPt();
112  out.qual_1=mu.hwQual();
113  out.eta_1=mu.hwEta();
114  out.HF_1=mu.hwHF();
115  out.phi_1=mu.hwPhi();
116  out.bx0_1=0;
117  out.charge_1=mu.hwSign();
118  out.chargeValid_1=mu.hwSignValid();
119  out.dxy_1=mu.hwDXY();
125  out.ptSTA_1=mu.hwPt2();
126  }
127 
128  if (tracks.size()>1) {
129  l1t::RegionalMuonCand mu = trackMaker->convertToBMTF(tracks[1]);
130  out.pt_2=mu.hwPt();
131  out.qual_2=mu.hwQual();
132  out.eta_2=mu.hwEta();
133  out.HF_2=mu.hwHF();
134  out.phi_2=mu.hwPhi();
135  out.bx0_2=0;
136  out.charge_2=mu.hwSign();
137  out.chargeValid_2=mu.hwSignValid();
138  out.dxy_2=mu.hwDXY();
144 
145 
146  out.ptSTA_2=mu.hwPt2();
147  }
148 
149  if (tracks.size()>2) {
150  l1t::RegionalMuonCand mu = trackMaker->convertToBMTF(tracks[2]);
151  out.pt_3=mu.hwPt();
152  out.qual_3=mu.hwQual();
153  out.eta_3=mu.hwEta();
154  out.HF_3=mu.hwHF();
155  out.phi_3=mu.hwPhi();
156  out.bx0_3=0;
157  out.charge_3=mu.hwSign();
158  out.chargeValid_3=mu.hwSignValid();
159  out.dxy_3=mu.hwDXY();
165  out.ptSTA_3=mu.hwPt2();
166  }
167  return out;
168 
169 }
170 
171 
172 
173 
174 
177  std::cout << "O "<<sector_<<" "<< out.pt_1 << " " << out.qual_1 << " " << out.eta_1 << " " << out.HF_1 << " " << out.phi_1 << " " << out.charge_1 << " " << out.chargeValid_1 << " " << out.dxy_1 <<" " << out.addr1_1<< " " << out.addr2_1 <<" " << out.addr3_1 << " " << out.addr4_1 << " " << out.wheel_1 << " " << out.ptSTA_1 << " " << out.pt_2 << " " << out.qual_2 << " " << out.eta_2 << " " << out.HF_2 << " " << out.phi_2 << " " << out.charge_2 << " " << out.chargeValid_2 << " " << out.dxy_2 <<" " << out.addr1_2<< " " << out.addr2_2 <<" " << out.addr3_2 << " " << out.addr4_2 << " " << out.wheel_2 << " " << out.ptSTA_2 << " " << out.pt_3 << " " << out.qual_3 << " " << out.eta_3 << " " << out.HF_3 << " " << out.phi_3 << " " << out.charge_3 << " " << out.chargeValid_3 << " " << out.dxy_3 <<" " << out.addr1_3<< " " << out.addr2_3 <<" " << out.addr3_3 << " " << out.addr4_3 << " " << out.wheel_3 << " " << out.ptSTA_3 << std::endl;
178 
179 
180 }
181 
182 
183 
184 
185 // L1MuKBMTrackCollection L1TMuonBarrelKalmanSectorProcessor::cleanAndSort(const L1MuKBMTrackCollection& pretracks,uint keep) {
186 // L1MuKBMTrackCollection out;
187 
188 // if (verbose_)
189 // printf" -----Preselected Kalman Tracks for sector %d----- \n",sector_);
190 
191 
192 // for(const auto& track1 : pretracks) {
193 // if (verbose_)
194 // printf("Pre Track charge=%d pt=%f eta=%f phi=%f curvature=%d curvature STA =%d stubs=%d bitmask=%d rank=%d chi=%d pts=%f %f\n",track1.charge(),track1.pt(),track1.eta(),track1.phi(),track1.curvatureAtVertex(),track1.curvatureAtMuon(),int(track1.stubs().size()),track1.hitPattern(),track1.rank(),track1.approxChi2(),track1.pt(),track1.ptUnconstrained());
195 
196 // bool keep=true;
197 // for(const auto& track2 : pretracks) {
198 // if (track1==track2)
199 // continue;
200 // if (!track1.overlapTrack(track2))
201 // continue;
202 
203 // if (track1.rank()<track2.rank())
204 // keep=false;
205 
206 // if ((track1.rank()==track2.rank()) && (fabs(track1.stubs()[0]->whNum())<fabs(track2.stubs()[0]->whNum())))
207 // keep=false;
208 // }
209 // if (keep)
210 // out.push_back(track1);
211 // }
212 
213 // if (verbose_) {
214 // printf(" -----Algo Result Kalman Tracks-----\n");
215 // for (const auto& track1 :out)
216 // printf("Final Kalman Track charge=%d pt=%f eta=%f phi=%f curvature=%d curvature STA =%d stubs=%d chi2=%d pts=%f %f\n",track1.charge(),track1.pt(),track1.eta(),track1.phi(),track1.curvatureAtVertex(),track1.curvatureAtMuon(),int(track1.stubs().size()),track1.approxChi2(),track1.pt(),track1.ptUnconstrained());
217 // }
218 
219 
220 
221 // TrackSorter sorter;
222 // if (!out.empty())
223 // std::sort(out.begin(),out.end(),sorter);
224 
225 
226 // L1MuKBMTrackCollection exported;
227 // for (uint i=0;i<out.size();++i)
228 // if (i<=keep)
229 // exported.push_back(out[i]);
230 // return exported;
231 // }
232 
233 
236 
237  for(const auto& track1 : coll1) {
238  if (verbose_)
239  printf("Pre Track charge=%d pt=%f eta=%f phi=%f curvature=%d curvature STA =%d stubs=%d bitmask=%d rank=%d chi=%d pts=%f %f\n",track1.charge(),track1.pt(),track1.eta(),track1.phi(),track1.curvatureAtVertex(),track1.curvatureAtMuon(),int(track1.stubs().size()),track1.hitPattern(),track1.rank(),track1.approxChi2(),track1.pt(),track1.ptUnconstrained());
240 
241  bool keep=true;
242  for(const auto& track2 : coll2) {
243  if (!track1.overlapTrack(track2))
244  continue;
245 
246  if (track1.rank()<track2.rank())
247  keep=false;
248 
249  if ((track1.rank()==track2.rank()) && (fabs(track1.stubs()[0]->whNum())<fabs(track2.stubs()[0]->whNum())))
250  keep=false;
251  }
252  if (keep)
253  out.push_back(track1);
254  }
255 
256  return out;
257 }
258 
261 
262  for(const auto& track1 : coll1) {
263  // if (verbose_)
264  // printf("Pre Track charge=%d pt=%f eta=%f phi=%f curvature=%d curvature STA =%d stubs=%d bitmask=%d rank=%d chi=%d pts=%f %f\n",track1.charge(),track1.pt(),track1.eta(),track1.phi(),track1.curvatureAtVertex(),track1.curvatureAtMuon(),int(track1.stubs().size()),track1.hitPattern(),track1.rank(),track1.approxChi2(),track1.pt(),track1.ptUnconstrained());
265 
266  bool keep=true;
267  for(const auto& track2 : coll2) {
268  if (!track1.overlapTrack(track2))
269  continue;
270 
271  if (track1.rank()<track2.rank())
272  keep=false;
273 
274  if ((track1.rank()==track2.rank()) && (fabs(track1.stubs()[0]->whNum())<fabs(track2.stubs()[0]->whNum())))
275  keep=false;
276  }
277 
278  for(const auto& track2 : coll3) {
279  if (!track1.overlapTrack(track2))
280  continue;
281 
282  if (track1.rank()<track2.rank())
283  keep=false;
284 
285  if ((track1.rank()==track2.rank()) && (fabs(track1.stubs()[0]->whNum())<fabs(track2.stubs()[0]->whNum())))
286  keep=false;
287  }
288 
289  if (keep)
290  out.push_back(track1);
291  }
292 
293  return out;
294 }
295 
296 void swap(std::map<uint,double>& info,std::map<uint,L1MuKBMTrack>& trackInfo, uint i, uint j) {
297  double pt1 = info[i];
298  double pt2 = info[j];
299 
300 
301  if (pt2>pt1) {
302  info[j] = pt1;
303  info[i] = pt2;
304 
305  if (pt1!=0.0 && pt2!=0.0) {
306  L1MuKBMTrack tmp = trackInfo[i];
307  trackInfo[i] = trackInfo[j];
308  trackInfo[j]=tmp;
309  }
310  if (pt2!=0.0 && pt1==0.0) {
311  trackInfo[i] = trackInfo[j];
312 
313  }
314 
315  }
316 
317 
318 }
319 
320 
322 
323  //first clean
324 
325  L1MuKBMTrackCollection minus2 = cleanNeighbor(preminus2,preminus1);
326  L1MuKBMTrackCollection minus1 = cleanNeighbors(preminus1,preminus2,prezero);
327  L1MuKBMTrackCollection zero = cleanNeighbors(prezero,preminus1,preone);
328  L1MuKBMTrackCollection plus1 = cleanNeighbors(preone,prezero,pretwo);
329  L1MuKBMTrackCollection plus2 = cleanNeighbor(pretwo,preone);
330 
331  std::map<uint,L1MuKBMTrack> trackInfo;
332  std::map<uint,double> ptInfo;
333 
334 
335 
336 
337  for (uint i=0;i<10;++i)
338  ptInfo[i]=0.0;
339 
340 
341  if (minus2.size()>1) {
342  ptInfo[0] = minus2[0].pt();
343  trackInfo[0] = minus2[0];
344  ptInfo[1] = minus2[1].pt();
345  trackInfo[1] = minus2[1];
346  }
347  else if (minus2.size()==1) {
348  if (minus2[0].stubs()[0]->tag()) {
349  ptInfo[1] = minus2[0].pt();
350  trackInfo[1] = minus2[0];
351  }
352  else {
353  ptInfo[0] = minus2[0].pt();
354  trackInfo[0] = minus2[0];
355  }
356  }
357 
358  if (minus1.size()>1) {
359  ptInfo[2] = minus1[0].pt();
360  trackInfo[2] = minus1[0];
361  ptInfo[3] = minus1[1].pt();
362  trackInfo[3] = minus1[1];
363  }
364  else if (minus1.size()==1) {
365  if (minus1[0].stubs()[0]->tag()) {
366  ptInfo[3] = minus1[0].pt();
367  trackInfo[3] = minus1[0];
368  }
369  else {
370  ptInfo[2] = minus1[0].pt();
371  trackInfo[2] = minus1[0];
372  }
373  }
374 
375  if (zero.size()>1) {
376  ptInfo[4] = zero[0].pt();
377  trackInfo[4] = zero[0];
378  ptInfo[5] = zero[1].pt();
379  trackInfo[5] = zero[1];
380  }
381  else if (zero.size()==1) {
382  if (zero[0].stubs()[0]->tag()) {
383  ptInfo[5] = zero[0].pt();
384  trackInfo[5] = zero[0];
385  }
386  else {
387  ptInfo[4] = zero[0].pt();
388  trackInfo[4] = zero[0];
389  }
390  }
391 
392 
393  if (plus1.size()>1) {
394  ptInfo[6] = plus1[0].pt();
395  trackInfo[6] = plus1[0];
396  ptInfo[7] = plus1[1].pt();
397  trackInfo[7] = plus1[1];
398  }
399  else if (plus1.size()==1) {
400  if (plus1[0].stubs()[0]->tag()) {
401  ptInfo[7] = plus1[0].pt();
402  trackInfo[7] = plus1[0];
403  }
404  else {
405  ptInfo[6] = plus1[0].pt();
406  trackInfo[6] = plus1[0];
407  }
408  }
409 
410  if (plus2.size()>1) {
411  ptInfo[8] = plus2[0].pt();
412  trackInfo[8] = plus2[0];
413  ptInfo[9] = plus2[1].pt();
414  trackInfo[9] = plus2[1];
415  }
416  else if (plus2.size()==1) {
417  if (plus2[0].stubs()[0]->tag()) {
418  ptInfo[9] = plus2[0].pt();
419  trackInfo[9] = plus2[0];
420  }
421  else {
422  ptInfo[8] = plus2[0].pt();
423  trackInfo[8] = plus2[0];
424  }
425  }
426 
427 
428 
429 
430  //Now my glorious partial bitonic != power of two sorter
431  swap(ptInfo,trackInfo,0,5);
432  swap(ptInfo,trackInfo,1,6);
433  swap(ptInfo,trackInfo,2,7);
434  swap(ptInfo,trackInfo,3,8);
435  swap(ptInfo,trackInfo,4,9);
436 
437  swap(ptInfo,trackInfo,0,3);
438  swap(ptInfo,trackInfo,1,4);
439  swap(ptInfo,trackInfo,5,8);
440  swap(ptInfo,trackInfo,6,9);
441 
442  swap(ptInfo,trackInfo,0,2);
443  swap(ptInfo,trackInfo,3,6);
444  swap(ptInfo,trackInfo,7,9);
445 
446  swap(ptInfo,trackInfo,0,1);
447  swap(ptInfo,trackInfo,2,4);
448  swap(ptInfo,trackInfo,5,7);
449  swap(ptInfo,trackInfo,8,9);
450 
451 
452  swap(ptInfo,trackInfo,1,2);
453  swap(ptInfo,trackInfo,3,5);
454  swap(ptInfo,trackInfo,4,6);
455  swap(ptInfo,trackInfo,7,8);
456 
457  swap(ptInfo,trackInfo,1,3);
458  swap(ptInfo,trackInfo,2,5);
459  swap(ptInfo,trackInfo,4,7);
460  swap(ptInfo,trackInfo,6,8);
461 
462  swap(ptInfo,trackInfo,2,3);
463 
464 
465 
467  if (ptInfo[0]!=0.0)
468  out.push_back(trackInfo[0]);
469  if (ptInfo[1]!=0.0)
470  out.push_back(trackInfo[1]);
471  if (ptInfo[2]!=0.0)
472  out.push_back(trackInfo[2]);
473 
474  return out;
475 }
476 
477 
T getParameter(std::string const &) const
l1t::RegionalMuonCand convertToBMTF(const L1MuKBMTrack &track)
std::vector< L1TMuonBarrelKalmanRegionModule > regions_
static const TGPicture * info(bool iBackgroundIsBlack)
const int hwSignValid() const
Get charge sign valid bit (0 - not valid (high pT muon); 1 - valid)
const int hwDXY() const
Get compressed impact parameter (4 bits)
L1MuKBMTrackCollection cleanNeighbors(const L1MuKBMTrackCollection &, const L1MuKBMTrackCollection &, const L1MuKBMTrackCollection &)
void verbose(L1TMuonBarrelKalmanAlgo *, const L1MuKBMTrackCollection &)
std::vector< edm::Ref< L1MuKBMTCombinedStubCollection > > L1MuKBMTCombinedStubRefVector
const int hwQual() const
Get quality code.
const int keep
const int hwHF() const
Get HF (halo / fine eta) bit (EMTF: halo -> 1; BMTF: fine eta -> 1)
const int hwEta() const
Get compressed eta (returned int * 0.010875 = eta)
const int mu
Definition: Constants.h:22
bmtf_out makeWord(L1TMuonBarrelKalmanAlgo *, const L1MuKBMTrackCollection &)
const int hwPhi() const
Get compressed local phi (returned int * 2*pi/576 = local phi in rad)
L1MuKBMTrackCollection process(L1TMuonBarrelKalmanAlgo *, const L1MuKBMTCombinedStubRefVector &stubs, int bx)
void swap(std::map< uint, double > &info, std::map< uint, L1MuKBMTrack > &trackInfo, uint i, uint j)
def uint(string)
L1MuKBMTrackCollection cleanNeighbor(const L1MuKBMTrackCollection &, const L1MuKBMTrackCollection &)
std::vector< std::vector< double > > tmp
Definition: MVATrainer.cc:100
int trackSubAddress(bmtfAddress subAddress) const
Get part of track address (identifies track primitives used for reconstruction)
std::vector< L1MuKBMTrack > L1MuKBMTrackCollection
Definition: L1MuKBMTrack.h:15
const int hwPt() const
Get compressed pT (returned int * 0.5 = pT (GeV))
const int hwSign() const
Get charge sign bit (charge = (-1)^(sign))
L1TMuonBarrelKalmanSectorProcessor(const edm::ParameterSet &, int sector)
L1MuKBMTrackCollection wedgeSort(const L1MuKBMTrackCollection &, const L1MuKBMTrackCollection &, const L1MuKBMTrackCollection &, const L1MuKBMTrackCollection &, const L1MuKBMTrackCollection &)
const int hwPt2() const
Get second compressed pT (returned int * 1.0 = pT (GeV))