CMS 3D CMS Logo

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

Go to the source code of this file.

Functions

bool neighbor (int endcap, int sector, int SectIndex, int id, int sub, int station)
 
std::vector< ConvertedHitPrimConv (std::vector< TriggerPrimitive > TriggPrim, int SectIndex)
 

Variables

int ph_offsets_neighbor [5][10][3]
 

Function Documentation

bool neighbor ( int  endcap,
int  sector,
int  SectIndex,
int  id,
int  sub,
int  station 
)

Definition at line 14 of file PrimitiveConverter_Neighbor.h.

Referenced by PrimitiveConverter::convert(), HcalTopology::down(), HcalHF_PETalgorithm::HFSetFlagFromPET(), HcalHF_S9S1algorithm::HFSetFlagFromS9S1(), neighbor(), HcalTopology::north(), PrimConv(), l1t::Stage1Layer2TauAlgorithmImpPP::processEvent(), l1t::Stage1Layer2TauAlgorithmImpHW::processEvent(), PixelForwardLayer::searchNeighbors(), PixelForwardLayerPhase1::searchNeighbors(), TIBRing::searchNeighbors(), ConvertedHit::SetNeighbor(), l1t::slidingWindowJetFinder(), HcalTopology::south(), l1t::TwelveByTwelveFinder(), l1t::TwoByTwoFinder(), and HcalTopology::up().

14  {
15 
16  bool neighbor = false;
17 
18  int CompIndex = (endcap - 1)*6 + sector - 1;
19  bool AdSector = false;
20  if((SectIndex == 0 && CompIndex == 5) ||
21  (SectIndex == 1 && CompIndex == 0) ||
22  (SectIndex == 2 && CompIndex == 1) ||
23  (SectIndex == 3 && CompIndex == 2) ||
24  (SectIndex == 4 && CompIndex == 3) ||
25  (SectIndex == 5 && CompIndex == 4) ||
26  (SectIndex == 6 && CompIndex == 11) ||
27  (SectIndex == 7 && CompIndex == 6) ||
28  (SectIndex == 8 && CompIndex == 7) ||
29  (SectIndex == 9 && CompIndex == 8) ||
30  (SectIndex == 10 && CompIndex == 9) ||
31  (SectIndex == 11 && CompIndex == 10) ){AdSector = true;}
32 
33  if(AdSector && sub == 2 && station == 1 && (id == 3 || id == 6 || id == 9) )
34  neighbor = true;
35 
36  if(AdSector && station > 1 && (id == 3 || id == 9) )
37  neighbor = true;
38 
39  return neighbor;
40 
41 }
bool neighbor(int endcap, int sector, int SectIndex, int id, int sub, int station)
std::vector<ConvertedHit> PrimConv ( std::vector< TriggerPrimitive >  TriggPrim,
int  SectIndex 
)
Define Subsector ///

/// ME1 only ////////

Define look-up index ///

Definition at line 57 of file PrimitiveConverter_Neighbor.h.

References rpcdqm::BX, CSCDetId::chamber(), Reference_intrackfit_cff::endcap, CSCDetId::endcap(), V0MonitoringClient_cfi::factor, recoMuon::in, cmsHarvester::index, neighbor(), listBenchmarks::pattern, Ph_Disp_Neighbor, Ph_Init_Neighbor, ph_offsets_neighbor, ConvertedHit::Phi(), HLT_25ns10e33_v2_cff::quality, relativeConstraints::ring, CSCDetId::ring(), ConvertedHit::SetNeighbor(), ConvertedHit::SetSectorIndex(), ConvertedHit::SetTP(), ConvertedHit::SetValues(), ConvertedHit::SetZhit(), relativeConstraints::station, CSCDetId::station(), Th_Corr_Neighbor, Th_Init_Neighbor, Th_LUT_St1_Neighbor, Th_LUT_St234_Neighbor, ConvertedHit::Theta(), and CSCDetId::triggerSector().

57  {
58 
59  //bool verbose = false;
60 
61  std::vector<ConvertedHit> ConvHits;
62  for(std::vector<TriggerPrimitive>::iterator C1 = TriggPrim.begin();C1 != TriggPrim.end();C1++){
63 
67  TriggerPrimitive C3 = *C1;
68  CSCDetId Det = C3.detId<CSCDetId>();
69 
70  int station = Det.station(), chamber = Det.chamber(), ring = Det.ring(), wire = C3.getCSCData().keywire;
71  int sector = Det.triggerSector(), strip = C3.getCSCData().strip, pattern = C3.getPattern(), Id = C3.Id();
72  int quality = C3.getCSCData().quality, BX = C3.getCSCData().bx, endcap = Det.endcap();
73 
74  if(station == 1 && ring == 1 && strip > 127){
75  ring = 4;
76  }
77 
78  int sub = 0;
79 
84 
85  if(station == 1)
86  {
87  if(chamber%6 > 2)
88  sub = 1;
89  else
90  sub = 2;
91  }
92 
93  bool IsNeighbor = neighbor(endcap,sector,SectIndex,Id,sub,station);
94 
95  if(ring == 4){Id += 9;}
96 
97  //if(endcap == 1 && sector == 1)//
98  if( (SectIndex == (endcap - 1)*6 + sector - 1 ) || IsNeighbor )
99  {
100 
101 
102  //if(verbose){
103  // std::cout<<"\n\nSECTOR "<<SectIndex<<"\n\n";
104  // std::cout<<"\n\nRING = "<<ring<<"\n\n";
105  //}
106 
110 
111  int ph_tmp = -999, th_tmp = -999;
112  int clctpatcor = -999, clctpatsign = -999;
113  int eightstrip = -999;
114 
115  int factor =
116  (station == 1 && ring == 4) ? 1707://ME1/1a1707?
117  (station == 1 && ring == 3) ? 947: //ME1/3//changed Id > 6 to ring == 3.
118  (station == 1 && ring == 1) ? 1301://ME1/1b
119  1024;//all other chambers
120 
121  //std::cout<<"factor = "<<factor<<std::endl;
122 
123  bool ph_reverse =
124  (endcap == 1 && station >= 3) ? 1:
125  (endcap == 2 && station < 3) ? 1: 0;
126 
127  int ph_coverage =
128  (station <= 1 && Id > 6 && Id < 10) ? 15 : //30 :
129  (station >= 2 && Id <= 3) ? 40 : 20; //80 : 40;
130 
131  int th_coverage =
132  (station == 1 && Id <= 3) ? 45 :
133  (station == 1 && Id > 6 && Id < 10) ? 27 :
134  (station == 1 && Id > 3) ? 39 :
135  (station == 2 && Id <= 3) ? 43 :
136  (station == 2 && Id > 3) ? 56 :
137  (station == 3 && Id <= 3) ? 34 :
138  (station == 3 && Id > 3) ? 52 :
139  (station == 4 && Id <= 3) ? 28 :
140  (station == 4 && Id > 3) ? 50 : 0;
141 
142  int ph_zone_bnd1 =
143  (station <= 1 && (Id <= 3 || Id > 9)) ? 41 :
144  (station == 2 && Id <= 3) ? 41 :
145  (station == 2 && Id > 3) ? 87 :
146  (station == 3 && Id > 3) ? 49 :
147  (station == 4 && Id > 3) ? 49 : 127;
148 
149  int ph_zone_bnd2 = (station == 3 && Id > 3) ? 87 : 127;
150 
151  int zone_overlap = 2;
152 
153  int fph = -999, th = -999, ph_hit = -999, phzvl = -999;// th_hit = -999, ////
154 
155  //if(sub && verbose)
156  // std::cout<<"\nsub = "<<sub<<"\n";
157 
161 
162  int LUTi = -999;
163  int nId = Id;
164  if(IsNeighbor){
165 
166  if(station < 2){
167 
168  nId = 12 + Id/3;
169  if(ring == 4)
170  nId ++;
171 
172  }
173  else{
174  int xx = Id;
175  if(xx > 6)
176  xx = 6;
177 
178  nId = 9 + xx/3;
179 
180  }
181 
182  }
183  switch(station)
184  {
185  case 1:
186  switch(sub)
187  {
188  case 1: LUTi = nId - 1;break;
189  case 2: LUTi = 15 + nId;break;
190  default:;//std::cout<<"Sub is out of range"<<std::endl;
191  }
192  break;
193  case 2: LUTi = 27 + nId;break;
194  case 3: LUTi = 38 + nId;break;
195  case 4: LUTi = 49 + nId;break;
196  default:;//std::cout<<"station is out of range"<<std::endl;
197  }
198 
199  if(IsNeighbor && station == 1){
200 
201  switch(sub)
202  {
203  case 1: LUTi = 15 + nId;break;
204  case 2: LUTi = nId - 1;break;
205  default:;//std::cout<<"Sub is out of range"<<std::endl;
206  }
207 
208  }
209 
213 
214  clctpatcor = 0;
215  clctpatsign = 0;
216 
217  if(pattern > 0 && pattern < 11){
218 
219  clctpatsign = ((pattern%2) == 0);
220 
221  if(pattern >= 2) {clctpatcor = 5;}
222  if(pattern >= 6) {clctpatcor = 2;}
223  if(pattern == 10) {clctpatcor = 0;clctpatsign = 0;}
224  }
225 
229 
230  eightstrip = 8*strip;
231  int patcor = clctpatcor;
232 
233  //std::cout<<"8strip = "<<eightstrip<<"\n";
234 
235  if(station == 1 || Id > 3){//10 Degree Chambers
236 
237  eightstrip = (eightstrip>>1);
238  patcor = (patcor>>1);
239  if(ring == 4 && strip > 127) eightstrip -= 512;
240  }
241 
242  //std::cout<<"8strip = "<<eightstrip<<"\n";
243 
244  if(clctpatsign) patcor = -patcor;
245  eightstrip += patcor;
246 
250 
251  ph_tmp = ((eightstrip*factor)>>10);
252  int phShift = (ph_tmp>>5);
253  int phLow = 0;
254 
255  if(ph_reverse){
256 
257  ph_tmp = -ph_tmp;
258  phShift = -phShift;
259  phLow = ph_coverage;
260  }
261 
262  int phInitIndex = Id;
263  //std::cout<<"phInitIndex = "<<phInitIndex<<" and ph_tmp = "<<ph_tmp<<"\n";
264 
265  if(station == 1){
266 
267  int neighborId = C3.Id()/3;
268  int subId = sub;
269  if(IsNeighbor ){
270 
271  subId = 1;
272  phInitIndex = 12 + neighborId;
273  if(ring == 4)
274  phInitIndex = 16;//phInitIndex++;
275 
276  }
277 
278  fph = Ph_Init_Neighbor[SectIndex][subId-1][phInitIndex - 1] + ph_tmp;
279  //std::cout<<"ph init = "<<Ph_Init_Neighbor[SectIndex][subId-1][phInitIndex - 1]<<", index = "<<phInitIndex<<", neighborId = "<<neighborId<<", Id = "<<Id<<"\n";
280  }
281  else{
282 
283  int neighborId = Id/3;
284  if(neighborId > 2)
285  neighborId = 2;
286 
287  if(IsNeighbor)
288  phInitIndex = 9 + neighborId;
289 
290  fph = Ph_Init_Neighbor[SectIndex][station][phInitIndex - 1] + ph_tmp;
291  }
292 
293  //std::cout<<"pl = "<<phLow<<", ps = "<<phShift<<", ph disp = "<<Ph_Disp_Neighbor[SectIndex][LUTi]<<", >>1 = "<<(Ph_Disp_Neighbor[SectIndex][LUTi]>>1)<<", LUTi = "<<LUTi<<"\n";
294  ph_hit = phLow + phShift + (Ph_Disp_Neighbor[SectIndex][LUTi]>>1);
295 
299 
300  int index = -999;
301  int th_corr = -999;
302 
303  int idl = Id;
304 
305  if(station == 1){
306 
307  int neighborId = C3.Id()/3;
308  int subId = sub;
309  if(IsNeighbor){
310 
311  subId = 1;
312  idl = 12 + neighborId;
313  if(ring == 4)
314  idl = 16;
315  }
316 
317  //std::cout<<"nid = "<<neighborId<<", idl = "<<idl<<"\n";
318 
319  th_tmp = Th_LUT_St1_Neighbor[subId-1][SectIndex][idl -1][wire];
320  //std::cout<<"th_tmpr = "<<th_tmp<<"\n";
321  }
322  else{
323 
324  int neighborId = Id/3;
325  if(neighborId > 2)
326  neighborId = 2;
327 
328  if(IsNeighbor)
329  idl = 9 + neighborId;
330 
331  th_tmp = Th_LUT_St234_Neighbor[station-2][SectIndex][idl-1][wire];
332  //if(verbose) std::cout<<"\n\nth_tmpr = "<<th_tmp<<"\n\n";
333  }
334 
335  th = th_tmp + Th_Init_Neighbor[SectIndex][LUTi];
336  int rth = th;
337  //std::cout<<"Th_Init_Neighbor["<<SectIndex<<"]["<<LUTi<<"] = "<<Th_Init_Neighbor[SectIndex][LUTi]<<"\n";
338 
339  if(station == 1 && (ring == 1 || ring == 4) /*&& endcap == 1*/){
340 
341  index = (wire>>4)*32 + (eightstrip>>4);
342 
343  int corrIndex = Id;
344  int subId = sub;
345  //std::cout<<"corrIndex = "<<corrIndex<<"\n";
346  if(corrIndex > 3)
347  corrIndex -= 9;
348 
349  //std::cout<<"corrIndex = "<<corrIndex<<"\n";
350 
351  if(IsNeighbor && ring == 4){
352  subId = 1;
353  corrIndex++;
354  }
355 
356  //std::cout<<"corrIndex = "<<corrIndex<<"\n";
357 
358  th_corr = Th_Corr_Neighbor[subId-1][SectIndex][corrIndex-1][index];
359  //std::cout<<"th_corr["<<subId-1<<"]["<<SectIndex<<"]["<<corrIndex-1<<"]["<<index<<"] = "<<th_corr<<"\n";
360 
361  if(ph_reverse) th_corr = -th_corr;
362  //std::cout<<"th_tmp = "<<th_tmp<<"\n";
363 
364  th_tmp += th_corr; //add correction to th_tmp
365  //std::cout<<"th_tmp = "<<th_tmp<<"\n";
366  if(th_tmp < 0 || wire == 0)
367  th_tmp = 0;
368 
369  if(th_tmp > th_coverage)//this is one change that I'm not sure if it does anything good or not
370  th_tmp = th_coverage;
371 
372  th_tmp &= 0x3f; //keep only lowest 6 bits
373  //std::cout<<"th_tmp = "<<th_tmp<<"\n";
374  //std::cout<<"coverage = "<<th_coverage<<"\n";
375 
376  if(th_tmp <= th_coverage){
377 
378  //if(ring == 1){LUTi += 9;} //change because new Verilog3 sp_tf treats ME11b with LUT's of ME11a
379 
380  th = th_tmp + Th_Init_Neighbor[SectIndex][LUTi];
381  //std::cout<<"th_init["<<SectIndex<<"]["<<LUTi<<"] = "<<Th_Init_Neighbor[SectIndex][LUTi]<<"\n";
382  }
383  else{th = rth;}//was -999
384 
385  }
386 
390 
391  if(th != -999){
392 
393  phzvl = 0;
394 
395  if(th <= (ph_zone_bnd1 + zone_overlap))
396  {phzvl |= 1;}
397 
398  if(th > (ph_zone_bnd2 - zone_overlap))
399  {phzvl |= 4;}
400 
401  if((th > (ph_zone_bnd1 - zone_overlap)) && (th <= (ph_zone_bnd2 + zone_overlap)))
402  {phzvl |= 2;}
403  }
404 
410 
411  int zhit = -99, pz = -99;
412  //Each hit could go in more than one zone so we make a vector which stores all the zones for which this hit will contribute
413  std::vector<int> zonecontribution;
414 
415  if(ring == 4){
416  Id -= 9;
417 
418  if(strip < 128)
419  strip += 128;
420  }
421 
422  //determination of zone contribution
423  if((phzvl & 1) && (Id < 4 || Id > 9)){pz=0;zonecontribution.push_back(0);}
424  if((phzvl & 2) && (Id < 4)){pz=1;zonecontribution.push_back(1);}
425  if((phzvl & 1) && (Id > 3) && (station > 2)){pz=0;zonecontribution.push_back(1);}
426  if((phzvl & 1) && (Id > 3) && (Id < 7) && (station == 1)){pz=0;zonecontribution.push_back(2);}
427  if((phzvl & 1) && (Id > 3) && (station == 2)){pz=0;zonecontribution.push_back(2);}
428  if((phzvl & 2) && (Id > 3) && (station > 2)){pz=1;zonecontribution.push_back(2);}
429  if((phzvl & 1) && (Id > 4) && (station < 2)){pz=0;zonecontribution.push_back(3);}
430  if(phzvl & 4){pz=2;zonecontribution.push_back(3);}
431  if((phzvl & 2) && (Id > 3) && (station < 3)){pz=1;zonecontribution.push_back(3);}
432 
433  int phOffIndex = Id;
434  if(IsNeighbor)
435  phOffIndex = 10;
436 
437  //applying ph_offsets
438  if(sub == 1){
439  zhit = ph_hit + ph_offsets_neighbor[station-1][phOffIndex-1][pz];
440  //std::cout<<"\nph_hit = "<<ph_hit<<" and ph_offsets_neighbor["<<station-1<<"]["<<phOffIndex-1<<"]["<<pz<<"] = "<<ph_offsets_neighbor[station-1][phOffIndex-1][pz]<<"\n";
441  }
442  else{
443 
444  zhit = ph_hit + ph_offsets_neighbor[station][phOffIndex-1][pz];
445  //std::cout<<"ph_hit = "<<ph_hit<<" and ph_offsets_neighbor["<<station<<"]["<<phOffIndex-1<<"]["<<pz<<"] = "<<ph_offsets_neighbor[station][phOffIndex-1][pz]<<"\n";
446  }
447 
452 
453 
454  //if(SectIndex == 8){
455  //std::cout<<"phi = "<<fph<<", theta = "<<th<<", ph_hit = "<<ph_hit<<",zhit = "<<zhit<<", station = "<<station<<", ring = "<<ring<<", id = "<<Id<<", sector "<<SectIndex<<",sub = "<<sub<<", strip = "<<strip<<", wire = "<<wire<<", IsNeighbor = "<<IsNeighbor<<"\n";
456 
457  //std::cout<<BX-3<<" "<<endcap<<" "<<sector<<" "<<sub<<" "<<station<<" 1 "<<quality<<" "<<pattern<<" "<<wire<<" "<<C3.Id()<<" 0 "<<strip<<"\n";
458  //}
459 
460  /* if(station != 1) */
461  /* sub = 1; */
462  /* std::cout<<"proper FR[0] = "<<FRLUT[endcap-1][sector-1][station-1][sub-1][Id-1]<<"\n"; */
463  /* if(station != 1) */
464  /* sub = 0; */
465 
467 
468  int in = 0;
469  if(IsNeighbor)
470  in = 1;
471 
472  Hit.SetValues(fph,th,ph_hit,phzvl,station,sub,Id,quality,pattern,wire,strip,BX);
473  Hit.SetTP(C3);
474  Hit.SetZhit(zhit);
475  Hit.SetZoneContribution(zonecontribution);
476  Hit.SetSectorIndex(SectIndex);
477  Hit.SetNeighbor(in);
478 
479  if(Hit.Theta() != -999 && Hit.Phi() > 0){//if theta is valid
480  ConvHits.push_back(Hit);
481  /*if(verbose){
482  std::cout<<"Phzvl() = "<<Hit.Phzvl()<<", ph_hit = "<<Hit.Ph_hit()<<", station = "<<Hit.Station()<<" and id = "<<Hit.Id()<<std::endl;
483  std::cout<<"strip = "<<strip<<", wire = "<<wire<<" and zhit = "<<zhit<<std::endl;
484  std::cout<<"\n\nIn Zones: ";
485  for(std::vector<int>::iterator in = zonecontribution.begin();in!=zonecontribution.end();in++){
486  std::cout<<" "<<*in<<" ";
487  }
488  }*/
489  }
490 
491  }//if sector == sectIndex
492 
493  }
494  return ConvHits;
495 
496 }
int chamber() const
Definition: CSCDetId.h:68
int Th_LUT_St234_Neighbor[3][12][11][112]
void SetNeighbor(int neighbor)
bool neighbor(int endcap, int sector, int SectIndex, int id, int sub, int station)
int endcap() const
Definition: CSCDetId.h:93
int Th_LUT_St1_Neighbor[2][12][16][64]
int ph_offsets_neighbor[5][10][3]
void SetTP(L1TMuon::TriggerPrimitive tp)
SeedingHitSet::ConstRecHitPointer Hit
int ring() const
Definition: CSCDetId.h:75
int Th_Corr_Neighbor[2][12][4][96]
int triggerSector() const
Definition: CSCDetId.cc:3
unsigned int Ph_Disp_Neighbor[12][61]
unsigned int Th_Init_Neighbor[12][61]
void SetZhit(int zhit)
void SetValues(int phi, int theta, int ph_hit, int phzvl, int station, int sub, int id, int quality, int pattern, int wire, int strip, int BX)
int station() const
Definition: CSCDetId.h:86
int Ph_Init_Neighbor[12][5][16]
void SetSectorIndex(int sectorIndex)

Variable Documentation

int ph_offsets_neighbor[5][10][3]
Initial value:
=
{{{39,39,-99}, {57,57,-99}, {76,76,-99}, {39,-99,-99}, {58,-99,-99},
{76,-99,-99}, {41,-99,-99}, {60,-99,-99}, {79,-99,-99}, {21,21,23}},
{{95,95,-99}, {114,114,-99}, {132,132,-99}, {95,-99,-99}, {114,-99,-99},
{133,-99,-99}, {98,-99,-99}, {116,-99,-99}, {135,-99,-99}, {21,21,23}},
{{38,38,-99}, {76,76,-99}, {113,113,-99}, {39,39,-99}, {58,58,-99},
{76,76,-99}, {95,95,-99}, {114,114,-99}, {132,132,-99}, {1,21,21}},
{{38,-99,-99}, {76,-99,-99}, {113,-99,-99}, {39,39,39}, {58,58,58},
{76,76,76}, {95,95,95}, {114,114,114}, {132,132,132}, {1,21,21}},
{{38,-99,-99}, {76,-99,-99}, {113,-99,-99}, {38,38,-99}, {57,57,-99},
{76,76,-99}, {95,95,-99}, {113,113,-99}, {132,132,-99}, {1,20,20}}}

Definition at line 45 of file PrimitiveConverter_Neighbor.h.

Referenced by PrimConv().