CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_6_1_2_SLHC2/src/L1Trigger/CSCTrackFinder/src/CSCTFPtLUT.cc

Go to the documentation of this file.
00001 /*****************************************************
00002  * 28/01/2010
00003  * GP: added new switch to use the beam start Pt LUTs
00004  * if (eta > 2.1) 2 stations tracks have quality 2
00005  *                3 stations tracks have quality 3
00006  * NB: no matter if the have ME1
00007  * 
00008  * --> by default is set to true
00009  *****************************************************/
00010 
00011 #include <L1Trigger/CSCTrackFinder/interface/CSCTFPtLUT.h>
00012 #include <DataFormats/L1CSCTrackFinder/interface/CSCTFConstants.h>
00013 #include <FWCore/MessageLogger/interface/MessageLogger.h>
00014 #include <fstream>
00015 
00016 ptdat* CSCTFPtLUT::pt_lut = NULL;
00017 bool CSCTFPtLUT::lut_read_in = false;
00018 // L1MuTriggerScales CSCTFPtLUT::trigger_scale;
00019 // L1MuTriggerPtScale CSCTFPtLUT::trigger_ptscale;
00020 // CSCTFPtMethods CSCTFPtLUT::ptMethods;
00021 
00023 #include "CondFormats/L1TObjects/interface/L1MuCSCPtLut.h"
00024 #include "CondFormats/DataRecord/interface/L1MuCSCPtLutRcd.h"
00025 #include "FWCore/Framework/interface/ESHandle.h"
00026 #include <L1Trigger/CSCTrackFinder/interface/CSCTFPtLUT.h>
00027 
00028 #include "CondFormats/L1TObjects/interface/L1MuTriggerScales.h"
00029 #include "CondFormats/DataRecord/interface/L1MuTriggerScalesRcd.h"
00030 #include "CondFormats/L1TObjects/interface/L1MuTriggerPtScale.h"
00031 #include "CondFormats/DataRecord/interface/L1MuTriggerPtScaleRcd.h"
00032 
00033 // info for getPtScale() pt scale in GeV
00034 // low edges of pt bins
00035 /*     const float ptscale[33] = {  */
00036 /*       -1.,   0.0,   1.5,   2.0,   2.5,   3.0,   3.5,   4.0, */
00037 /*       4.5,   5.0,   6.0,   7.0,   8.0,  10.0,  12.0,  14.0,   */
00038 /*       16.0,  18.0,  20.0,  25.0,  30.0,  35.0,  40.0,  45.0,  */
00039 /*       50.0,  60.0,  70.0,  80.0,  90.0, 100.0, 120.0, 140.0, 1.E6 }; */
00040 
00041 /*
00042   These arrays were defined such that they take integer dPhi --> dPhi-units which are used by CSCTFPtMethods.
00043   The values were defined using:
00044   
00045   Phi_{i} = Phi_{i-1} + MAX( phi_Unit * alphi^{i}, phi_Unit), where phi_Unit = 62 deg / 4096, and alpha is solved for
00046   such that the phi-space is resonably covered. This will be better optimized in the future.
00047   
00048 */
00049 
00050 // Array that maps the 5-bit integer dPhi --> dPhi-units. It is assumed that this is used for dPhi23,
00051 // which has a maximum value of 3.83 degrees (255 units) in the extrapolation units.
00052 const int CSCTFPtLUT::dPhiNLBMap_5bit[32] =
00053      {  0       ,       1       ,       2       ,       4       ,       5       ,       7       ,       9       ,       11      ,       13      ,       15      ,       18      ,       21      ,       24      ,       28      ,       32      ,       37      ,       41      ,       47      ,       53      ,       60      ,       67      ,       75      ,       84      ,       94      ,       105     ,       117     ,       131     ,       145     ,       162     ,       180     ,       200     ,       222};
00054 
00055 // Array that maps the 7-bit integer dPhi --> dPhi-units. It is assumed that this is used for dPhi12,
00056 // which has a maximum value of 7.67 degrees (511 units) in the extrapolation units.
00057 const int CSCTFPtLUT::dPhiNLBMap_7bit[128] =
00058   {     0       ,       1       ,       2       ,       3       ,       4       ,       5       ,       6       ,       8       ,       9       ,       10      ,       11      ,       12      ,       14      ,       15      ,       16      ,       17      ,       19      ,       20      ,       21      ,       23      ,       24      ,       26      ,       27      ,       29      ,       30      ,       32      ,       33      ,       35      ,       37      ,       38      ,       40      ,       42      ,       44      ,       45      ,       47      ,       49      ,       51      ,       53      ,       55      ,       57      ,       59      ,       61      ,       63      ,       65      ,       67      ,       70      ,       72      ,       74      ,       77      ,       79      ,       81      ,       84      ,       86      ,       89      ,       92      ,       94      ,       97      ,       100     ,       103     ,       105     ,       108     ,       111     ,       114     ,       117     ,       121     ,       124     ,       127     ,       130     ,       134     ,       137     ,       141     ,       144     ,       148     ,       151     ,       155     ,       159     ,       163     ,       167     ,       171     ,       175     ,       179     ,       183     ,       188     ,       192     ,       197     ,       201     ,       206     ,       210     ,       215     ,       220     ,       225     ,       230     ,       235     ,       241     ,       246     ,       251     ,       257     ,       263     ,       268     ,       274     ,       280     ,       286     ,       292     ,       299     ,       305     ,       312     ,       318     ,       325     ,       332     ,       339     ,       346     ,       353     ,       361     ,       368     ,       376     ,       383     ,       391     ,       399     ,       408     ,       416     ,       425     ,       433     ,       442     ,       451     ,       460     ,       469     ,       479     ,       489 };
00059 
00060 // Array that maps the 8-bit integer dPhi --> dPhi-units. It is assumed that this is used for dPhi12,
00061 // which has a maximum value of 7.67 degrees (511 units) in the extrapolation units.
00062 const int CSCTFPtLUT::dPhiNLBMap_8bit[256] =
00063  {      0       ,       1       ,       2       ,       3       ,       4       ,       5       ,       6       ,       7       ,       8       ,       9       ,       10      ,       11      ,       12      ,       13      ,       14      ,       16      ,       17      ,       18      ,       19      ,       20      ,       21      ,       22      ,       23      ,       24      ,       25      ,       27      ,       28      ,       29      ,       30      ,       31      ,       32      ,       33      ,       35      ,       36      ,       37      ,       38      ,       39      ,       40      ,       42      ,       43      ,       44      ,       45      ,       46      ,       48      ,       49      ,       50      ,       51      ,       53      ,       54      ,       55      ,       56      ,       58      ,       59      ,       60      ,       61      ,       63      ,       64      ,       65      ,       67      ,       68      ,       69      ,       70      ,       72      ,       73      ,       74      ,       76      ,       77      ,       79      ,       80      ,       81      ,       83      ,       84      ,       85      ,       87      ,       88      ,       90      ,       91      ,       92      ,       94      ,       95      ,       97      ,       98      ,       100     ,       101     ,       103     ,       104     ,       105     ,       107     ,       108     ,       110     ,       111     ,       113     ,       115     ,       116     ,       118     ,       119     ,       121     ,       122     ,       124     ,       125     ,       127     ,       129     ,       130     ,       132     ,       133     ,       135     ,       137     ,       138     ,       140     ,       141     ,       143     ,       145     ,       146     ,       148     ,       150     ,       151     ,       153     ,       155     ,       157     ,       158     ,       160     ,       162     ,       163     ,       165     ,       167     ,       169     ,       171     ,       172     ,       174     ,       176     ,       178     ,       180     ,       181     ,       183     ,       185     ,       187     ,       189     ,       191     ,       192     ,       194     ,       196     ,       198     ,       200     ,       202     ,       204     ,       206     ,       208     ,       210     ,       212     ,       214     ,       216     ,       218     ,       220     ,       222     ,       224     ,       226     ,       228     ,       230     ,       232     ,       234     ,       236     ,       238     ,       240     ,       242     ,       244     ,       246     ,       249     ,       251     ,       253     ,       255     ,       257     ,       259     ,       261     ,       264     ,       266     ,       268     ,       270     ,       273     ,       275     ,       277     ,       279     ,       282     ,       284     ,       286     ,       289     ,       291     ,       293     ,       296     ,       298     ,       300     ,       303     ,       305     ,       307     ,       310     ,       312     ,       315     ,       317     ,       320     ,       322     ,       324     ,       327     ,       329     ,       332     ,       334     ,       337     ,       340     ,       342     ,       345     ,       347     ,       350     ,       352     ,       355     ,       358     ,       360     ,       363     ,       366     ,       368     ,       371     ,       374     ,       376     ,       379     ,       382     ,       385     ,       387     ,       390     ,       393     ,       396     ,       398     ,       401     ,       404     ,       407     ,       410     ,       413     ,       416     ,       419     ,       421     ,       424     ,       427     ,       430     ,       433     ,       436     ,       439     ,       442     ,       445     ,       448     ,       451     ,       454     ,       457     ,       461     ,       464     ,       467     ,       470     ,       473     ,       476     ,       479     ,       483     };
00064   
00065 
00066 //const int CSCTFPtLUT::dEtaCut_Low[24]    = {2,2,2,4,2,1,2,4,7,7,3,4,1,1,1,1,7,7,2,2,7,7,1,1};
00067 //const int CSCTFPtLUT::dEtaCut_Mid[24]    = {2,2,3,5,2,2,3,5,7,7,4,5,2,2,2,2,7,7,2,2,7,7,2,2};
00068 //const int CSCTFPtLUT::dEtaCut_High_A[24] = {3,3,4,6,3,2,4,6,7,7,5,6,2,2,2,2,7,7,3,3,7,7,2,2};
00069 //const int CSCTFPtLUT::dEtaCut_High_B[24] = {3,3,4,7,3,3,5,7,7,7,6,7,2,2,3,3,7,7,3,3,7,7,3,2};
00070 //const int CSCTFPtLUT::dEtaCut_High_C[24] = {4,4,5,7,4,3,6,7,7,7,7,7,3,3,3,3,7,7,4,4,7,7,3,3};
00071 const int CSCTFPtLUT::dEtaCut_Low[24]    = {2,2,2,7,2,1,2,7,3,3,3,7,1,1,1,1,2,2,2,2,1,1,1,1};
00072 const int CSCTFPtLUT::dEtaCut_Mid[24]    = {2,2,3,7,2,2,3,7,4,4,4,7,2,2,2,2,2,2,2,2,2,2,2,2};
00073 const int CSCTFPtLUT::dEtaCut_High_A[24] = {3,3,4,7,3,2,4,7,5,5,5,7,2,2,2,2,3,3,3,3,2,2,2,2};
00074 const int CSCTFPtLUT::dEtaCut_High_B[24] = {3,3,4,7,3,3,5,7,6,6,6,7,2,2,3,3,3,3,3,3,3,3,3,2};
00075 const int CSCTFPtLUT::dEtaCut_High_C[24] = {4,4,5,7,4,3,6,7,7,7,7,7,3,3,3,3,4,4,4,4,3,3,3,3};
00076 const int CSCTFPtLUT::dEtaCut_Open[24]   = {7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7};
00077 
00078 const int CSCTFPtLUT::getPtbyMLH = 0xFFFF; // all modes on
00079 
00080 
00081 CSCTFPtLUT::CSCTFPtLUT(const edm::EventSetup& es) 
00082     : read_pt_lut(true),
00083       isBinary(false)
00084 {
00085         pt_method = 32;
00086         //std::cout << "pt_method from 4 " << std::endl; 
00087         lowQualityFlag = 4;
00088         isBeamStartConf = true;
00089         pt_lut = new ptdat[1<<21];
00090 
00091         edm::ESHandle<L1MuCSCPtLut> ptLUT;
00092         es.get<L1MuCSCPtLutRcd>().get(ptLUT);
00093         const L1MuCSCPtLut *myConfigPt_ = ptLUT.product();
00094 
00095         memcpy((void*)pt_lut,(void*)myConfigPt_->lut(),(1<<21)*sizeof(ptdat));
00096 
00097         lut_read_in = true;
00098 
00099         edm::ESHandle< L1MuTriggerScales > scales ;
00100         es.get< L1MuTriggerScalesRcd >().get( scales ) ;
00101         trigger_scale = scales.product() ;
00102 
00103         edm::ESHandle< L1MuTriggerPtScale > ptScale ;
00104         es.get< L1MuTriggerPtScaleRcd >().get( ptScale ) ;
00105         trigger_ptscale = ptScale.product() ;
00106 
00107         ptMethods = CSCTFPtMethods( ptScale.product() ) ;
00108  
00109 }
00111 
00112 CSCTFPtLUT::CSCTFPtLUT(const edm::ParameterSet& pset,
00113                        const L1MuTriggerScales* scales,
00114                        const L1MuTriggerPtScale* ptScale)
00115   : trigger_scale( scales ),
00116     trigger_ptscale( ptScale ),
00117     ptMethods( ptScale ),
00118     read_pt_lut(false),
00119     isBinary(false)
00120 {
00121   //read_pt_lut = pset.getUntrackedParameter<bool>("ReadPtLUT",false);
00122   read_pt_lut = pset.getParameter<bool>("ReadPtLUT");
00123   if(read_pt_lut)
00124     {
00125       pt_lut_file = pset.getParameter<edm::FileInPath>("PtLUTFile");
00126       //isBinary = pset.getUntrackedParameter<bool>("isBinary", false);
00127       isBinary = pset.getParameter<bool>("isBinary");
00128 
00129       edm::LogInfo("CSCTFPtLUT::CSCTFPtLUT") << "Reading file: "
00130                                              << pt_lut_file.fullPath().c_str()
00131                                              << " isBinary?(1/0): "
00132                                              << isBinary;
00133     }
00134 
00135   // Determine the pt assignment method to use
00136   // 1 - Darin's parameterization method
00137   // 2 - Cathy Yeh's chi-square minimization method
00138   // 3 - Hybrid
00139   // 4 - Anna's parameterization method
00140   // 5 - Anna's parameterization method 
00141          //with improvments at ME1/1a: find max pt for 3 links hypothesis
00142   // 11 - Anna's: for fw 20101011 <- 2011 data taking <- not valide any more
00143   // 12 - Anna's: for fw 20101011 <- 2011 data taking <- not valide any more
00144           //with improvments at ME1/1a: find max pt for 3 links hypothesis
00145   // 21 - Anna's: for fw 20110118 and up, curves with data 2010 <- 2011 data taking
00146   // 22 - Anna's: for fw 20110118 and up, curves with data 2010 <- 2011 data taking
00147           //with improvments at ME1/1a: find max pt for 3 links hypothesis
00148   // 23 - Anna's: for fw 20110118 and up, curves with MC like method 4 <- 2011 data taking
00149   // 24 - Anna's: for fw 20110118 and up, curves with MC like method 4 <- 2011 data taking
00150           //with improvments at ME1/1a: find max pt for 3 links hypothesis
00151   //25 and 26 like 23 and 24 correspondenly but fix high pt assignment in DT-CSC region
00152   // 25 - Anna's: for fw 20110118 and up, curves with MC like method 4 <- 2011 data taking
00153   // 26 - Anna's: for fw 20110118 and up, curves with MC like method 4 <- 2011 data taking
00154           //with improvments at ME1/1a: find max pt for 3 links hypothesis
00155   // change Quality: Q = 3 for mode 5, Quility = 2 for mode = 8, 9, 10 at eta = 1.6-1.8   
00156   // 27 - Anna's: for fw 20110118 and up, curves with MC like method 4 <- 2011 data taking
00157   // 28 - Anna's: for fw 20110118 and up, curves with MC like method 4 <- 2011 data taking
00158           //with improvments at ME1/1a: find max pt for 3 links hypothesis
00159   // 29 - Bobby's medium Quality: using fw 2012_01_31. Switch to Global Log(L). Non-Linear dphi binning. 
00160   // 33 - Bobby's medium Quality: using fw 2012_01_31. Switch to Global Log(L). Non-Linear dphi binning. No max pt at eta > 2.1 
00161   // 30 - Bobby's loose Quality: using fw 2012_01_31. Switch to Global Log(L). Non-Linear dphi binning. 
00162   // 31 - Bobby's tight Quality: using fw 2012_01_31. Switch to Global Log(L). Non-Linear dphi binning. 
00163   // 32 - Bobby's medium Quality+ {tight only mode5 at eta > 2.1}: using fw 2012_01_31. Switch to Global Log(L). Non-Linear dphi binning. 
00164   pt_method = pset.getUntrackedParameter<unsigned>("PtMethod",32);
00165   //std::cout << "pt_method from pset " << std::endl; 
00166   // what does this mean???
00167   lowQualityFlag = pset.getUntrackedParameter<unsigned>("LowQualityFlag",4);
00168 
00169   if(read_pt_lut && !lut_read_in)
00170     {
00171       pt_lut = new ptdat[1<<21];
00172       readLUT();
00173       lut_read_in = true;
00174     }
00175 
00176   isBeamStartConf = pset.getUntrackedParameter<bool>("isBeamStartConf", true);
00177   
00178 }
00179 
00180 ptdat CSCTFPtLUT::Pt(const ptadd& address) const
00181 {
00182   ptdat result;
00183   if(read_pt_lut)
00184   {
00185     int shortAdd = (address.toint()& 0x1fffff);
00186     result = pt_lut[shortAdd];
00187   } else
00188     result = calcPt(address);
00189   return result;
00190 }
00191 
00192 ptdat CSCTFPtLUT::Pt(const unsigned& address) const
00193 {
00194   return Pt(ptadd(address));
00195 }
00196 
00197 ptdat CSCTFPtLUT::Pt(const unsigned& delta_phi_12, const unsigned& delta_phi_23,
00198                      const unsigned& track_eta, const unsigned& track_mode,
00199                      const unsigned& track_fr, const unsigned& delta_phi_sign) const
00200 {
00201   ptadd address;
00202   address.delta_phi_12 = delta_phi_12;
00203   address.delta_phi_23 = delta_phi_23;
00204   address.track_eta = track_eta;
00205   address.track_mode = track_mode;
00206   address.track_fr = track_fr;
00207   address.delta_phi_sign = delta_phi_sign;
00208 
00209   return Pt(address);
00210 }
00211 
00212 ptdat CSCTFPtLUT::Pt(const unsigned& delta_phi_12, const unsigned& track_eta,
00213                      const unsigned& track_mode, const unsigned& track_fr,
00214                      const unsigned& delta_phi_sign) const
00215 {
00216   ptadd address;
00217   address.delta_phi_12 = ((1<<8)-1)&delta_phi_12;
00218   address.delta_phi_23 = ((1<<4)-1)&(delta_phi_12>>8);
00219   address.track_eta = track_eta;
00220   address.track_mode = track_mode;
00221   address.track_fr = track_fr;
00222   address.delta_phi_sign = delta_phi_sign;
00223 
00224   return Pt(address);
00225 }
00226 
00227 
00228 ptdat CSCTFPtLUT::calcPt(const ptadd& address) const
00229 {
00230   ptdat result;
00231 
00232   double Pi  = acos(-1.);
00233   float etaR = 0, ptR_front = 0, ptR_rear = 0, dphi12R = 0, dphi23R = 0;
00234   int charge12, charge23;
00235   unsigned type, mode, eta, fr, quality, charge, absPhi12, absPhi23;
00236 
00237   mode = address.track_mode;
00238    
00239   int usedetaCUT = true;
00240   // Chose Eta cut tightness. 1=tightest, 2=moderate, 3=loose, 4=very loose, 5=extremely loose, 6=open
00241 
00242   // modes 6, 7, 13
00243   int EtaCutLevel_1 = 2;
00244   int dEtaCut_1[24];
00245   
00246   for (int i=0;i<24;i++)
00247     {
00248       dEtaCut_1[i] = 10;
00249       if (EtaCutLevel_1 == 1)
00250         dEtaCut_1[i] = dEtaCut_Low[i];
00251       else if (EtaCutLevel_1 == 2)
00252         dEtaCut_1[i] = dEtaCut_Mid[i];
00253       else if (EtaCutLevel_1 == 3)
00254         dEtaCut_1[i] = dEtaCut_High_A[i];
00255       else if (EtaCutLevel_1 == 4)
00256         dEtaCut_1[i] = dEtaCut_High_B[i];
00257       else if (EtaCutLevel_1 == 5)
00258         dEtaCut_1[i] = dEtaCut_High_C[i];
00259       else if (EtaCutLevel_1 == 6)
00260         dEtaCut_1[i] = dEtaCut_Open[i];
00261     }
00262   // modes 8, 9, 10
00263   int EtaCutLevel_2 = 2;
00264   int dEtaCut_2[24];
00265   
00266   for (int i=0;i<24;i++)
00267     {
00268       dEtaCut_2[i] = 10;
00269       if (EtaCutLevel_2 == 1)
00270         dEtaCut_2[i] = dEtaCut_Low[i];
00271       else if (EtaCutLevel_2 == 2)
00272         dEtaCut_2[i] = dEtaCut_Mid[i];
00273       else if (EtaCutLevel_2 == 3)
00274         dEtaCut_2[i] = dEtaCut_High_A[i];
00275       else if (EtaCutLevel_2 == 4)
00276         dEtaCut_2[i] = dEtaCut_High_B[i];
00277       else if (EtaCutLevel_2 == 5)
00278         dEtaCut_2[i] = dEtaCut_High_C[i];
00279       else if (EtaCutLevel_2 == 6)
00280         dEtaCut_2[i] = dEtaCut_Open[i];
00281 
00282       float scalef = 1.0;
00283       if (mode == 8 || mode == 10)
00284         dEtaCut_2[i] = scalef*dEtaCut_2[i];
00285       
00286     }
00287   
00288   
00289 
00290   eta = address.track_eta;
00291  
00292   fr = address.track_fr;
00293   charge = address.delta_phi_sign;
00294   quality = trackQuality(eta, mode, fr);
00295   unsigned front_pt, rear_pt;
00296   front_pt = 0.; rear_pt = 0.;
00297   unsigned front_quality, rear_quality;
00298 
00299   etaR = trigger_scale->getRegionalEtaScale(2)->getLowEdge(2*eta+1);
00300 
00301   front_quality = rear_quality = quality;
00302 
00303   unsigned int remerged;
00304   int iME11;
00305   int CLCT_pattern;
00306   int dEta;
00307   int index = 0;
00308   float bestLH = -999;
00309  float bestLH_front = -999.0;
00310  float bestLH_rear = -999.0;
00311 
00312  int PtbyMLH = false;
00313   
00314   //***************************************************//
00315   if(pt_method >= 29 && pt_method <= 33)
00316     {
00317         // using fw 2012_01_31. Switch to Global Log(L). Non-Linear dphi binning.
00318       PtbyMLH = 0x1 & (getPtbyMLH >> (int)mode);
00320       // switch off any improvment for eta > 2.1
00321       if(etaR > 2.1){
00322          usedetaCUT = false;
00323          PtbyMLH = 0x0;
00324       }
00326       
00327       switch(mode)
00328         {
00329         case 2:
00330         case 3:
00331         case 4:
00332         case 5:
00333   
00334       
00335       charge12 = 1;
00336 
00337       // First remake the 12-bit dPhi word from the core
00338       remerged = (address.delta_phi_12 | (address.delta_phi_23 << 8 ) );
00339       
00340       // Now separate it into 7-bit dPhi12 and 5-bit dPhi23 parts
00341       absPhi12 = ((1<<7)-1) &  remerged; 
00342       absPhi23 = ((1<<5)-1) & (remerged >> 7);
00343 
00344       // Now get the corresponding dPhi value in our phi-units using the inverse dPhi LUTs
00345       absPhi12 = dPhiNLBMap_7bit[absPhi12];
00346       absPhi23 = dPhiNLBMap_5bit[absPhi23];
00347 
00348       if(charge) charge23 = 1;
00349       else charge23 = -1;
00350 
00351       dphi12R = (static_cast<float>(absPhi12)) / (static_cast<float>(1<<12)) * CSCTFConstants::SECTOR_RAD;
00352       dphi23R = (static_cast<float>(absPhi23)) / (static_cast<float>(1<<12)) * CSCTFConstants::SECTOR_RAD;
00353       if(charge12 * charge23 < 0) dphi23R = -dphi23R;
00354 
00355       ptR_front = ptMethods.Pt3Stn2012(int(mode), etaR, dphi12R, dphi23R, PtbyMLH, bestLH, 1, int(pt_method));
00356       bestLH_front = bestLH;
00357       ptR_rear  = ptMethods.Pt3Stn2012(int(mode), etaR, dphi12R, dphi23R, PtbyMLH, bestLH, 0, int(pt_method));    
00358       bestLH_rear = bestLH;
00359       
00360       if((pt_method == 29 || pt_method == 32 || pt_method == 30 || pt_method == 31) && mode != 5 && etaR > 2.1)//exclude mode without ME11a
00361         {
00362             float dphi12Rmin = dphi12R - Pi*10/180/3; // 10/3 degrees 
00363             float dphi12Rmax = dphi12R + Pi*10/180/3; // 10/3 degrees
00364             float dphi23Rmin = dphi23R;
00365             float dphi23Rmax = dphi23R;
00366             //if(dphi12Rmin*dphi12R < 0) dphi23Rmin = -dphi23R;
00367             //if(dphi12Rmax*dphi12R < 0) dphi23Rmax = -dphi23R;
00368             float ptR_front_min = ptMethods.Pt3Stn2012(int(mode), etaR, dphi12Rmin, dphi23Rmin, PtbyMLH, bestLH, 1, int(pt_method));
00369             float bestLH_front_min = bestLH;
00370             float ptR_rear_min = ptMethods.Pt3Stn2012(int(mode), etaR, dphi12Rmin, dphi23Rmin,  PtbyMLH, bestLH, 0, int(pt_method));
00371             float bestLH_rear_min = bestLH;
00372             float ptR_front_max = ptMethods.Pt3Stn2012(int(mode), etaR, dphi12Rmax, dphi23Rmax, PtbyMLH, bestLH, 1, int(pt_method));
00373             float bestLH_front_max = bestLH;
00374             float ptR_rear_max = ptMethods.Pt3Stn2012(int(mode), etaR, dphi12Rmax, dphi23Rmax,  PtbyMLH, bestLH, 0, int(pt_method));
00375             float bestLH_rear_max = bestLH;
00376 
00377             if (PtbyMLH)
00378               {
00379                 float best_pt_front = ptR_front;
00380                 float best_LH_front = bestLH_front;
00381                 if (bestLH_front_min > best_LH_front)
00382                   {
00383                     best_pt_front = ptR_front_min;
00384                     best_LH_front = bestLH_front_min;
00385                   }
00386                 if (bestLH_front_max > best_LH_front)
00387                   {
00388                     best_pt_front = ptR_front_max;
00389                     best_LH_front = bestLH_front_max;
00390                   }
00391                 ptR_front = best_pt_front;
00392 
00393                 float best_pt_rear = ptR_rear;
00394                 float best_LH_rear = bestLH_rear;
00395                 if (bestLH_rear_min > best_LH_rear)
00396                   {
00397                     best_pt_rear = ptR_rear_min;
00398                     best_LH_rear = bestLH_rear_min;
00399                   }
00400                 if (bestLH_rear_max > best_LH_rear)
00401                   {
00402                     best_pt_rear = ptR_rear_max;
00403                     best_LH_rear = bestLH_rear_max;
00404                   }
00405                 ptR_rear = best_pt_rear;
00406               }
00407             else
00408               {
00409                 // select max pt solution for 3 links:
00410                 ptR_front = std::max(ptR_front, ptR_front_min);
00411                 ptR_front = std::max(ptR_front, ptR_front_max);
00412                 ptR_rear = std::max(ptR_rear, ptR_rear_min);
00413                 ptR_rear = std::max(ptR_rear, ptR_rear_max);
00414               }
00415         }
00416       break;
00417     case 6: // for mode 6, 7 and 13 add CLCT information in dph23 bit and iME11 in charge bit   
00418     case 7:
00419     case 13: // ME1-ME4
00420       
00421       // First remake the 12-bit dPhi word from the core
00422       remerged = (address.delta_phi_12 | (address.delta_phi_23 << 8 ) );
00423       // Now get 8-bit dPhi12 
00424       absPhi12 = ((1<<8)-1) & remerged; 
00425       // Now get 3-bit dEta
00426       dEta = ((1<<3)-1) & (remerged >> 8);
00427       // New get CLCT bit. CLCT = true if CLCTPattern = 8, 9, or 10, else 0.
00428       CLCT_pattern = 0x1 & (remerged >> 11);
00429       
00430       iME11 = int(charge); // = 0 if ME1/1, = 1 if ME1/2 or ME1/3 station 
00431       if(iME11 == 1 && etaR > 1.6) etaR = 1.55; // shift for ME1/2 station  
00432       if(iME11 == 0 && etaR < 1.6) etaR = 1.65; // shift for ME1/1 station
00433 
00434       // Get the 8-bit dPhi bin number  
00435       absPhi12 = ((1<<8)-1) & address.delta_phi_12;
00436       
00437       // Now get the corresponding dPhi value in our phi-units using the inverse dPhi LUTs
00438       absPhi12 = dPhiNLBMap_8bit[absPhi12];
00439       
00440       //int CLCT_pattern = static_cast<int>(address.delta_phi_23);
00441     
00442       dphi12R = (static_cast<float>(absPhi12)) / (static_cast<float>(1<<12)) * CSCTFConstants::SECTOR_RAD;
00443       
00444       //std::cout<< " Sector_rad = " << (CSCTFConstants::SECTOR_RAD) << std::endl;
00445       ptR_front = ptMethods.Pt2Stn2012(int(mode), etaR, dphi12R, PtbyMLH, bestLH, 1, int(pt_method));
00446       bestLH_front = bestLH;
00447       ptR_rear  = ptMethods.Pt2Stn2012(int(mode), etaR, dphi12R, PtbyMLH, bestLH, 0, int(pt_method));
00448       bestLH_rear = bestLH;
00449       if((pt_method == 29 || pt_method == 32 || pt_method == 30 || pt_method == 31) && etaR > 2.1)//exclude tracks without ME11a 
00450         {
00451           float dphi12Rmin = fabs(fabs(dphi12R) - Pi*10/180/3); // 10/3 degrees 
00452           float ptR_front_min = ptMethods.Pt2Stn2012(int(mode), etaR, dphi12Rmin,  PtbyMLH, bestLH, 1, int(pt_method));
00453           float bestLH_front_min = bestLH;
00454           float ptR_rear_min = ptMethods.Pt2Stn2012(int(mode), etaR, dphi12Rmin,   PtbyMLH, bestLH, 0, int(pt_method));
00455           float bestLH_rear_min = bestLH;
00456 
00457           if (PtbyMLH)
00458             {
00459               ptR_front = bestLH_front > bestLH_front_min ? ptR_front : ptR_front_min;
00460               ptR_rear  = bestLH_rear  > bestLH_rear_min ? ptR_rear : ptR_rear_min;
00461             }
00462           else
00463             {
00464               // select max pt solution for 3 links:
00465               ptR_front = std::max(ptR_front, ptR_front_min);
00466               ptR_rear = std::max(ptR_rear, ptR_rear_min);
00467             }
00468         }
00469       
00470       if( (!CLCT_pattern) && (ptR_front > 5.)) ptR_front = 5.;
00471       if( (!CLCT_pattern) && (ptR_rear > 5.)) ptR_rear = 5.;
00472 
00473        // Check dEta against reasonable values for high-pt muons
00474       index = 0;
00475       if (mode == 6) index = 0;
00476       if (mode == 7) index = 4;
00477       if (mode == 13) index = 8;
00478       
00479       if (usedetaCUT)
00480         {
00481           if (fabs(etaR)>1.2 && fabs(etaR)<=1.5)
00482             if (dEta>dEtaCut_1[index+0] )
00483               {
00484                 if (ptR_front > 5) ptR_front = 5;
00485                 if (ptR_rear  > 5) ptR_rear  = 5;
00486               }
00487           if (fabs(etaR)>1.5 && fabs(etaR)<=1.65)
00488             if (dEta>dEtaCut_1[index+1])
00489               {
00490                 if (ptR_front > 5) ptR_front = 5;
00491                 if (ptR_rear  > 5) ptR_rear  = 5;
00492               }
00493           
00494           if (fabs(etaR)>1.65 && fabs(etaR)<=2.1)
00495             if (dEta>dEtaCut_1[index+2] )
00496               {
00497                 if (ptR_front > 5) ptR_front = 5;
00498                 if (ptR_rear  > 5) ptR_rear  = 5;
00499               }
00500           if (fabs(etaR)>2.1)
00501             if (dEta>dEtaCut_1[index+3] )
00502               {
00503                 if (ptR_front > 5) ptR_front = 5;
00504                 if (ptR_rear  > 5) ptR_rear  = 5;
00505               }
00506         }
00507             
00508       break;
00509     
00510     case 8:
00511     case 9:
00512     case 10:
00513       
00514       
00515       // First remake the 12-bit dPhi word from the core
00516       remerged = (address.delta_phi_12 | (address.delta_phi_23 << 8 ) );
00517       // Now get 9-bit dPhi12 
00518       absPhi12 = ((1<<9)-1) & remerged; 
00519       // Now get 3-bit dEta
00520       dEta = ((1<<3)-1) & (remerged >> 9);
00521      
00522       dphi12R = (static_cast<float>(absPhi12)) / (static_cast<float>(1<<12)) * CSCTFConstants::SECTOR_RAD;
00523 
00524       //std::cout<< " Sector_rad = " << (CSCTFConstants::SECTOR_RAD) << std::endl;
00525       ptR_front = ptMethods.Pt2Stn2012(int(mode), etaR, dphi12R,  PtbyMLH, bestLH, 1, int(pt_method));
00526       ptR_rear  = ptMethods.Pt2Stn2012(int(mode), etaR, dphi12R,  PtbyMLH, bestLH, 0, int(pt_method));
00527 
00528       index = 0;
00529       if (mode == 8) index = 12;
00530       if (mode == 9) index = 16;
00531       if (mode == 10) index = 20;
00532 
00533       
00534       
00535       
00536       if (usedetaCUT)
00537         {
00538           if (fabs(etaR)>1.2 && fabs(etaR)<=1.5)
00539             if (dEta>dEtaCut_2[index+0] )
00540               {
00541                 if (ptR_front > 5) ptR_front = 5;
00542                 if (ptR_rear  > 5) ptR_rear  = 5;
00543               }
00544           if (fabs(etaR)>1.5 && fabs(etaR)<=1.65)
00545             if (dEta>dEtaCut_2[index+1])
00546               {
00547                 if (ptR_front > 5) ptR_front = 5;
00548                 if (ptR_rear  > 5) ptR_rear  = 5;
00549               }
00550           
00551           if (fabs(etaR)>1.65 && fabs(etaR)<=2.1)
00552             if (dEta>dEtaCut_2[index+2] )
00553               {
00554                 if (ptR_front > 5) ptR_front = 5;
00555                 if (ptR_rear  > 5) ptR_rear  = 5;
00556               }
00557           if (fabs(etaR)>2.1)
00558             if (dEta>dEtaCut_2[index+3] )
00559               {
00560                 if (ptR_front > 5) ptR_front = 5;
00561                 if (ptR_rear  > 5) ptR_rear  = 5;
00562               }
00563         }
00564             
00565       break;
00566     // for overlap DT-CSC region using curves from data 2010
00567     case 11: // FR = 1 -> b1-1-3,     FR = 0 -> b1-3 
00568     case 12: // FR = 1 -> b1-2-3,     FR = 0 -> b1-2 
00569     case 14: // FR = 1 -> b1-1-2-(3), FR = 0 -> b1-1
00570     
00571       
00572     //sign definition: sign dphi12 = Phi_DT - Phi_CSC
00573     //                 sing dphi23 = 5th sign. bit of phiBend
00574     // -> charge = 1 -> dphi12 = +, phiBend = -
00575     // -> charge = 0 -> dphi12 = +, phiBend = +    
00576         charge12 = 1;
00577 
00578         // DT tracks are still using linear dPhi binning
00579         absPhi12 = address.delta_phi_12;
00580         absPhi23 = address.delta_phi_23;
00581 
00582         if(charge) charge23 = -1;
00583         else charge23 = 1;
00584 
00585         dphi12R = (static_cast<float>(absPhi12<<1)) / (static_cast<float>(1<<12)) * CSCTFConstants::SECTOR_RAD;
00586         dphi23R = float(absPhi23);
00587         if(charge12 * charge23 < 0) dphi23R = -dphi23R;
00588 
00589         int mode1;
00590         mode1 = int(mode);
00591         if(fr == 1 && mode1 == 11) mode1 = 14; // 3 station track we use dphi12 and phiBend for 2 and 3 station track
00592 
00593         ptR_front = ptMethods.Pt3Stn2012_DT(mode1, etaR, dphi12R, dphi23R,  PtbyMLH, bestLH, int(0), int(pt_method));
00594         ptR_rear = ptMethods.Pt3Stn2012_DT(mode1, etaR, dphi12R, dphi23R,   PtbyMLH, bestLH, int(0), int(pt_method));
00595 
00596       break;
00597     case 15: // halo trigger
00598     case 1: // tracks that fail delta phi cuts
00599       ptR_front = trigger_ptscale->getPtScale()->getLowEdge(3); // 2 GeV
00600       ptR_rear  = trigger_ptscale->getPtScale()->getLowEdge(3); 
00601       break;
00602     default: // Tracks in this category are not considered muons.
00603       ptR_front = trigger_ptscale->getPtScale()->getLowEdge(0); // 0 GeV 
00604       ptR_rear  = trigger_ptscale->getPtScale()->getLowEdge(0);
00605     };// end switch
00606 
00607   front_pt = trigger_ptscale->getPtScale()->getPacked(ptR_front);
00608   rear_pt  = trigger_ptscale->getPtScale()->getPacked(ptR_rear);
00609 
00610   } //end pt_methods 29
00611 
00612 
00613 //***************************************************//
00614   if(pt_method >= 23 && pt_method <= 28){ //here we have only pt_methods greater then 
00615                        //for fw 20110118 <- 2011 data taking, curves from MC like method 4
00616   // mode definition you could find at page 6 & 7: 
00617   // https://www.phys.ufl.edu/~madorsky/sp/2011-11-18/sp_core_interface.pdf 
00618   // it is valid starting the beggining of 2011 
00619   //std::cout << " pt_method = " << pt_method << std::endl;//test 
00620   switch(mode)
00621     {
00622     case 2:
00623     case 3:
00624     case 4:
00625     case 5:
00626 
00627       charge12 = 1;
00628       absPhi12 = address.delta_phi_12;
00629       absPhi23 = address.delta_phi_23;
00630 
00631       if(charge) charge23 = 1;
00632       else charge23 = -1;
00633 
00634       dphi12R = (static_cast<float>(absPhi12<<1)) / (static_cast<float>(1<<12)) * CSCTFConstants::SECTOR_RAD;
00635       dphi23R = (static_cast<float>(absPhi23<<4)) / (static_cast<float>(1<<12)) * CSCTFConstants::SECTOR_RAD;
00636       if(charge12 * charge23 < 0) dphi23R = -dphi23R;
00637 
00638       ptR_front = ptMethods.Pt3Stn2010(int(mode), etaR, dphi12R, dphi23R, 1, int(pt_method));
00639       ptR_rear  = ptMethods.Pt3Stn2010(int(mode), etaR, dphi12R, dphi23R, 0, int(pt_method));    
00640 
00641       if((pt_method == 24 || pt_method == 26 || pt_method == 28) && mode != 5 && etaR > 2.1)//exclude mode without ME11a
00642         {
00643             float dphi12Rmin = dphi12R - Pi*10/180/3; // 10/3 degrees 
00644             float dphi12Rmax = dphi12R + Pi*10/180/3; // 10/3 degrees
00645             float dphi23Rmin = dphi23R;
00646             float dphi23Rmax = dphi23R;
00647             //if(dphi12Rmin*dphi12R < 0) dphi23Rmin = -dphi23R;
00648             //if(dphi12Rmax*dphi12R < 0) dphi23Rmax = -dphi23R;
00649             float ptR_front_min = ptMethods.Pt3Stn2010(int(mode), etaR, dphi12Rmin, dphi23Rmin, 1, int(pt_method));
00650             float ptR_rear_min = ptMethods.Pt3Stn2010(int(mode), etaR, dphi12Rmin, dphi23Rmin, 0, int(pt_method));
00651             float ptR_front_max = ptMethods.Pt3Stn2010(int(mode), etaR, dphi12Rmax, dphi23Rmax, 1, int(pt_method));
00652             float ptR_rear_max = ptMethods.Pt3Stn2010(int(mode), etaR, dphi12Rmax, dphi23Rmax, 0, int(pt_method));
00653             // select max pt solution for 3 links:
00654             ptR_front = std::max(ptR_front, ptR_front_min);
00655             ptR_front = std::max(ptR_front, ptR_front_max);
00656             ptR_rear = std::max(ptR_rear, ptR_rear_min);
00657             ptR_rear = std::max(ptR_rear, ptR_rear_max);
00658         }
00659       break;
00660     case 6: // for mode 6, 7 and 13 add CLCT information in dph23 bit and iME11 in charge bit  
00661     case 7:
00662     case 13: // ME1-ME4
00663       int iME11;
00664       iME11 = int(charge); // = 0 if ME1/1, = 1 if ME1/2 or ME1/3 station 
00665       if(iME11 == 1 && etaR > 1.6) etaR = 1.55; // shift for ME1/2 station  
00666       if(iME11 == 0 && etaR < 1.6) etaR = 1.65; // shift for ME1/1 station 
00667       absPhi12 = address.delta_phi_12;
00668       //int CLCT_pattern = static_cast<int>(address.delta_phi_23);
00669       int CLCT_pattern;
00670       CLCT_pattern = int(address.delta_phi_23);
00671       dphi12R = (static_cast<float>(absPhi12<<1)) / (static_cast<float>(1<<12)) * CSCTFConstants::SECTOR_RAD;
00672 
00673       //std::cout<< " Sector_rad = " << (CSCTFConstants::SECTOR_RAD) << std::endl;
00674       ptR_front = ptMethods.Pt2Stn2010(int(mode), etaR, dphi12R, 1, int(pt_method));
00675       ptR_rear  = ptMethods.Pt2Stn2010(int(mode), etaR, dphi12R, 0, int(pt_method));
00676       if((pt_method == 24 || pt_method == 26 || pt_method == 28) && etaR > 2.1)//exclude tracks without ME11a 
00677         {
00678            float dphi12Rmin = fabs(fabs(dphi12R) - Pi*10/180/3); // 10/3 degrees 
00679            float ptR_front_min = ptMethods.Pt2Stn2010(int(mode), etaR, dphi12Rmin, 1, int(pt_method));
00680            float ptR_rear_min = ptMethods.Pt2Stn2010(int(mode), etaR, dphi12Rmin, 0, int(pt_method));
00681            // select max pt solution for 3 links:
00682            ptR_front = std::max(ptR_front, ptR_front_min);
00683            ptR_rear = std::max(ptR_rear, ptR_rear_min);
00684         }
00685       if( ((CLCT_pattern < 8) || (CLCT_pattern > 10)) && (ptR_front > 5.)) ptR_front = 5.;
00686       if( ((CLCT_pattern < 8) || (CLCT_pattern > 10)) && (ptR_rear > 5.)) ptR_rear = 5.;
00687       //std::cout << "mode = "<< mode << " CLCT_pattern = " << CLCT_pattern << " ptR_rear = " << ptR_rear << std::endl;
00688 
00689       break;
00690     case 8:
00691     case 9:
00692     case 10:
00693       if(charge) absPhi12 = address.delta_phi();
00694       else
00695         {
00696           int temp_phi = address.delta_phi();
00697           absPhi12 = static_cast<unsigned>(-temp_phi) & 0xfff;
00698         }
00699 
00700       dphi12R = (static_cast<float>(absPhi12)) / (static_cast<float>(1<<12)) * CSCTFConstants::SECTOR_RAD;
00701 
00702       //std::cout<< " Sector_rad = " << (CSCTFConstants::SECTOR_RAD) << std::endl;
00703       ptR_front = ptMethods.Pt2Stn2010(int(mode), etaR, dphi12R, 1, int(pt_method));
00704       ptR_rear  = ptMethods.Pt2Stn2010(int(mode), etaR, dphi12R, 0, int(pt_method));
00705 
00706       break;
00707     // for overlap DT-CSC region using curves from data 2010
00708     case 11: // FR = 1 -> b1-1-3,     FR = 0 -> b1-3 
00709     case 12: // FR = 1 -> b1-2-3,     FR = 0 -> b1-2 
00710     case 14: // FR = 1 -> b1-1-2-(3), FR = 0 -> b1-1
00711 
00712     //sign definition: sign dphi12 = Phi_DT - Phi_CSC
00713     //                 sing dphi23 = 5th sign. bit of phiBend
00714     // -> charge = 1 -> dphi12 = +, phiBend = -
00715     // -> charge = 0 -> dphi12 = +, phiBend = +    
00716         charge12 = 1;
00717         absPhi12 = address.delta_phi_12;
00718         absPhi23 = address.delta_phi_23;
00719 
00720         if(charge) charge23 = -1;
00721         else charge23 = 1;
00722 
00723         dphi12R = (static_cast<float>(absPhi12<<1)) / (static_cast<float>(1<<12)) * CSCTFConstants::SECTOR_RAD;
00724         dphi23R = float(absPhi23);
00725         if(charge12 * charge23 < 0) dphi23R = -dphi23R;
00726 
00727         int mode1;
00728         mode1 = int(mode);
00729         if(fr == 1 && mode1 == 11) mode1 = 14; // 3 station track we use dphi12 and phiBend for 2 and 3 station track
00730 
00731         ptR_front = ptMethods.Pt3Stn2011(mode1, etaR, dphi12R, dphi23R, int(0), int(pt_method));
00732         ptR_rear = ptMethods.Pt3Stn2011(mode1, etaR, dphi12R, dphi23R, int(0), int(pt_method));
00733 
00734       break;
00735     case 15: // halo trigger
00736     case 1: // tracks that fail delta phi cuts
00737       ptR_front = trigger_ptscale->getPtScale()->getLowEdge(3); // 2 GeV
00738       ptR_rear  = trigger_ptscale->getPtScale()->getLowEdge(3); 
00739       break;
00740     default: // Tracks in this category are not considered muons.
00741       ptR_front = trigger_ptscale->getPtScale()->getLowEdge(0); // 0 GeV 
00742       ptR_rear  = trigger_ptscale->getPtScale()->getLowEdge(0);
00743     };// end switch
00744 
00745   front_pt = trigger_ptscale->getPtScale()->getPacked(ptR_front);
00746   rear_pt  = trigger_ptscale->getPtScale()->getPacked(ptR_rear);
00747 
00748   } //end pt_methods 23 - 28 
00749 
00750 //***************************************************//
00751 //***************************************************//
00752   if(pt_method == 21 || pt_method == 22){ //here we have only pt_methods greater then 
00753                        //for fw 20110118 <- 2011 data taking
00754   // mode definition you could find at page 6 & 7: 
00755   // https://www.phys.ufl.edu/~madorsky/sp/2011-11-18/sp_core_interface.pdf 
00756   // it is valid starting the beggining of 2011 
00757   switch(mode)
00758     {
00759     case 2:
00760     case 3:
00761     case 4:
00762     case 5:
00763 
00764       charge12 = 1;
00765       absPhi12 = address.delta_phi_12;
00766       absPhi23 = address.delta_phi_23;
00767 
00768       if(charge) charge23 = 1;
00769       else charge23 = -1;
00770 
00771       dphi12R = (static_cast<float>(absPhi12<<1)) / (static_cast<float>(1<<12)) * CSCTFConstants::SECTOR_RAD;
00772       dphi23R = (static_cast<float>(absPhi23<<4)) / (static_cast<float>(1<<12)) * CSCTFConstants::SECTOR_RAD;
00773       if(charge12 * charge23 < 0) dphi23R = -dphi23R;
00774 
00775       ptR_front = ptMethods.Pt3Stn2011(int(mode), etaR, dphi12R, dphi23R, 1, int(pt_method));
00776       ptR_rear  = ptMethods.Pt3Stn2011(int(mode), etaR, dphi12R, dphi23R, 0, int(pt_method));    
00777 
00778       if(pt_method == 22 && mode != 5 && etaR > 2.1)//exclude mode without ME11a
00779         {
00780             float dphi12Rmin = dphi12R - Pi*10/180/3; // 10/3 degrees 
00781             float dphi12Rmax = dphi12R + Pi*10/180/3; // 10/3 degrees
00782             float dphi23Rmin = dphi23R;
00783             float dphi23Rmax = dphi23R;
00784             //if(dphi12Rmin*dphi12R < 0) dphi23Rmin = -dphi23R;
00785             //if(dphi12Rmax*dphi12R < 0) dphi23Rmax = -dphi23R;
00786             float ptR_front_min = ptMethods.Pt3Stn2011(int(mode), etaR, dphi12Rmin, dphi23Rmin, 1, int(pt_method));
00787             float ptR_rear_min = ptMethods.Pt3Stn2011(int(mode), etaR, dphi12Rmin, dphi23Rmin, 0, int(pt_method));
00788             float ptR_front_max = ptMethods.Pt3Stn2011(int(mode), etaR, dphi12Rmax, dphi23Rmax, 1, int(pt_method));
00789             float ptR_rear_max = ptMethods.Pt3Stn2011(int(mode), etaR, dphi12Rmax, dphi23Rmax, 0, int(pt_method));
00790             // select max pt solution for 3 links:
00791             ptR_front = std::max(ptR_front, ptR_front_min);
00792             ptR_front = std::max(ptR_front, ptR_front_max);
00793             ptR_rear = std::max(ptR_rear, ptR_rear_min);
00794             ptR_rear = std::max(ptR_rear, ptR_rear_max);
00795         }
00796       break;
00797     case 6: // for mode 6, 7 and 13 add CLCT information in dph23 bit and iME11 in charge bit  
00798     case 7:
00799     case 13: // ME1-ME4
00800       int iME11;
00801       iME11 = int(charge);
00802       absPhi12 = address.delta_phi_12;
00803       //int CLCT_pattern = static_cast<int>(address.delta_phi_23);
00804       int CLCT_pattern;
00805       CLCT_pattern = int(address.delta_phi_23);
00806 
00807       dphi12R = (static_cast<float>(absPhi12<<1)) / (static_cast<float>(1<<12)) * CSCTFConstants::SECTOR_RAD;
00808 
00809       //std::cout<< " Sector_rad = " << (CSCTFConstants::SECTOR_RAD) << std::endl;
00810       ptR_front = ptMethods.Pt2Stn2011(int(mode), etaR, dphi12R, 1, int(pt_method), iME11);
00811       ptR_rear  = ptMethods.Pt2Stn2011(int(mode), etaR, dphi12R, 0, int(pt_method), iME11);
00812       if((pt_method == 22) && etaR > 2.1)//exclude tracks without ME11a 
00813         {
00814            float dphi12Rmin = fabs(fabs(dphi12R) - Pi*10/180/3); // 10/3 degrees 
00815            float ptR_front_min = ptMethods.Pt2Stn2011(int(mode), etaR, dphi12Rmin, 1, int(pt_method), iME11);
00816            float ptR_rear_min = ptMethods.Pt2Stn2011(int(mode), etaR, dphi12Rmin, 0, int(pt_method), iME11);
00817            // select max pt solution for 3 links:
00818            ptR_front = std::max(ptR_front, ptR_front_min);
00819            ptR_rear = std::max(ptR_rear, ptR_rear_min);
00820         }
00821       if( ((CLCT_pattern < 8) || (CLCT_pattern > 10)) && (ptR_front > 5.)) ptR_front = 5.;
00822       if( ((CLCT_pattern < 8) || (CLCT_pattern > 10)) && (ptR_rear > 5.)) ptR_rear = 5.;
00823 
00824       break;
00825     case 8:
00826     case 9:
00827     case 10:
00828       if(charge) absPhi12 = address.delta_phi();
00829       else
00830         {
00831           int temp_phi = address.delta_phi();
00832           absPhi12 = static_cast<unsigned>(-temp_phi) & 0xfff;
00833         }
00834 
00835       dphi12R = (static_cast<float>(absPhi12)) / (static_cast<float>(1<<12)) * CSCTFConstants::SECTOR_RAD;
00836 
00837       //std::cout<< " Sector_rad = " << (CSCTFConstants::SECTOR_RAD) << std::endl;
00838       ptR_front = ptMethods.Pt2Stn2011(int(mode), etaR, dphi12R, 1, int(pt_method), int(2));
00839       ptR_rear  = ptMethods.Pt2Stn2011(int(mode), etaR, dphi12R, 0, int(pt_method), int(2));
00840 
00841       break;
00842     case 11: // FR = 1 -> b1-1-3,     FR = 0 -> b1-3 
00843     case 12: // FR = 1 -> b1-2-3,     FR = 0 -> b1-2 
00844     case 14: // FR = 1 -> b1-1-2-(3), FR = 0 -> b1-1
00845 
00846     //sign definition: sign dphi12 = Phi_DT - Phi_CSC
00847     //                 sing dphi23 = 5th sign. bit of phiBend
00848     // -> charge = 1 -> dphi12 = +, phiBend = -
00849     // -> charge = 0 -> dphi12 = +, phiBend = +    
00850         charge12 = 1;
00851         absPhi12 = address.delta_phi_12;
00852         absPhi23 = address.delta_phi_23;
00853 
00854         if(charge) charge23 = -1;
00855         else charge23 = 1;
00856 
00857         dphi12R = (static_cast<float>(absPhi12<<1)) / (static_cast<float>(1<<12)) * CSCTFConstants::SECTOR_RAD;
00858         dphi23R = float(absPhi23);
00859         if(charge12 * charge23 < 0) dphi23R = -dphi23R;
00860 
00861         int mode1;
00862         mode1 = int(mode);
00863         if(fr == 1 && mode1 == 11) mode1 = 14; // 3 station track we use dphi12 and phiBend for 2 and 3 station track
00864 
00865         ptR_front = ptMethods.Pt3Stn2011(mode1, etaR, dphi12R, dphi23R, int(0), int(pt_method));
00866         ptR_rear = ptMethods.Pt3Stn2011(mode1, etaR, dphi12R, dphi23R, int(0), int(pt_method));
00867 
00868       break;
00869     case 15: // halo trigger
00870     case 1: // tracks that fail delta phi cuts
00871       ptR_front = trigger_ptscale->getPtScale()->getLowEdge(3); // 2 GeV
00872       ptR_rear  = trigger_ptscale->getPtScale()->getLowEdge(3); 
00873       break;
00874     default: // Tracks in this category are not considered muons.
00875       ptR_front = trigger_ptscale->getPtScale()->getLowEdge(0); // 0 GeV 
00876       ptR_rear  = trigger_ptscale->getPtScale()->getLowEdge(0);
00877     };// end switch
00878 
00879   front_pt = trigger_ptscale->getPtScale()->getPacked(ptR_front);
00880   rear_pt  = trigger_ptscale->getPtScale()->getPacked(ptR_rear);
00881 
00882   } //end pt_methods greater or equal to 21 
00883 
00884 //***************************************************//
00885 //***************************************************//
00886   if(pt_method >= 11 && pt_method < 20){ //here we have only pt_methods greater or equal to 11 
00887                        //for fw 20101011 <- 2011 data taking
00888   // mode definition you could find at page 6 & 7: 
00889   // https://www.phys.ufl.edu/~madorsky/sp/2010-10-11/sp_core_interface.pdf 
00890   // it is valid starting the beggining of 2011 
00891   switch(mode)
00892     {
00893     case 2:
00894     case 3:
00895     case 4:
00896     case 5:
00897 
00898       charge12 = 1;
00899       absPhi12 = address.delta_phi_12;
00900       absPhi23 = address.delta_phi_23;
00901 
00902       if(charge) charge23 = 1;
00903       else charge23 = -1;
00904 
00905       dphi12R = (static_cast<float>(absPhi12<<1)) / (static_cast<float>(1<<12)) * CSCTFConstants::SECTOR_RAD;
00906       dphi23R = (static_cast<float>(absPhi23<<4)) / (static_cast<float>(1<<12)) * CSCTFConstants::SECTOR_RAD;
00907       if(charge12 * charge23 < 0) dphi23R = -dphi23R;
00908 
00909       ptR_front = ptMethods.Pt3Stn2010(mode, etaR, dphi12R, dphi23R, 1, int(pt_method));
00910       ptR_rear  = ptMethods.Pt3Stn2010(mode, etaR, dphi12R, dphi23R, 0, int(pt_method));    
00911 
00912       if(pt_method == 12 && mode != 5 && etaR > 2.1)//exclude mode without ME11a
00913         {
00914             float dphi12Rmin = dphi12R - Pi*10/180/3; // 10/3 degrees 
00915             float dphi12Rmax = dphi12R + Pi*10/180/3; // 10/3 degrees
00916             float dphi23Rmin = dphi23R;
00917             float dphi23Rmax = dphi23R;
00918             if(dphi12Rmin*dphi12R < 0) dphi23Rmin = -dphi23R;
00919             if(dphi12Rmax*dphi12R < 0) dphi23Rmax = -dphi23R;
00920             float ptR_front_min = ptMethods.Pt3Stn2010(mode, etaR, dphi12Rmin, dphi23Rmin, 1, int(pt_method));
00921             float ptR_rear_min = ptMethods.Pt3Stn2010(mode, etaR, dphi12Rmin, dphi23Rmin, 0, int(pt_method));
00922             float ptR_front_max = ptMethods.Pt3Stn2010(mode, etaR, dphi12Rmax, dphi23Rmax, 1, int(pt_method));
00923             float ptR_rear_max = ptMethods.Pt3Stn2010(mode, etaR, dphi12Rmax, dphi23Rmax, 0, int(pt_method));
00924             // select max pt solution for 3 links:
00925             ptR_front = std::max(ptR_front, ptR_front_min);
00926             ptR_front = std::max(ptR_front, ptR_front_max);
00927             ptR_rear = std::max(ptR_rear, ptR_rear_min);
00928             ptR_rear = std::max(ptR_rear, ptR_rear_max);
00929         }
00930       break;
00931     case 6:
00932     case 7:
00933     case 8:
00934     case 9:
00935     case 10:
00936     case 13: // ME1-ME4
00937       type = mode - 5;
00938 
00939       if(charge) absPhi12 = address.delta_phi();
00940       else
00941         {
00942           int temp_phi = address.delta_phi();
00943           absPhi12 = static_cast<unsigned>(-temp_phi) & 0xfff;
00944         }
00945 
00946       dphi12R = (static_cast<float>(absPhi12)) / (static_cast<float>(1<<12)) * CSCTFConstants::SECTOR_RAD;
00947 
00948       //std::cout<< " Sector_rad = " << (CSCTFConstants::SECTOR_RAD) << std::endl;
00949       ptR_front = ptMethods.Pt2Stn2010(mode, etaR, dphi12R, 1, int(pt_method));
00950       ptR_rear  = ptMethods.Pt2Stn2010(mode, etaR, dphi12R, 0, int(pt_method));
00951       if((pt_method == 12) && etaR > 2.1 && mode != 8 && mode !=9 && mode !=10)//exclude tracks without ME11a 
00952         {
00953            float dphi12Rmin = fabs(fabs(dphi12R) - Pi*10/180/3); // 10/3 degrees 
00954            float ptR_front_min = ptMethods.Pt2Stn2010(mode, etaR, dphi12Rmin, 1, int(pt_method));
00955            float ptR_rear_min = ptMethods.Pt2Stn2010(mode, etaR, dphi12Rmin, 0, int(pt_method));
00956            // select max pt solution for 3 links:
00957            ptR_front = std::max(ptR_front, ptR_front_min);
00958            ptR_rear = std::max(ptR_rear, ptR_rear_min);
00959         }
00960 
00961       break;
00962     case 11: // FR = 1 -> b1-1-3,     FR = 0 -> b1-3 
00963     case 12: // FR = 1 -> b1-2-3,     FR = 0 -> b1-2 
00964     case 14: // FR = 1 -> b1-1-2-(3), FR = 0 -> b1-1
00965 
00966       if(fr == 0){ // 2 station track
00967         if(charge) absPhi12 = address.delta_phi();
00968         else
00969           {
00970             int temp_phi = address.delta_phi();
00971             absPhi12 = static_cast<unsigned>(-temp_phi) & 0xfff;
00972           }
00973           dphi12R = (static_cast<float>(absPhi12)) / (static_cast<float>(1<<12)) * CSCTFConstants::SECTOR_RAD;
00974           ptR_rear  = ptMethods.Pt2Stn2010(mode, etaR, dphi12R, 0, int(pt_method));
00975 
00976       }// end fr == 0
00977       if(fr == 1){ // 3 station track
00978         charge12 = 1;
00979         absPhi12 = address.delta_phi_12;
00980         absPhi23 = address.delta_phi_23;
00981 
00982         if(charge) charge23 = 1;
00983         else charge23 = -1;
00984 
00985         dphi12R = (static_cast<float>(absPhi12<<1)) / (static_cast<float>(1<<12)) * CSCTFConstants::SECTOR_RAD;
00986         dphi23R = (static_cast<float>(absPhi23<<4)) / (static_cast<float>(1<<12)) * CSCTFConstants::SECTOR_RAD;
00987         if(charge12 * charge23 < 0) dphi23R = -dphi23R;
00988 
00989         ptR_front = ptMethods.Pt3Stn2010(mode, etaR, dphi12R, dphi23R, 1, int(pt_method));
00990 
00991         if(pt_method == 12 && mode != 5 && etaR > 2.1)//exclude mode without ME11a
00992           {
00993               float dphi12Rmin = dphi12R - Pi*10/180/3; // 10/3 degrees 
00994               float dphi12Rmax = dphi12R + Pi*10/180/3; // 10/3 degrees
00995               float dphi23Rmin = dphi23R;
00996               float dphi23Rmax = dphi23R;
00997               if(dphi12Rmin*dphi12R < 0) dphi23Rmin = -dphi23R;
00998               if(dphi12Rmax*dphi12R < 0) dphi23Rmax = -dphi23R;
00999               float ptR_front_min = ptMethods.Pt3Stn2010(mode, etaR, dphi12Rmin, dphi23Rmin, 1, int(pt_method));
01000               float ptR_front_max = ptMethods.Pt3Stn2010(mode, etaR, dphi12Rmax, dphi23Rmax, 1, int(pt_method));
01001               // select max pt solution for 3 links:
01002               ptR_front = std::max(ptR_front, ptR_front_min);
01003               ptR_front = std::max(ptR_front, ptR_front_max);
01004           }
01005       } // end fr == 1 
01006 
01007       break;
01008     case 15: // halo trigger
01009     case 1: // tracks that fail delta phi cuts
01010       ptR_front = trigger_ptscale->getPtScale()->getLowEdge(3); // 2 GeV
01011       ptR_rear  = trigger_ptscale->getPtScale()->getLowEdge(3); 
01012       break;
01013     default: // Tracks in this category are not considered muons.
01014       ptR_front = trigger_ptscale->getPtScale()->getLowEdge(0); // 0 GeV 
01015       ptR_rear  = trigger_ptscale->getPtScale()->getLowEdge(0);
01016     };// end switch
01017 
01018   front_pt = trigger_ptscale->getPtScale()->getPacked(ptR_front);
01019   rear_pt  = trigger_ptscale->getPtScale()->getPacked(ptR_rear);
01020 
01021   } //end pt_methods greater or equal to 11 
01022 //***************************************************//
01023   if(pt_method <= 5){ //here we have only pt_methods less or equal to 5
01024   // mode definition you could find at https://twiki.cern.ch/twiki/pub/Main/PtLUTs/mode_codes.xls
01025   // it is valid till the end 2010 
01026 
01027   //  kluge to use 2-stn track in overlap region
01028   //  see also where this routine is called, and encode LUTaddress, and assignPT
01029   if (pt_method != 4 && pt_method !=5 
01030       && (mode == 2 || mode == 3 || mode == 4) && (eta<3)) mode = 6;
01031   if (pt_method != 4 && pt_method !=5 && (mode == 5)
01032       && (eta<3)) mode = 8;
01033 
01034   switch(mode)
01035     {
01036     case 2:
01037     case 3:
01038     case 4:
01039     case 5:
01040       type = mode - 1;
01041       charge12 = 1;
01042       absPhi12 = address.delta_phi_12;
01043       absPhi23 = address.delta_phi_23;
01044 
01045       if(charge) charge23 = 1;
01046       else charge23 = -1;
01047 
01048       // now convert to real numbers for input into PT assignment algos.
01049 
01050       if(pt_method == 4 || pt_method == 5) // param method 2010
01051         {
01052           dphi12R = (static_cast<float>(absPhi12<<1)) / (static_cast<float>(1<<12)) * CSCTFConstants::SECTOR_RAD;
01053           dphi23R = (static_cast<float>(absPhi23<<4)) / (static_cast<float>(1<<12)) * CSCTFConstants::SECTOR_RAD;
01054           if(charge12 * charge23 < 0) dphi23R = -dphi23R;
01055 
01056           ptR_front = ptMethods.Pt3Stn2010(mode, etaR, dphi12R, dphi23R, 1, int(pt_method));
01057           ptR_rear  = ptMethods.Pt3Stn2010(mode, etaR, dphi12R, dphi23R, 0, int(pt_method));
01058 
01059           if(pt_method == 5 && mode != 5 && etaR > 2.1)//exclude mode without ME11a
01060             {
01061                 float dphi12Rmin = dphi12R - Pi*10/180/3; // 10/3 degrees 
01062                 float dphi12Rmax = dphi12R + Pi*10/180/3; // 10/3 degrees
01063                 float dphi23Rmin = dphi23R;
01064                 float dphi23Rmax = dphi23R;
01065                 if(dphi12Rmin*dphi12R < 0) dphi23Rmin = -dphi23R;
01066                 if(dphi12Rmax*dphi12R < 0) dphi23Rmax = -dphi23R;
01067                 float ptR_front_min = ptMethods.Pt3Stn2010(mode, etaR, dphi12Rmin, dphi23Rmin, 1, int(pt_method));
01068                 float ptR_rear_min = ptMethods.Pt3Stn2010(mode, etaR, dphi12Rmin, dphi23Rmin, 0, int(pt_method));
01069                 float ptR_front_max = ptMethods.Pt3Stn2010(mode, etaR, dphi12Rmax, dphi23Rmax, 1, int(pt_method));
01070                 float ptR_rear_max = ptMethods.Pt3Stn2010(mode, etaR, dphi12Rmax, dphi23Rmax, 0, int(pt_method));
01071                 // select max pt solution for 3 links:
01072                 ptR_front = std::max(ptR_front, ptR_front_min);
01073                 ptR_front = std::max(ptR_front, ptR_front_max);
01074                 ptR_rear = std::max(ptR_rear, ptR_rear_min);
01075                 ptR_rear = std::max(ptR_rear, ptR_rear_max);
01076             }
01077         }
01078       else if(pt_method == 1) // param method
01079         {
01080           dphi12R = (static_cast<float>(absPhi12<<1)) / (static_cast<float>(1<<12)) * CSCTFConstants::SECTOR_RAD;
01081           dphi23R = (static_cast<float>(absPhi23<<4)) / (static_cast<float>(1<<12)) * CSCTFConstants::SECTOR_RAD;
01082           if(charge12 * charge23 < 0) dphi23R = -dphi23R;
01083 
01084           ptR_front = ptMethods.Pt3Stn(type, etaR, dphi12R, dphi23R, 1);
01085           ptR_rear  = ptMethods.Pt3Stn(type, etaR, dphi12R, dphi23R, 0);
01086 
01087         }
01088       else if(pt_method == 2) // cathy's method
01089         {
01090           if(type <= 2)
01091             {
01092               ptR_front = ptMethods.Pt3StnChiSq(type+3, etaR, absPhi12<<1, ((charge == 0) ? -(absPhi23<<4) : (absPhi23<<4)), 1);
01093               ptR_rear  = ptMethods.Pt3StnChiSq(type+3, etaR, absPhi12<<1, ((charge == 0) ? -(absPhi23<<4) : (absPhi23<<4)), 0);
01094             }
01095           else
01096             {
01097               ptR_front = ptMethods.Pt2StnChiSq(type-2, etaR, absPhi12<<1, 1);
01098               ptR_rear  = ptMethods.Pt2StnChiSq(type-2, etaR, absPhi12<<1, 0);
01099             }
01100 
01101         }
01102       else // hybrid
01103         {
01104 
01105           if(type <= 2)
01106             {
01107               ptR_front = ptMethods.Pt3StnHybrid(type+3, etaR, absPhi12<<1, ((charge == 0) ? -(absPhi23<<4) : (absPhi23<<4)), 1);
01108               ptR_rear  = ptMethods.Pt3StnHybrid(type+3, etaR, absPhi12<<1, ((charge == 0) ? -(absPhi23<<4) : (absPhi23<<4)), 0);
01109             }
01110           else
01111             {
01112               ptR_front = ptMethods.Pt2StnHybrid(type-2, etaR, absPhi12<<1, 1);
01113               ptR_rear  = ptMethods.Pt2StnHybrid(type-2, etaR, absPhi12<<1, 0);
01114             }
01115 
01116         }
01117       break;
01118     case 6:
01119     case 7:
01120     case 8:
01121     case 9:
01122     case 10:
01123       type = mode - 5;
01124 
01125       if(charge) absPhi12 = address.delta_phi();
01126       else
01127         {
01128           int temp_phi = address.delta_phi();
01129           absPhi12 = static_cast<unsigned>(-temp_phi) & 0xfff;
01130         }
01131 
01132       if(absPhi12 < (1<<9))
01133         {
01134           if(pt_method == 1 || type == 5)
01135             {
01136               dphi12R = (static_cast<float>(absPhi12)) / (static_cast<float>(1<<12)) * CSCTFConstants::SECTOR_RAD;
01137 
01138               ptR_front = ptMethods.Pt2Stn(type, etaR, dphi12R, 1);
01139               ptR_rear  = ptMethods.Pt2Stn(type, etaR, dphi12R, 0);
01140 
01141             }
01142           else if(pt_method == 2)
01143             {
01144               ptR_front = ptMethods.Pt2StnChiSq(type-1, etaR, absPhi12, 1);
01145               ptR_rear  = ptMethods.Pt2StnChiSq(type-1, etaR, absPhi12, 0);
01146             }
01147           else
01148             {
01149               ptR_front = ptMethods.Pt2StnHybrid(type-1, etaR, absPhi12, 1);
01150               ptR_rear  = ptMethods.Pt2StnHybrid(type-1, etaR, absPhi12, 0);
01151             }
01152         }
01153       else
01154         {
01155           ptR_front = trigger_ptscale->getPtScale()->getLowEdge(1);
01156           ptR_rear  = trigger_ptscale->getPtScale()->getLowEdge(1);
01157         }
01158       if(pt_method == 4 || pt_method == 5) // param method 2010
01159         {
01160               dphi12R = (static_cast<float>(absPhi12)) / (static_cast<float>(1<<12)) * CSCTFConstants::SECTOR_RAD;
01161 
01162               //std::cout<< " Sector_rad = " << (CSCTFConstants::SECTOR_RAD) << std::endl;
01163               ptR_front = ptMethods.Pt2Stn2010(mode, etaR, dphi12R, 1, int(pt_method));
01164               ptR_rear  = ptMethods.Pt2Stn2010(mode, etaR, dphi12R, 0, int(pt_method));
01165               if((pt_method == 5) && etaR > 2.1 && mode != 8 && mode !=9 && mode !=10)//exclude tracks without ME11a 
01166                 {
01167                    float dphi12Rmin = fabs(fabs(dphi12R) - Pi*10/180/3); // 10/3 degrees 
01168                    float ptR_front_min = ptMethods.Pt2Stn2010(mode, etaR, dphi12Rmin, 1, int(pt_method));
01169                    float ptR_rear_min = ptMethods.Pt2Stn2010(mode, etaR, dphi12Rmin, 0, int(pt_method));
01170                    // select max pt solution for 3 links:
01171                    ptR_front = std::max(ptR_front, ptR_front_min);
01172                    ptR_rear = std::max(ptR_rear, ptR_rear_min);
01173                 }
01174         }
01175 
01176       break;
01177     case 12:  // 1-2-b1 calculated only delta_phi12 = 2-b1
01178     case 14:
01179       type = 2;
01180 
01181       if(charge) absPhi12 = address.delta_phi();
01182       else
01183         {
01184           int temp_phi = address.delta_phi();
01185           absPhi12 = static_cast<unsigned>(-temp_phi) & 0xfff;
01186         }
01187       if(absPhi12 < (1<<9))
01188         {
01189           dphi12R = (static_cast<float>(absPhi12)) / (static_cast<float>(1<<12)) * CSCTFConstants::SECTOR_RAD;
01190           ptR_front = ptMethods.Pt2Stn(type, etaR, dphi12R, 1);
01191           ptR_rear  = ptMethods.Pt2Stn(type, etaR, dphi12R, 0);
01192         }
01193       else
01194         {
01195           ptR_front = trigger_ptscale->getPtScale()->getLowEdge(1);
01196           ptR_rear  = trigger_ptscale->getPtScale()->getLowEdge(1);
01197         }
01198       if(pt_method == 4 || pt_method == 5) // param method 2010 
01199         {
01200               dphi12R = (static_cast<float>(absPhi12)) / (static_cast<float>(1<<12)) * CSCTFConstants::SECTOR_RAD;
01201 
01202               ptR_front = ptMethods.Pt2Stn2010(mode, etaR, dphi12R, 1, int(pt_method));
01203               ptR_rear  = ptMethods.Pt2Stn2010(mode, etaR, dphi12R, 0, int(pt_method));
01204 
01205               if(fabs(dphi12R)<0.01 && (ptR_rear < 10 || ptR_front < 10))
01206                 std::cout << "dphi12R = " << dphi12R << " ptR_rear = " << ptR_rear
01207                 << " ptR_front = " << ptR_front << " etaR = " << etaR << " mode = " << mode << std::endl;
01208         }
01209       break;
01210     case 13:
01211       type = 4;
01212 
01213       if(charge) absPhi12 = address.delta_phi();
01214       else
01215         {
01216           int temp_phi = address.delta_phi();
01217           absPhi12 = static_cast<unsigned>(-temp_phi) & 0xfff;
01218         }
01219       if(absPhi12 < (1<<9))
01220         {
01221           dphi12R = (static_cast<float>(absPhi12)) / (static_cast<float>(1<<12)) * CSCTFConstants::SECTOR_RAD;
01222           ptR_front = ptMethods.Pt2Stn(type, etaR, dphi12R, 1);
01223           ptR_rear  = ptMethods.Pt2Stn(type, etaR, dphi12R, 0);
01224         }
01225       else
01226         {
01227           ptR_front = trigger_ptscale->getPtScale()->getLowEdge(1);
01228           ptR_rear  = trigger_ptscale->getPtScale()->getLowEdge(1);
01229         }
01230 
01231       if(pt_method == 4 || pt_method == 5) // param method 2010
01232         {
01233               dphi12R = (static_cast<float>(absPhi12)) / (static_cast<float>(1<<12)) * CSCTFConstants::SECTOR_RAD;
01234 
01235               ptR_front = ptMethods.Pt2Stn2010(mode, etaR, dphi12R, 1, int(pt_method));
01236               ptR_rear  = ptMethods.Pt2Stn2010(mode, etaR, dphi12R, 0, int(pt_method));
01237               if((pt_method == 5) && etaR > 2.1)//mode = 13: ME1-ME4 exclude tracks without ME11a 
01238                 {
01239                    float dphi12Rmin = fabs(fabs(dphi12R) - Pi*10/180/3); // 10/3 degrees 
01240                    float ptR_front_min = ptMethods.Pt2Stn2010(mode, etaR, dphi12Rmin, 1, int(pt_method));
01241                    float ptR_rear_min = ptMethods.Pt2Stn2010(mode, etaR, dphi12Rmin, 0, int(pt_method));
01242                    // select max pt solution for 3 links:
01243                    ptR_front = std::max(ptR_front, ptR_front_min);
01244                    ptR_rear = std::max(ptR_rear, ptR_rear_min);
01245                 }
01246         }
01247 
01248       break;
01249     case 11:
01250       // singles trigger
01251       ptR_front = trigger_ptscale->getPtScale()->getLowEdge(5);
01252       ptR_rear  = trigger_ptscale->getPtScale()->getLowEdge(5);
01253       //ptR_front = trigger_ptscale->getPtScale()->getLowEdge(31);
01254       //ptR_rear  = trigger_ptscale->getPtScale()->getLowEdge(31);
01255       break;
01256     case 15:
01257       // halo trigger
01258       ptR_front = trigger_ptscale->getPtScale()->getLowEdge(5);
01259       ptR_rear  = trigger_ptscale->getPtScale()->getLowEdge(5);
01260       break;
01261     case 1:
01262       // tracks that fail delta phi cuts
01263       ptR_front = trigger_ptscale->getPtScale()->getLowEdge(5);
01264       ptR_rear  = trigger_ptscale->getPtScale()->getLowEdge(5); 
01265      break;
01266     default: // Tracks in this category are not considered muons.
01267       ptR_front = trigger_ptscale->getPtScale()->getLowEdge(0);
01268       ptR_rear  = trigger_ptscale->getPtScale()->getLowEdge(0);
01269     };
01270 
01271   front_pt = trigger_ptscale->getPtScale()->getPacked(ptR_front);
01272   rear_pt  = trigger_ptscale->getPtScale()->getPacked(ptR_rear);
01273 
01274   // kluge to set arbitrary Pt for some tracks with lousy resolution (and no param)
01275   if(pt_method != 4 && pt_method != 5) 
01276     {
01277       if ((front_pt==0 || front_pt==1) && (eta<3) && quality==1 && pt_method != 2) front_pt = 31;
01278       if ((rear_pt==0  || rear_pt==1) && (eta<3) && quality==1 && pt_method != 2) rear_pt = 31;
01279     }
01280   if(pt_method != 2 && pt_method != 4 && quality == 1)
01281     {
01282       if (front_pt < 5) front_pt = 5;
01283       if (rear_pt  < 5) rear_pt  = 5;
01284     }
01285 
01286   // in order to match the pt assignement of the previous routine
01287   if(isBeamStartConf && pt_method != 2 && pt_method != 4 && pt_method !=5) {
01288     if(quality == 3 && mode == 5) {
01289       
01290       if (front_pt < 5) front_pt = 5;
01291       if (rear_pt  < 5) rear_pt  = 5;
01292     }
01293 
01294     if(quality == 2 && mode > 7 && mode < 11) {
01295       
01296       if (front_pt < 5) front_pt = 5;
01297       if (rear_pt  < 5) rear_pt  = 5;
01298     }
01299   }
01300 
01301   } // end if for pt_method less or equal to 5
01302 //***************************************************//
01303 
01304  
01305   result.front_rank = front_pt | front_quality << 5;
01306   result.rear_rank  = rear_pt  | rear_quality << 5;
01307 
01308   result.charge_valid_front = 1; //ptMethods.chargeValid(front_pt, quality, eta, pt_method);
01309   result.charge_valid_rear  = 1; //ptMethods.chargeValid(rear_pt, quality, eta, pt_method);
01310 
01311 
01312   /*  if (mode == 1) { 
01313     std::cout << "F_pt: "      << front_pt      << std::endl;
01314     std::cout << "R_pt: "      << rear_pt       << std::endl;
01315     std::cout << "F_quality: " << front_quality << std::endl;
01316     std::cout << "R_quality: " << rear_quality  << std::endl;
01317     std::cout << "F_rank: " << std::hex << result.front_rank << std::endl;
01318     std::cout << "R_rank: " << std::hex << result.rear_rank  << std::endl;
01319   }
01320   */
01321   return result;
01322 }
01323 
01324 
01325 unsigned CSCTFPtLUT::trackQuality(const unsigned& eta, const unsigned& mode, const unsigned& fr) const
01326 {
01327  // eta and mode should be only 4-bits, since that is the input to the large LUT
01328     if (eta>15 || mode>15)
01329       {
01330         //std::cout << "Error: Eta or Mode out of range in AU quality assignment" << std::endl;
01331         edm::LogError("CSCTFPtLUT::trackQuality()")<<"Eta or Mode out of range in AU quality assignment";
01332         return 0;
01333       }
01334     unsigned int quality;
01335     switch (mode) {
01336     case 2:
01337       quality = 3;
01338       if(pt_method > 10 && eta < 3) quality = 1; //eta < 1.2
01339       if(pt_method == 32 && eta >= 12) quality = 2; // eta > 2.1  
01340       break;
01341     case 3:
01342     case 4:
01344       //        quality = 2;
01345       quality = 3;
01346       if(pt_method == 32 && eta >= 12) quality = 2; // eta > 2.1  
01347       break;
01348     case 5:
01349       quality = 1;
01350       if (isBeamStartConf && eta >= 12 && pt_method < 20) // eta > 2.1
01351         quality = 3;
01352       if(pt_method == 27 || pt_method == 28 || pt_method == 29 || pt_method == 32 || pt_method == 30 || pt_method == 33) quality = 3;// all mode = 5 set to quality 3 due to a lot dead ME1/1a stations
01353       break;
01354     case 6:
01355       if (eta>=3) // eta > 1.2
01356         quality = 2;
01357       else
01358         quality = 1;
01359       if(pt_method == 32 && eta >= 12) quality = 1; // eta > 2.1  
01360       break;
01361     case 7:
01362       quality = 2;
01363       if(pt_method > 10 && eta < 3) quality = 1; //eta < 1.2  
01364       if(pt_method == 32 && eta >= 12) quality = 1; // eta > 2.1  
01365       break;
01366     case 8:
01367     case 9:
01368     case 10:
01369       quality = 1;
01370       if (isBeamStartConf && eta >= 12 && pt_method < 20) // eta > 2.1
01371         quality = 2;
01372       if((pt_method == 27 || pt_method == 28 || pt_method == 30) && (eta >= 7 && eta < 9)) quality = 2; //set to quality 2 for eta = 1.6-1.8 due to a lot dead ME1/1a stations
01373       break;
01374     case 11:
01375       // single LCTs
01376       quality = 1;
01377       // overlap region
01378       if(pt_method > 10 && fr == 0) quality = 2;
01379       if(pt_method > 10 && fr == 1) quality = 3;
01380       if(pt_method > 20 && fr == 0) quality = 3;
01381       break;
01382     case 12:
01383       quality = 3;
01384       // overlap region
01385       if(pt_method > 10 && fr == 0) quality = 2;
01386       if(pt_method > 10 && fr == 1) quality = 3;
01387       if(pt_method > 20 && fr == 0) quality = 3;
01388       break;
01389     case 13:
01390       quality = 2;
01391       if(pt_method == 32 && eta >= 12) quality = 1; // eta > 2.1  
01392       break;
01393     case 14:
01394       quality = 2;
01395       // overlap region
01396       if(pt_method > 10 && fr == 0) quality = 2;
01397       if(pt_method > 10 && fr == 1) quality = 3;
01398       if(pt_method > 20 && fr == 0) quality = 3;
01399       break;
01400     case 15:
01401       // halo triggers
01402       quality = 1;
01403       break;
01404       //DEA: keep muons that fail delta phi cut
01405     case 1:
01406       quality = 1;
01407       break;
01408     default:
01409       quality = 0;
01410       break;
01411     }
01412 
01413     // allow quality = 1 only in overlap region or eta = 1.6 region
01414     //    if ((quality == 1) && (eta >= 4) && (eta != 6) && (eta != 7)) quality = 0;
01415     //    if ( (quality == 1) && (eta >= 4) ) quality = 0;
01416 
01417     if ( (quality == 1) && (eta >= 4) && (eta < 11)
01418          && ((lowQualityFlag&4)==0) ) quality = 0;
01419     if ( (quality == 1) && (eta < 4) && ((lowQualityFlag&1)==0)
01420          && ((lowQualityFlag&4)==0) ) quality = 0;
01421     if ( (quality == 1) && (eta >=11) && ((lowQualityFlag&2)==0)
01422          && ((lowQualityFlag&4)==0) ) quality = 0;
01423 
01424     return quality;
01425 
01426 }
01427 
01428 void CSCTFPtLUT::readLUT()
01429 {
01430   std::ifstream PtLUT;
01431 
01432   if(isBinary)
01433     {
01434       PtLUT.open(pt_lut_file.fullPath().c_str(), std::ios::binary);
01435       PtLUT.seekg(0, std::ios::end);
01436       int length = PtLUT.tellg();;
01437       if( length == (1<<CSCBitWidths::kPtAddressWidth)*sizeof(short) )
01438         {
01439           PtLUT.seekg(0, std::ios::beg);
01440           PtLUT.read(reinterpret_cast<char*>(pt_lut),length);
01441         }
01442       else
01443         {
01444           edm::LogError("CSCPtLUT") << "File " << pt_lut_file.fullPath() << " is incorrect size!\n";
01445         }
01446       PtLUT.close();
01447     }
01448   else
01449     {
01450       PtLUT.open(pt_lut_file.fullPath().c_str());
01451       unsigned i = 0;
01452       unsigned short temp = 0;
01453       while(!PtLUT.eof() && i < 1 << CSCBitWidths::kPtAddressWidth)
01454         {
01455           PtLUT >> temp;
01456           pt_lut[i++] = (*reinterpret_cast<ptdat*>(&temp));
01457         }
01458       PtLUT.close();
01459     }
01460 }
01461 
01462