CMS 3D CMS Logo

/afs/cern.ch/work/a/aaltunda/public/www/CMSSW_5_3_14/src/L1Trigger/GlobalMuonTrigger/src/L1MuGMTMIAUPhiPro1LUT.cc

Go to the documentation of this file.
00001 //-------------------------------------------------
00002 //
00003 //   Class: L1MuGMTMIAUPhiPro1LUT
00004 //
00005 // 
00006 //   $Date: 2008/04/21 17:22:41 $
00007 //   $Revision: 1.7 $
00008 //
00009 //   Author :
00010 //   H. Sakulin            HEPHY Vienna
00011 //
00012 //   Migrated to CMSSW:
00013 //   I. Mikulec
00014 //
00015 //--------------------------------------------------
00016 
00017 //-----------------------
00018 // This Class's Header --
00019 //-----------------------
00020 #include "L1Trigger/GlobalMuonTrigger/src/L1MuGMTMIAUPhiPro1LUT.h"
00021 
00022 //---------------
00023 // C++ Headers --
00024 //---------------
00025 
00026 //-------------------------------
00027 // Collaborating Class Headers --
00028 //-------------------------------
00029 #include "L1Trigger/GlobalMuonTrigger/src/L1MuGMTConfig.h"
00030 #include "CondFormats/L1TObjects/interface/L1MuTriggerScales.h"
00031 #include "CondFormats/L1TObjects/interface/L1MuTriggerPtScale.h"
00032 
00033 #include "L1Trigger/GlobalMuonTrigger/src/L1MuGMTPhiLUT.h"
00034 
00035 #include "FWCore/MessageLogger/interface/MessageLogger.h"
00036 
00037 using namespace std;
00038 
00039 //-------------------
00040 // InitParameters  --
00041 //-------------------
00042 
00043 void L1MuGMTMIAUPhiPro1LUT::InitParameters() {
00044   m_calo_align = 0.; //***FIXME: read from DB or .orcarc
00045 }
00046 
00047 //--------------------------------------------------------------------------------
00048 // Phi Projection LUT 1: project in phi based on eta(4bit), pt and charge
00049 // =====================
00050 //
00051 // This LUT contains the phi projection. Based on the fine phi (lower 3 bits of the 
00052 // phi code) inside a calo region, eta(4bit), pt and charge it delivers a 3-bit offset
00053 // to the starting calo region(=upper 5 bits of phi code) and a 1-bit fine grain 
00054 // information indicating which half of the target calo region the projection points to.
00055 //
00056 // The offset for positive charge is always positive, for neg charge it is always negative
00057 // However, to accomodate for a calo alignment, an offset of 1 region into the opposite 
00058 // direction is possible.
00059 // 
00060 // meaning of 3-bit calo-offset cphi_ofs:
00061 //        charge +               charge - 
00062 //       offset        phi(*)     offset      phi(*)        
00063 // 0   | -1 reg  -20deg..  0deg | +1 reg  +20deg..  40deg |
00064 // 1   | 0       - 0deg.. 20deg | 0         0deg..  20deg |
00065 // 2   | +1 reg   20deg.. 40deg | -1 reg  -20deg..   0deg |
00066 // 3   | +2 reg   40deg.. 60deg | -2 reg  -40deg.. -20deg |
00067 // 4   | +3 reg   60deg.. 80deg | -3 reg  -60deg.. -40deg |
00068 // 5   | +4 reg   80deg..100deg | -4 reg  -80deg.. -60deg |
00069 // 6   | +5 reg  100deg..120deg | -5 reg -100deg.. -80deg |
00070 // 7   | +6 reg  120deg..140deg | -6 reg -120deg..-100deg | 
00071 //
00072 // (*) relative to low edge of start region
00073 //
00074 //
00075 // 
00076 // It is possible to specify a calo alignment: This is the angle between the low 
00077 // edge of the first calo region an the low edge of the first bin of the muon phi 
00078 // scale. By default both low edges are at phi=0. 
00079 //
00080 // calo_align = Phi(low edge of first calo reg) - Phi (Low edge of first muon oh bin)
00081 //
00082 //--------------------------------------------------------------------------------
00083 
00084 
00085 unsigned L1MuGMTMIAUPhiPro1LUT::TheLookupFunction (int idx, unsigned phi_fine, unsigned eta, unsigned pt, unsigned charge) const {
00086   // idx is MIP_DT, MIP_BRPC, ISO_DT, ISO_BRPC, MIP_CSC, MIP_FRPC, ISO_CSC, ISO_FRPC
00087   // INPUTS:  phi_fine(3) eta(4) pt(5) charge(1)
00088   // OUTPUTS: cphi_fine(1) cphi_ofs(3) 
00089 
00090 //  const L1MuTriggerScales* theTriggerScales = L1MuGMTConfig::getTriggerScales();
00091   const L1MuTriggerPtScale* theTriggerPtScale = L1MuGMTConfig::getTriggerPtScale();
00092 
00093   int isRPC = idx % 2;
00094   int isFWD = idx / 4;
00095       
00096   int isys = isFWD + 2 * isRPC; // DT, CSC, BRPC, FRPC
00097   int isISO = (idx / 2) % 2;
00098 
00099   int ch_idx = (charge == 0) ? 1 : 0; // positive charge is 0 (but idx 1)
00100 
00101   // currently only support 3-bit eta (3 lower bits); ignore 4th bit
00102   if (eta>7) eta -= 8;
00103 
00104   float dphi =  L1MuGMTPhiLUT::dphi (isys, isISO, ch_idx, (int) eta, 
00105      theTriggerPtScale->getPtScale()->getLowEdge(pt) );  // use old LUT, here
00106   // theTriggerScales->getPtScale()->getLowEdge(pt) );  // use old LUT, here
00107       
00108   // calculate phi in calo relative to low edge of start region
00109   // == use low edge of muon phi bin as dphi was calculated with this assumption
00110 
00111   float calophi = phi_fine *  2.5 / 180. * M_PI - dphi - m_calo_align;
00112 
00113   if (charge == 0 && calophi < 0.) { // plus charge
00114     edm::LogWarning("LUTMismatch")
00115          << "warning: calo offset goes into wrong direction. charge is plus and calophi < 0deg" << endl
00116          << "SYS=" << ( isys==0?"DT":isys==1? "CSC" : isys== 2? "BRPC" : "FRPC" )
00117          << " ISO = " << isISO
00118          << " etabin = " << eta
00119          << " pval = " << theTriggerPtScale->getPtScale()->getLowEdge(pt)
00120       // << " pval = " << theTriggerScales->getPtScale()->getLowEdge(pt)
00121          << " charge = " << ( charge==0?"pos":"neg" )
00122          << " phi_fine = " << phi_fine
00123          << " calophi(deg) = " << calophi * 180. / M_PI
00124          << endl;
00125   }
00126   else if (charge == 1 && calophi > 20. / 180. * M_PI) { // neg charge
00127      edm::LogWarning("LUTMismatch")
00128          << "warning: calo offset goes into wrong direction. charge is minus and calophi > 20deg" << endl       
00129          << "SYS=" << ( isys==0?"DT":isys==1? "CSC" : isys== 2? "BRPC" : "FRPC" )
00130          << " ISO = " << isISO
00131          << " etabin = " << eta
00132          << " pval = " << theTriggerPtScale->getPtScale()->getLowEdge(pt)
00133        // << " pval = " << theTriggerScales->getPtScale()->getLowEdge(pt)
00134          << " charge = " << ( charge==0?"pos":"neg" )
00135          << " phi_fine = " << phi_fine
00136          << " calophi(deg) = " << calophi * 180. / M_PI
00137          << endl;
00138   }
00139       
00140   // which half of calo region
00141   int cphi_fine = (int) ( ( calophi + 2. * M_PI ) /  ( 10. / 180. * M_PI )  );
00142   cphi_fine %= 2;
00143 
00144   // shift by one region so that an offset in wrong direction w.r.t. bending becomes possible
00145   // (may be necessary to accomodate a calo alignment)
00146   if (charge == 1) // neg charge
00147     calophi = 20. / 180 * M_PI - calophi;
00148   calophi += 20. / 180 * M_PI;
00149 
00150   if (calophi < 0.) {
00151     edm::LogWarning("LUTMismatch")
00152         << "warning: calo offset goes into wrong direction by more than 20deg !!!! please correct!" << endl;    
00153     calophi = 0.;
00154   }
00155   int cphi_ofs =  (int) ( calophi / ( 20. / 180. * M_PI) ); // in 20 deg regions
00156   // 0; -1 region; 1 no offset; 2: +1 region , ... 7: +6 regions
00157 
00158   if (cphi_ofs > 7) {
00159     edm::LogWarning("LUTMismatch")
00160         << "warning: calo offset is larger than 6 regions !!!! please correct!" << endl;        
00161     cphi_ofs = 7;
00162   }
00163 
00164   return (  (cphi_fine << 3) + cphi_ofs  );
00165 }
00166 
00167 
00168 
00169 
00170 
00171 
00172 
00173 
00174 
00175 
00176 
00177 
00178 
00179 
00180 
00181 
00182 
00183 
00184