CMS 3D CMS Logo

/data/git/CMSSW_5_3_11_patch5/src/L1Trigger/CSCTrackFinder/src/CSCSectorReceiverMiniLUT.cc

Go to the documentation of this file.
00001 #include <L1Trigger/CSCCommonTrigger/interface/CSCTriggerGeometry.h>
00002 #include <L1Trigger/CSCCommonTrigger/interface/CSCTriggerGeomManager.h>
00003 #include <L1Trigger/CSCCommonTrigger/interface/CSCPatternLUT.h>
00004 #include <L1Trigger/CSCCommonTrigger/interface/CSCFrontRearLUT.h>
00005 #include <DataFormats/L1CSCTrackFinder/interface/CSCBitWidths.h>
00006 #include <DataFormats/L1CSCTrackFinder/interface/CSCTFConstants.h>
00007 #include <L1Trigger/CSCCommonTrigger/interface/CSCConstants.h>
00008 
00009 #include <Geometry/CSCGeometry/interface/CSCLayerGeometry.h>
00010 #include "DataFormats/GeometryVector/interface/LocalPoint.h"
00011 #include "DataFormats/GeometryVector/interface/GlobalPoint.h"
00012 
00013 #include <DataFormats/MuonDetId/interface/CSCTriggerNumbering.h>
00014 
00015 #include <FWCore/MessageLogger/interface/MessageLogger.h>
00016 
00017 #include <fstream>
00018 #include <math.h>
00019 #include <L1Trigger/CSCTrackFinder/interface/CSCSectorReceiverMiniLUT.h>
00020 
00021 lclphidat CSCSectorReceiverMiniLUT::calcLocalPhiMini(unsigned theadd)
00022 {
00023   // This method is ripped from CSCSectorReceverLUT.cc with minor changes
00024   
00025   lclphidat data;
00026   
00027   static int maxPhiL = 1<<CSCBitWidths::kLocalPhiDataBitWidth;
00028   unsigned short int pattern = ((theadd >> 8) & 0xf);
00029   unsigned short int strip   = (theadd & 0xff);
00030   
00031   if(strip < 2*CSCConstants::MAX_NUM_STRIPS && pattern < CSCConstants::NUM_CLCT_PATTERNS)
00032     data.phi_local = static_cast<unsigned>((lcl_phi_param0[pattern] + strip)*lcl_phi_param1);
00033   else
00034     edm::LogWarning("CSCSectorReceiverMiniLUT")
00035       << "+++ Value of strip, " << strip
00036       << ", exceeds max allowed, " << 2*CSCConstants::MAX_NUM_STRIPS-1
00037       << " +++\n";
00038   
00039   if(data.phi_local >= maxPhiL)
00040     edm::LogWarning("CSCSectorReceiverMiniLUT")
00041       << "+++ Value of phi_local, " << data.phi_local
00042       << ", exceeds max allowed, " << CSCConstants::NUM_CLCT_PATTERNS-1 << " +++\n";
00043   
00044 //  data.phi_bend_local = 0;
00045 // Just pass through all bits of pattern as bend angle (so 2 MSB unfilled)
00046   data.phi_bend_local = pattern & 0x3F;
00047 
00048   return data;
00049 }
00050 
00051 global_eta_data CSCSectorReceiverMiniLUT::calcGlobalEtaMEMini(unsigned short endcap, 
00052                                                               unsigned short sector, 
00053                                                               unsigned short station, 
00054                                                               unsigned short subsector, 
00055                                                               unsigned theadd)
00056 {
00057   if(endcap < 1 || endcap > 2)
00058     edm::LogWarning("CSCSectorReceiverMiniLUT")
00059       << "+++ Value of endcap, " << endcap
00060       << ", is out of bounds, [1, 2] +++\n";
00061   if(sector < 1 || sector > 6)
00062     edm::LogWarning("CSCSectorReceiverMiniLUT")
00063       << "+++ Value of sector, " << sector
00064       << ", is out of bounds, [1, 6] +++\n";
00065   if(station < 1 || station > 4)
00066     edm::LogWarning("CSCSectorReceiverMiniLUT")
00067       << "+++ Value of station, " << station
00068       << ", is out of bounds, [1, 4] +++\n";
00069   
00070   gbletadat data(0);
00071   
00072   unsigned short int cscid  = ((theadd >> 15) & 0xf);
00073   unsigned short int lclPhi = ((theadd >> 6)  & 0x3);
00074   unsigned short int WG     = ((theadd >> 8)  & 0x7f);
00075   unsigned short int bend   = ((theadd)       & 0x3f);
00076   
00077   int eta_temp=999, eta_min=999, eta_max=999;
00078   
00079   if((cscid > 0) && (cscid <= 9) && (WG < CSCConstants::MAX_NUM_WIRES))
00080     {
00081       if(station == 1)
00082         {
00083           eta_temp = (gbl_eta_params[endcap-1][sector-1][station-1][subsector-1][lclPhi][cscid-1][0] + 
00084                       gbl_eta_params[endcap-1][sector-1][station-1][subsector-1][lclPhi][cscid-1][1] *
00085                       log(gbl_eta_params[endcap-1][sector-1][station-1][subsector-1][lclPhi][cscid-1][2] + WG));
00086           eta_min = gbl_eta_bounds[endcap-1][sector-1][station-1][subsector-1][lclPhi][cscid-1][0];
00087           eta_max = gbl_eta_bounds[endcap-1][sector-1][station-1][subsector-1][lclPhi][cscid-1][1];
00088 
00089           // add offset to ME+11a, subtract for ME-11a (wire tilt and strip direction)1
00090           if ( (cscid < 4)&&(lclPhi == 3) ) {
00091             if (endcap == 1) 
00092               eta_temp += 3;  
00093             else
00094               eta_temp -= 3;  
00095           }
00096         }
00097       else
00098         {
00099           eta_temp = (gbl_eta_params[endcap-1][sector-1][station-1][0][lclPhi][cscid-1][0] + 
00100                       gbl_eta_params[endcap-1][sector-1][station-1][0][lclPhi][cscid-1][1] *
00101                       log(gbl_eta_params[endcap-1][sector-1][station-1][0][lclPhi][cscid-1][2] + WG));
00102           eta_min = gbl_eta_bounds[endcap-1][sector-1][station-1][0][lclPhi][cscid-1][0];
00103           eta_max = gbl_eta_bounds[endcap-1][sector-1][station-1][0][lclPhi][cscid-1][1];
00104         }
00105     }
00106   else
00107     {
00108       edm::LogWarning("CSCSectorReceiverMiniLUT")
00109         << "+++ Value of cscid, " << cscid
00110         << ", is out of bounds, [1, 9] -- or --"
00111         << " Value of wire group, " << WG 
00112         << ", exceeds max allowed, " << CSCConstants::MAX_NUM_WIRES << " +++\n";
00113     }
00114   
00115   // protect from negative numbers.  If the value of eta_temp is <0, set global eta to the minimum value
00116   if((eta_temp >= eta_min) &&
00117      (eta_temp <= eta_max))
00118     data.global_eta = eta_temp;
00119   else if(eta_temp < eta_min)
00120     data.global_eta = eta_min;
00121   else
00122     data.global_eta = eta_max;
00123   
00124 //  data.global_bend = 0;
00125 // Just pass through lowest 5 bits of local bend (drop 1 MSB)
00126   data.global_bend = bend & 0x1F;
00127   
00128   return data;
00129 }
00130 
00131 global_phi_data CSCSectorReceiverMiniLUT::calcGlobalPhiMEMini(unsigned short endcap, 
00132                                                               unsigned short sector, 
00133                                                               unsigned short station, 
00134                                                               unsigned short subsector, 
00135                                                               unsigned theadd)
00136 {
00137   if(endcap < 1 || endcap > 2)
00138     edm::LogWarning("CSCSectorReceiverMiniLUT")
00139       << "+++ Value of endcap, " << endcap
00140       << ", is out of bounds, [1, 2] +++\n";
00141   if(sector < 1 || sector > 6)
00142     edm::LogWarning("CSCSectorReceiverMiniLUT")
00143       << "+++ Value of sector, " << sector
00144       << ", is out of bounds, [1, 6] +++\n";
00145   if(station < 1 || station > 4)
00146     edm::LogWarning("CSCSectorReceiverMiniLUT")
00147       << "+++ Value of station, " << station
00148       << ", is out of bounds, [1, 4] +++\n";
00149   
00150   gblphidat data(0);
00151   
00152   unsigned short int maxPhiL = 1<<CSCBitWidths::kLocalPhiDataBitWidth;
00153   unsigned short int maxPhiG = 1<<CSCBitWidths::kGlobalPhiDataBitWidth;
00154   unsigned short int cscid  = ((theadd >> 15)&0xf);
00155   unsigned short int lclPhi = (theadd & 0x3ff);
00156 
00157   // 12/11/09
00158   // GP et DA: how to identify the strip number and isolate and shift the localPhi value
00159   const double binPhiL = static_cast<double>(maxPhiL)/(2*CSCConstants::MAX_NUM_STRIPS);
00160 
00161   int strip = static_cast<int>(lclPhi/binPhiL);
00162   //  edm::LogWarning("GP Input") << " CSCID " << cscid << " strip:" << strip << " lclPhi: " << lclPhi << "theadd: " << theadd; 
00163   if (station == 1 && (cscid <= 3) && (strip >= 127 && strip < 160)){
00164     //edm::LogWarning("GP Input") << " -> Matched Selection Criteria";
00165 
00166     // in this case need to redefine lclPhi in order to
00167     // place local phi in the middle of the 5th CFEB
00168     // and not on the first third of the CFEB as default
00169     lclPhi = (strip-127+31)*(4*binPhiL/3);
00170   }
00171   // end GP et DA
00172   
00173   if(station == 1 && ((cscid <= 3) || (cscid >= 7))) { 
00174     //if ( (strip >= 127 && strip < 160) || (cscid >= 10) ) // VK: the || (cscid >= 10) for unganged ME1a
00175     //  maxPhiL = maxPhiL*(48./80); // GP et DA: currently a hack that is in place to handle the different number of strips in ME1/1a and ME1/3
00176     //else
00177       maxPhiL = maxPhiL*(64./80); // currently a hack that is in place to handle the different number of strips in ME1/1 and ME1/3
00178   }
00179   
00180   // VK: The the unganged ME1a hack
00181   if (station == 1 && (cscid >= 10)) {
00182     lclPhi = strip*(4*binPhiL/3);
00183     cscid = cscid - 9; // back to normal 1-9 range
00184   }
00185   // end VK
00186 
00187   if((cscid > 0) && (cscid <= 9))
00188     {
00189       if((station == 1) && (lclPhi < maxPhiL))
00190         data.global_phi = (gbl_phi_me_params[endcap-1][sector-1][station-1][subsector-1][cscid-1][0] + 
00191                            gbl_phi_me_params[endcap-1][sector-1][station-1][subsector-1][cscid-1][1]*lclPhi);
00192       else if((station == 1) && (lclPhi >= maxPhiL))
00193         data.global_phi = (gbl_phi_me_params[endcap-1][sector-1][station-1][subsector-1][cscid-1][0] + 
00194                            gbl_phi_me_params[endcap-1][sector-1][station-1][subsector-1][cscid-1][1]*(maxPhiL-1));
00195       else
00196         data.global_phi = (gbl_phi_me_params[endcap-1][sector-1][station-1][0][cscid-1][0] + 
00197                            gbl_phi_me_params[endcap-1][sector-1][station-1][0][cscid-1][1]*lclPhi);
00198     }
00199   else
00200     edm::LogWarning("CSCSectorReceiverMiniLUT")
00201       << "+++ Value of cscid, " << cscid
00202       << ", is out of bounds, [1, 9] +++\n";
00203   
00204   if(data.global_phi >= maxPhiG)
00205     edm::LogWarning("CSCSectorReceiverMiniLUT")
00206       << "+++ Value of global_phi, " << data.global_phi
00207       << ", exceeds max allowed, " << maxPhiG-1 << " +++\n";
00208   
00209   return data;
00210 }
00211 
00212 global_phi_data CSCSectorReceiverMiniLUT::calcGlobalPhiMBMini(unsigned short endcap, 
00213                                                               unsigned short sector, 
00214                                                               unsigned short subsector, 
00215                                                               unsigned theadd)
00216 {
00217   if(endcap < 1 || endcap > 2)
00218     edm::LogWarning("CSCSectorReceiverMiniLUT")
00219       << "+++ Value of endcap, " << endcap
00220       << ", is out of bounds, [1, 2] +++\n";
00221   if(sector < 1 || sector > 6)
00222     edm::LogWarning("CSCSectorReceiverMiniLUT")
00223       << "+++ Value of sector, " << sector
00224       << ", is out of bounds, [1, 6] +++\n";
00225   
00226   gblphidat data(0);
00227   
00228   unsigned short int maxPhiL = 1<<CSCBitWidths::kLocalPhiDataBitWidth;
00229   unsigned short int maxPhiG = 1<<CSCBitWidths::kGlobalPhiDataBitWidth;
00230   unsigned short int cscid  = ((theadd >> 15)&0xf);
00231   unsigned short int lclPhi = (theadd & 0x3ff);
00232   
00233   if((cscid <= 3) || (cscid >= 7)) 
00234     maxPhiL = maxPhiL*(64./80); // currently a hack that is in place to handle the different number of strips in ME1/1 and ME1/3
00235   
00236   if((cscid > 0) && (cscid <= 9))
00237     {
00238       if(lclPhi < maxPhiL)
00239         data.global_phi = (gbl_phi_mb_params[endcap-1][sector-1][subsector-1][cscid-1][0] + 
00240                            gbl_phi_mb_params[endcap-1][sector-1][subsector-1][cscid-1][1]*lclPhi);
00241       else
00242         data.global_phi = (gbl_phi_mb_params[endcap-1][sector-1][subsector-1][cscid-1][0] + 
00243                            gbl_phi_mb_params[endcap-1][sector-1][subsector-1][cscid-1][1]*(maxPhiL-1));
00244     }
00245   else
00246     edm::LogWarning("CSCSectorReceiverMiniLUT")
00247       << "+++ Value of cscid, " << cscid
00248       << ", is out of bounds, [1, 9] +++\n";
00249   
00250   if(data.global_phi >= maxPhiG)
00251     edm::LogWarning("CSCSectorReceiverMiniLUT")
00252       << "+++ Value of global_phi, " << data.global_phi
00253       << ", exceeds max allowed, " << maxPhiG-1 << " +++\n";
00254   
00255   if(data.global_phi >= maxPhiG)
00256     edm::LogWarning("CSCSectorReceiverMiniLUT")
00257       << "+++ Value of global_phi, " << data.global_phi
00258       << ", exceeds max allowed, " << maxPhiG-1 << " +++\n";
00259   
00260   return data;
00261 }