CMS 3D CMS Logo

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