test
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< L1TMuon::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 66 of file PrimitiveConverter.cc.

References read_buf().

66  {
67  read_buf("L1Trigger/L1TMuon/data/emtf_luts/ph_lut_v1/ph_disp_neighbor.txt", &Ph_Disp_Neighbor_[0][0], 12*61);
68  read_buf("L1Trigger/L1TMuon/data/emtf_luts/ph_lut_v1/ph_init_neighbor.txt", &Ph_Init_Neighbor_[0][0][0], 12*5*16);
69  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);
70  read_buf("L1Trigger/L1TMuon/data/emtf_luts/ph_lut_v1/th_init_neighbor.txt", &Th_Init_Neighbor_[0][0], 12*61);
71  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);
72  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);
73 }
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< L1TMuon::TriggerPrimitive TriggPrim,
int  SectIndex 
)
Define Subsector ///

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

Define look-up index ///

Definition at line 75 of file PrimitiveConverter.cc.

References ConvertedHit::AddTheta(), rpcdqm::BX, L1TMuon::TriggerPrimitive::CSCData::bx, CSCDetId::chamber(), gather_cfg::cout, L1TMuon::TriggerPrimitive::detId(), Reference_intrackfit_cff::endcap, CSCDetId::endcap(), V0MonitoringClient_cfi::factor, L1TMuon::TriggerPrimitive::getCSCData(), L1TMuon::TriggerPrimitive::getPattern(), L1TMuon::TriggerPrimitive::Id(), recoMuon::in, cmsHarvester::index, L1TMuon::TriggerPrimitive::CSCData::keywire, neighbor(), listBenchmarks::pattern, ph_offsets, ConvertedHit::Phi(), L1TMuon::TriggerPrimitive::CSCData::quality, HLT_25ns10e33_v2_cff::quality, relativeConstraints::ring, CSCDetId::ring(), ConvertedHit::SetNeighbor(), ConvertedHit::SetSectorIndex(), ConvertedHit::SetTP(), ConvertedHit::SetValues(), ConvertedHit::SetZhit(), ConvertedHit::SetZoneWord(), relativeConstraints::station, CSCDetId::station(), L1TMuon::TriggerPrimitive::CSCData::strip, ConvertedHit::Theta(), and CSCDetId::triggerSector().

75  {
76 
77  //bool verbose = false;
78 
79  std::vector<ConvertedHit> ConvHits;
80  for(std::vector<L1TMuon::TriggerPrimitive>::iterator C1 = TriggPrim.begin();C1 != TriggPrim.end();C1++){
81 
86  CSCDetId Det = C3.detId<CSCDetId>();
87 
88  int station = Det.station(), chamber = Det.chamber(), ring = Det.ring(), wire = C3.getCSCData().keywire;
89  int sector = Det.triggerSector(), strip = C3.getCSCData().strip, pattern = C3.getPattern(), Id = C3.Id();
90  int quality = C3.getCSCData().quality, BX = C3.getCSCData().bx, endcap = Det.endcap();
91 
92  if (station == 1 && ring == 1 && strip > 127) ring = 4;
93  int sub = 0;
94 
99 
100  if (station == 1)//is this correct? I know it starts from 1 so not quite what I intended I think.
101  {
102  if(chamber%6 > 2)
103  sub = 1;
104  else
105  sub = 2;
106  }
107 
108  bool IsNeighbor = neighbor(endcap,sector,SectIndex,Id,sub,station);
109 
110  if(ring == 4){Id += 9;}
111 
112  if( (SectIndex == (endcap - 1)*6 + sector - 1 ) || IsNeighbor ) {
113 
117 
118  int ph_tmp = -999, th_tmp = -999;
119  int clctpatcor = -999, clctpatsign = -999;
120  int eightstrip = -999;
121 
122  int factor = (station == 1 && ring == 4) ? 1707://ME1/1a1707?
123  (station == 1 && ring == 3) ? 947: //ME1/3//changed Id > 6 to ring == 3.
124  (station == 1 && ring == 1) ? 1301://ME1/1b
125  1024;//all other chambers
126 
127  bool ph_reverse = (endcap == 1 && station >= 3) ? 1:
128  (endcap == 2 && station < 3) ? 1: 0;
129 
130  int ph_coverage = (station <= 1 && Id > 6 && Id < 10) ? 15 : //30 :
131  (station >= 2 && Id <= 3) ? 40 : 20; //80 : 40;
132 
133  int th_coverage = (station == 1 && Id <= 3) ? 45 :
134  (station == 1 && Id > 6 && Id < 10) ? 27 :
135  (station == 1 && Id > 3) ? 39 :
136  (station == 2 && Id <= 3) ? 43 :
137  (station == 2 && Id > 3) ? 56 :
138  (station == 3 && Id <= 3) ? 34 :
139  (station == 3 && Id > 3) ? 52 :
140  (station == 4 && Id <= 3) ? 28 :
141  (station == 4 && Id > 3) ? 50 : 0;
142 
143  int ph_zone_bnd1 = (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 
158 
159  int LUTi = -999;
160  int nId = Id;
161  if(IsNeighbor){
162 
163  if(station < 2){
164  nId = 12 + Id/3;
165  }
166  else{
167  int xx = Id;
168  if(xx > 6) xx = 6;
169  nId = 9 + xx/3;
170  }
171  }
172  switch(station)
173  {
174  case 1:
175  switch(sub)
176  {
177  case 1: LUTi = nId - 1;break;
178  case 2: LUTi = 15 + nId;break;
179  default:;//std::cout<<"Sub is out of range"<<std::endl;
180  }
181  break;
182  case 2: LUTi = 27 + nId;break;
183  case 3: LUTi = 38 + nId;break;
184  case 4: LUTi = 49 + nId;break;
185  default:;//std::cout<<"station is out of range"<<std::endl;
186  }
187  if(IsNeighbor && station == 1){
188  switch(sub)
189  {
190  case 1: LUTi = 15 + nId;break;
191  case 2: LUTi = nId - 1;break;
192  default:;//std::cout<<"Sub is out of range"<<std::endl;
193  }
194  }
195 
199 
200  clctpatcor = 0;
201  clctpatsign = 0;
202 
203  if(pattern > 0 && pattern < 11){
204  clctpatsign = ((pattern%2) == 0);
205  if(pattern >= 2) {clctpatcor = 5;}
206  if(pattern >= 6) {clctpatcor = 2;}
207  if(pattern == 10) {clctpatcor = 0;clctpatsign = 0;}
208  }
209 
213 
214  eightstrip = 8*strip;
215  int patcor = clctpatcor;
216 
217  if(station == 1 || Id > 3){//10 Degree Chambers
218  eightstrip = (eightstrip>>1);
219  patcor = (patcor>>1);
220  if(ring == 4 && strip > 127) eightstrip -= 512;
221  }
222 
223  if(clctpatsign) patcor = -patcor;
224  eightstrip += patcor;
225 
229 
230  ph_tmp = ((eightstrip*factor)>>10);
231  int phShift = (ph_tmp>>5);
232  int phLow = 0;
233 
234  if(ph_reverse){
235  ph_tmp = -ph_tmp;
236  phShift = -phShift;
237  phLow = ph_coverage;
238  }
239 
240  int phInitIndex = Id;
241 
242  if(station == 1){
243  int neighborId = C3.Id()/3;
244  int subId = sub;
245  if(IsNeighbor ){
246  subId = 1;
247  phInitIndex = 12 + neighborId;
248  if(ring == 4)
249  phInitIndex = 16;//phInitIndex++;
250  }
251  fph = Ph_Init_Neighbor_[SectIndex][subId-1][phInitIndex - 1] + ph_tmp;
252  }
253  else{
254  int neighborId = Id/3;
255  if(neighborId > 2) neighborId = 2;
256 
257  if(IsNeighbor) phInitIndex = 9 + neighborId;
258 
259  fph = Ph_Init_Neighbor_[SectIndex][station][phInitIndex - 1] + ph_tmp;
260  }
261 
262  if (station == 0 || nId == -1 || SectIndex < 0 || SectIndex > 11 || LUTi < 0 || LUTi > 60) {
263  std::cout << "\n*********************************************************************" << std::endl;
264  std::cout << "EMTF malformed LCT: BX " << C3.getCSCData().bx << ", endcap " << Det.endcap()
265  << ", station " << Det.station() << ", sector " << Det.triggerSector()
266  << ", ring " << Det.ring() << ", ID " << C3.Id() << ", chamber " << Det.chamber()
267  << ", strip " << C3.getCSCData().strip << ", wire " << C3.getCSCData().keywire
268  << ", pattern " << C3.getPattern() << ", quality " << C3.getCSCData().quality << std::endl;
269  std::cout << "Produces: station " << station << ", nId " << nId
270  << ", SectIndex " << SectIndex << ", LUTi " << LUTi << std::endl;
271  continue;
272  }
273 
274  ph_hit = phLow + phShift + (Ph_Disp_Neighbor_[SectIndex][LUTi]>>1);
275 
279 
280  int index = -999;
281  int th_corr = -999;
282  int idl = Id;
283 
284  if(station == 1){
285  int neighborId = C3.Id()/3;
286  int subId = sub;
287  if(IsNeighbor){
288  subId = 1;
289  idl = 12 + neighborId;
290  if(ring == 4) idl = 16;
291  }
292  th_tmp = Th_LUT_St1_Neighbor_[subId-1][SectIndex][idl -1][wire];
293  }
294  else{
295  int neighborId = Id/3;
296  if(neighborId > 2) neighborId = 2;
297  if(IsNeighbor) idl = 9 + neighborId;
298  th_tmp = Th_LUT_St234_Neighbor_[station-2][SectIndex][idl-1][wire];
299  }
300 
301  th = th_tmp + Th_Init_Neighbor_[SectIndex][LUTi];
302  int rth = th;
303 
304  if(station == 1 && (ring == 1 || ring == 4) /*&& endcap == 1*/){
305 
306  index = (wire>>4)*32 + (eightstrip>>4);
307 
308  int corrIndex = Id;
309  int subId = sub;
310  if(corrIndex > 3) corrIndex -= 9;
311 
312  if(IsNeighbor && ring == 4){
313  subId = 1;
314  corrIndex++;
315  }
316 
317  th_corr = Th_Corr_Neighbor_[subId-1][SectIndex][corrIndex-1][index];
318 
319  if(ph_reverse) th_corr = -th_corr;
320 
321  th_tmp += th_corr; // add correction to th_tmp
322  if(th_tmp < 0 || wire == 0) th_tmp = 0;
323 
324  if(th_tmp > th_coverage)//this is one change that I'm not sure if it does anything good or not
325  th_tmp = th_coverage;
326 
327  th_tmp &= 0x3f; //keep only lowest 6 bits
328 
329  if (th_tmp <= th_coverage) th = th_tmp + Th_Init_Neighbor_[SectIndex][LUTi];
330  else th = rth; //was -999
331  }
332 
336 
337  if(th != -999){
338  phzvl = 0;
339  if (th <= (ph_zone_bnd1 + zone_overlap)) phzvl |= 1;
340  if (th > (ph_zone_bnd2 - zone_overlap)) phzvl |= 4;
341  if ((th > (ph_zone_bnd1 - zone_overlap)) && (th <= (ph_zone_bnd2 + zone_overlap))) phzvl |= 2;
342  }
343 
349 
350  if(ring == 4){
351  Id -= 9;
352  if(strip < 128) strip += 128;
353  }
354 
355  //determination of zone contribution
356  int zoneword = 0, zhit = -99, zmask[4] = {1,2,4,8};
357  bool zoneConditions[4] {((phzvl & 1) && (Id < 4)),
358  (((phzvl & 2) && (Id < 4) && (station < 3)) || ((phzvl & 1) && (Id > 3) && (station > 2))),
359  (((phzvl & 1) && (Id > 3) && (Id < 7) && (station == 1)) || ((phzvl & 1) && (Id > 3) && (station == 2)) || ((phzvl & 2) && (Id > 3) && (station > 2))),
360  ( ((station == 1) && (Id > 6)) || ((phzvl & 2) && (Id > 3) && (station == 2)) || ((phzvl & 4) && (station == 3) && (Id > 3)) )};
361 
362  for(int z=0;z<4;z++){
363  if(zoneConditions[z]) zoneword |= zmask[z];
364  }
365 
366  int cindex = Id - 1;
367  int sindex = station;
368  if(sub == 1) sindex--;
369 
370  if(IsNeighbor){
371  sindex = 5;
372  if(station == 1) cindex = Id/3 - 1;
373  else cindex = (station - 1)*2 + ((Id > 6) ? 2:1);
374  }
375 
376  zhit = ph_hit + ph_offsets[sindex][cindex];
377 
382 
384 
385  int in = 0;
386  if(IsNeighbor) in = 1;
387 
388  Hit.SetValues(fph,th,ph_hit,phzvl,station,sub,Id,quality,pattern,wire,strip,BX);
389  Hit.AddTheta(th);
390  Hit.SetTP(C3);
391  Hit.SetZhit(zhit);
392  Hit.SetSectorIndex(SectIndex);
393  Hit.SetNeighbor(in);
394  Hit.SetZoneWord(zoneword);
395 
396  if(Hit.Theta() != -999 && Hit.Phi() > 0 ){//if theta is valid
397  ConvHits.push_back(Hit);
398  }
399  else {
400  std::cout << "\n#####################################################################" << std::endl;
401  std::cout << "LCT w/o theta/phi: BX " << C3.getCSCData().bx << ", endcap " << Det.endcap()
402  << ", station " << Det.station() << ", sector " << Det.triggerSector()
403  << ", ring " << Det.ring() << ", ID " << C3.Id() << ", chamber " << Det.chamber()
404  << ", strip " << C3.getCSCData().strip << ", wire " << C3.getCSCData().keywire
405  << ", pattern " << C3.getPattern() << ", quality " << C3.getCSCData().quality << std::endl;
406  std::cout << "Has fph " << fph << ", th " << th << ", ph_hit " << ph_hit
407  << ", phzvl " << phzvl << ", station " << station << ", sub " << sub
408  << ", Id " << Id << ", quality " << quality << ", pattern " << pattern
409  << ", wire " << wire << ", strip " << strip << ", BX " << BX << std::endl;
410  }
411 
412  } //if sector == sectIndex
413  }
414  return ConvHits;
415 }
unsigned int Th_Init_Neighbor_[12][61]
int chamber() const
Definition: CSCDetId.h:68
void SetNeighbor(int neighbor)
int Th_LUT_St234_Neighbor_[3][12][11][112]
void SetZoneWord(int zword)
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
void SetTP(L1TMuon::TriggerPrimitive tp)
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
void AddTheta(int theta)
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
tuple cout
Definition: gather_cfg.py:145
int Ph_Init_Neighbor_[12][5][16]
void SetSectorIndex(int sectorIndex)
int ph_offsets[6][9]

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.