CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_5_3_10/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   /*
00184   if(read_pt_lut) 
00185   {
00186     int shortAdd = (address.toint()& 0x1fffff);
00187     result = pt_lut[shortAdd];
00188   } else
00189   */
00190   result = calcPt(address);
00191   return result;
00192 }
00193 
00194 ptdat CSCTFPtLUT::Pt(const unsigned& address) const
00195 {
00196   return Pt(ptadd(address));
00197 }
00198 
00199 ptdat CSCTFPtLUT::Pt(const unsigned& delta_phi_12, const unsigned& delta_phi_23,
00200                      const unsigned& track_eta, const unsigned& track_mode,
00201                      const unsigned& track_fr, const unsigned& delta_phi_sign) const
00202 {
00203   ptadd address;
00204   address.delta_phi_12 = delta_phi_12;
00205   address.delta_phi_23 = delta_phi_23;
00206   address.track_eta = track_eta;
00207   address.track_mode = track_mode;
00208   address.track_fr = track_fr;
00209   address.delta_phi_sign = delta_phi_sign;
00210 
00211   return Pt(address);
00212 }
00213 
00214 ptdat CSCTFPtLUT::Pt(const unsigned& delta_phi_12, const unsigned& track_eta,
00215                      const unsigned& track_mode, const unsigned& track_fr,
00216                      const unsigned& delta_phi_sign) const
00217 {
00218   ptadd address;
00219   address.delta_phi_12 = ((1<<8)-1)&delta_phi_12;
00220   address.delta_phi_23 = ((1<<4)-1)&(delta_phi_12>>8);
00221   address.track_eta = track_eta;
00222   address.track_mode = track_mode;
00223   address.track_fr = track_fr;
00224   address.delta_phi_sign = delta_phi_sign;
00225 
00226   return Pt(address);
00227 }
00228 
00229 
00230 ptdat CSCTFPtLUT::calcPt(const ptadd& address) const
00231 {
00232   ptdat result;
00233 
00234   double Pi  = acos(-1.);
00235   float etaR = 0, ptR_front = 0, ptR_rear = 0, dphi12R = 0, dphi23R = 0;
00236   int charge12, charge23;
00237   unsigned type, mode, eta, fr, quality, charge, absPhi12, absPhi23;
00238 
00239   mode = address.track_mode;
00240    
00241   int usedetaCUT = true;
00242   // Chose Eta cut tightness. 1=tightest, 2=moderate, 3=loose, 4=very loose, 5=extremely loose, 6=open
00243 
00244   // modes 6, 7, 13
00245   int EtaCutLevel_1 = 2;
00246   int dEtaCut_1[24];
00247   
00248   for (int i=0;i<24;i++)
00249     {
00250       dEtaCut_1[i] = 10;
00251       if (EtaCutLevel_1 == 1)
00252         dEtaCut_1[i] = dEtaCut_Low[i];
00253       else if (EtaCutLevel_1 == 2)
00254         dEtaCut_1[i] = dEtaCut_Mid[i];
00255       else if (EtaCutLevel_1 == 3)
00256         dEtaCut_1[i] = dEtaCut_High_A[i];
00257       else if (EtaCutLevel_1 == 4)
00258         dEtaCut_1[i] = dEtaCut_High_B[i];
00259       else if (EtaCutLevel_1 == 5)
00260         dEtaCut_1[i] = dEtaCut_High_C[i];
00261       else if (EtaCutLevel_1 == 6)
00262         dEtaCut_1[i] = dEtaCut_Open[i];
00263     }
00264   // modes 8, 9, 10
00265   int EtaCutLevel_2 = 2;
00266   int dEtaCut_2[24];
00267   
00268   for (int i=0;i<24;i++)
00269     {
00270       dEtaCut_2[i] = 10;
00271       if (EtaCutLevel_2 == 1)
00272         dEtaCut_2[i] = dEtaCut_Low[i];
00273       else if (EtaCutLevel_2 == 2)
00274         dEtaCut_2[i] = dEtaCut_Mid[i];
00275       else if (EtaCutLevel_2 == 3)
00276         dEtaCut_2[i] = dEtaCut_High_A[i];
00277       else if (EtaCutLevel_2 == 4)
00278         dEtaCut_2[i] = dEtaCut_High_B[i];
00279       else if (EtaCutLevel_2 == 5)
00280         dEtaCut_2[i] = dEtaCut_High_C[i];
00281       else if (EtaCutLevel_2 == 6)
00282         dEtaCut_2[i] = dEtaCut_Open[i];
00283 
00284       float scalef = 1.0;
00285       if (mode == 8 || mode == 10)
00286         dEtaCut_2[i] = scalef*dEtaCut_2[i];
00287       
00288     }
00289   
00290   
00291 
00292   eta = address.track_eta;
00293  
00294   fr = address.track_fr;
00295   charge = address.delta_phi_sign;
00296   quality = trackQuality(eta, mode, fr);
00297   unsigned front_pt, rear_pt;
00298   front_pt = 0.; rear_pt = 0.;
00299   unsigned front_quality, rear_quality;
00300 
00301   etaR = trigger_scale->getRegionalEtaScale(2)->getLowEdge(2*eta+1);
00302 
00303   front_quality = rear_quality = quality;
00304 
00305   unsigned int remerged;
00306   int iME11;
00307   int CLCT_pattern;
00308   int dEta;
00309   int index = 0;
00310   float bestLH = -999;
00311  float bestLH_front = -999.0;
00312  float bestLH_rear = -999.0;
00313 
00314  int PtbyMLH = false;
00315   
00316   //***************************************************//
00317   if(pt_method >= 29 && pt_method <= 33)
00318     {
00319         // using fw 2012_01_31. Switch to Global Log(L). Non-Linear dphi binning.
00320       PtbyMLH = 0x1 & (getPtbyMLH >> (int)mode);
00322       // switch off any improvment for eta > 2.1
00323       if(etaR > 2.1){
00324          usedetaCUT = false;
00325          PtbyMLH = 0x0;
00326       }
00328       
00329       switch(mode)
00330         {
00331         case 2:
00332         case 3:
00333         case 4:
00334         case 5:
00335   
00336       
00337       charge12 = 1;
00338 
00339       // First remake the 12-bit dPhi word from the core
00340       remerged = (address.delta_phi_12 | (address.delta_phi_23 << 8 ) );
00341       
00342       // Now separate it into 7-bit dPhi12 and 5-bit dPhi23 parts
00343       absPhi12 = ((1<<7)-1) &  remerged; 
00344       absPhi23 = ((1<<5)-1) & (remerged >> 7);
00345 
00346       // Now get the corresponding dPhi value in our phi-units using the inverse dPhi LUTs
00347       absPhi12 = dPhiNLBMap_7bit[absPhi12];
00348       absPhi23 = dPhiNLBMap_5bit[absPhi23];
00349 
00350       if(charge) charge23 = 1;
00351       else charge23 = -1;
00352 
00353       dphi12R = (static_cast<float>(absPhi12)) / (static_cast<float>(1<<12)) * CSCTFConstants::SECTOR_RAD;
00354       dphi23R = (static_cast<float>(absPhi23)) / (static_cast<float>(1<<12)) * CSCTFConstants::SECTOR_RAD;
00355       if(charge12 * charge23 < 0) dphi23R = -dphi23R;
00356 
00357       ptR_front = ptMethods.Pt3Stn2012(int(mode), etaR, dphi12R, dphi23R, PtbyMLH, bestLH, 1, int(pt_method));
00358       bestLH_front = bestLH;
00359       ptR_rear  = ptMethods.Pt3Stn2012(int(mode), etaR, dphi12R, dphi23R, PtbyMLH, bestLH, 0, int(pt_method));    
00360       bestLH_rear = bestLH;
00361       
00362       if((pt_method == 29 || pt_method == 32 || pt_method == 30 || pt_method == 31) && mode != 5 && etaR > 2.1)//exclude mode without ME11a
00363         {
00364             float dphi12Rmin = dphi12R - Pi*10/180/3; // 10/3 degrees 
00365             float dphi12Rmax = dphi12R + Pi*10/180/3; // 10/3 degrees
00366             float dphi23Rmin = dphi23R;
00367             float dphi23Rmax = dphi23R;
00368             //if(dphi12Rmin*dphi12R < 0) dphi23Rmin = -dphi23R;
00369             //if(dphi12Rmax*dphi12R < 0) dphi23Rmax = -dphi23R;
00370             float ptR_front_min = ptMethods.Pt3Stn2012(int(mode), etaR, dphi12Rmin, dphi23Rmin, PtbyMLH, bestLH, 1, int(pt_method));
00371             float bestLH_front_min = bestLH;
00372             float ptR_rear_min = ptMethods.Pt3Stn2012(int(mode), etaR, dphi12Rmin, dphi23Rmin,  PtbyMLH, bestLH, 0, int(pt_method));
00373             float bestLH_rear_min = bestLH;
00374             float ptR_front_max = ptMethods.Pt3Stn2012(int(mode), etaR, dphi12Rmax, dphi23Rmax, PtbyMLH, bestLH, 1, int(pt_method));
00375             float bestLH_front_max = bestLH;
00376             float ptR_rear_max = ptMethods.Pt3Stn2012(int(mode), etaR, dphi12Rmax, dphi23Rmax,  PtbyMLH, bestLH, 0, int(pt_method));
00377             float bestLH_rear_max = bestLH;
00378 
00379             if (PtbyMLH)
00380               {
00381                 float best_pt_front = ptR_front;
00382                 float best_LH_front = bestLH_front;
00383                 if (bestLH_front_min > best_LH_front)
00384                   {
00385                     best_pt_front = ptR_front_min;
00386                     best_LH_front = bestLH_front_min;
00387                   }
00388                 if (bestLH_front_max > best_LH_front)
00389                   {
00390                     best_pt_front = ptR_front_max;
00391                     best_LH_front = bestLH_front_max;
00392                   }
00393                 ptR_front = best_pt_front;
00394 
00395                 float best_pt_rear = ptR_rear;
00396                 float best_LH_rear = bestLH_rear;
00397                 if (bestLH_rear_min > best_LH_rear)
00398                   {
00399                     best_pt_rear = ptR_rear_min;
00400                     best_LH_rear = bestLH_rear_min;
00401                   }
00402                 if (bestLH_rear_max > best_LH_rear)
00403                   {
00404                     best_pt_rear = ptR_rear_max;
00405                     best_LH_rear = bestLH_rear_max;
00406                   }
00407                 ptR_rear = best_pt_rear;
00408               }
00409             else
00410               {
00411                 // select max pt solution for 3 links:
00412                 ptR_front = std::max(ptR_front, ptR_front_min);
00413                 ptR_front = std::max(ptR_front, ptR_front_max);
00414                 ptR_rear = std::max(ptR_rear, ptR_rear_min);
00415                 ptR_rear = std::max(ptR_rear, ptR_rear_max);
00416               }
00417         }
00418       break;
00419     case 6: // for mode 6, 7 and 13 add CLCT information in dph23 bit and iME11 in charge bit   
00420     case 7:
00421     case 13: // ME1-ME4
00422       
00423       // First remake the 12-bit dPhi word from the core
00424       remerged = (address.delta_phi_12 | (address.delta_phi_23 << 8 ) );
00425       // Now get 8-bit dPhi12 
00426       absPhi12 = ((1<<8)-1) & remerged; 
00427       // Now get 3-bit dEta
00428       dEta = ((1<<3)-1) & (remerged >> 8);
00429       // New get CLCT bit. CLCT = true if CLCTPattern = 8, 9, or 10, else 0.
00430       CLCT_pattern = 0x1 & (remerged >> 11);
00431       
00432       iME11 = int(charge); // = 0 if ME1/1, = 1 if ME1/2 or ME1/3 station 
00433       if(iME11 == 1 && etaR > 1.6) etaR = 1.55; // shift for ME1/2 station  
00434       if(iME11 == 0 && etaR < 1.6) etaR = 1.65; // shift for ME1/1 station
00435 
00436       // Get the 8-bit dPhi bin number  
00437       absPhi12 = ((1<<8)-1) & address.delta_phi_12;
00438       
00439       // Now get the corresponding dPhi value in our phi-units using the inverse dPhi LUTs
00440       absPhi12 = dPhiNLBMap_8bit[absPhi12];
00441       
00442       //int CLCT_pattern = static_cast<int>(address.delta_phi_23);
00443     
00444       dphi12R = (static_cast<float>(absPhi12)) / (static_cast<float>(1<<12)) * CSCTFConstants::SECTOR_RAD;
00445       
00446       //std::cout<< " Sector_rad = " << (CSCTFConstants::SECTOR_RAD) << std::endl;
00447       ptR_front = ptMethods.Pt2Stn2012(int(mode), etaR, dphi12R, PtbyMLH, bestLH, 1, int(pt_method));
00448       bestLH_front = bestLH;
00449       ptR_rear  = ptMethods.Pt2Stn2012(int(mode), etaR, dphi12R, PtbyMLH, bestLH, 0, int(pt_method));
00450       bestLH_rear = bestLH;
00451       if((pt_method == 29 || pt_method == 32 || pt_method == 30 || pt_method == 31) && etaR > 2.1)//exclude tracks without ME11a 
00452         {
00453           float dphi12Rmin = fabs(fabs(dphi12R) - Pi*10/180/3); // 10/3 degrees 
00454           float ptR_front_min = ptMethods.Pt2Stn2012(int(mode), etaR, dphi12Rmin,  PtbyMLH, bestLH, 1, int(pt_method));
00455           float bestLH_front_min = bestLH;
00456           float ptR_rear_min = ptMethods.Pt2Stn2012(int(mode), etaR, dphi12Rmin,   PtbyMLH, bestLH, 0, int(pt_method));
00457           float bestLH_rear_min = bestLH;
00458 
00459           if (PtbyMLH)
00460             {
00461               ptR_front = bestLH_front > bestLH_front_min ? ptR_front : ptR_front_min;
00462               ptR_rear  = bestLH_rear  > bestLH_rear_min ? ptR_rear : ptR_rear_min;
00463             }
00464           else
00465             {
00466               // select max pt solution for 3 links:
00467               ptR_front = std::max(ptR_front, ptR_front_min);
00468               ptR_rear = std::max(ptR_rear, ptR_rear_min);
00469             }
00470         }
00471       
00472       if( (!CLCT_pattern) && (ptR_front > 5.)) ptR_front = 5.;
00473       if( (!CLCT_pattern) && (ptR_rear > 5.)) ptR_rear = 5.;
00474 
00475        // Check dEta against reasonable values for high-pt muons
00476       index = 0;
00477       if (mode == 6) index = 0;
00478       if (mode == 7) index = 4;
00479       if (mode == 13) index = 8;
00480       
00481       if (usedetaCUT)
00482         {
00483           if (fabs(etaR)>1.2 && fabs(etaR)<=1.5)
00484             if (dEta>dEtaCut_1[index+0] )
00485               {
00486                 if (ptR_front > 5) ptR_front = 5;
00487                 if (ptR_rear  > 5) ptR_rear  = 5;
00488               }
00489           if (fabs(etaR)>1.5 && fabs(etaR)<=1.65)
00490             if (dEta>dEtaCut_1[index+1])
00491               {
00492                 if (ptR_front > 5) ptR_front = 5;
00493                 if (ptR_rear  > 5) ptR_rear  = 5;
00494               }
00495           
00496           if (fabs(etaR)>1.65 && fabs(etaR)<=2.1)
00497             if (dEta>dEtaCut_1[index+2] )
00498               {
00499                 if (ptR_front > 5) ptR_front = 5;
00500                 if (ptR_rear  > 5) ptR_rear  = 5;
00501               }
00502           if (fabs(etaR)>2.1)
00503             if (dEta>dEtaCut_1[index+3] )
00504               {
00505                 if (ptR_front > 5) ptR_front = 5;
00506                 if (ptR_rear  > 5) ptR_rear  = 5;
00507               }
00508         }
00509             
00510       break;
00511     
00512     case 8:
00513     case 9:
00514     case 10:
00515       
00516       
00517       // First remake the 12-bit dPhi word from the core
00518       remerged = (address.delta_phi_12 | (address.delta_phi_23 << 8 ) );
00519       // Now get 9-bit dPhi12 
00520       absPhi12 = ((1<<9)-1) & remerged; 
00521       // Now get 3-bit dEta
00522       dEta = ((1<<3)-1) & (remerged >> 9);
00523      
00524       dphi12R = (static_cast<float>(absPhi12)) / (static_cast<float>(1<<12)) * CSCTFConstants::SECTOR_RAD;
00525 
00526       //std::cout<< " Sector_rad = " << (CSCTFConstants::SECTOR_RAD) << std::endl;
00527       ptR_front = ptMethods.Pt2Stn2012(int(mode), etaR, dphi12R,  PtbyMLH, bestLH, 1, int(pt_method));
00528       ptR_rear  = ptMethods.Pt2Stn2012(int(mode), etaR, dphi12R,  PtbyMLH, bestLH, 0, int(pt_method));
00529 
00530       index = 0;
00531       if (mode == 8) index = 12;
00532       if (mode == 9) index = 16;
00533       if (mode == 10) index = 20;
00534 
00535       
00536       
00537       
00538       if (usedetaCUT)
00539         {
00540           if (fabs(etaR)>1.2 && fabs(etaR)<=1.5)
00541             if (dEta>dEtaCut_2[index+0] )
00542               {
00543                 if (ptR_front > 5) ptR_front = 5;
00544                 if (ptR_rear  > 5) ptR_rear  = 5;
00545               }
00546           if (fabs(etaR)>1.5 && fabs(etaR)<=1.65)
00547             if (dEta>dEtaCut_2[index+1])
00548               {
00549                 if (ptR_front > 5) ptR_front = 5;
00550                 if (ptR_rear  > 5) ptR_rear  = 5;
00551               }
00552           
00553           if (fabs(etaR)>1.65 && fabs(etaR)<=2.1)
00554             if (dEta>dEtaCut_2[index+2] )
00555               {
00556                 if (ptR_front > 5) ptR_front = 5;
00557                 if (ptR_rear  > 5) ptR_rear  = 5;
00558               }
00559           if (fabs(etaR)>2.1)
00560             if (dEta>dEtaCut_2[index+3] )
00561               {
00562                 if (ptR_front > 5) ptR_front = 5;
00563                 if (ptR_rear  > 5) ptR_rear  = 5;
00564               }
00565         }
00566             
00567       break;
00568     // for overlap DT-CSC region using curves from data 2010
00569     case 11: // FR = 1 -> b1-1-3,     FR = 0 -> b1-3 
00570     case 12: // FR = 1 -> b1-2-3,     FR = 0 -> b1-2 
00571     case 14: // FR = 1 -> b1-1-2-(3), FR = 0 -> b1-1
00572     
00573       
00574     //sign definition: sign dphi12 = Phi_DT - Phi_CSC
00575     //                 sing dphi23 = 5th sign. bit of phiBend
00576     // -> charge = 1 -> dphi12 = +, phiBend = -
00577     // -> charge = 0 -> dphi12 = +, phiBend = +    
00578         charge12 = 1;
00579 
00580         // DT tracks are still using linear dPhi binning
00581         absPhi12 = address.delta_phi_12;
00582         absPhi23 = address.delta_phi_23;
00583 
00584         if(charge) charge23 = -1;
00585         else charge23 = 1;
00586 
00587         dphi12R = (static_cast<float>(absPhi12<<1)) / (static_cast<float>(1<<12)) * CSCTFConstants::SECTOR_RAD;
00588         dphi23R = float(absPhi23);
00589         if(charge12 * charge23 < 0) dphi23R = -dphi23R;
00590 
00591         int mode1;
00592         mode1 = int(mode);
00593         if(fr == 1 && mode1 == 11) mode1 = 14; // 3 station track we use dphi12 and phiBend for 2 and 3 station track
00594 
00595         ptR_front = ptMethods.Pt3Stn2012_DT(mode1, etaR, dphi12R, dphi23R,  PtbyMLH, bestLH, int(0), int(pt_method));
00596         ptR_rear = ptMethods.Pt3Stn2012_DT(mode1, etaR, dphi12R, dphi23R,   PtbyMLH, bestLH, int(0), int(pt_method));
00597 
00598       break;
00599     case 15: // halo trigger
00600     case 1: // tracks that fail delta phi cuts
00601       ptR_front = trigger_ptscale->getPtScale()->getLowEdge(3); // 2 GeV
00602       ptR_rear  = trigger_ptscale->getPtScale()->getLowEdge(3); 
00603       break;
00604     default: // Tracks in this category are not considered muons.
00605       ptR_front = trigger_ptscale->getPtScale()->getLowEdge(0); // 0 GeV 
00606       ptR_rear  = trigger_ptscale->getPtScale()->getLowEdge(0);
00607     };// end switch
00608 
00609   front_pt = trigger_ptscale->getPtScale()->getPacked(ptR_front);
00610   rear_pt  = trigger_ptscale->getPtScale()->getPacked(ptR_rear);
00611 
00612   } //end pt_methods 29
00613 
00614 
00615 //***************************************************//
00616   if(pt_method >= 23 && pt_method <= 28){ //here we have only pt_methods greater then 
00617                        //for fw 20110118 <- 2011 data taking, curves from MC like method 4
00618   // mode definition you could find at page 6 & 7: 
00619   // http://www.phys.ufl.edu/~madorsky/sp/2011-11-18/sp_core_interface.pdf 
00620   // it is valid starting the beggining of 2011 
00621   //std::cout << " pt_method = " << pt_method << std::endl;//test 
00622   switch(mode)
00623     {
00624     case 2:
00625     case 3:
00626     case 4:
00627     case 5:
00628 
00629       charge12 = 1;
00630       absPhi12 = address.delta_phi_12;
00631       absPhi23 = address.delta_phi_23;
00632 
00633       if(charge) charge23 = 1;
00634       else charge23 = -1;
00635 
00636       dphi12R = (static_cast<float>(absPhi12<<1)) / (static_cast<float>(1<<12)) * CSCTFConstants::SECTOR_RAD;
00637       dphi23R = (static_cast<float>(absPhi23<<4)) / (static_cast<float>(1<<12)) * CSCTFConstants::SECTOR_RAD;
00638       if(charge12 * charge23 < 0) dphi23R = -dphi23R;
00639 
00640       ptR_front = ptMethods.Pt3Stn2010(int(mode), etaR, dphi12R, dphi23R, 1, int(pt_method));
00641       ptR_rear  = ptMethods.Pt3Stn2010(int(mode), etaR, dphi12R, dphi23R, 0, int(pt_method));    
00642 
00643       if((pt_method == 24 || pt_method == 26 || pt_method == 28) && mode != 5 && etaR > 2.1)//exclude mode without ME11a
00644         {
00645             float dphi12Rmin = dphi12R - Pi*10/180/3; // 10/3 degrees 
00646             float dphi12Rmax = dphi12R + Pi*10/180/3; // 10/3 degrees
00647             float dphi23Rmin = dphi23R;
00648             float dphi23Rmax = dphi23R;
00649             //if(dphi12Rmin*dphi12R < 0) dphi23Rmin = -dphi23R;
00650             //if(dphi12Rmax*dphi12R < 0) dphi23Rmax = -dphi23R;
00651             float ptR_front_min = ptMethods.Pt3Stn2010(int(mode), etaR, dphi12Rmin, dphi23Rmin, 1, int(pt_method));
00652             float ptR_rear_min = ptMethods.Pt3Stn2010(int(mode), etaR, dphi12Rmin, dphi23Rmin, 0, int(pt_method));
00653             float ptR_front_max = ptMethods.Pt3Stn2010(int(mode), etaR, dphi12Rmax, dphi23Rmax, 1, int(pt_method));
00654             float ptR_rear_max = ptMethods.Pt3Stn2010(int(mode), etaR, dphi12Rmax, dphi23Rmax, 0, int(pt_method));
00655             // select max pt solution for 3 links:
00656             ptR_front = std::max(ptR_front, ptR_front_min);
00657             ptR_front = std::max(ptR_front, ptR_front_max);
00658             ptR_rear = std::max(ptR_rear, ptR_rear_min);
00659             ptR_rear = std::max(ptR_rear, ptR_rear_max);
00660         }
00661       break;
00662     case 6: // for mode 6, 7 and 13 add CLCT information in dph23 bit and iME11 in charge bit  
00663     case 7:
00664     case 13: // ME1-ME4
00665       int iME11;
00666       iME11 = int(charge); // = 0 if ME1/1, = 1 if ME1/2 or ME1/3 station 
00667       if(iME11 == 1 && etaR > 1.6) etaR = 1.55; // shift for ME1/2 station  
00668       if(iME11 == 0 && etaR < 1.6) etaR = 1.65; // shift for ME1/1 station 
00669       absPhi12 = address.delta_phi_12;
00670       //int CLCT_pattern = static_cast<int>(address.delta_phi_23);
00671       int CLCT_pattern;
00672       CLCT_pattern = int(address.delta_phi_23);
00673       dphi12R = (static_cast<float>(absPhi12<<1)) / (static_cast<float>(1<<12)) * CSCTFConstants::SECTOR_RAD;
00674 
00675       //std::cout<< " Sector_rad = " << (CSCTFConstants::SECTOR_RAD) << std::endl;
00676       ptR_front = ptMethods.Pt2Stn2010(int(mode), etaR, dphi12R, 1, int(pt_method));
00677       ptR_rear  = ptMethods.Pt2Stn2010(int(mode), etaR, dphi12R, 0, int(pt_method));
00678       if((pt_method == 24 || pt_method == 26 || pt_method == 28) && etaR > 2.1)//exclude tracks without ME11a 
00679         {
00680            float dphi12Rmin = fabs(fabs(dphi12R) - Pi*10/180/3); // 10/3 degrees 
00681            float ptR_front_min = ptMethods.Pt2Stn2010(int(mode), etaR, dphi12Rmin, 1, int(pt_method));
00682            float ptR_rear_min = ptMethods.Pt2Stn2010(int(mode), etaR, dphi12Rmin, 0, int(pt_method));
00683            // select max pt solution for 3 links:
00684            ptR_front = std::max(ptR_front, ptR_front_min);
00685            ptR_rear = std::max(ptR_rear, ptR_rear_min);
00686         }
00687       if( ((CLCT_pattern < 8) || (CLCT_pattern > 10)) && (ptR_front > 5.)) ptR_front = 5.;
00688       if( ((CLCT_pattern < 8) || (CLCT_pattern > 10)) && (ptR_rear > 5.)) ptR_rear = 5.;
00689       //std::cout << "mode = "<< mode << " CLCT_pattern = " << CLCT_pattern << " ptR_rear = " << ptR_rear << std::endl;
00690 
00691       break;
00692     case 8:
00693     case 9:
00694     case 10:
00695       if(charge) absPhi12 = address.delta_phi();
00696       else
00697         {
00698           int temp_phi = address.delta_phi();
00699           absPhi12 = static_cast<unsigned>(-temp_phi) & 0xfff;
00700         }
00701 
00702       dphi12R = (static_cast<float>(absPhi12)) / (static_cast<float>(1<<12)) * CSCTFConstants::SECTOR_RAD;
00703 
00704       //std::cout<< " Sector_rad = " << (CSCTFConstants::SECTOR_RAD) << std::endl;
00705       ptR_front = ptMethods.Pt2Stn2010(int(mode), etaR, dphi12R, 1, int(pt_method));
00706       ptR_rear  = ptMethods.Pt2Stn2010(int(mode), etaR, dphi12R, 0, int(pt_method));
00707 
00708       break;
00709     // for overlap DT-CSC region using curves from data 2010
00710     case 11: // FR = 1 -> b1-1-3,     FR = 0 -> b1-3 
00711     case 12: // FR = 1 -> b1-2-3,     FR = 0 -> b1-2 
00712     case 14: // FR = 1 -> b1-1-2-(3), FR = 0 -> b1-1
00713 
00714     //sign definition: sign dphi12 = Phi_DT - Phi_CSC
00715     //                 sing dphi23 = 5th sign. bit of phiBend
00716     // -> charge = 1 -> dphi12 = +, phiBend = -
00717     // -> charge = 0 -> dphi12 = +, phiBend = +    
00718         charge12 = 1;
00719         absPhi12 = address.delta_phi_12;
00720         absPhi23 = address.delta_phi_23;
00721 
00722         if(charge) charge23 = -1;
00723         else charge23 = 1;
00724 
00725         dphi12R = (static_cast<float>(absPhi12<<1)) / (static_cast<float>(1<<12)) * CSCTFConstants::SECTOR_RAD;
00726         dphi23R = float(absPhi23);
00727         if(charge12 * charge23 < 0) dphi23R = -dphi23R;
00728 
00729         int mode1;
00730         mode1 = int(mode);
00731         if(fr == 1 && mode1 == 11) mode1 = 14; // 3 station track we use dphi12 and phiBend for 2 and 3 station track
00732 
00733         ptR_front = ptMethods.Pt3Stn2011(mode1, etaR, dphi12R, dphi23R, int(0), int(pt_method));
00734         ptR_rear = ptMethods.Pt3Stn2011(mode1, etaR, dphi12R, dphi23R, int(0), int(pt_method));
00735 
00736       break;
00737     case 15: // halo trigger
00738     case 1: // tracks that fail delta phi cuts
00739       ptR_front = trigger_ptscale->getPtScale()->getLowEdge(3); // 2 GeV
00740       ptR_rear  = trigger_ptscale->getPtScale()->getLowEdge(3); 
00741       break;
00742     default: // Tracks in this category are not considered muons.
00743       ptR_front = trigger_ptscale->getPtScale()->getLowEdge(0); // 0 GeV 
00744       ptR_rear  = trigger_ptscale->getPtScale()->getLowEdge(0);
00745     };// end switch
00746 
00747   front_pt = trigger_ptscale->getPtScale()->getPacked(ptR_front);
00748   rear_pt  = trigger_ptscale->getPtScale()->getPacked(ptR_rear);
00749 
00750   } //end pt_methods 23 - 28 
00751 
00752 //***************************************************//
00753 //***************************************************//
00754   if(pt_method == 21 || pt_method == 22){ //here we have only pt_methods greater then 
00755                        //for fw 20110118 <- 2011 data taking
00756   // mode definition you could find at page 6 & 7: 
00757   // http://www.phys.ufl.edu/~madorsky/sp/2011-11-18/sp_core_interface.pdf 
00758   // it is valid starting the beggining of 2011 
00759   switch(mode)
00760     {
00761     case 2:
00762     case 3:
00763     case 4:
00764     case 5:
00765 
00766       charge12 = 1;
00767       absPhi12 = address.delta_phi_12;
00768       absPhi23 = address.delta_phi_23;
00769 
00770       if(charge) charge23 = 1;
00771       else charge23 = -1;
00772 
00773       dphi12R = (static_cast<float>(absPhi12<<1)) / (static_cast<float>(1<<12)) * CSCTFConstants::SECTOR_RAD;
00774       dphi23R = (static_cast<float>(absPhi23<<4)) / (static_cast<float>(1<<12)) * CSCTFConstants::SECTOR_RAD;
00775       if(charge12 * charge23 < 0) dphi23R = -dphi23R;
00776 
00777       ptR_front = ptMethods.Pt3Stn2011(int(mode), etaR, dphi12R, dphi23R, 1, int(pt_method));
00778       ptR_rear  = ptMethods.Pt3Stn2011(int(mode), etaR, dphi12R, dphi23R, 0, int(pt_method));    
00779 
00780       if(pt_method == 22 && mode != 5 && etaR > 2.1)//exclude mode without ME11a
00781         {
00782             float dphi12Rmin = dphi12R - Pi*10/180/3; // 10/3 degrees 
00783             float dphi12Rmax = dphi12R + Pi*10/180/3; // 10/3 degrees
00784             float dphi23Rmin = dphi23R;
00785             float dphi23Rmax = dphi23R;
00786             //if(dphi12Rmin*dphi12R < 0) dphi23Rmin = -dphi23R;
00787             //if(dphi12Rmax*dphi12R < 0) dphi23Rmax = -dphi23R;
00788             float ptR_front_min = ptMethods.Pt3Stn2011(int(mode), etaR, dphi12Rmin, dphi23Rmin, 1, int(pt_method));
00789             float ptR_rear_min = ptMethods.Pt3Stn2011(int(mode), etaR, dphi12Rmin, dphi23Rmin, 0, int(pt_method));
00790             float ptR_front_max = ptMethods.Pt3Stn2011(int(mode), etaR, dphi12Rmax, dphi23Rmax, 1, int(pt_method));
00791             float ptR_rear_max = ptMethods.Pt3Stn2011(int(mode), etaR, dphi12Rmax, dphi23Rmax, 0, int(pt_method));
00792             // select max pt solution for 3 links:
00793             ptR_front = std::max(ptR_front, ptR_front_min);
00794             ptR_front = std::max(ptR_front, ptR_front_max);
00795             ptR_rear = std::max(ptR_rear, ptR_rear_min);
00796             ptR_rear = std::max(ptR_rear, ptR_rear_max);
00797         }
00798       break;
00799     case 6: // for mode 6, 7 and 13 add CLCT information in dph23 bit and iME11 in charge bit  
00800     case 7:
00801     case 13: // ME1-ME4
00802       int iME11;
00803       iME11 = int(charge);
00804       absPhi12 = address.delta_phi_12;
00805       //int CLCT_pattern = static_cast<int>(address.delta_phi_23);
00806       int CLCT_pattern;
00807       CLCT_pattern = int(address.delta_phi_23);
00808 
00809       dphi12R = (static_cast<float>(absPhi12<<1)) / (static_cast<float>(1<<12)) * CSCTFConstants::SECTOR_RAD;
00810 
00811       //std::cout<< " Sector_rad = " << (CSCTFConstants::SECTOR_RAD) << std::endl;
00812       ptR_front = ptMethods.Pt2Stn2011(int(mode), etaR, dphi12R, 1, int(pt_method), iME11);
00813       ptR_rear  = ptMethods.Pt2Stn2011(int(mode), etaR, dphi12R, 0, int(pt_method), iME11);
00814       if((pt_method == 22) && etaR > 2.1)//exclude tracks without ME11a 
00815         {
00816            float dphi12Rmin = fabs(fabs(dphi12R) - Pi*10/180/3); // 10/3 degrees 
00817            float ptR_front_min = ptMethods.Pt2Stn2011(int(mode), etaR, dphi12Rmin, 1, int(pt_method), iME11);
00818            float ptR_rear_min = ptMethods.Pt2Stn2011(int(mode), etaR, dphi12Rmin, 0, int(pt_method), iME11);
00819            // select max pt solution for 3 links:
00820            ptR_front = std::max(ptR_front, ptR_front_min);
00821            ptR_rear = std::max(ptR_rear, ptR_rear_min);
00822         }
00823       if( ((CLCT_pattern < 8) || (CLCT_pattern > 10)) && (ptR_front > 5.)) ptR_front = 5.;
00824       if( ((CLCT_pattern < 8) || (CLCT_pattern > 10)) && (ptR_rear > 5.)) ptR_rear = 5.;
00825 
00826       break;
00827     case 8:
00828     case 9:
00829     case 10:
00830       if(charge) absPhi12 = address.delta_phi();
00831       else
00832         {
00833           int temp_phi = address.delta_phi();
00834           absPhi12 = static_cast<unsigned>(-temp_phi) & 0xfff;
00835         }
00836 
00837       dphi12R = (static_cast<float>(absPhi12)) / (static_cast<float>(1<<12)) * CSCTFConstants::SECTOR_RAD;
00838 
00839       //std::cout<< " Sector_rad = " << (CSCTFConstants::SECTOR_RAD) << std::endl;
00840       ptR_front = ptMethods.Pt2Stn2011(int(mode), etaR, dphi12R, 1, int(pt_method), int(2));
00841       ptR_rear  = ptMethods.Pt2Stn2011(int(mode), etaR, dphi12R, 0, int(pt_method), int(2));
00842 
00843       break;
00844     case 11: // FR = 1 -> b1-1-3,     FR = 0 -> b1-3 
00845     case 12: // FR = 1 -> b1-2-3,     FR = 0 -> b1-2 
00846     case 14: // FR = 1 -> b1-1-2-(3), FR = 0 -> b1-1
00847 
00848     //sign definition: sign dphi12 = Phi_DT - Phi_CSC
00849     //                 sing dphi23 = 5th sign. bit of phiBend
00850     // -> charge = 1 -> dphi12 = +, phiBend = -
00851     // -> charge = 0 -> dphi12 = +, phiBend = +    
00852         charge12 = 1;
00853         absPhi12 = address.delta_phi_12;
00854         absPhi23 = address.delta_phi_23;
00855 
00856         if(charge) charge23 = -1;
00857         else charge23 = 1;
00858 
00859         dphi12R = (static_cast<float>(absPhi12<<1)) / (static_cast<float>(1<<12)) * CSCTFConstants::SECTOR_RAD;
00860         dphi23R = float(absPhi23);
00861         if(charge12 * charge23 < 0) dphi23R = -dphi23R;
00862 
00863         int mode1;
00864         mode1 = int(mode);
00865         if(fr == 1 && mode1 == 11) mode1 = 14; // 3 station track we use dphi12 and phiBend for 2 and 3 station track
00866 
00867         ptR_front = ptMethods.Pt3Stn2011(mode1, etaR, dphi12R, dphi23R, int(0), int(pt_method));
00868         ptR_rear = ptMethods.Pt3Stn2011(mode1, etaR, dphi12R, dphi23R, int(0), int(pt_method));
00869 
00870       break;
00871     case 15: // halo trigger
00872     case 1: // tracks that fail delta phi cuts
00873       ptR_front = trigger_ptscale->getPtScale()->getLowEdge(3); // 2 GeV
00874       ptR_rear  = trigger_ptscale->getPtScale()->getLowEdge(3); 
00875       break;
00876     default: // Tracks in this category are not considered muons.
00877       ptR_front = trigger_ptscale->getPtScale()->getLowEdge(0); // 0 GeV 
00878       ptR_rear  = trigger_ptscale->getPtScale()->getLowEdge(0);
00879     };// end switch
00880 
00881   front_pt = trigger_ptscale->getPtScale()->getPacked(ptR_front);
00882   rear_pt  = trigger_ptscale->getPtScale()->getPacked(ptR_rear);
00883 
00884   } //end pt_methods greater or equal to 21 
00885 
00886 //***************************************************//
00887 //***************************************************//
00888   if(pt_method >= 11 && pt_method < 20){ //here we have only pt_methods greater or equal to 11 
00889                        //for fw 20101011 <- 2011 data taking
00890   // mode definition you could find at page 6 & 7: 
00891   // http://www.phys.ufl.edu/~madorsky/sp/2010-10-11/sp_core_interface.pdf 
00892   // it is valid starting the beggining of 2011 
00893   switch(mode)
00894     {
00895     case 2:
00896     case 3:
00897     case 4:
00898     case 5:
00899 
00900       charge12 = 1;
00901       absPhi12 = address.delta_phi_12;
00902       absPhi23 = address.delta_phi_23;
00903 
00904       if(charge) charge23 = 1;
00905       else charge23 = -1;
00906 
00907       dphi12R = (static_cast<float>(absPhi12<<1)) / (static_cast<float>(1<<12)) * CSCTFConstants::SECTOR_RAD;
00908       dphi23R = (static_cast<float>(absPhi23<<4)) / (static_cast<float>(1<<12)) * CSCTFConstants::SECTOR_RAD;
00909       if(charge12 * charge23 < 0) dphi23R = -dphi23R;
00910 
00911       ptR_front = ptMethods.Pt3Stn2010(mode, etaR, dphi12R, dphi23R, 1, int(pt_method));
00912       ptR_rear  = ptMethods.Pt3Stn2010(mode, etaR, dphi12R, dphi23R, 0, int(pt_method));    
00913 
00914       if(pt_method == 12 && mode != 5 && etaR > 2.1)//exclude mode without ME11a
00915         {
00916             float dphi12Rmin = dphi12R - Pi*10/180/3; // 10/3 degrees 
00917             float dphi12Rmax = dphi12R + Pi*10/180/3; // 10/3 degrees
00918             float dphi23Rmin = dphi23R;
00919             float dphi23Rmax = dphi23R;
00920             if(dphi12Rmin*dphi12R < 0) dphi23Rmin = -dphi23R;
00921             if(dphi12Rmax*dphi12R < 0) dphi23Rmax = -dphi23R;
00922             float ptR_front_min = ptMethods.Pt3Stn2010(mode, etaR, dphi12Rmin, dphi23Rmin, 1, int(pt_method));
00923             float ptR_rear_min = ptMethods.Pt3Stn2010(mode, etaR, dphi12Rmin, dphi23Rmin, 0, int(pt_method));
00924             float ptR_front_max = ptMethods.Pt3Stn2010(mode, etaR, dphi12Rmax, dphi23Rmax, 1, int(pt_method));
00925             float ptR_rear_max = ptMethods.Pt3Stn2010(mode, etaR, dphi12Rmax, dphi23Rmax, 0, int(pt_method));
00926             // select max pt solution for 3 links:
00927             ptR_front = std::max(ptR_front, ptR_front_min);
00928             ptR_front = std::max(ptR_front, ptR_front_max);
00929             ptR_rear = std::max(ptR_rear, ptR_rear_min);
00930             ptR_rear = std::max(ptR_rear, ptR_rear_max);
00931         }
00932       break;
00933     case 6:
00934     case 7:
00935     case 8:
00936     case 9:
00937     case 10:
00938     case 13: // ME1-ME4
00939       type = mode - 5;
00940 
00941       if(charge) absPhi12 = address.delta_phi();
00942       else
00943         {
00944           int temp_phi = address.delta_phi();
00945           absPhi12 = static_cast<unsigned>(-temp_phi) & 0xfff;
00946         }
00947 
00948       dphi12R = (static_cast<float>(absPhi12)) / (static_cast<float>(1<<12)) * CSCTFConstants::SECTOR_RAD;
00949 
00950       //std::cout<< " Sector_rad = " << (CSCTFConstants::SECTOR_RAD) << std::endl;
00951       ptR_front = ptMethods.Pt2Stn2010(mode, etaR, dphi12R, 1, int(pt_method));
00952       ptR_rear  = ptMethods.Pt2Stn2010(mode, etaR, dphi12R, 0, int(pt_method));
00953       if((pt_method == 12) && etaR > 2.1 && mode != 8 && mode !=9 && mode !=10)//exclude tracks without ME11a 
00954         {
00955            float dphi12Rmin = fabs(fabs(dphi12R) - Pi*10/180/3); // 10/3 degrees 
00956            float ptR_front_min = ptMethods.Pt2Stn2010(mode, etaR, dphi12Rmin, 1, int(pt_method));
00957            float ptR_rear_min = ptMethods.Pt2Stn2010(mode, etaR, dphi12Rmin, 0, int(pt_method));
00958            // select max pt solution for 3 links:
00959            ptR_front = std::max(ptR_front, ptR_front_min);
00960            ptR_rear = std::max(ptR_rear, ptR_rear_min);
00961         }
00962 
00963       break;
00964     case 11: // FR = 1 -> b1-1-3,     FR = 0 -> b1-3 
00965     case 12: // FR = 1 -> b1-2-3,     FR = 0 -> b1-2 
00966     case 14: // FR = 1 -> b1-1-2-(3), FR = 0 -> b1-1
00967 
00968       if(fr == 0){ // 2 station track
00969         if(charge) absPhi12 = address.delta_phi();
00970         else
00971           {
00972             int temp_phi = address.delta_phi();
00973             absPhi12 = static_cast<unsigned>(-temp_phi) & 0xfff;
00974           }
00975           dphi12R = (static_cast<float>(absPhi12)) / (static_cast<float>(1<<12)) * CSCTFConstants::SECTOR_RAD;
00976           ptR_rear  = ptMethods.Pt2Stn2010(mode, etaR, dphi12R, 0, int(pt_method));
00977 
00978       }// end fr == 0
00979       if(fr == 1){ // 3 station track
00980         charge12 = 1;
00981         absPhi12 = address.delta_phi_12;
00982         absPhi23 = address.delta_phi_23;
00983 
00984         if(charge) charge23 = 1;
00985         else charge23 = -1;
00986 
00987         dphi12R = (static_cast<float>(absPhi12<<1)) / (static_cast<float>(1<<12)) * CSCTFConstants::SECTOR_RAD;
00988         dphi23R = (static_cast<float>(absPhi23<<4)) / (static_cast<float>(1<<12)) * CSCTFConstants::SECTOR_RAD;
00989         if(charge12 * charge23 < 0) dphi23R = -dphi23R;
00990 
00991         ptR_front = ptMethods.Pt3Stn2010(mode, etaR, dphi12R, dphi23R, 1, int(pt_method));
00992 
00993         if(pt_method == 12 && mode != 5 && etaR > 2.1)//exclude mode without ME11a
00994           {
00995               float dphi12Rmin = dphi12R - Pi*10/180/3; // 10/3 degrees 
00996               float dphi12Rmax = dphi12R + Pi*10/180/3; // 10/3 degrees
00997               float dphi23Rmin = dphi23R;
00998               float dphi23Rmax = dphi23R;
00999               if(dphi12Rmin*dphi12R < 0) dphi23Rmin = -dphi23R;
01000               if(dphi12Rmax*dphi12R < 0) dphi23Rmax = -dphi23R;
01001               float ptR_front_min = ptMethods.Pt3Stn2010(mode, etaR, dphi12Rmin, dphi23Rmin, 1, int(pt_method));
01002               float ptR_front_max = ptMethods.Pt3Stn2010(mode, etaR, dphi12Rmax, dphi23Rmax, 1, int(pt_method));
01003               // select max pt solution for 3 links:
01004               ptR_front = std::max(ptR_front, ptR_front_min);
01005               ptR_front = std::max(ptR_front, ptR_front_max);
01006           }
01007       } // end fr == 1 
01008 
01009       break;
01010     case 15: // halo trigger
01011     case 1: // tracks that fail delta phi cuts
01012       ptR_front = trigger_ptscale->getPtScale()->getLowEdge(3); // 2 GeV
01013       ptR_rear  = trigger_ptscale->getPtScale()->getLowEdge(3); 
01014       break;
01015     default: // Tracks in this category are not considered muons.
01016       ptR_front = trigger_ptscale->getPtScale()->getLowEdge(0); // 0 GeV 
01017       ptR_rear  = trigger_ptscale->getPtScale()->getLowEdge(0);
01018     };// end switch
01019 
01020   front_pt = trigger_ptscale->getPtScale()->getPacked(ptR_front);
01021   rear_pt  = trigger_ptscale->getPtScale()->getPacked(ptR_rear);
01022 
01023   } //end pt_methods greater or equal to 11 
01024 //***************************************************//
01025   if(pt_method <= 5){ //here we have only pt_methods less or equal to 5
01026   // mode definition you could find at https://twiki.cern.ch/twiki/pub/Main/PtLUTs/mode_codes.xls
01027   // it is valid till the end 2010 
01028 
01029   //  kluge to use 2-stn track in overlap region
01030   //  see also where this routine is called, and encode LUTaddress, and assignPT
01031   if (pt_method != 4 && pt_method !=5 
01032       && (mode == 2 || mode == 3 || mode == 4) && (eta<3)) mode = 6;
01033   if (pt_method != 4 && pt_method !=5 && (mode == 5)
01034       && (eta<3)) mode = 8;
01035 
01036   switch(mode)
01037     {
01038     case 2:
01039     case 3:
01040     case 4:
01041     case 5:
01042       type = mode - 1;
01043       charge12 = 1;
01044       absPhi12 = address.delta_phi_12;
01045       absPhi23 = address.delta_phi_23;
01046 
01047       if(charge) charge23 = 1;
01048       else charge23 = -1;
01049 
01050       // now convert to real numbers for input into PT assignment algos.
01051 
01052       if(pt_method == 4 || pt_method == 5) // param method 2010
01053         {
01054           dphi12R = (static_cast<float>(absPhi12<<1)) / (static_cast<float>(1<<12)) * CSCTFConstants::SECTOR_RAD;
01055           dphi23R = (static_cast<float>(absPhi23<<4)) / (static_cast<float>(1<<12)) * CSCTFConstants::SECTOR_RAD;
01056           if(charge12 * charge23 < 0) dphi23R = -dphi23R;
01057 
01058           ptR_front = ptMethods.Pt3Stn2010(mode, etaR, dphi12R, dphi23R, 1, int(pt_method));
01059           ptR_rear  = ptMethods.Pt3Stn2010(mode, etaR, dphi12R, dphi23R, 0, int(pt_method));
01060 
01061           if(pt_method == 5 && mode != 5 && etaR > 2.1)//exclude mode without ME11a
01062             {
01063                 float dphi12Rmin = dphi12R - Pi*10/180/3; // 10/3 degrees 
01064                 float dphi12Rmax = dphi12R + Pi*10/180/3; // 10/3 degrees
01065                 float dphi23Rmin = dphi23R;
01066                 float dphi23Rmax = dphi23R;
01067                 if(dphi12Rmin*dphi12R < 0) dphi23Rmin = -dphi23R;
01068                 if(dphi12Rmax*dphi12R < 0) dphi23Rmax = -dphi23R;
01069                 float ptR_front_min = ptMethods.Pt3Stn2010(mode, etaR, dphi12Rmin, dphi23Rmin, 1, int(pt_method));
01070                 float ptR_rear_min = ptMethods.Pt3Stn2010(mode, etaR, dphi12Rmin, dphi23Rmin, 0, int(pt_method));
01071                 float ptR_front_max = ptMethods.Pt3Stn2010(mode, etaR, dphi12Rmax, dphi23Rmax, 1, int(pt_method));
01072                 float ptR_rear_max = ptMethods.Pt3Stn2010(mode, etaR, dphi12Rmax, dphi23Rmax, 0, int(pt_method));
01073                 // select max pt solution for 3 links:
01074                 ptR_front = std::max(ptR_front, ptR_front_min);
01075                 ptR_front = std::max(ptR_front, ptR_front_max);
01076                 ptR_rear = std::max(ptR_rear, ptR_rear_min);
01077                 ptR_rear = std::max(ptR_rear, ptR_rear_max);
01078             }
01079         }
01080       else if(pt_method == 1) // param method
01081         {
01082           dphi12R = (static_cast<float>(absPhi12<<1)) / (static_cast<float>(1<<12)) * CSCTFConstants::SECTOR_RAD;
01083           dphi23R = (static_cast<float>(absPhi23<<4)) / (static_cast<float>(1<<12)) * CSCTFConstants::SECTOR_RAD;
01084           if(charge12 * charge23 < 0) dphi23R = -dphi23R;
01085 
01086           ptR_front = ptMethods.Pt3Stn(type, etaR, dphi12R, dphi23R, 1);
01087           ptR_rear  = ptMethods.Pt3Stn(type, etaR, dphi12R, dphi23R, 0);
01088 
01089         }
01090       else if(pt_method == 2) // cathy's method
01091         {
01092           if(type <= 2)
01093             {
01094               ptR_front = ptMethods.Pt3StnChiSq(type+3, etaR, absPhi12<<1, ((charge == 0) ? -(absPhi23<<4) : (absPhi23<<4)), 1);
01095               ptR_rear  = ptMethods.Pt3StnChiSq(type+3, etaR, absPhi12<<1, ((charge == 0) ? -(absPhi23<<4) : (absPhi23<<4)), 0);
01096             }
01097           else
01098             {
01099               ptR_front = ptMethods.Pt2StnChiSq(type-2, etaR, absPhi12<<1, 1);
01100               ptR_rear  = ptMethods.Pt2StnChiSq(type-2, etaR, absPhi12<<1, 0);
01101             }
01102 
01103         }
01104       else // hybrid
01105         {
01106 
01107           if(type <= 2)
01108             {
01109               ptR_front = ptMethods.Pt3StnHybrid(type+3, etaR, absPhi12<<1, ((charge == 0) ? -(absPhi23<<4) : (absPhi23<<4)), 1);
01110               ptR_rear  = ptMethods.Pt3StnHybrid(type+3, etaR, absPhi12<<1, ((charge == 0) ? -(absPhi23<<4) : (absPhi23<<4)), 0);
01111             }
01112           else
01113             {
01114               ptR_front = ptMethods.Pt2StnHybrid(type-2, etaR, absPhi12<<1, 1);
01115               ptR_rear  = ptMethods.Pt2StnHybrid(type-2, etaR, absPhi12<<1, 0);
01116             }
01117 
01118         }
01119       break;
01120     case 6:
01121     case 7:
01122     case 8:
01123     case 9:
01124     case 10:
01125       type = mode - 5;
01126 
01127       if(charge) absPhi12 = address.delta_phi();
01128       else
01129         {
01130           int temp_phi = address.delta_phi();
01131           absPhi12 = static_cast<unsigned>(-temp_phi) & 0xfff;
01132         }
01133 
01134       if(absPhi12 < (1<<9))
01135         {
01136           if(pt_method == 1 || type == 5)
01137             {
01138               dphi12R = (static_cast<float>(absPhi12)) / (static_cast<float>(1<<12)) * CSCTFConstants::SECTOR_RAD;
01139 
01140               ptR_front = ptMethods.Pt2Stn(type, etaR, dphi12R, 1);
01141               ptR_rear  = ptMethods.Pt2Stn(type, etaR, dphi12R, 0);
01142 
01143             }
01144           else if(pt_method == 2)
01145             {
01146               ptR_front = ptMethods.Pt2StnChiSq(type-1, etaR, absPhi12, 1);
01147               ptR_rear  = ptMethods.Pt2StnChiSq(type-1, etaR, absPhi12, 0);
01148             }
01149           else
01150             {
01151               ptR_front = ptMethods.Pt2StnHybrid(type-1, etaR, absPhi12, 1);
01152               ptR_rear  = ptMethods.Pt2StnHybrid(type-1, etaR, absPhi12, 0);
01153             }
01154         }
01155       else
01156         {
01157           ptR_front = trigger_ptscale->getPtScale()->getLowEdge(1);
01158           ptR_rear  = trigger_ptscale->getPtScale()->getLowEdge(1);
01159         }
01160       if(pt_method == 4 || pt_method == 5) // param method 2010
01161         {
01162               dphi12R = (static_cast<float>(absPhi12)) / (static_cast<float>(1<<12)) * CSCTFConstants::SECTOR_RAD;
01163 
01164               //std::cout<< " Sector_rad = " << (CSCTFConstants::SECTOR_RAD) << std::endl;
01165               ptR_front = ptMethods.Pt2Stn2010(mode, etaR, dphi12R, 1, int(pt_method));
01166               ptR_rear  = ptMethods.Pt2Stn2010(mode, etaR, dphi12R, 0, int(pt_method));
01167               if((pt_method == 5) && etaR > 2.1 && mode != 8 && mode !=9 && mode !=10)//exclude tracks without ME11a 
01168                 {
01169                    float dphi12Rmin = fabs(fabs(dphi12R) - Pi*10/180/3); // 10/3 degrees 
01170                    float ptR_front_min = ptMethods.Pt2Stn2010(mode, etaR, dphi12Rmin, 1, int(pt_method));
01171                    float ptR_rear_min = ptMethods.Pt2Stn2010(mode, etaR, dphi12Rmin, 0, int(pt_method));
01172                    // select max pt solution for 3 links:
01173                    ptR_front = std::max(ptR_front, ptR_front_min);
01174                    ptR_rear = std::max(ptR_rear, ptR_rear_min);
01175                 }
01176         }
01177 
01178       break;
01179     case 12:  // 1-2-b1 calculated only delta_phi12 = 2-b1
01180     case 14:
01181       type = 2;
01182 
01183       if(charge) absPhi12 = address.delta_phi();
01184       else
01185         {
01186           int temp_phi = address.delta_phi();
01187           absPhi12 = static_cast<unsigned>(-temp_phi) & 0xfff;
01188         }
01189       if(absPhi12 < (1<<9))
01190         {
01191           dphi12R = (static_cast<float>(absPhi12)) / (static_cast<float>(1<<12)) * CSCTFConstants::SECTOR_RAD;
01192           ptR_front = ptMethods.Pt2Stn(type, etaR, dphi12R, 1);
01193           ptR_rear  = ptMethods.Pt2Stn(type, etaR, dphi12R, 0);
01194         }
01195       else
01196         {
01197           ptR_front = trigger_ptscale->getPtScale()->getLowEdge(1);
01198           ptR_rear  = trigger_ptscale->getPtScale()->getLowEdge(1);
01199         }
01200       if(pt_method == 4 || pt_method == 5) // param method 2010 
01201         {
01202               dphi12R = (static_cast<float>(absPhi12)) / (static_cast<float>(1<<12)) * CSCTFConstants::SECTOR_RAD;
01203 
01204               ptR_front = ptMethods.Pt2Stn2010(mode, etaR, dphi12R, 1, int(pt_method));
01205               ptR_rear  = ptMethods.Pt2Stn2010(mode, etaR, dphi12R, 0, int(pt_method));
01206 
01207               if(fabs(dphi12R)<0.01 && (ptR_rear < 10 || ptR_front < 10))
01208                 std::cout << "dphi12R = " << dphi12R << " ptR_rear = " << ptR_rear
01209                 << " ptR_front = " << ptR_front << " etaR = " << etaR << " mode = " << mode << std::endl;
01210         }
01211       break;
01212     case 13:
01213       type = 4;
01214 
01215       if(charge) absPhi12 = address.delta_phi();
01216       else
01217         {
01218           int temp_phi = address.delta_phi();
01219           absPhi12 = static_cast<unsigned>(-temp_phi) & 0xfff;
01220         }
01221       if(absPhi12 < (1<<9))
01222         {
01223           dphi12R = (static_cast<float>(absPhi12)) / (static_cast<float>(1<<12)) * CSCTFConstants::SECTOR_RAD;
01224           ptR_front = ptMethods.Pt2Stn(type, etaR, dphi12R, 1);
01225           ptR_rear  = ptMethods.Pt2Stn(type, etaR, dphi12R, 0);
01226         }
01227       else
01228         {
01229           ptR_front = trigger_ptscale->getPtScale()->getLowEdge(1);
01230           ptR_rear  = trigger_ptscale->getPtScale()->getLowEdge(1);
01231         }
01232 
01233       if(pt_method == 4 || pt_method == 5) // param method 2010
01234         {
01235               dphi12R = (static_cast<float>(absPhi12)) / (static_cast<float>(1<<12)) * CSCTFConstants::SECTOR_RAD;
01236 
01237               ptR_front = ptMethods.Pt2Stn2010(mode, etaR, dphi12R, 1, int(pt_method));
01238               ptR_rear  = ptMethods.Pt2Stn2010(mode, etaR, dphi12R, 0, int(pt_method));
01239               if((pt_method == 5) && etaR > 2.1)//mode = 13: ME1-ME4 exclude tracks without ME11a 
01240                 {
01241                    float dphi12Rmin = fabs(fabs(dphi12R) - Pi*10/180/3); // 10/3 degrees 
01242                    float ptR_front_min = ptMethods.Pt2Stn2010(mode, etaR, dphi12Rmin, 1, int(pt_method));
01243                    float ptR_rear_min = ptMethods.Pt2Stn2010(mode, etaR, dphi12Rmin, 0, int(pt_method));
01244                    // select max pt solution for 3 links:
01245                    ptR_front = std::max(ptR_front, ptR_front_min);
01246                    ptR_rear = std::max(ptR_rear, ptR_rear_min);
01247                 }
01248         }
01249 
01250       break;
01251     case 11:
01252       // singles trigger
01253       ptR_front = trigger_ptscale->getPtScale()->getLowEdge(5);
01254       ptR_rear  = trigger_ptscale->getPtScale()->getLowEdge(5);
01255       //ptR_front = trigger_ptscale->getPtScale()->getLowEdge(31);
01256       //ptR_rear  = trigger_ptscale->getPtScale()->getLowEdge(31);
01257       break;
01258     case 15:
01259       // halo trigger
01260       ptR_front = trigger_ptscale->getPtScale()->getLowEdge(5);
01261       ptR_rear  = trigger_ptscale->getPtScale()->getLowEdge(5);
01262       break;
01263     case 1:
01264       // tracks that fail delta phi cuts
01265       ptR_front = trigger_ptscale->getPtScale()->getLowEdge(5);
01266       ptR_rear  = trigger_ptscale->getPtScale()->getLowEdge(5); 
01267      break;
01268     default: // Tracks in this category are not considered muons.
01269       ptR_front = trigger_ptscale->getPtScale()->getLowEdge(0);
01270       ptR_rear  = trigger_ptscale->getPtScale()->getLowEdge(0);
01271     };
01272 
01273   front_pt = trigger_ptscale->getPtScale()->getPacked(ptR_front);
01274   rear_pt  = trigger_ptscale->getPtScale()->getPacked(ptR_rear);
01275 
01276   // kluge to set arbitrary Pt for some tracks with lousy resolution (and no param)
01277   if(pt_method != 4 && pt_method != 5) 
01278     {
01279       if ((front_pt==0 || front_pt==1) && (eta<3) && quality==1 && pt_method != 2) front_pt = 31;
01280       if ((rear_pt==0  || rear_pt==1) && (eta<3) && quality==1 && pt_method != 2) rear_pt = 31;
01281     }
01282   if(pt_method != 2 && pt_method != 4 && quality == 1)
01283     {
01284       if (front_pt < 5) front_pt = 5;
01285       if (rear_pt  < 5) rear_pt  = 5;
01286     }
01287 
01288   // in order to match the pt assignement of the previous routine
01289   if(isBeamStartConf && pt_method != 2 && pt_method != 4 && pt_method !=5) {
01290     if(quality == 3 && mode == 5) {
01291       
01292       if (front_pt < 5) front_pt = 5;
01293       if (rear_pt  < 5) rear_pt  = 5;
01294     }
01295 
01296     if(quality == 2 && mode > 7 && mode < 11) {
01297       
01298       if (front_pt < 5) front_pt = 5;
01299       if (rear_pt  < 5) rear_pt  = 5;
01300     }
01301   }
01302 
01303   } // end if for pt_method less or equal to 5
01304 //***************************************************//
01305 
01306  
01307   result.front_rank = front_pt | front_quality << 5;
01308   result.rear_rank  = rear_pt  | rear_quality << 5;
01309 
01310   result.charge_valid_front = 1; //ptMethods.chargeValid(front_pt, quality, eta, pt_method);
01311   result.charge_valid_rear  = 1; //ptMethods.chargeValid(rear_pt, quality, eta, pt_method);
01312 
01313 
01314   /*  if (mode == 1) { 
01315     std::cout << "F_pt: "      << front_pt      << std::endl;
01316     std::cout << "R_pt: "      << rear_pt       << std::endl;
01317     std::cout << "F_quality: " << front_quality << std::endl;
01318     std::cout << "R_quality: " << rear_quality  << std::endl;
01319     std::cout << "F_rank: " << std::hex << result.front_rank << std::endl;
01320     std::cout << "R_rank: " << std::hex << result.rear_rank  << std::endl;
01321   }
01322   */
01323   return result;
01324 }
01325 
01326 
01327 unsigned CSCTFPtLUT::trackQuality(const unsigned& eta, const unsigned& mode, const unsigned& fr) const
01328 {
01329  // eta and mode should be only 4-bits, since that is the input to the large LUT
01330     if (eta>15 || mode>15)
01331       {
01332         //std::cout << "Error: Eta or Mode out of range in AU quality assignment" << std::endl;
01333         edm::LogError("CSCTFPtLUT::trackQuality()")<<"Eta or Mode out of range in AU quality assignment";
01334         return 0;
01335       }
01336     unsigned int quality;
01337     switch (mode) {
01338     case 2:
01339       quality = 3;
01340       if(pt_method > 10 && eta < 3) quality = 1; //eta < 1.2
01341       if(pt_method == 32 && eta >= 12) quality = 2; // eta > 2.1  
01342       break;
01343     case 3:
01344     case 4:
01346       //        quality = 2;
01347       quality = 3;
01348       if(pt_method == 32 && eta >= 12) quality = 2; // eta > 2.1  
01349       break;
01350     case 5:
01351       quality = 1;
01352       if (isBeamStartConf && eta >= 12 && pt_method < 20) // eta > 2.1
01353         quality = 3;
01354       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
01355       break;
01356     case 6:
01357       if (eta>=3) // eta > 1.2
01358         quality = 2;
01359       else
01360         quality = 1;
01361       if(pt_method == 32 && eta >= 12) quality = 1; // eta > 2.1  
01362       break;
01363     case 7:
01364       quality = 2;
01365       if(pt_method > 10 && eta < 3) quality = 1; //eta < 1.2  
01366       if(pt_method == 32 && eta >= 12) quality = 1; // eta > 2.1  
01367       break;
01368     case 8:
01369     case 9:
01370     case 10:
01371       quality = 1;
01372       if (isBeamStartConf && eta >= 12 && pt_method < 20) // eta > 2.1
01373         quality = 2;
01374       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
01375       break;
01376     case 11:
01377       // single LCTs
01378       quality = 1;
01379       // overlap region
01380       if(pt_method > 10 && fr == 0) quality = 2;
01381       if(pt_method > 10 && fr == 1) quality = 3;
01382       if(pt_method > 20 && fr == 0) quality = 3;
01383       break;
01384     case 12:
01385       quality = 3;
01386       // overlap region
01387       if(pt_method > 10 && fr == 0) quality = 2;
01388       if(pt_method > 10 && fr == 1) quality = 3;
01389       if(pt_method > 20 && fr == 0) quality = 3;
01390       break;
01391     case 13:
01392       quality = 2;
01393       if(pt_method == 32 && eta >= 12) quality = 1; // eta > 2.1  
01394       break;
01395     case 14:
01396       quality = 2;
01397       // overlap region
01398       if(pt_method > 10 && fr == 0) quality = 2;
01399       if(pt_method > 10 && fr == 1) quality = 3;
01400       if(pt_method > 20 && fr == 0) quality = 3;
01401       break;
01402     case 15:
01403       // halo triggers
01404       quality = 1;
01405       break;
01406       //DEA: keep muons that fail delta phi cut
01407     case 1:
01408       quality = 1;
01409       break;
01410     default:
01411       quality = 0;
01412       break;
01413     }
01414 
01415     // allow quality = 1 only in overlap region or eta = 1.6 region
01416     //    if ((quality == 1) && (eta >= 4) && (eta != 6) && (eta != 7)) quality = 0;
01417     //    if ( (quality == 1) && (eta >= 4) ) quality = 0;
01418 
01419     if ( (quality == 1) && (eta >= 4) && (eta < 11)
01420          && ((lowQualityFlag&4)==0) ) quality = 0;
01421     if ( (quality == 1) && (eta < 4) && ((lowQualityFlag&1)==0)
01422          && ((lowQualityFlag&4)==0) ) quality = 0;
01423     if ( (quality == 1) && (eta >=11) && ((lowQualityFlag&2)==0)
01424          && ((lowQualityFlag&4)==0) ) quality = 0;
01425 
01426     return quality;
01427 
01428 }
01429 
01430 void CSCTFPtLUT::readLUT()
01431 {
01432   std::ifstream PtLUT;
01433 
01434   if(isBinary)
01435     {
01436       PtLUT.open(pt_lut_file.fullPath().c_str(), std::ios::binary);
01437       PtLUT.seekg(0, std::ios::end);
01438       int length = PtLUT.tellg();;
01439       if( length == (1<<CSCBitWidths::kPtAddressWidth)*sizeof(short) )
01440         {
01441           PtLUT.seekg(0, std::ios::beg);
01442           PtLUT.read(reinterpret_cast<char*>(pt_lut),length);
01443         }
01444       else
01445         {
01446           edm::LogError("CSCPtLUT") << "File " << pt_lut_file.fullPath() << " is incorrect size!\n";
01447         }
01448       PtLUT.close();
01449     }
01450   else
01451     {
01452       PtLUT.open(pt_lut_file.fullPath().c_str());
01453       unsigned i = 0;
01454       unsigned short temp = 0;
01455       while(!PtLUT.eof() && i < 1 << CSCBitWidths::kPtAddressWidth)
01456         {
01457           PtLUT >> temp;
01458           pt_lut[i++] = (*reinterpret_cast<ptdat*>(&temp));
01459         }
01460       PtLUT.close();
01461     }
01462 }
01463 
01464