CMS 3D CMS Logo

Functions | Variables
PrimitiveConverter_Neighbor.h File Reference
#include "DataFormats/MuonDetId/interface/CSCDetId.h"
#include "L1Trigger/L1TMuonEndCap/interface/EmulatorClasses.h"
#include "L1Trigger/L1TMuonEndCap/interface/PhThLUT_Neighbor.h"
#include "L1Trigger/L1TMuon/interface/deprecate/MuonTriggerPrimitive.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< L1TMuon::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 16 of file PrimitiveConverter_Neighbor.h.

Referenced by HcalTopology::down(), HGCalTriggerGeometryHexImp2::fillNeighborMaps(), HcalHF_PETalgorithm::HFSetFlagFromPET(), HcalHF_S9S1algorithm::HFSetFlagFromS9S1(), HGCalClusteringImpl::NNKernel(), HcalTopology::north(), PrimConv(), l1t::Stage1Layer2TauAlgorithmImpPP::processEvent(), l1t::Stage1Layer2TauAlgorithmImpHW::processEvent(), HcalTopology::producerTag(), PixelForwardLayer::searchNeighbors(), PixelForwardLayerPhase1::searchNeighbors(), TIBRing::searchNeighbors(), ConvertedHit::SetNeighbor(), l1t::slidingWindowJetFinder(), HcalTopology::south(), l1t::TwelveByTwelveFinder(), l1t::TwoByTwoFinder(), and HcalTopology::up().

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

Define Subsector /// /// ME1 only ////////

Define look-up index ///

Definition at line 59 of file PrimitiveConverter_Neighbor.h.

References rpcdqm::BX, L1TMuon::TriggerPrimitive::CSCData::bx, relativeConstraints::chamber, CSCDetId::chamber(), L1TMuon::TriggerPrimitive::detId(), CSCDetId::endcap(), makeMuonMisalignmentScenario::endcap, L1TMuon::TriggerPrimitive::getCSCData(), L1TMuon::TriggerPrimitive::getPattern(), L1TMuon::TriggerPrimitive::Id(), recoMuon::in, diffTreeTool::index, L1TMuon::TriggerPrimitive::CSCData::keywire, neighbor(), listBenchmarks::pattern, Ph_Disp_Neighbor, Ph_Init_Neighbor, ph_offsets_neighbor, ConvertedHit::Phi(), btvTracks_cfi::quality, L1TMuon::TriggerPrimitive::CSCData::quality, relativeConstraints::ring, CSCDetId::ring(), ConvertedHit::SetNeighbor(), ConvertedHit::SetSectorIndex(), ConvertedHit::SetTP(), ConvertedHit::SetValues(), ConvertedHit::SetZhit(), relativeConstraints::station, CSCDetId::station(), digi_MixPreMix_cfi::strip, L1TMuon::TriggerPrimitive::CSCData::strip, Th_Corr_Neighbor, Th_Init_Neighbor, Th_LUT_St1_Neighbor, Th_LUT_St234_Neighbor, ConvertedHit::Theta(), CSCDetId::triggerSector(), and geometryCSVtoXML::xx.

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

Referenced by PrimConv().