CMS 3D CMS Logo

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     
00046   return data;
00047 }
00048 
00049 global_eta_data CSCSectorReceiverMiniLUT::calcGlobalEtaMEMini(unsigned short endcap, 
00050                                                               unsigned short sector, 
00051                                                               unsigned short station, 
00052                                                               unsigned short subsector, 
00053                                                               unsigned theadd)
00054 {
00055   if(endcap < 1 || endcap > 2)
00056     edm::LogWarning("CSCSectorReceiverMiniLUT")
00057       << "+++ Value of endcap, " << endcap
00058       << ", is out of bounds, [1, 2] +++\n";
00059   if(sector < 1 || sector > 6)
00060     edm::LogWarning("CSCSectorReceiverMiniLUT")
00061       << "+++ Value of sector, " << sector
00062       << ", is out of bounds, [1, 6] +++\n";
00063   if(station < 1 || station > 4)
00064     edm::LogWarning("CSCSectorReceiverMiniLUT")
00065       << "+++ Value of station, " << station
00066       << ", is out of bounds, [1, 4] +++\n";
00067   
00068   gbletadat data(0);
00069   
00070   unsigned short int cscid  = ((theadd >> 15) & 0xf);
00071   unsigned short int lclPhi = ((theadd >> 6)  & 0x3);
00072   unsigned short int WG     = ((theadd >> 8)  & 0x7f);
00073   
00074   int eta_temp, eta_min, eta_max;
00075   
00076   if((cscid > 0) && (cscid <= 9) && (WG < CSCConstants::MAX_NUM_WIRES))
00077     {
00078       if(station == 1)
00079         {
00080           eta_temp = (gbl_eta_params[endcap-1][sector-1][station-1][subsector-1][lclPhi][cscid-1][0] + 
00081                       gbl_eta_params[endcap-1][sector-1][station-1][subsector-1][lclPhi][cscid-1][1] *
00082                       log(gbl_eta_params[endcap-1][sector-1][station-1][subsector-1][lclPhi][cscid-1][2] + WG));
00083           eta_min = gbl_eta_bounds[endcap-1][sector-1][station-1][subsector-1][lclPhi][cscid-1][0];
00084           eta_max = gbl_eta_bounds[endcap-1][sector-1][station-1][subsector-1][lclPhi][cscid-1][1];
00085         }
00086       else
00087         {
00088           eta_temp = (gbl_eta_params[endcap-1][sector-1][station-1][0][lclPhi][cscid-1][0] + 
00089                       gbl_eta_params[endcap-1][sector-1][station-1][0][lclPhi][cscid-1][1] *
00090                       log(gbl_eta_params[endcap-1][sector-1][station-1][0][lclPhi][cscid-1][2] + WG));
00091           eta_min = gbl_eta_bounds[endcap-1][sector-1][station-1][0][lclPhi][cscid-1][0];
00092           eta_max = gbl_eta_bounds[endcap-1][sector-1][station-1][0][lclPhi][cscid-1][1];
00093         }
00094     }
00095   else
00096     {
00097       edm::LogWarning("CSCSectorReceiverMiniLUT")
00098         << "+++ Value of cscid, " << cscid
00099         << ", is out of bounds, [1, 9] -- or --"
00100         << " Value of wire group, " << WG 
00101         << ", exceeds max allowed, " << CSCConstants::MAX_NUM_WIRES << " +++\n";
00102     }
00103   
00104   // protect from negative numbers.  If the value of eta_temp is <0, set global eta to the minimum value
00105   if((eta_temp >= eta_min) &&
00106      (eta_temp <= eta_max))
00107     data.global_eta = eta_temp;
00108   else if(eta_temp < eta_min)
00109     data.global_eta = eta_min;
00110   else
00111     data.global_eta = eta_max;
00112   
00113   data.global_bend = 0;
00114   
00115   return data;
00116 }
00117 
00118 global_phi_data CSCSectorReceiverMiniLUT::calcGlobalPhiMEMini(unsigned short endcap, 
00119                                                               unsigned short sector, 
00120                                                               unsigned short station, 
00121                                                               unsigned short subsector, 
00122                                                               unsigned theadd)
00123 {
00124   if(endcap < 1 || endcap > 2)
00125     edm::LogWarning("CSCSectorReceiverMiniLUT")
00126       << "+++ Value of endcap, " << endcap
00127       << ", is out of bounds, [1, 2] +++\n";
00128   if(sector < 1 || sector > 6)
00129     edm::LogWarning("CSCSectorReceiverMiniLUT")
00130       << "+++ Value of sector, " << sector
00131       << ", is out of bounds, [1, 6] +++\n";
00132   if(station < 1 || station > 4)
00133     edm::LogWarning("CSCSectorReceiverMiniLUT")
00134       << "+++ Value of station, " << station
00135       << ", is out of bounds, [1, 4] +++\n";
00136   
00137   gblphidat data(0);
00138   
00139   unsigned short int maxPhiL = 1<<CSCBitWidths::kLocalPhiDataBitWidth;
00140   unsigned short int maxPhiG = 1<<CSCBitWidths::kGlobalPhiDataBitWidth;
00141   unsigned short int cscid  = ((theadd >> 15)&0xf);
00142   unsigned short int lclPhi = (theadd & 0x3ff);
00143 
00144   if(station == 1 && ((cscid <= 3) || (cscid >= 7))) 
00145     maxPhiL = maxPhiL*(64./80); // currently a hack that is in place to handle the different number of strips in ME1/1 and ME1/3
00146   
00147   if((cscid > 0) && (cscid <= 9))
00148     {
00149       if((station == 1) && (lclPhi < maxPhiL))
00150         data.global_phi = (gbl_phi_me_params[endcap-1][sector-1][station-1][subsector-1][cscid-1][0] + 
00151                            gbl_phi_me_params[endcap-1][sector-1][station-1][subsector-1][cscid-1][1]*lclPhi);
00152       else if((station == 1) && (lclPhi >= maxPhiL))
00153         data.global_phi = (gbl_phi_me_params[endcap-1][sector-1][station-1][subsector-1][cscid-1][0] + 
00154                            gbl_phi_me_params[endcap-1][sector-1][station-1][subsector-1][cscid-1][1]*(maxPhiL-1));
00155       else
00156         data.global_phi = (gbl_phi_me_params[endcap-1][sector-1][station-1][0][cscid-1][0] + 
00157                            gbl_phi_me_params[endcap-1][sector-1][station-1][0][cscid-1][1]*lclPhi);
00158     }
00159   else
00160     edm::LogWarning("CSCSectorReceiverMiniLUT")
00161       << "+++ Value of cscid, " << cscid
00162       << ", is out of bounds, [1, 9] +++\n";
00163   
00164   if(data.global_phi >= maxPhiG)
00165     edm::LogWarning("CSCSectorReceiverMiniLUT")
00166       << "+++ Value of global_phi, " << data.global_phi
00167       << ", exceeds max allowed, " << maxPhiG-1 << " +++\n";
00168   
00169   return data;
00170 }
00171 
00172 global_phi_data CSCSectorReceiverMiniLUT::calcGlobalPhiMBMini(unsigned short endcap, 
00173                                                               unsigned short sector, 
00174                                                               unsigned short subsector, 
00175                                                               unsigned theadd)
00176 {
00177   if(endcap < 1 || endcap > 2)
00178     edm::LogWarning("CSCSectorReceiverMiniLUT")
00179       << "+++ Value of endcap, " << endcap
00180       << ", is out of bounds, [1, 2] +++\n";
00181   if(sector < 1 || sector > 6)
00182     edm::LogWarning("CSCSectorReceiverMiniLUT")
00183       << "+++ Value of sector, " << sector
00184       << ", is out of bounds, [1, 6] +++\n";
00185   
00186   gblphidat data(0);
00187   
00188   unsigned short int maxPhiL = 1<<CSCBitWidths::kLocalPhiDataBitWidth;
00189   unsigned short int maxPhiG = 1<<CSCBitWidths::kGlobalPhiDataBitWidth;
00190   unsigned short int cscid  = ((theadd >> 15)&0xf);
00191   unsigned short int lclPhi = (theadd & 0x3ff);
00192   
00193   if((cscid <= 3) || (cscid >= 7)) 
00194     maxPhiL = maxPhiL*(64./80); // currently a hack that is in place to handle the different number of strips in ME1/1 and ME1/3
00195   
00196   if((cscid > 0) && (cscid <= 9))
00197     {
00198       if(lclPhi < maxPhiL)
00199         data.global_phi = (gbl_phi_mb_params[endcap-1][sector-1][subsector-1][cscid-1][0] + 
00200                            gbl_phi_mb_params[endcap-1][sector-1][subsector-1][cscid-1][1]*lclPhi);
00201       else
00202         data.global_phi = (gbl_phi_mb_params[endcap-1][sector-1][subsector-1][cscid-1][0] + 
00203                            gbl_phi_mb_params[endcap-1][sector-1][subsector-1][cscid-1][1]*(maxPhiL-1));
00204     }
00205   else
00206     edm::LogWarning("CSCSectorReceiverMiniLUT")
00207       << "+++ Value of cscid, " << cscid
00208       << ", is out of bounds, [1, 9] +++\n";
00209   
00210   if(data.global_phi >= maxPhiG)
00211     edm::LogWarning("CSCSectorReceiverMiniLUT")
00212       << "+++ Value of global_phi, " << data.global_phi
00213       << ", exceeds max allowed, " << maxPhiG-1 << " +++\n";
00214   
00215   if(data.global_phi >= maxPhiG)
00216     edm::LogWarning("CSCSectorReceiverMiniLUT")
00217       << "+++ Value of global_phi, " << data.global_phi
00218       << ", exceeds max allowed, " << maxPhiG-1 << " +++\n";
00219   
00220   return data;
00221 }

Generated on Tue Jun 9 17:39:41 2009 for CMSSW by  doxygen 1.5.4