CMS 3D CMS Logo

MakeRegionalCand.h
Go to the documentation of this file.
1 
5 #ifndef ADD_MakeRegionalCand
6 #define ADD_MakeRegionalCand
7 
8 
11 
12 #include <cmath>
13 
14 int GMT_eta_from_theta[128] = {239, 235, 233, 230, 227, 224, 222, 219, 217, 214, 212, 210, 207, 205, 203, 201,
15  199, 197, 195, 193, 191, 189, 187, 186, 184, 182, 180, 179, 177, 176, 174, 172,
16  171, 169, 168, 166, 165, 164, 162, 161, 160, 158, 157, 156, 154, 153, 152, 151,
17  149, 148, 147, 146, 145, 143, 142, 141, 140, 139, 138, 137, 136, 135, 134, 133,
18  132, 131, 130, 129, 128, 127, 126, 125, 124, 123, 122, 121, 120, 119, 118, 117,
19  116, 116, 115, 114, 113, 112, 111, 110, 110, 109, 108, 107, 106, 106, 105, 104,
20  103, 102, 102, 101, 100, 99, 99, 98, 97, 96, 96, 95, 94, 93, 93, 92,
21  91, 91, 90, 89, 89, 88, 87, 87, 86, 85, 84, 84, 83, 83, 82, 81};
22 
23 int GetPackedEta (int theta, int sector) {
24 
25  if (theta < 0) return 0;
26  if (sector > 5) {
27  if (theta > 127) return -240;
28  else return -1*GMT_eta_from_theta[theta] - 1;
29  }
30  else {
31  if (theta > 127) return 239;
32  else return GMT_eta_from_theta[theta];
33  }
34 }
35 
36 float GetGlobalEta(int theta, int sector){ // Should use calc_eta to compute - AWB 07.05.16
37 
38  // Underlying calculation:
39  // float theta_angle = (theta*0.2851562 + 8.5)*(pi/180);
40  // float eta = (-1)*log(tan(theta_angle/2));
41 
42  return 0.010875 * GetPackedEta(theta, sector);
43 }
44 
45 int GetPackedPhi(int phi){
46 
47  // Experimentally, this factor must be between 0.979752 and 0.979758 - AWB 11.05.16
48  float phiDeg = (phi / (0.625 * 60)) * 0.979755;
49  int PackedPhi = floor( phiDeg - 35 );
50 
51  return PackedPhi;
52 
53 }
54 
55 
57  int sign, int mode,
58  int trackaddress, int sector){
59 
61 
62  int iEta = GetPackedEta(theta,sector);
63  int iPhi = GetPackedPhi(phi);
64 
66  if(sector > 5){
67  TFtype = l1t::tftype::emtf_neg;
68  sector -= 6;
69  }
70 
71  // compressed pt = pt*2 (scale) + 1 (iPt = 0 is empty candidate)
72  int iPt = pt*2 + 1;
73  if(iPt > 511)
74  iPt = 511;
75 
76  if(iPt < 0)
77  iPt = 0;
78 
79  int iQual = -999;
80 
81  int LSB = mode & 3;
82 
83  float eta = GetGlobalEta(theta,sector);
84 
85  if(eta < 1.2){
86 
87  switch(mode){
88  case(15): iQual = 8;break;
89  case(14): iQual = 4;break;
90  case(13): iQual = 4;break;
91  case(12): iQual = 4;break;
92  case(11): iQual = 4;break;
93  default: iQual = 4;break;
94  }
95 
96  }
97  else{
98 
99  switch(mode){
100  case(15): iQual = 12;break;
101  case(14): iQual = 12;break;
102  case(13): iQual = 12;break;
103  case(12): iQual = 8;break;
104  case(11): iQual = 12;break;
105  case(10): iQual = 8;break;
106  case(7): iQual = 8;break;
107  default: iQual = 4;break;
108  }
109 
110  }
111  iQual |= LSB;
112 
113  Cand.setHwPt(iPt);
114  Cand.setHwEta(iEta);
115  Cand.setHwPhi(iPhi);
116  Cand.setHwSign(sign);
117  Cand.setHwSignValid(1);
118  Cand.setHwQual(iQual);
119  // jl: FIXME this has to be adapted to the new schema of saving track addresses
120  //Cand.setTrackSubAddress(l1t::RegionalMuonCand::kME12, trackaddress&0xf);
121  //Cand.setTrackSubAddress(l1t::RegionalMuonCand::kME22, trackaddress>>4);
122  Cand.setTFIdentifiers(sector,TFtype);
123 
124  return Cand;
125 
126 }
127 
128 #endif
void setHwPhi(int bits)
Set compressed relative phi as transmitted by hardware LSB = 2*pi/576 (8 bits)
Geom::Theta< T > theta() const
int GetPackedPhi(int phi)
void setTFIdentifiers(int processor, tftype trackFinder)
Set the processor ID, track-finder type. From these two, the link is set.
l1t::RegionalMuonCand MakeRegionalCand(float pt, int phi, int theta, int sign, int mode, int trackaddress, int sector)
float GetGlobalEta(int theta, int sector)
void setHwQual(int bits)
Set compressed quality code as transmitted by hardware (4 bits)
void setHwPt(int bits)
Set compressed pT as transmitted by hardware LSB = 0.5 (9 bits)
void setHwEta(int bits)
Set compressed eta as transmitted by hardware LSB = 0.010875 (9 bits)
int GetPackedEta(int theta, int sector)
int GMT_eta_from_theta[128]
void setHwSignValid(int bits)
Set whether charge measurement is valid (0 for high pT muons)
void setHwSign(int bits)
Set charge sign bit (charge = (-1)^(sign))