Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:19:57

0001 //-------------------------------------------------
0002 //
0003 //   Class: L1MuGMTMIAUPhiPro1LUT
0004 //
0005 //
0006 //
0007 //   Author :
0008 //   H. Sakulin            HEPHY Vienna
0009 //
0010 //   Migrated to CMSSW:
0011 //   I. Mikulec
0012 //
0013 //--------------------------------------------------
0014 
0015 //-----------------------
0016 // This Class's Header --
0017 //-----------------------
0018 #include "L1Trigger/GlobalMuonTrigger/src/L1MuGMTMIAUPhiPro1LUT.h"
0019 
0020 //---------------
0021 // C++ Headers --
0022 //---------------
0023 
0024 //-------------------------------
0025 // Collaborating Class Headers --
0026 //-------------------------------
0027 #include "L1Trigger/GlobalMuonTrigger/src/L1MuGMTConfig.h"
0028 #include "CondFormats/L1TObjects/interface/L1MuTriggerScales.h"
0029 #include "CondFormats/L1TObjects/interface/L1MuTriggerPtScale.h"
0030 
0031 #include "L1Trigger/GlobalMuonTrigger/src/L1MuGMTPhiLUT.h"
0032 
0033 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0034 
0035 using namespace std;
0036 
0037 //-------------------
0038 // InitParameters  --
0039 //-------------------
0040 
0041 void L1MuGMTMIAUPhiPro1LUT::InitParameters() {
0042   m_calo_align = 0.;  //***FIXME: read from DB or .orcarc
0043 }
0044 
0045 //--------------------------------------------------------------------------------
0046 // Phi Projection LUT 1: project in phi based on eta(4bit), pt and charge
0047 // =====================
0048 //
0049 // This LUT contains the phi projection. Based on the fine phi (lower 3 bits of the
0050 // phi code) inside a calo region, eta(4bit), pt and charge it delivers a 3-bit offset
0051 // to the starting calo region(=upper 5 bits of phi code) and a 1-bit fine grain
0052 // information indicating which half of the target calo region the projection points to.
0053 //
0054 // The offset for positive charge is always positive, for neg charge it is always negative
0055 // However, to accomodate for a calo alignment, an offset of 1 region into the opposite
0056 // direction is possible.
0057 //
0058 // meaning of 3-bit calo-offset cphi_ofs:
0059 //        charge +               charge -
0060 //       offset        phi(*)     offset      phi(*)
0061 // 0   | -1 reg  -20deg..  0deg | +1 reg  +20deg..  40deg |
0062 // 1   | 0       - 0deg.. 20deg | 0         0deg..  20deg |
0063 // 2   | +1 reg   20deg.. 40deg | -1 reg  -20deg..   0deg |
0064 // 3   | +2 reg   40deg.. 60deg | -2 reg  -40deg.. -20deg |
0065 // 4   | +3 reg   60deg.. 80deg | -3 reg  -60deg.. -40deg |
0066 // 5   | +4 reg   80deg..100deg | -4 reg  -80deg.. -60deg |
0067 // 6   | +5 reg  100deg..120deg | -5 reg -100deg.. -80deg |
0068 // 7   | +6 reg  120deg..140deg | -6 reg -120deg..-100deg |
0069 //
0070 // (*) relative to low edge of start region
0071 //
0072 //
0073 //
0074 // It is possible to specify a calo alignment: This is the angle between the low
0075 // edge of the first calo region an the low edge of the first bin of the muon phi
0076 // scale. By default both low edges are at phi=0.
0077 //
0078 // calo_align = Phi(low edge of first calo reg) - Phi (Low edge of first muon oh bin)
0079 //
0080 //--------------------------------------------------------------------------------
0081 
0082 unsigned L1MuGMTMIAUPhiPro1LUT::TheLookupFunction(
0083     int idx, unsigned phi_fine, unsigned eta, unsigned pt, unsigned charge) const {
0084   // idx is MIP_DT, MIP_BRPC, ISO_DT, ISO_BRPC, MIP_CSC, MIP_FRPC, ISO_CSC, ISO_FRPC
0085   // INPUTS:  phi_fine(3) eta(4) pt(5) charge(1)
0086   // OUTPUTS: cphi_fine(1) cphi_ofs(3)
0087 
0088   //  const L1MuTriggerScales* theTriggerScales = L1MuGMTConfig::getTriggerScales();
0089   const L1MuTriggerPtScale* theTriggerPtScale = L1MuGMTConfig::getTriggerPtScale();
0090 
0091   int isRPC = idx % 2;
0092   int isFWD = idx / 4;
0093 
0094   int isys = isFWD + 2 * isRPC;  // DT, CSC, BRPC, FRPC
0095   int isISO = (idx / 2) % 2;
0096 
0097   int ch_idx = (charge == 0) ? 1 : 0;  // positive charge is 0 (but idx 1)
0098 
0099   // currently only support 3-bit eta (3 lower bits); ignore 4th bit
0100   if (eta > 7)
0101     eta -= 8;
0102 
0103   float dphi = L1MuGMTPhiLUT::dphi(isys,
0104                                    isISO,
0105                                    ch_idx,
0106                                    (int)eta,
0107                                    theTriggerPtScale->getPtScale()->getLowEdge(pt));  // use old LUT, here
0108   // theTriggerScales->getPtScale()->getLowEdge(pt) );  // use old LUT, here
0109 
0110   // calculate phi in calo relative to low edge of start region
0111   // == use low edge of muon phi bin as dphi was calculated with this assumption
0112 
0113   float calophi = phi_fine * 2.5 / 180. * M_PI - dphi - m_calo_align;
0114 
0115   if (charge == 0 && calophi < 0.) {  // plus charge
0116     edm::LogWarning("LUTMismatch")
0117         << "warning: calo offset goes into wrong direction. charge is plus and calophi < 0deg" << endl
0118         << "SYS="
0119         << (isys == 0   ? "DT"
0120             : isys == 1 ? "CSC"
0121             : isys == 2 ? "BRPC"
0122                         : "FRPC")
0123         << " ISO = " << isISO << " etabin = " << eta << " pval = "
0124         << theTriggerPtScale->getPtScale()->getLowEdge(pt)
0125         // << " pval = " << theTriggerScales->getPtScale()->getLowEdge(pt)
0126         << " charge = " << (charge == 0 ? "pos" : "neg") << " phi_fine = " << phi_fine
0127         << " calophi(deg) = " << calophi * 180. / M_PI << endl;
0128   } else if (charge == 1 && calophi > 20. / 180. * M_PI) {  // neg charge
0129     edm::LogWarning("LUTMismatch")
0130         << "warning: calo offset goes into wrong direction. charge is minus and calophi > 20deg" << endl
0131         << "SYS="
0132         << (isys == 0   ? "DT"
0133             : isys == 1 ? "CSC"
0134             : isys == 2 ? "BRPC"
0135                         : "FRPC")
0136         << " ISO = " << isISO << " etabin = " << eta << " pval = "
0137         << theTriggerPtScale->getPtScale()->getLowEdge(pt)
0138         // << " pval = " << theTriggerScales->getPtScale()->getLowEdge(pt)
0139         << " charge = " << (charge == 0 ? "pos" : "neg") << " phi_fine = " << phi_fine
0140         << " calophi(deg) = " << calophi * 180. / M_PI << endl;
0141   }
0142 
0143   // which half of calo region
0144   int cphi_fine = (int)((calophi + 2. * M_PI) / (10. / 180. * M_PI));
0145   cphi_fine %= 2;
0146 
0147   // shift by one region so that an offset in wrong direction w.r.t. bending becomes possible
0148   // (may be necessary to accomodate a calo alignment)
0149   if (charge == 1)  // neg charge
0150     calophi = 20. / 180 * M_PI - calophi;
0151   calophi += 20. / 180 * M_PI;
0152 
0153   if (calophi < 0.) {
0154     edm::LogWarning("LUTMismatch")
0155         << "warning: calo offset goes into wrong direction by more than 20deg !!!! please correct!" << endl;
0156     calophi = 0.;
0157   }
0158   int cphi_ofs = (int)(calophi / (20. / 180. * M_PI));  // in 20 deg regions
0159   // 0; -1 region; 1 no offset; 2: +1 region , ... 7: +6 regions
0160 
0161   if (cphi_ofs > 7) {
0162     edm::LogWarning("LUTMismatch") << "warning: calo offset is larger than 6 regions !!!! please correct!" << endl;
0163     cphi_ofs = 7;
0164   }
0165 
0166   return ((cphi_fine << 3) + cphi_ofs);
0167 }