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 10 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().

10  {
11 
12  bool neighbor = false;
13 
14  int CompIndex = (endcap - 1)*6 + sector - 1;
15  bool AdSector = false;
16  if((SectIndex == 0 && CompIndex == 5) ||
17  (SectIndex == 1 && CompIndex == 0) ||
18  (SectIndex == 2 && CompIndex == 1) ||
19  (SectIndex == 3 && CompIndex == 2) ||
20  (SectIndex == 4 && CompIndex == 3) ||
21  (SectIndex == 5 && CompIndex == 4) ||
22  (SectIndex == 6 && CompIndex == 11) ||
23  (SectIndex == 7 && CompIndex == 6) ||
24  (SectIndex == 8 && CompIndex == 7) ||
25  (SectIndex == 9 && CompIndex == 8) ||
26  (SectIndex == 10 && CompIndex == 9) ||
27  (SectIndex == 11 && CompIndex == 10) ){AdSector = true;}
28 
29  if(AdSector && sub == 2 && station == 1 && (id == 3 || id == 6 || id == 9) )
30  neighbor = true;
31 
32  if(AdSector && station > 1 && (id == 3 || id == 9) )
33  neighbor = true;
34 
35  return neighbor;
36 
37 }
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 53 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(), TrackCollections2monitor_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().

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

Referenced by PrimConv().