CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
L1MuGMTMIAUPhiPro1LUT.cc
Go to the documentation of this file.
1 //-------------------------------------------------
2 //
3 // Class: L1MuGMTMIAUPhiPro1LUT
4 //
5 //
6 // $Date: 2008/04/21 17:22:41 $
7 // $Revision: 1.7 $
8 //
9 // Author :
10 // H. Sakulin HEPHY Vienna
11 //
12 // Migrated to CMSSW:
13 // I. Mikulec
14 //
15 //--------------------------------------------------
16 
17 //-----------------------
18 // This Class's Header --
19 //-----------------------
21 
22 //---------------
23 // C++ Headers --
24 //---------------
25 
26 //-------------------------------
27 // Collaborating Class Headers --
28 //-------------------------------
32 
34 
36 
37 using namespace std;
38 
39 //-------------------
40 // InitParameters --
41 //-------------------
42 
44  m_calo_align = 0.; //***FIXME: read from DB or .orcarc
45 }
46 
47 //--------------------------------------------------------------------------------
48 // Phi Projection LUT 1: project in phi based on eta(4bit), pt and charge
49 // =====================
50 //
51 // This LUT contains the phi projection. Based on the fine phi (lower 3 bits of the
52 // phi code) inside a calo region, eta(4bit), pt and charge it delivers a 3-bit offset
53 // to the starting calo region(=upper 5 bits of phi code) and a 1-bit fine grain
54 // information indicating which half of the target calo region the projection points to.
55 //
56 // The offset for positive charge is always positive, for neg charge it is always negative
57 // However, to accomodate for a calo alignment, an offset of 1 region into the opposite
58 // direction is possible.
59 //
60 // meaning of 3-bit calo-offset cphi_ofs:
61 // charge + charge -
62 // offset phi(*) offset phi(*)
63 // 0 | -1 reg -20deg.. 0deg | +1 reg +20deg.. 40deg |
64 // 1 | 0 - 0deg.. 20deg | 0 0deg.. 20deg |
65 // 2 | +1 reg 20deg.. 40deg | -1 reg -20deg.. 0deg |
66 // 3 | +2 reg 40deg.. 60deg | -2 reg -40deg.. -20deg |
67 // 4 | +3 reg 60deg.. 80deg | -3 reg -60deg.. -40deg |
68 // 5 | +4 reg 80deg..100deg | -4 reg -80deg.. -60deg |
69 // 6 | +5 reg 100deg..120deg | -5 reg -100deg.. -80deg |
70 // 7 | +6 reg 120deg..140deg | -6 reg -120deg..-100deg |
71 //
72 // (*) relative to low edge of start region
73 //
74 //
75 //
76 // It is possible to specify a calo alignment: This is the angle between the low
77 // edge of the first calo region an the low edge of the first bin of the muon phi
78 // scale. By default both low edges are at phi=0.
79 //
80 // calo_align = Phi(low edge of first calo reg) - Phi (Low edge of first muon oh bin)
81 //
82 //--------------------------------------------------------------------------------
83 
84 
85 unsigned L1MuGMTMIAUPhiPro1LUT::TheLookupFunction (int idx, unsigned phi_fine, unsigned eta, unsigned pt, unsigned charge) const {
86  // idx is MIP_DT, MIP_BRPC, ISO_DT, ISO_BRPC, MIP_CSC, MIP_FRPC, ISO_CSC, ISO_FRPC
87  // INPUTS: phi_fine(3) eta(4) pt(5) charge(1)
88  // OUTPUTS: cphi_fine(1) cphi_ofs(3)
89 
90 // const L1MuTriggerScales* theTriggerScales = L1MuGMTConfig::getTriggerScales();
91  const L1MuTriggerPtScale* theTriggerPtScale = L1MuGMTConfig::getTriggerPtScale();
92 
93  int isRPC = idx % 2;
94  int isFWD = idx / 4;
95 
96  int isys = isFWD + 2 * isRPC; // DT, CSC, BRPC, FRPC
97  int isISO = (idx / 2) % 2;
98 
99  int ch_idx = (charge == 0) ? 1 : 0; // positive charge is 0 (but idx 1)
100 
101  // currently only support 3-bit eta (3 lower bits); ignore 4th bit
102  if (eta>7) eta -= 8;
103 
104  float dphi = L1MuGMTPhiLUT::dphi (isys, isISO, ch_idx, (int) eta,
105  theTriggerPtScale->getPtScale()->getLowEdge(pt) ); // use old LUT, here
106  // theTriggerScales->getPtScale()->getLowEdge(pt) ); // use old LUT, here
107 
108  // calculate phi in calo relative to low edge of start region
109  // == use low edge of muon phi bin as dphi was calculated with this assumption
110 
111  float calophi = phi_fine * 2.5 / 180. * M_PI - dphi - m_calo_align;
112 
113  if (charge == 0 && calophi < 0.) { // plus charge
114  edm::LogWarning("LUTMismatch")
115  << "warning: calo offset goes into wrong direction. charge is plus and calophi < 0deg" << endl
116  << "SYS=" << ( isys==0?"DT":isys==1? "CSC" : isys== 2? "BRPC" : "FRPC" )
117  << " ISO = " << isISO
118  << " etabin = " << eta
119  << " pval = " << theTriggerPtScale->getPtScale()->getLowEdge(pt)
120  // << " pval = " << theTriggerScales->getPtScale()->getLowEdge(pt)
121  << " charge = " << ( charge==0?"pos":"neg" )
122  << " phi_fine = " << phi_fine
123  << " calophi(deg) = " << calophi * 180. / M_PI
124  << endl;
125  }
126  else if (charge == 1 && calophi > 20. / 180. * M_PI) { // neg charge
127  edm::LogWarning("LUTMismatch")
128  << "warning: calo offset goes into wrong direction. charge is minus and calophi > 20deg" << endl
129  << "SYS=" << ( isys==0?"DT":isys==1? "CSC" : isys== 2? "BRPC" : "FRPC" )
130  << " ISO = " << isISO
131  << " etabin = " << eta
132  << " pval = " << theTriggerPtScale->getPtScale()->getLowEdge(pt)
133  // << " pval = " << theTriggerScales->getPtScale()->getLowEdge(pt)
134  << " charge = " << ( charge==0?"pos":"neg" )
135  << " phi_fine = " << phi_fine
136  << " calophi(deg) = " << calophi * 180. / M_PI
137  << endl;
138  }
139 
140  // which half of calo region
141  int cphi_fine = (int) ( ( calophi + 2. * M_PI ) / ( 10. / 180. * M_PI ) );
142  cphi_fine %= 2;
143 
144  // shift by one region so that an offset in wrong direction w.r.t. bending becomes possible
145  // (may be necessary to accomodate a calo alignment)
146  if (charge == 1) // neg charge
147  calophi = 20. / 180 * M_PI - calophi;
148  calophi += 20. / 180 * M_PI;
149 
150  if (calophi < 0.) {
151  edm::LogWarning("LUTMismatch")
152  << "warning: calo offset goes into wrong direction by more than 20deg !!!! please correct!" << endl;
153  calophi = 0.;
154  }
155  int cphi_ofs = (int) ( calophi / ( 20. / 180. * M_PI) ); // in 20 deg regions
156  // 0; -1 region; 1 no offset; 2: +1 region , ... 7: +6 regions
157 
158  if (cphi_ofs > 7) {
159  edm::LogWarning("LUTMismatch")
160  << "warning: calo offset is larger than 6 regions !!!! please correct!" << endl;
161  cphi_ofs = 7;
162  }
163 
164  return ( (cphi_fine << 3) + cphi_ofs );
165 }
166 
167 
168 
169 
170 
171 
172 
173 
174 
175 
176 
177 
178 
179 
180 
181 
182 
183 
184 
const L1MuScale * getPtScale() const
get the Pt scale
virtual float getLowEdge(unsigned packed) const =0
get the low edge of bin represented by packed
T eta() const
double charge(const std::vector< uint8_t > &Ampls)
void InitParameters()
Initialize scales, configuration parameters, alignment constants, ...
static const L1MuTriggerPtScale * getTriggerPtScale()
#define M_PI
Definition: BFit3D.cc:3
unsigned TheLookupFunction(int idx, unsigned phi_fine, unsigned eta, unsigned pt, unsigned charge) const
The lookup function - here the functionality of the LUT is implemented.
static float dphi(int isys, int isISO, int icharge, int ieta, float pt)
look up delta-phi with integer eta