CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Member Functions | Private Attributes
PrimitiveConverter Class Reference

#include <PrimitiveConverter.h>

Public Member Functions

std::vector< ConvertedHitconvert (std::vector< TriggerPrimitive > TriggPrim, int SectIndex)
 
 PrimitiveConverter ()
 

Private Attributes

unsigned int Ph_Disp_Neighbor_ [12][61]
 
int Ph_Init_Neighbor_ [12][5][16]
 
int Th_Corr_Neighbor_ [2][12][4][96]
 
unsigned int Th_Init_Neighbor_ [12][61]
 
int Th_LUT_St1_Neighbor_ [2][12][16][64]
 
int Th_LUT_St234_Neighbor_ [3][12][11][112]
 

Detailed Description

Definition at line 9 of file PrimitiveConverter.h.

Constructor & Destructor Documentation

PrimitiveConverter::PrimitiveConverter ( )

Definition at line 71 of file PrimitiveConverter.cc.

References read_buf().

71  {
72  read_buf("L1Trigger/L1TMuon/data/emtf_luts/ph_lut_v1/ph_disp_neighbor.txt", &Ph_Disp_Neighbor_[0][0], 12*61);
73  read_buf("L1Trigger/L1TMuon/data/emtf_luts/ph_lut_v1/ph_init_neighbor.txt", &Ph_Init_Neighbor_[0][0][0], 12*5*16);
74  read_buf("L1Trigger/L1TMuon/data/emtf_luts/ph_lut_v1/th_corr_neighbor.txt", &Th_Corr_Neighbor_[0][0][0][0], 2*12*4*96);
75  read_buf("L1Trigger/L1TMuon/data/emtf_luts/ph_lut_v1/th_init_neighbor.txt", &Th_Init_Neighbor_[0][0], 12*61);
76  read_buf("L1Trigger/L1TMuon/data/emtf_luts/ph_lut_v1/th_lut_st1_neighbor.txt", &Th_LUT_St1_Neighbor_[0][0][0][0], 2*12*16*64);
77  read_buf("L1Trigger/L1TMuon/data/emtf_luts/ph_lut_v1/th_lut_st234_neighbor.txt", &Th_LUT_St234_Neighbor_[0][0][0][0], 3*12*11*112);
78 
79 
80 }
unsigned int Th_Init_Neighbor_[12][61]
static void read_buf(const char *name, T *buf, unsigned size)
int Th_LUT_St234_Neighbor_[3][12][11][112]
int Th_Corr_Neighbor_[2][12][4][96]
int Th_LUT_St1_Neighbor_[2][12][16][64]
unsigned int Ph_Disp_Neighbor_[12][61]
int Ph_Init_Neighbor_[12][5][16]

Member Function Documentation

std::vector< ConvertedHit > PrimitiveConverter::convert ( std::vector< TriggerPrimitive TriggPrim,
int  SectIndex 
)
Define Subsector ///

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

Define look-up index ///

Definition at line 82 of file PrimitiveConverter.cc.

References rpcdqm::BX, L1TMuon::TriggerPrimitive::CSCData::bx, CSCDetId::chamber(), L1TMuon::TriggerPrimitive::detId(), Reference_intrackfit_cff::endcap, CSCDetId::endcap(), L1TMuon::TriggerPrimitive::getCSCData(), L1TMuon::TriggerPrimitive::getPattern(), L1TMuon::TriggerPrimitive::Id(), recoMuon::in, cmsHarvester::index, L1TMuon::TriggerPrimitive::CSCData::keywire, neighbor(), listBenchmarks::pattern, ph_offsets_neighbor, ConvertedHit::Phi(), L1TMuon::TriggerPrimitive::CSCData::quality, HLT_FULL_cff::quality, relativeConstraints::ring, CSCDetId::ring(), ConvertedHit::SetNeighbor(), ConvertedHit::SetSectorIndex(), ConvertedHit::SetTP(), ConvertedHit::SetValues(), ConvertedHit::SetZhit(), ConvertedHit::SetZoneContribution(), relativeConstraints::station, CSCDetId::station(), L1TMuon::TriggerPrimitive::CSCData::strip, ConvertedHit::Theta(), and CSCDetId::triggerSector().

82  {
83 
84  //bool verbose = false;
85 
86  std::vector<ConvertedHit> ConvHits;
87  for(std::vector<TriggerPrimitive>::iterator C1 = TriggPrim.begin();C1 != TriggPrim.end();C1++){
88 
92  TriggerPrimitive C3 = *C1;
93  CSCDetId Det = C3.detId<CSCDetId>();
94 
95  int station = Det.station(), chamber = Det.chamber(), ring = Det.ring(), wire = C3.getCSCData().keywire, sector = Det.triggerSector(), strip = C3.getCSCData().strip;
96  int pattern = C3.getPattern(), Id = C3.Id(), quality = C3.getCSCData().quality, BX = C3.getCSCData().bx, endcap = Det.endcap();
97 
98  if(station == 1 && ring == 1 && strip > 127){
99  ring = 4;
100  }
101 
102  int sub = 0;
103 
108 
109  if(station == 1)//is this correct? I know it starts from 1 so not quite what I intended I think.
110  {
111 
112  if(chamber%6 > 2)
113  sub = 1;
114  else
115  sub = 2;
116 
117  }
118 
119  bool IsNeighbor = neighbor(endcap,sector,SectIndex,Id,sub,station);
120 
121 
122  if(ring == 4){Id += 9;}
123 
124  //if(endcap == 1 && sector == 1)//
125  if( (SectIndex == (endcap - 1)*6 + sector - 1 ) || IsNeighbor )
126  {
127 
128 
129  //if(verbose){
130  // std::cout<<"\n\nSECTOR "<<SectIndex<<"\n\n";
131  // std::cout<<"\n\nRING = "<<ring<<"\n\n";
132  //}
133 
137 
138  int ph_tmp = -999, th_tmp = -999;
139  int clctpatcor = -999, clctpatsign = -999;
140  int eightstrip = -999;
141 
142  int factor = (station == 1 && ring == 4) ? 1707://ME1/1a1707?
143  (station == 1 && ring == 3) ? 947: //ME1/3//changed Id > 6 to ring == 3.
144  (station == 1 && ring == 1) ? 1301://ME1/1b
145  1024;//all other chambers
146 
147  //std::cout<<"factor = "<<factor<<std::endl;
148 
149  bool ph_reverse = (endcap == 1 && station >= 3) ? 1:
150  (endcap == 2 && station < 3) ? 1: 0;
151 
152  int ph_coverage = (station <= 1 && Id > 6 && Id < 10) ? 15 : //30 :
153  (station >= 2 && Id <= 3) ? 40 : 20; //80 : 40;
154 
155  int th_coverage = (station == 1 && Id <= 3) ? 45 :
156  (station == 1 && Id > 6 && Id < 10) ? 27 :
157  (station == 1 && Id > 3) ? 39 :
158  (station == 2 && Id <= 3) ? 43 :
159  (station == 2 && Id > 3) ? 56 :
160  (station == 3 && Id <= 3) ? 34 :
161  (station == 3 && Id > 3) ? 52 :
162  (station == 4 && Id <= 3) ? 28 :
163  (station == 4 && Id > 3) ? 50 : 0;
164 
165  int ph_zone_bnd1 = (station <= 1 && (Id <= 3 || Id > 9)) ? 41 :
166  (station == 2 && Id <= 3) ? 41 :
167  (station == 2 && Id > 3) ? 87 :
168  (station == 3 && Id > 3) ? 49 :
169  (station == 4 && Id > 3) ? 49 : 127;
170 
171  int ph_zone_bnd2 = (station == 3 && Id > 3) ? 87 : 127;
172 
173  int zone_overlap = 2;
174 
175  int fph = -999, th = -999, ph_hit = -999, phzvl = -999;// th_hit = -999, ////
176 
177 
178 
179  //if(sub && verbose)
180  // std::cout<<"\nsub = "<<sub<<"\n";
181 
185 
186  int LUTi = -999;
187  int nId = Id;
188  if(IsNeighbor){
189 
190  if(station < 2){
191 
192  nId = 12 + Id/3;
193  if(ring == 4)
194  nId ++;
195 
196  }
197  else{
198  int xx = Id;
199  if(xx > 6)
200  xx = 6;
201 
202  nId = 9 + xx/3;
203 
204  }
205 
206  }
207  switch(station)
208  {
209  case 1:
210  switch(sub)
211  {
212  case 1: LUTi = nId - 1;break;
213  case 2: LUTi = 15 + nId;break;
214  default:;//std::cout<<"Sub is out of range"<<std::endl;
215  }
216  break;
217  case 2: LUTi = 27 + nId;break;
218  case 3: LUTi = 38 + nId;break;
219  case 4: LUTi = 49 + nId;break;
220  default:;//std::cout<<"station is out of range"<<std::endl;
221  }
222 
223  if(IsNeighbor && station == 1){
224 
225  switch(sub)
226  {
227  case 1: LUTi = 15 + nId;break;
228  case 2: LUTi = nId - 1;break;
229  default:;//std::cout<<"Sub is out of range"<<std::endl;
230  }
231 
232  }
233 
234 
235 
239 
240  clctpatcor = 0;
241  clctpatsign = 0;
242 
243  if(pattern > 0 && pattern < 11){
244 
245  clctpatsign = ((pattern%2) == 0);
246 
247  if(pattern >= 2) {clctpatcor = 5;}
248  if(pattern >= 6) {clctpatcor = 2;}
249  if(pattern == 10) {clctpatcor = 0;clctpatsign = 0;}
250  }
251 
252 
253 
257 
258  eightstrip = 8*strip;
259  int patcor = clctpatcor;
260 
261  //std::cout<<"8strip = "<<eightstrip<<"\n";
262 
263  if(station == 1 || Id > 3){//10 Degree Chambers
264 
265  eightstrip = (eightstrip>>1);
266  patcor = (patcor>>1);
267  if(ring == 4 && strip > 127) eightstrip -= 512;
268  }
269 
270  //std::cout<<"8strip = "<<eightstrip<<"\n";
271 
272  if(clctpatsign) patcor = -patcor;
273  eightstrip += patcor;
274 
278 
279  ph_tmp = ((eightstrip*factor)>>10);
280  int phShift = (ph_tmp>>5);
281  int phLow = 0;
282 
283  if(ph_reverse){
284 
285  ph_tmp = -ph_tmp;
286  phShift = -phShift;
287  phLow = ph_coverage;
288  }
289 
290  int phInitIndex = Id;
291  //std::cout<<"phInitIndex = "<<phInitIndex<<" and ph_tmp = "<<ph_tmp<<"\n";
292 
293  if(station == 1){
294 
295  int neighborId = C3.Id()/3;
296  int subId = sub;
297  if(IsNeighbor ){
298 
299  subId = 1;
300  phInitIndex = 12 + neighborId;
301  if(ring == 4)
302  phInitIndex = 16;//phInitIndex++;
303 
304 
305  }
306 
307  fph = Ph_Init_Neighbor_[SectIndex][subId-1][phInitIndex - 1] + ph_tmp;
308  //std::cout<<"ph init = "<<Ph_Init_Neighbor_[SectIndex][subId-1][phInitIndex - 1]<<", index = "<<phInitIndex<<", neighborId = "<<neighborId<<", Id = "<<Id<<"\n";
309  }
310  else{
311 
312  int neighborId = Id/3;
313  if(neighborId > 2)
314  neighborId = 2;
315 
316  if(IsNeighbor)
317  phInitIndex = 9 + neighborId;
318 
319  fph = Ph_Init_Neighbor_[SectIndex][station][phInitIndex - 1] + ph_tmp;
320  }
321 
322  //std::cout<<"pl = "<<phLow<<", ps = "<<phShift<<", ph disp = "<<Ph_Disp_Neighbor_[SectIndex][LUTi]<<", >>1 = "<<(Ph_Disp_Neighbor_[SectIndex][LUTi]>>1)<<", LUTi = "<<LUTi<<"\n";
323  ph_hit = phLow + phShift + (Ph_Disp_Neighbor_[SectIndex][LUTi]>>1);
324 
328 
329  int index = -999;
330  int th_corr = -999;
331 
332  int idl = Id;
333 
334  if(station == 1){
335 
336 
337  int neighborId = C3.Id()/3;
338  int subId = sub;
339  if(IsNeighbor){
340 
341  subId = 1;
342  idl = 12 + neighborId;
343  if(ring == 4)
344  idl = 16;
345 
346  }
347 
348  //std::cout<<"nid = "<<neighborId<<", idl = "<<idl<<"\n";
349 
350  th_tmp = Th_LUT_St1_Neighbor_[subId-1][SectIndex][idl -1][wire];
351  //std::cout<<"th_tmpr = "<<th_tmp<<"\n";
352  }
353  else{
354 
355 
356  int neighborId = Id/3;
357  if(neighborId > 2)
358  neighborId = 2;
359 
360  if(IsNeighbor)
361  idl = 9 + neighborId;
362 
363  th_tmp = Th_LUT_St234_Neighbor_[station-2][SectIndex][idl-1][wire];
364  //if(verbose) std::cout<<"\n\nth_tmpr = "<<th_tmp<<"\n\n";
365  }
366 
367 
368  th = th_tmp + Th_Init_Neighbor_[SectIndex][LUTi];
369  int rth = th;
370  //std::cout<<"Th_Init_Neighbor_["<<SectIndex<<"]["<<LUTi<<"] = "<<Th_Init_Neighbor_[SectIndex][LUTi]<<"\n";
371 
372  if(station == 1 && (ring == 1 || ring == 4) /*&& endcap == 1*/){
373 
374  index = (wire>>4)*32 + (eightstrip>>4);
375 
376  int corrIndex = Id;
377  int subId = sub;
378  //std::cout<<"corrIndex = "<<corrIndex<<"\n";
379  if(corrIndex > 3)
380  corrIndex -= 9;
381 
382  //std::cout<<"corrIndex = "<<corrIndex<<"\n";
383 
384  if(IsNeighbor && ring == 4){
385  subId = 1;
386  corrIndex++;
387  }
388 
389  //std::cout<<"corrIndex = "<<corrIndex<<"\n";
390 
391  //if(Id > 3){
392  // th_corr = Th_Corr_Neighbor_[sub-1][SectIndex][Id-10][index];
393  //if(verbose) std::cout<<"\n\nth_corr = "<<th_corr<<"\n\n";
394  //}
395  //else{
396  th_corr = Th_Corr_Neighbor_[subId-1][SectIndex][corrIndex-1][index];
397  //std::cout<<"th_corr["<<subId-1<<"]["<<SectIndex<<"]["<<corrIndex-1<<"] = "<<th_corr<<"\n";
398  //}
399 
400 
401  if(ph_reverse) th_corr = -th_corr;
402 
403  //std::cout<<"th_tmp = "<<th_tmp<<"\n";
404 
405  th_tmp += th_corr; //add correction to th_tmp
406  //std::cout<<"th_tmp = "<<th_tmp<<"\n";
407  if(th_tmp < 0)
408  th_tmp = 0;
409  th_tmp &= 0x3f; //keep only lowest 6 bits
410  //std::cout<<"th_tmp = "<<th_tmp<<"\n";
411  //std::cout<<"coverage = "<<th_coverage<<"\n";
412 
413  if(th_tmp < th_coverage){
414 
415  //if(ring == 1){LUTi += 9;} //change because new Verilog3 sp_tf treats ME11b with LUT's of ME11a
416 
417  th = th_tmp + Th_Init_Neighbor_[SectIndex][LUTi];
418  //std::cout<<"th_init["<<SectIndex<<"]["<<LUTi<<"] = "<<Th_Init_Neighbor_[SectIndex][LUTi]<<"\n";
419  }
420  else{th = rth;}//was -999
421 
422  }
423 
427 
428  if(th != -999){
429 
430  phzvl = 0;
431 
432  if(th <= (ph_zone_bnd1 + zone_overlap))
433  {phzvl |= 1;}
434 
435  if(th > (ph_zone_bnd2 - zone_overlap))
436  {phzvl |= 4;}
437 
438  if((th > (ph_zone_bnd1 - zone_overlap)) && (th <= (ph_zone_bnd2 + zone_overlap)))
439  {phzvl |= 2;}
440  }
441 
442 
443 
449 
450 
451 
452  int zhit = -99, pz = -99;
453  std::vector<int> zonecontribution; //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
454 
455  if(ring == 4){
456  Id -= 9;
457 
458  if(strip < 128)
459  strip += 128;
460  }
461 
462 
463  //determination of zone contribution
464  if((phzvl & 1) && (Id < 4 || Id > 9)){pz=0;zonecontribution.push_back(0);}
465  if((phzvl & 2) && (Id < 4)){pz=1;zonecontribution.push_back(1);}
466  if((phzvl & 1) && (Id > 3) && (station > 2)){pz=0;zonecontribution.push_back(1);}
467  if((phzvl & 1) && (Id > 3) && (Id < 7) && (station == 1)){pz=0;zonecontribution.push_back(2);}
468  if((phzvl & 1) && (Id > 3) && (station == 2)){pz=0;zonecontribution.push_back(2);}
469  if((phzvl & 2) && (Id > 3) && (station > 2)){pz=1;zonecontribution.push_back(2);}
470  if((phzvl & 1) && (Id > 4) && (station < 2)){pz=0;zonecontribution.push_back(3);}
471  if(phzvl & 4){pz=2;zonecontribution.push_back(3);}
472  if((phzvl & 2) && (Id > 3) && (station < 3)){pz=1;zonecontribution.push_back(3);}
473 
474 
475  int phOffIndex = Id;
476  if(IsNeighbor)
477  phOffIndex = 10;
478 
479  //applying ph_offsets
480  if(sub == 1){
481  zhit = ph_hit + ph_offsets_neighbor[station-1][phOffIndex-1][pz];
482  //std::cout<<"\nph_hit = "<<ph_hit<<" and ph_offsets_neighbor["<<station-1<<"]["<<phOffIndex-1<<"]["<<pz<<"] = "<<ph_offsets_neighbor[station-1][phOffIndex-1][pz]<<"\n";
483  }
484  else{
485 
486  zhit = ph_hit + ph_offsets_neighbor[station][phOffIndex-1][pz];
487  //std::cout<<"ph_hit = "<<ph_hit<<" and ph_offsets_neighbor["<<station<<"]["<<phOffIndex-1<<"]["<<pz<<"] = "<<ph_offsets_neighbor[station][phOffIndex-1][pz]<<"\n";
488  }
489 
490 
491 
492 
493 
498 
499 
500  //if(SectIndex == 8){
501  //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";
502 
503  //std::cout<<BX-3<<" "<<endcap<<" "<<sector<<" "<<sub<<" "<<station<<" 1 "<<quality<<" "<<pattern<<" "<<wire<<" "<<C3.Id()<<" 0 "<<strip<<"\n";
504  //}
505 
506  /* if(station != 1) */
507  /* sub = 1; */
508  /* std::cout<<"proper FR[0] = "<<FRLUT[endcap-1][sector-1][station-1][sub-1][Id-1]<<"\n"; */
509  /* if(station != 1) */
510  /* sub = 0; */
511 
512 
514 
515  int in = 0;
516  if(IsNeighbor)
517  in = 1;
518 
519  Hit.SetValues(fph,th,ph_hit,phzvl,station,sub,Id,quality,pattern,wire,strip,BX);
520  Hit.SetTP(C3);
521  Hit.SetZhit(zhit);
522  Hit.SetZoneContribution(zonecontribution);
523  Hit.SetSectorIndex(SectIndex);
524  Hit.SetNeighbor(in);
525 
526  if(Hit.Theta() != -999 && Hit.Phi() > 0){//if theta is valid
527  ConvHits.push_back(Hit);
528  /*if(verbose){
529  std::cout<<"Phzvl() = "<<Hit.Phzvl()<<", ph_hit = "<<Hit.Ph_hit()<<", station = "<<Hit.Station()<<" and id = "<<Hit.Id()<<std::endl;
530  std::cout<<"strip = "<<strip<<", wire = "<<wire<<" and zhit = "<<zhit<<std::endl;
531  std::cout<<"\n\nIn Zones: ";
532  for(std::vector<int>::iterator in = zonecontribution.begin();in!=zonecontribution.end();in++){
533  std::cout<<" "<<*in<<" ";
534  }
535  }*/
536  }
537 
538 
539  }//if sector == sectIndex
540 
541  }
542  return ConvHits;
543 
544 }
unsigned int Th_Init_Neighbor_[12][61]
int chamber() const
Definition: CSCDetId.h:68
bool neighbor(int endcap, int sector, int SectIndex, int id, int sub, int station)
void SetZoneContribution(std::vector< int > zonecontribution)
void SetNeighbor(int neighbor)
int Th_LUT_St234_Neighbor_[3][12][11][112]
const CSCData getCSCData() const
int endcap() const
Definition: CSCDetId.h:93
SeedingHitSet::ConstRecHitPointer Hit
int Th_Corr_Neighbor_[2][12][4][96]
int Th_LUT_St1_Neighbor_[2][12][16][64]
int ring() const
Definition: CSCDetId.h:75
int triggerSector() const
Definition: CSCDetId.cc:3
unsigned int Ph_Disp_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 SetTP(TriggerPrimitive tp)
int ph_offsets_neighbor[5][10][3]
void SetSectorIndex(int sectorIndex)

Member Data Documentation

unsigned int PrimitiveConverter::Ph_Disp_Neighbor_[12][61]
private

Definition at line 16 of file PrimitiveConverter.h.

int PrimitiveConverter::Ph_Init_Neighbor_[12][5][16]
private

Definition at line 17 of file PrimitiveConverter.h.

int PrimitiveConverter::Th_Corr_Neighbor_[2][12][4][96]
private

Definition at line 18 of file PrimitiveConverter.h.

unsigned int PrimitiveConverter::Th_Init_Neighbor_[12][61]
private

Definition at line 19 of file PrimitiveConverter.h.

int PrimitiveConverter::Th_LUT_St1_Neighbor_[2][12][16][64]
private

Definition at line 20 of file PrimitiveConverter.h.

int PrimitiveConverter::Th_LUT_St234_Neighbor_[3][12][11][112]
private

Definition at line 21 of file PrimitiveConverter.h.