CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_4_2_9_HLT1_bphpatch4/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 CSCTFPtLUT::CSCTFPtLUT(const edm::EventSetup& es) 
00043     : read_pt_lut(false),
00044       isBinary(false)
00045 {
00046         pt_method = 26;
00047         //std::cout << "pt_method from 4 " << std::endl; 
00048         lowQualityFlag = 4;
00049         isBeamStartConf = true;
00050         pt_lut = new ptdat[1<<21];
00051 
00052         edm::ESHandle<L1MuCSCPtLut> ptLUT;
00053         es.get<L1MuCSCPtLutRcd>().get(ptLUT);
00054         const L1MuCSCPtLut *myConfigPt_ = ptLUT.product();
00055 
00056         memcpy((void*)pt_lut,(void*)myConfigPt_->lut(),(1<<21)*sizeof(ptdat));
00057 
00058         lut_read_in = true;
00059 
00060         edm::ESHandle< L1MuTriggerScales > scales ;
00061         es.get< L1MuTriggerScalesRcd >().get( scales ) ;
00062         trigger_scale = scales.product() ;
00063 
00064         edm::ESHandle< L1MuTriggerPtScale > ptScale ;
00065         es.get< L1MuTriggerPtScaleRcd >().get( ptScale ) ;
00066         trigger_ptscale = ptScale.product() ;
00067 
00068         ptMethods = CSCTFPtMethods( ptScale.product() ) ;
00069 }
00071 
00072 CSCTFPtLUT::CSCTFPtLUT(const edm::ParameterSet& pset,
00073                        const L1MuTriggerScales* scales,
00074                        const L1MuTriggerPtScale* ptScale)
00075   : trigger_scale( scales ),
00076     trigger_ptscale( ptScale ),
00077     ptMethods( ptScale ),
00078     read_pt_lut(false),
00079     isBinary(false)
00080 {
00081   //read_pt_lut = pset.getUntrackedParameter<bool>("ReadPtLUT",false);
00082   read_pt_lut = pset.getParameter<bool>("ReadPtLUT");
00083   if(read_pt_lut)
00084     {
00085       pt_lut_file = pset.getParameter<edm::FileInPath>("PtLUTFile");
00086       //isBinary = pset.getUntrackedParameter<bool>("isBinary", false);
00087       isBinary = pset.getParameter<bool>("isBinary");
00088 
00089       edm::LogInfo("CSCTFPtLUT::CSCTFPtLUT") << "Reading file: "
00090                                              << pt_lut_file.fullPath().c_str()
00091                                              << " isBinary?(1/0): "
00092                                              << isBinary;
00093     }
00094 
00095   // Determine the pt assignment method to use
00096   // 1 - Darin's parameterization method
00097   // 2 - Cathy Yeh's chi-square minimization method
00098   // 3 - Hybrid
00099   // 4 - Anna's parameterization method
00100   // 5 - Anna's parameterization method 
00101          //with improvments at ME1/1a: find max pt for 3 links hypothesis
00102   // 11 - Anna's: for fw 20101011 <- 2011 data taking <- not valide any more
00103   // 12 - Anna's: for fw 20101011 <- 2011 data taking <- not valide any more
00104           //with improvments at ME1/1a: find max pt for 3 links hypothesis
00105   // 21 - Anna's: for fw 20110118 and up, curves with data 2010 <- 2011 data taking
00106   // 22 - Anna's: for fw 20110118 and up, curves with data 2010 <- 2011 data taking
00107           //with improvments at ME1/1a: find max pt for 3 links hypothesis
00108   // 23 - Anna's: for fw 20110118 and up, curves with MC like method 4 <- 2011 data taking
00109   // 24 - Anna's: for fw 20110118 and up, curves with MC like method 4 <- 2011 data taking
00110           //with improvments at ME1/1a: find max pt for 3 links hypothesis
00111   //25 and 26 like 23 and 24 correspondenly but fix high pt assignment in DT-CSC region
00112   // 25 - Anna's: for fw 20110118 and up, curves with MC like method 4 <- 2011 data taking
00113   // 26 - Anna's: for fw 20110118 and up, curves with MC like method 4 <- 2011 data taking
00114           //with improvments at ME1/1a: find max pt for 3 links hypothesis
00115   pt_method = pset.getUntrackedParameter<unsigned>("PtMethod",26);
00116   //std::cout << "pt_method from pset " << std::endl; 
00117   // what does this mean???
00118   lowQualityFlag = pset.getUntrackedParameter<unsigned>("LowQualityFlag",4);
00119 
00120   if(read_pt_lut && !lut_read_in)
00121     {
00122       pt_lut = new ptdat[1<<21];
00123       readLUT();
00124       lut_read_in = true;
00125     }
00126 
00127   isBeamStartConf = pset.getUntrackedParameter<bool>("isBeamStartConf", true);
00128 }
00129 
00130 ptdat CSCTFPtLUT::Pt(const ptadd& address) const
00131 {
00132   ptdat result;
00133   if(read_pt_lut)
00134   {
00135     int shortAdd = (address.toint()& 0x1fffff);
00136     result = pt_lut[shortAdd];
00137   } else
00138     result = calcPt(address);
00139   return result;
00140 }
00141 
00142 ptdat CSCTFPtLUT::Pt(const unsigned& address) const
00143 {
00144   return Pt(ptadd(address));
00145 }
00146 
00147 ptdat CSCTFPtLUT::Pt(const unsigned& delta_phi_12, const unsigned& delta_phi_23,
00148                      const unsigned& track_eta, const unsigned& track_mode,
00149                      const unsigned& track_fr, const unsigned& delta_phi_sign) const
00150 {
00151   ptadd address;
00152   address.delta_phi_12 = delta_phi_12;
00153   address.delta_phi_23 = delta_phi_23;
00154   address.track_eta = track_eta;
00155   address.track_mode = track_mode;
00156   address.track_fr = track_fr;
00157   address.delta_phi_sign = delta_phi_sign;
00158 
00159   return Pt(address);
00160 }
00161 
00162 ptdat CSCTFPtLUT::Pt(const unsigned& delta_phi_12, const unsigned& track_eta,
00163                      const unsigned& track_mode, const unsigned& track_fr,
00164                      const unsigned& delta_phi_sign) const
00165 {
00166   ptadd address;
00167   address.delta_phi_12 = ((1<<8)-1)&delta_phi_12;
00168   address.delta_phi_23 = ((1<<4)-1)&(delta_phi_12>>8);
00169   address.track_eta = track_eta;
00170   address.track_mode = track_mode;
00171   address.track_fr = track_fr;
00172   address.delta_phi_sign = delta_phi_sign;
00173 
00174   return Pt(address);
00175 }
00176 
00177 
00178 ptdat CSCTFPtLUT::calcPt(const ptadd& address) const
00179 {
00180   ptdat result;
00181 
00182   double Pi  = acos(-1.);
00183   float etaR = 0, ptR_front = 0, ptR_rear = 0, dphi12R = 0, dphi23R = 0;
00184   int charge12, charge23;
00185   unsigned type, mode, eta, fr, quality, charge, absPhi12, absPhi23;
00186 
00187   eta = address.track_eta;
00188   mode = address.track_mode;
00189   fr = address.track_fr;
00190   charge = address.delta_phi_sign;
00191   quality = trackQuality(eta, mode, fr);
00192   unsigned front_pt, rear_pt;
00193   front_pt = 0.; rear_pt = 0.;
00194   unsigned front_quality, rear_quality;
00195 
00196   etaR = trigger_scale->getRegionalEtaScale(2)->getLowEdge(2*eta+1);
00197 
00198   front_quality = rear_quality = quality;
00199 
00200 
00201 //***************************************************//
00202   if(pt_method >= 23 && pt_method <= 26){ //here we have only pt_methods greater then 
00203                        //for fw 20110118 <- 2011 data taking, curves from MC like method 4
00204   // mode definition you could find at page 6 & 7: 
00205   // https://www.phys.ufl.edu/~madorsky/sp/2011-11-18/sp_core_interface.pdf 
00206   // it is valid starting the beggining of 2011 
00207   //std::cout << " pt_method = " << pt_method << std::endl;//test 
00208   switch(mode)
00209     {
00210     case 2:
00211     case 3:
00212     case 4:
00213     case 5:
00214 
00215       charge12 = 1;
00216       absPhi12 = address.delta_phi_12;
00217       absPhi23 = address.delta_phi_23;
00218 
00219       if(charge) charge23 = 1;
00220       else charge23 = -1;
00221 
00222       dphi12R = (static_cast<float>(absPhi12<<1)) / (static_cast<float>(1<<12)) * CSCTFConstants::SECTOR_RAD;
00223       dphi23R = (static_cast<float>(absPhi23<<4)) / (static_cast<float>(1<<12)) * CSCTFConstants::SECTOR_RAD;
00224       if(charge12 * charge23 < 0) dphi23R = -dphi23R;
00225 
00226       ptR_front = ptMethods.Pt3Stn2010(int(mode), etaR, dphi12R, dphi23R, 1, int(pt_method));
00227       ptR_rear  = ptMethods.Pt3Stn2010(int(mode), etaR, dphi12R, dphi23R, 0, int(pt_method));    
00228 
00229       if((pt_method == 24 || pt_method == 26) && mode != 5 && etaR > 2.1)//exclude mode without ME11a
00230         {
00231             float dphi12Rmin = dphi12R - Pi*10/180/3; // 10/3 degrees 
00232             float dphi12Rmax = dphi12R + Pi*10/180/3; // 10/3 degrees
00233             float dphi23Rmin = dphi23R;
00234             float dphi23Rmax = dphi23R;
00235             //if(dphi12Rmin*dphi12R < 0) dphi23Rmin = -dphi23R;
00236             //if(dphi12Rmax*dphi12R < 0) dphi23Rmax = -dphi23R;
00237             float ptR_front_min = ptMethods.Pt3Stn2010(int(mode), etaR, dphi12Rmin, dphi23Rmin, 1, int(pt_method));
00238             float ptR_rear_min = ptMethods.Pt3Stn2010(int(mode), etaR, dphi12Rmin, dphi23Rmin, 0, int(pt_method));
00239             float ptR_front_max = ptMethods.Pt3Stn2010(int(mode), etaR, dphi12Rmax, dphi23Rmax, 1, int(pt_method));
00240             float ptR_rear_max = ptMethods.Pt3Stn2010(int(mode), etaR, dphi12Rmax, dphi23Rmax, 0, int(pt_method));
00241             // select max pt solution for 3 links:
00242             ptR_front = std::max(ptR_front, ptR_front_min);
00243             ptR_front = std::max(ptR_front, ptR_front_max);
00244             ptR_rear = std::max(ptR_rear, ptR_rear_min);
00245             ptR_rear = std::max(ptR_rear, ptR_rear_max);
00246         }
00247       break;
00248     case 6: // for mode 6, 7 and 13 add CLCT information in dph23 bit and iME11 in charge bit  
00249     case 7:
00250     case 13: // ME1-ME4
00251       int iME11;
00252       iME11 = int(charge); // = 0 if ME1/1, = 1 if ME1/2 or ME1/3 station 
00253       if(iME11 == 1 && etaR > 1.6) etaR = 1.55; // shift for ME1/2 station  
00254       if(iME11 == 0 && etaR < 1.6) etaR = 1.65; // shift for ME1/1 station 
00255       absPhi12 = address.delta_phi_12;
00256       //int CLCT_pattern = static_cast<int>(address.delta_phi_23);
00257       int CLCT_pattern;
00258       CLCT_pattern = int(address.delta_phi_23);
00259       dphi12R = (static_cast<float>(absPhi12<<1)) / (static_cast<float>(1<<12)) * CSCTFConstants::SECTOR_RAD;
00260 
00261       //std::cout<< " Sector_rad = " << (CSCTFConstants::SECTOR_RAD) << std::endl;
00262       ptR_front = ptMethods.Pt2Stn2010(int(mode), etaR, dphi12R, 1, int(pt_method));
00263       ptR_rear  = ptMethods.Pt2Stn2010(int(mode), etaR, dphi12R, 0, int(pt_method));
00264       if((pt_method == 24 || pt_method ==26) && etaR > 2.1)//exclude tracks without ME11a 
00265         {
00266            float dphi12Rmin = fabs(fabs(dphi12R) - Pi*10/180/3); // 10/3 degrees 
00267            float ptR_front_min = ptMethods.Pt2Stn2010(int(mode), etaR, dphi12Rmin, 1, int(pt_method));
00268            float ptR_rear_min = ptMethods.Pt2Stn2010(int(mode), etaR, dphi12Rmin, 0, int(pt_method));
00269            // select max pt solution for 3 links:
00270            ptR_front = std::max(ptR_front, ptR_front_min);
00271            ptR_rear = std::max(ptR_rear, ptR_rear_min);
00272         }
00273       if( ((CLCT_pattern < 8) || (CLCT_pattern > 10)) && (ptR_front > 5.)) ptR_front = 5.;
00274       if( ((CLCT_pattern < 8) || (CLCT_pattern > 10)) && (ptR_rear > 5.)) ptR_rear = 5.;
00275       //std::cout << "mode = "<< mode << " CLCT_pattern = " << CLCT_pattern << " ptR_rear = " << ptR_rear << std::endl;
00276 
00277       break;
00278     case 8:
00279     case 9:
00280     case 10:
00281       if(charge) absPhi12 = address.delta_phi();
00282       else
00283         {
00284           int temp_phi = address.delta_phi();
00285           absPhi12 = static_cast<unsigned>(-temp_phi) & 0xfff;
00286         }
00287 
00288       dphi12R = (static_cast<float>(absPhi12)) / (static_cast<float>(1<<12)) * CSCTFConstants::SECTOR_RAD;
00289 
00290       //std::cout<< " Sector_rad = " << (CSCTFConstants::SECTOR_RAD) << std::endl;
00291       ptR_front = ptMethods.Pt2Stn2010(int(mode), etaR, dphi12R, 1, int(pt_method));
00292       ptR_rear  = ptMethods.Pt2Stn2010(int(mode), etaR, dphi12R, 0, int(pt_method));
00293 
00294       break;
00295     // for overlap DT-CSC region using curves from data 2010
00296     case 11: // FR = 1 -> b1-1-3,     FR = 0 -> b1-3 
00297     case 12: // FR = 1 -> b1-2-3,     FR = 0 -> b1-2 
00298     case 14: // FR = 1 -> b1-1-2-(3), FR = 0 -> b1-1
00299 
00300     //sign definition: sign dphi12 = Phi_DT - Phi_CSC
00301     //                 sing dphi23 = 5th sign. bit of phiBend
00302     // -> charge = 1 -> dphi12 = +, phiBend = -
00303     // -> charge = 0 -> dphi12 = +, phiBend = +    
00304         charge12 = 1;
00305         absPhi12 = address.delta_phi_12;
00306         absPhi23 = address.delta_phi_23;
00307 
00308         if(charge) charge23 = -1;
00309         else charge23 = 1;
00310 
00311         dphi12R = (static_cast<float>(absPhi12<<1)) / (static_cast<float>(1<<12)) * CSCTFConstants::SECTOR_RAD;
00312         dphi23R = float(absPhi23);
00313         if(charge12 * charge23 < 0) dphi23R = -dphi23R;
00314 
00315         int mode1;
00316         mode1 = int(mode);
00317         if(fr == 1 && mode1 == 11) mode1 = 14; // 3 station track we use dphi12 and phiBend for 2 and 3 station track
00318 
00319         ptR_front = ptMethods.Pt3Stn2011(mode1, etaR, dphi12R, dphi23R, int(0), int(pt_method));
00320         ptR_rear = ptMethods.Pt3Stn2011(mode1, etaR, dphi12R, dphi23R, int(0), int(pt_method));
00321 
00322       break;
00323     case 15: // halo trigger
00324     case 1: // tracks that fail delta phi cuts
00325       ptR_front = trigger_ptscale->getPtScale()->getLowEdge(3); // 2 GeV
00326       ptR_rear  = trigger_ptscale->getPtScale()->getLowEdge(3); 
00327       break;
00328     default: // Tracks in this category are not considered muons.
00329       ptR_front = trigger_ptscale->getPtScale()->getLowEdge(0); // 0 GeV 
00330       ptR_rear  = trigger_ptscale->getPtScale()->getLowEdge(0);
00331     };// end switch
00332 
00333   front_pt = trigger_ptscale->getPtScale()->getPacked(ptR_front);
00334   rear_pt  = trigger_ptscale->getPtScale()->getPacked(ptR_rear);
00335 
00336   } //end pt_methods 23 & 24 
00337 
00338 //***************************************************//
00339 //***************************************************//
00340   if(pt_method == 21 || pt_method == 22){ //here we have only pt_methods greater then 
00341                        //for fw 20110118 <- 2011 data taking
00342   // mode definition you could find at page 6 & 7: 
00343   // https://www.phys.ufl.edu/~madorsky/sp/2011-11-18/sp_core_interface.pdf 
00344   // it is valid starting the beggining of 2011 
00345   switch(mode)
00346     {
00347     case 2:
00348     case 3:
00349     case 4:
00350     case 5:
00351 
00352       charge12 = 1;
00353       absPhi12 = address.delta_phi_12;
00354       absPhi23 = address.delta_phi_23;
00355 
00356       if(charge) charge23 = 1;
00357       else charge23 = -1;
00358 
00359       dphi12R = (static_cast<float>(absPhi12<<1)) / (static_cast<float>(1<<12)) * CSCTFConstants::SECTOR_RAD;
00360       dphi23R = (static_cast<float>(absPhi23<<4)) / (static_cast<float>(1<<12)) * CSCTFConstants::SECTOR_RAD;
00361       if(charge12 * charge23 < 0) dphi23R = -dphi23R;
00362 
00363       ptR_front = ptMethods.Pt3Stn2011(int(mode), etaR, dphi12R, dphi23R, 1, int(pt_method));
00364       ptR_rear  = ptMethods.Pt3Stn2011(int(mode), etaR, dphi12R, dphi23R, 0, int(pt_method));    
00365 
00366       if(pt_method == 22 && mode != 5 && etaR > 2.1)//exclude mode without ME11a
00367         {
00368             float dphi12Rmin = dphi12R - Pi*10/180/3; // 10/3 degrees 
00369             float dphi12Rmax = dphi12R + Pi*10/180/3; // 10/3 degrees
00370             float dphi23Rmin = dphi23R;
00371             float dphi23Rmax = dphi23R;
00372             //if(dphi12Rmin*dphi12R < 0) dphi23Rmin = -dphi23R;
00373             //if(dphi12Rmax*dphi12R < 0) dphi23Rmax = -dphi23R;
00374             float ptR_front_min = ptMethods.Pt3Stn2011(int(mode), etaR, dphi12Rmin, dphi23Rmin, 1, int(pt_method));
00375             float ptR_rear_min = ptMethods.Pt3Stn2011(int(mode), etaR, dphi12Rmin, dphi23Rmin, 0, int(pt_method));
00376             float ptR_front_max = ptMethods.Pt3Stn2011(int(mode), etaR, dphi12Rmax, dphi23Rmax, 1, int(pt_method));
00377             float ptR_rear_max = ptMethods.Pt3Stn2011(int(mode), etaR, dphi12Rmax, dphi23Rmax, 0, int(pt_method));
00378             // select max pt solution for 3 links:
00379             ptR_front = std::max(ptR_front, ptR_front_min);
00380             ptR_front = std::max(ptR_front, ptR_front_max);
00381             ptR_rear = std::max(ptR_rear, ptR_rear_min);
00382             ptR_rear = std::max(ptR_rear, ptR_rear_max);
00383         }
00384       break;
00385     case 6: // for mode 6, 7 and 13 add CLCT information in dph23 bit and iME11 in charge bit  
00386     case 7:
00387     case 13: // ME1-ME4
00388       int iME11;
00389       iME11 = int(charge);
00390       absPhi12 = address.delta_phi_12;
00391       //int CLCT_pattern = static_cast<int>(address.delta_phi_23);
00392       int CLCT_pattern;
00393       CLCT_pattern = int(address.delta_phi_23);
00394 
00395       dphi12R = (static_cast<float>(absPhi12<<1)) / (static_cast<float>(1<<12)) * CSCTFConstants::SECTOR_RAD;
00396 
00397       //std::cout<< " Sector_rad = " << (CSCTFConstants::SECTOR_RAD) << std::endl;
00398       ptR_front = ptMethods.Pt2Stn2011(int(mode), etaR, dphi12R, 1, int(pt_method), iME11);
00399       ptR_rear  = ptMethods.Pt2Stn2011(int(mode), etaR, dphi12R, 0, int(pt_method), iME11);
00400       if((pt_method == 22) && etaR > 2.1)//exclude tracks without ME11a 
00401         {
00402            float dphi12Rmin = fabs(fabs(dphi12R) - Pi*10/180/3); // 10/3 degrees 
00403            float ptR_front_min = ptMethods.Pt2Stn2011(int(mode), etaR, dphi12Rmin, 1, int(pt_method), iME11);
00404            float ptR_rear_min = ptMethods.Pt2Stn2011(int(mode), etaR, dphi12Rmin, 0, int(pt_method), iME11);
00405            // select max pt solution for 3 links:
00406            ptR_front = std::max(ptR_front, ptR_front_min);
00407            ptR_rear = std::max(ptR_rear, ptR_rear_min);
00408         }
00409       if( ((CLCT_pattern < 8) || (CLCT_pattern > 10)) && (ptR_front > 5.)) ptR_front = 5.;
00410       if( ((CLCT_pattern < 8) || (CLCT_pattern > 10)) && (ptR_rear > 5.)) ptR_rear = 5.;
00411 
00412       break;
00413     case 8:
00414     case 9:
00415     case 10:
00416       if(charge) absPhi12 = address.delta_phi();
00417       else
00418         {
00419           int temp_phi = address.delta_phi();
00420           absPhi12 = static_cast<unsigned>(-temp_phi) & 0xfff;
00421         }
00422 
00423       dphi12R = (static_cast<float>(absPhi12)) / (static_cast<float>(1<<12)) * CSCTFConstants::SECTOR_RAD;
00424 
00425       //std::cout<< " Sector_rad = " << (CSCTFConstants::SECTOR_RAD) << std::endl;
00426       ptR_front = ptMethods.Pt2Stn2011(int(mode), etaR, dphi12R, 1, int(pt_method), int(2));
00427       ptR_rear  = ptMethods.Pt2Stn2011(int(mode), etaR, dphi12R, 0, int(pt_method), int(2));
00428 
00429       break;
00430     case 11: // FR = 1 -> b1-1-3,     FR = 0 -> b1-3 
00431     case 12: // FR = 1 -> b1-2-3,     FR = 0 -> b1-2 
00432     case 14: // FR = 1 -> b1-1-2-(3), FR = 0 -> b1-1
00433 
00434     //sign definition: sign dphi12 = Phi_DT - Phi_CSC
00435     //                 sing dphi23 = 5th sign. bit of phiBend
00436     // -> charge = 1 -> dphi12 = +, phiBend = -
00437     // -> charge = 0 -> dphi12 = +, phiBend = +    
00438         charge12 = 1;
00439         absPhi12 = address.delta_phi_12;
00440         absPhi23 = address.delta_phi_23;
00441 
00442         if(charge) charge23 = -1;
00443         else charge23 = 1;
00444 
00445         dphi12R = (static_cast<float>(absPhi12<<1)) / (static_cast<float>(1<<12)) * CSCTFConstants::SECTOR_RAD;
00446         dphi23R = float(absPhi23);
00447         if(charge12 * charge23 < 0) dphi23R = -dphi23R;
00448 
00449         int mode1;
00450         mode1 = int(mode);
00451         if(fr == 1 && mode1 == 11) mode1 = 14; // 3 station track we use dphi12 and phiBend for 2 and 3 station track
00452 
00453         ptR_front = ptMethods.Pt3Stn2011(mode1, etaR, dphi12R, dphi23R, int(0), int(pt_method));
00454         ptR_rear = ptMethods.Pt3Stn2011(mode1, etaR, dphi12R, dphi23R, int(0), int(pt_method));
00455 
00456       break;
00457     case 15: // halo trigger
00458     case 1: // tracks that fail delta phi cuts
00459       ptR_front = trigger_ptscale->getPtScale()->getLowEdge(3); // 2 GeV
00460       ptR_rear  = trigger_ptscale->getPtScale()->getLowEdge(3); 
00461       break;
00462     default: // Tracks in this category are not considered muons.
00463       ptR_front = trigger_ptscale->getPtScale()->getLowEdge(0); // 0 GeV 
00464       ptR_rear  = trigger_ptscale->getPtScale()->getLowEdge(0);
00465     };// end switch
00466 
00467   front_pt = trigger_ptscale->getPtScale()->getPacked(ptR_front);
00468   rear_pt  = trigger_ptscale->getPtScale()->getPacked(ptR_rear);
00469 
00470   } //end pt_methods greater or equal to 21 
00471 
00472 //***************************************************//
00473 //***************************************************//
00474   if(pt_method >= 11 && pt_method < 20){ //here we have only pt_methods greater or equal to 11 
00475                        //for fw 20101011 <- 2011 data taking
00476   // mode definition you could find at page 6 & 7: 
00477   // https://www.phys.ufl.edu/~madorsky/sp/2010-10-11/sp_core_interface.pdf 
00478   // it is valid starting the beggining of 2011 
00479   switch(mode)
00480     {
00481     case 2:
00482     case 3:
00483     case 4:
00484     case 5:
00485 
00486       charge12 = 1;
00487       absPhi12 = address.delta_phi_12;
00488       absPhi23 = address.delta_phi_23;
00489 
00490       if(charge) charge23 = 1;
00491       else charge23 = -1;
00492 
00493       dphi12R = (static_cast<float>(absPhi12<<1)) / (static_cast<float>(1<<12)) * CSCTFConstants::SECTOR_RAD;
00494       dphi23R = (static_cast<float>(absPhi23<<4)) / (static_cast<float>(1<<12)) * CSCTFConstants::SECTOR_RAD;
00495       if(charge12 * charge23 < 0) dphi23R = -dphi23R;
00496 
00497       ptR_front = ptMethods.Pt3Stn2010(mode, etaR, dphi12R, dphi23R, 1, int(pt_method));
00498       ptR_rear  = ptMethods.Pt3Stn2010(mode, etaR, dphi12R, dphi23R, 0, int(pt_method));    
00499 
00500       if(pt_method == 12 && mode != 5 && etaR > 2.1)//exclude mode without ME11a
00501         {
00502             float dphi12Rmin = dphi12R - Pi*10/180/3; // 10/3 degrees 
00503             float dphi12Rmax = dphi12R + Pi*10/180/3; // 10/3 degrees
00504             float dphi23Rmin = dphi23R;
00505             float dphi23Rmax = dphi23R;
00506             if(dphi12Rmin*dphi12R < 0) dphi23Rmin = -dphi23R;
00507             if(dphi12Rmax*dphi12R < 0) dphi23Rmax = -dphi23R;
00508             float ptR_front_min = ptMethods.Pt3Stn2010(mode, etaR, dphi12Rmin, dphi23Rmin, 1, int(pt_method));
00509             float ptR_rear_min = ptMethods.Pt3Stn2010(mode, etaR, dphi12Rmin, dphi23Rmin, 0, int(pt_method));
00510             float ptR_front_max = ptMethods.Pt3Stn2010(mode, etaR, dphi12Rmax, dphi23Rmax, 1, int(pt_method));
00511             float ptR_rear_max = ptMethods.Pt3Stn2010(mode, etaR, dphi12Rmax, dphi23Rmax, 0, int(pt_method));
00512             // select max pt solution for 3 links:
00513             ptR_front = std::max(ptR_front, ptR_front_min);
00514             ptR_front = std::max(ptR_front, ptR_front_max);
00515             ptR_rear = std::max(ptR_rear, ptR_rear_min);
00516             ptR_rear = std::max(ptR_rear, ptR_rear_max);
00517         }
00518       break;
00519     case 6:
00520     case 7:
00521     case 8:
00522     case 9:
00523     case 10:
00524     case 13: // ME1-ME4
00525       type = mode - 5;
00526 
00527       if(charge) absPhi12 = address.delta_phi();
00528       else
00529         {
00530           int temp_phi = address.delta_phi();
00531           absPhi12 = static_cast<unsigned>(-temp_phi) & 0xfff;
00532         }
00533 
00534       dphi12R = (static_cast<float>(absPhi12)) / (static_cast<float>(1<<12)) * CSCTFConstants::SECTOR_RAD;
00535 
00536       //std::cout<< " Sector_rad = " << (CSCTFConstants::SECTOR_RAD) << std::endl;
00537       ptR_front = ptMethods.Pt2Stn2010(mode, etaR, dphi12R, 1, int(pt_method));
00538       ptR_rear  = ptMethods.Pt2Stn2010(mode, etaR, dphi12R, 0, int(pt_method));
00539       if((pt_method == 12) && etaR > 2.1 && mode != 8 && mode !=9 && mode !=10)//exclude tracks without ME11a 
00540         {
00541            float dphi12Rmin = fabs(fabs(dphi12R) - Pi*10/180/3); // 10/3 degrees 
00542            float ptR_front_min = ptMethods.Pt2Stn2010(mode, etaR, dphi12Rmin, 1, int(pt_method));
00543            float ptR_rear_min = ptMethods.Pt2Stn2010(mode, etaR, dphi12Rmin, 0, int(pt_method));
00544            // select max pt solution for 3 links:
00545            ptR_front = std::max(ptR_front, ptR_front_min);
00546            ptR_rear = std::max(ptR_rear, ptR_rear_min);
00547         }
00548 
00549       break;
00550     case 11: // FR = 1 -> b1-1-3,     FR = 0 -> b1-3 
00551     case 12: // FR = 1 -> b1-2-3,     FR = 0 -> b1-2 
00552     case 14: // FR = 1 -> b1-1-2-(3), FR = 0 -> b1-1
00553 
00554       if(fr == 0){ // 2 station track
00555         if(charge) absPhi12 = address.delta_phi();
00556         else
00557           {
00558             int temp_phi = address.delta_phi();
00559             absPhi12 = static_cast<unsigned>(-temp_phi) & 0xfff;
00560           }
00561           dphi12R = (static_cast<float>(absPhi12)) / (static_cast<float>(1<<12)) * CSCTFConstants::SECTOR_RAD;
00562           ptR_rear  = ptMethods.Pt2Stn2010(mode, etaR, dphi12R, 0, int(pt_method));
00563 
00564       }// end fr == 0
00565       if(fr == 1){ // 3 station track
00566         charge12 = 1;
00567         absPhi12 = address.delta_phi_12;
00568         absPhi23 = address.delta_phi_23;
00569 
00570         if(charge) charge23 = 1;
00571         else charge23 = -1;
00572 
00573         dphi12R = (static_cast<float>(absPhi12<<1)) / (static_cast<float>(1<<12)) * CSCTFConstants::SECTOR_RAD;
00574         dphi23R = (static_cast<float>(absPhi23<<4)) / (static_cast<float>(1<<12)) * CSCTFConstants::SECTOR_RAD;
00575         if(charge12 * charge23 < 0) dphi23R = -dphi23R;
00576 
00577         ptR_front = ptMethods.Pt3Stn2010(mode, etaR, dphi12R, dphi23R, 1, int(pt_method));
00578 
00579         if(pt_method == 12 && mode != 5 && etaR > 2.1)//exclude mode without ME11a
00580           {
00581               float dphi12Rmin = dphi12R - Pi*10/180/3; // 10/3 degrees 
00582               float dphi12Rmax = dphi12R + Pi*10/180/3; // 10/3 degrees
00583               float dphi23Rmin = dphi23R;
00584               float dphi23Rmax = dphi23R;
00585               if(dphi12Rmin*dphi12R < 0) dphi23Rmin = -dphi23R;
00586               if(dphi12Rmax*dphi12R < 0) dphi23Rmax = -dphi23R;
00587               float ptR_front_min = ptMethods.Pt3Stn2010(mode, etaR, dphi12Rmin, dphi23Rmin, 1, int(pt_method));
00588               float ptR_front_max = ptMethods.Pt3Stn2010(mode, etaR, dphi12Rmax, dphi23Rmax, 1, int(pt_method));
00589               // select max pt solution for 3 links:
00590               ptR_front = std::max(ptR_front, ptR_front_min);
00591               ptR_front = std::max(ptR_front, ptR_front_max);
00592           }
00593       } // end fr == 1 
00594 
00595       break;
00596     case 15: // halo trigger
00597     case 1: // tracks that fail delta phi cuts
00598       ptR_front = trigger_ptscale->getPtScale()->getLowEdge(3); // 2 GeV
00599       ptR_rear  = trigger_ptscale->getPtScale()->getLowEdge(3); 
00600       break;
00601     default: // Tracks in this category are not considered muons.
00602       ptR_front = trigger_ptscale->getPtScale()->getLowEdge(0); // 0 GeV 
00603       ptR_rear  = trigger_ptscale->getPtScale()->getLowEdge(0);
00604     };// end switch
00605 
00606   front_pt = trigger_ptscale->getPtScale()->getPacked(ptR_front);
00607   rear_pt  = trigger_ptscale->getPtScale()->getPacked(ptR_rear);
00608 
00609   } //end pt_methods greater or equal to 11 
00610 //***************************************************//
00611   if(pt_method <= 5){ //here we have only pt_methods less or equal to 5
00612   // mode definition you could find at https://twiki.cern.ch/twiki/pub/Main/PtLUTs/mode_codes.xls
00613   // it is valid till the end 2010 
00614 
00615   //  kluge to use 2-stn track in overlap region
00616   //  see also where this routine is called, and encode LUTaddress, and assignPT
00617   if (pt_method != 4 && pt_method !=5 
00618       && (mode == 2 || mode == 3 || mode == 4) && (eta<3)) mode = 6;
00619   if (pt_method != 4 && pt_method !=5 && (mode == 5)
00620       && (eta<3)) mode = 8;
00621 
00622   switch(mode)
00623     {
00624     case 2:
00625     case 3:
00626     case 4:
00627     case 5:
00628       type = mode - 1;
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       // now convert to real numbers for input into PT assignment algos.
00637 
00638       if(pt_method == 4 || pt_method == 5) // param method 2010
00639         {
00640           dphi12R = (static_cast<float>(absPhi12<<1)) / (static_cast<float>(1<<12)) * CSCTFConstants::SECTOR_RAD;
00641           dphi23R = (static_cast<float>(absPhi23<<4)) / (static_cast<float>(1<<12)) * CSCTFConstants::SECTOR_RAD;
00642           if(charge12 * charge23 < 0) dphi23R = -dphi23R;
00643 
00644           ptR_front = ptMethods.Pt3Stn2010(mode, etaR, dphi12R, dphi23R, 1, int(pt_method));
00645           ptR_rear  = ptMethods.Pt3Stn2010(mode, etaR, dphi12R, dphi23R, 0, int(pt_method));
00646 
00647           if(pt_method == 5 && mode != 5 && etaR > 2.1)//exclude mode without ME11a
00648             {
00649                 float dphi12Rmin = dphi12R - Pi*10/180/3; // 10/3 degrees 
00650                 float dphi12Rmax = dphi12R + Pi*10/180/3; // 10/3 degrees
00651                 float dphi23Rmin = dphi23R;
00652                 float dphi23Rmax = dphi23R;
00653                 if(dphi12Rmin*dphi12R < 0) dphi23Rmin = -dphi23R;
00654                 if(dphi12Rmax*dphi12R < 0) dphi23Rmax = -dphi23R;
00655                 float ptR_front_min = ptMethods.Pt3Stn2010(mode, etaR, dphi12Rmin, dphi23Rmin, 1, int(pt_method));
00656                 float ptR_rear_min = ptMethods.Pt3Stn2010(mode, etaR, dphi12Rmin, dphi23Rmin, 0, int(pt_method));
00657                 float ptR_front_max = ptMethods.Pt3Stn2010(mode, etaR, dphi12Rmax, dphi23Rmax, 1, int(pt_method));
00658                 float ptR_rear_max = ptMethods.Pt3Stn2010(mode, etaR, dphi12Rmax, dphi23Rmax, 0, int(pt_method));
00659                 // select max pt solution for 3 links:
00660                 ptR_front = std::max(ptR_front, ptR_front_min);
00661                 ptR_front = std::max(ptR_front, ptR_front_max);
00662                 ptR_rear = std::max(ptR_rear, ptR_rear_min);
00663                 ptR_rear = std::max(ptR_rear, ptR_rear_max);
00664             }
00665         }
00666       else if(pt_method == 1) // param method
00667         {
00668           dphi12R = (static_cast<float>(absPhi12<<1)) / (static_cast<float>(1<<12)) * CSCTFConstants::SECTOR_RAD;
00669           dphi23R = (static_cast<float>(absPhi23<<4)) / (static_cast<float>(1<<12)) * CSCTFConstants::SECTOR_RAD;
00670           if(charge12 * charge23 < 0) dphi23R = -dphi23R;
00671 
00672           ptR_front = ptMethods.Pt3Stn(type, etaR, dphi12R, dphi23R, 1);
00673           ptR_rear  = ptMethods.Pt3Stn(type, etaR, dphi12R, dphi23R, 0);
00674 
00675         }
00676       else if(pt_method == 2) // cathy's method
00677         {
00678           if(type <= 2)
00679             {
00680               ptR_front = ptMethods.Pt3StnChiSq(type+3, etaR, absPhi12<<1, ((charge == 0) ? -(absPhi23<<4) : (absPhi23<<4)), 1);
00681               ptR_rear  = ptMethods.Pt3StnChiSq(type+3, etaR, absPhi12<<1, ((charge == 0) ? -(absPhi23<<4) : (absPhi23<<4)), 0);
00682             }
00683           else
00684             {
00685               ptR_front = ptMethods.Pt2StnChiSq(type-2, etaR, absPhi12<<1, 1);
00686               ptR_rear  = ptMethods.Pt2StnChiSq(type-2, etaR, absPhi12<<1, 0);
00687             }
00688 
00689         }
00690       else // hybrid
00691         {
00692 
00693           if(type <= 2)
00694             {
00695               ptR_front = ptMethods.Pt3StnHybrid(type+3, etaR, absPhi12<<1, ((charge == 0) ? -(absPhi23<<4) : (absPhi23<<4)), 1);
00696               ptR_rear  = ptMethods.Pt3StnHybrid(type+3, etaR, absPhi12<<1, ((charge == 0) ? -(absPhi23<<4) : (absPhi23<<4)), 0);
00697             }
00698           else
00699             {
00700               ptR_front = ptMethods.Pt2StnHybrid(type-2, etaR, absPhi12<<1, 1);
00701               ptR_rear  = ptMethods.Pt2StnHybrid(type-2, etaR, absPhi12<<1, 0);
00702             }
00703 
00704         }
00705       break;
00706     case 6:
00707     case 7:
00708     case 8:
00709     case 9:
00710     case 10:
00711       type = mode - 5;
00712 
00713       if(charge) absPhi12 = address.delta_phi();
00714       else
00715         {
00716           int temp_phi = address.delta_phi();
00717           absPhi12 = static_cast<unsigned>(-temp_phi) & 0xfff;
00718         }
00719 
00720       if(absPhi12 < (1<<9))
00721         {
00722           if(pt_method == 1 || type == 5)
00723             {
00724               dphi12R = (static_cast<float>(absPhi12)) / (static_cast<float>(1<<12)) * CSCTFConstants::SECTOR_RAD;
00725 
00726               ptR_front = ptMethods.Pt2Stn(type, etaR, dphi12R, 1);
00727               ptR_rear  = ptMethods.Pt2Stn(type, etaR, dphi12R, 0);
00728 
00729             }
00730           else if(pt_method == 2)
00731             {
00732               ptR_front = ptMethods.Pt2StnChiSq(type-1, etaR, absPhi12, 1);
00733               ptR_rear  = ptMethods.Pt2StnChiSq(type-1, etaR, absPhi12, 0);
00734             }
00735           else
00736             {
00737               ptR_front = ptMethods.Pt2StnHybrid(type-1, etaR, absPhi12, 1);
00738               ptR_rear  = ptMethods.Pt2StnHybrid(type-1, etaR, absPhi12, 0);
00739             }
00740         }
00741       else
00742         {
00743           ptR_front = trigger_ptscale->getPtScale()->getLowEdge(1);
00744           ptR_rear  = trigger_ptscale->getPtScale()->getLowEdge(1);
00745         }
00746       if(pt_method == 4 || pt_method == 5) // param method 2010
00747         {
00748               dphi12R = (static_cast<float>(absPhi12)) / (static_cast<float>(1<<12)) * CSCTFConstants::SECTOR_RAD;
00749 
00750               //std::cout<< " Sector_rad = " << (CSCTFConstants::SECTOR_RAD) << std::endl;
00751               ptR_front = ptMethods.Pt2Stn2010(mode, etaR, dphi12R, 1, int(pt_method));
00752               ptR_rear  = ptMethods.Pt2Stn2010(mode, etaR, dphi12R, 0, int(pt_method));
00753               if((pt_method == 5) && etaR > 2.1 && mode != 8 && mode !=9 && mode !=10)//exclude tracks without ME11a 
00754                 {
00755                    float dphi12Rmin = fabs(fabs(dphi12R) - Pi*10/180/3); // 10/3 degrees 
00756                    float ptR_front_min = ptMethods.Pt2Stn2010(mode, etaR, dphi12Rmin, 1, int(pt_method));
00757                    float ptR_rear_min = ptMethods.Pt2Stn2010(mode, etaR, dphi12Rmin, 0, int(pt_method));
00758                    // select max pt solution for 3 links:
00759                    ptR_front = std::max(ptR_front, ptR_front_min);
00760                    ptR_rear = std::max(ptR_rear, ptR_rear_min);
00761                 }
00762         }
00763 
00764       break;
00765     case 12:  // 1-2-b1 calculated only delta_phi12 = 2-b1
00766     case 14:
00767       type = 2;
00768 
00769       if(charge) absPhi12 = address.delta_phi();
00770       else
00771         {
00772           int temp_phi = address.delta_phi();
00773           absPhi12 = static_cast<unsigned>(-temp_phi) & 0xfff;
00774         }
00775       if(absPhi12 < (1<<9))
00776         {
00777           dphi12R = (static_cast<float>(absPhi12)) / (static_cast<float>(1<<12)) * CSCTFConstants::SECTOR_RAD;
00778           ptR_front = ptMethods.Pt2Stn(type, etaR, dphi12R, 1);
00779           ptR_rear  = ptMethods.Pt2Stn(type, etaR, dphi12R, 0);
00780         }
00781       else
00782         {
00783           ptR_front = trigger_ptscale->getPtScale()->getLowEdge(1);
00784           ptR_rear  = trigger_ptscale->getPtScale()->getLowEdge(1);
00785         }
00786       if(pt_method == 4 || pt_method == 5) // param method 2010 
00787         {
00788               dphi12R = (static_cast<float>(absPhi12)) / (static_cast<float>(1<<12)) * CSCTFConstants::SECTOR_RAD;
00789 
00790               ptR_front = ptMethods.Pt2Stn2010(mode, etaR, dphi12R, 1, int(pt_method));
00791               ptR_rear  = ptMethods.Pt2Stn2010(mode, etaR, dphi12R, 0, int(pt_method));
00792 
00793               if(fabs(dphi12R)<0.01 && (ptR_rear < 10 || ptR_front < 10))
00794                 std::cout << "dphi12R = " << dphi12R << " ptR_rear = " << ptR_rear
00795                 << " ptR_front = " << ptR_front << " etaR = " << etaR << " mode = " << mode << std::endl;
00796         }
00797       break;
00798     case 13:
00799       type = 4;
00800 
00801       if(charge) absPhi12 = address.delta_phi();
00802       else
00803         {
00804           int temp_phi = address.delta_phi();
00805           absPhi12 = static_cast<unsigned>(-temp_phi) & 0xfff;
00806         }
00807       if(absPhi12 < (1<<9))
00808         {
00809           dphi12R = (static_cast<float>(absPhi12)) / (static_cast<float>(1<<12)) * CSCTFConstants::SECTOR_RAD;
00810           ptR_front = ptMethods.Pt2Stn(type, etaR, dphi12R, 1);
00811           ptR_rear  = ptMethods.Pt2Stn(type, etaR, dphi12R, 0);
00812         }
00813       else
00814         {
00815           ptR_front = trigger_ptscale->getPtScale()->getLowEdge(1);
00816           ptR_rear  = trigger_ptscale->getPtScale()->getLowEdge(1);
00817         }
00818 
00819       if(pt_method == 4 || pt_method == 5) // param method 2010
00820         {
00821               dphi12R = (static_cast<float>(absPhi12)) / (static_cast<float>(1<<12)) * CSCTFConstants::SECTOR_RAD;
00822 
00823               ptR_front = ptMethods.Pt2Stn2010(mode, etaR, dphi12R, 1, int(pt_method));
00824               ptR_rear  = ptMethods.Pt2Stn2010(mode, etaR, dphi12R, 0, int(pt_method));
00825               if((pt_method == 5) && etaR > 2.1)//mode = 13: ME1-ME4 exclude tracks without ME11a 
00826                 {
00827                    float dphi12Rmin = fabs(fabs(dphi12R) - Pi*10/180/3); // 10/3 degrees 
00828                    float ptR_front_min = ptMethods.Pt2Stn2010(mode, etaR, dphi12Rmin, 1, int(pt_method));
00829                    float ptR_rear_min = ptMethods.Pt2Stn2010(mode, etaR, dphi12Rmin, 0, int(pt_method));
00830                    // select max pt solution for 3 links:
00831                    ptR_front = std::max(ptR_front, ptR_front_min);
00832                    ptR_rear = std::max(ptR_rear, ptR_rear_min);
00833                 }
00834         }
00835 
00836       break;
00837     case 11:
00838       // singles trigger
00839       ptR_front = trigger_ptscale->getPtScale()->getLowEdge(5);
00840       ptR_rear  = trigger_ptscale->getPtScale()->getLowEdge(5);
00841       //ptR_front = trigger_ptscale->getPtScale()->getLowEdge(31);
00842       //ptR_rear  = trigger_ptscale->getPtScale()->getLowEdge(31);
00843       break;
00844     case 15:
00845       // halo trigger
00846       ptR_front = trigger_ptscale->getPtScale()->getLowEdge(5);
00847       ptR_rear  = trigger_ptscale->getPtScale()->getLowEdge(5);
00848       break;
00849     case 1:
00850       // tracks that fail delta phi cuts
00851       ptR_front = trigger_ptscale->getPtScale()->getLowEdge(5);
00852       ptR_rear  = trigger_ptscale->getPtScale()->getLowEdge(5); 
00853      break;
00854     default: // Tracks in this category are not considered muons.
00855       ptR_front = trigger_ptscale->getPtScale()->getLowEdge(0);
00856       ptR_rear  = trigger_ptscale->getPtScale()->getLowEdge(0);
00857     };
00858 
00859   front_pt = trigger_ptscale->getPtScale()->getPacked(ptR_front);
00860   rear_pt  = trigger_ptscale->getPtScale()->getPacked(ptR_rear);
00861 
00862   // kluge to set arbitrary Pt for some tracks with lousy resolution (and no param)
00863   if(pt_method != 4 && pt_method != 5) 
00864     {
00865       if ((front_pt==0 || front_pt==1) && (eta<3) && quality==1 && pt_method != 2) front_pt = 31;
00866       if ((rear_pt==0  || rear_pt==1) && (eta<3) && quality==1 && pt_method != 2) rear_pt = 31;
00867     }
00868   if(pt_method != 2 && pt_method != 4 && quality == 1)
00869     {
00870       if (front_pt < 5) front_pt = 5;
00871       if (rear_pt  < 5) rear_pt  = 5;
00872     }
00873 
00874   // in order to match the pt assignement of the previous routine
00875   if(isBeamStartConf && pt_method != 2 && pt_method != 4 && pt_method !=5) {
00876     if(quality == 3 && mode == 5) {
00877       
00878       if (front_pt < 5) front_pt = 5;
00879       if (rear_pt  < 5) rear_pt  = 5;
00880     }
00881 
00882     if(quality == 2 && mode > 7 && mode < 11) {
00883       
00884       if (front_pt < 5) front_pt = 5;
00885       if (rear_pt  < 5) rear_pt  = 5;
00886     }
00887   }
00888 
00889   } // end if for pt_method less or equal to 5
00890 //***************************************************//
00891 
00892  
00893   result.front_rank = front_pt | front_quality << 5;
00894   result.rear_rank  = rear_pt  | rear_quality << 5;
00895 
00896   result.charge_valid_front = 1; //ptMethods.chargeValid(front_pt, quality, eta, pt_method);
00897   result.charge_valid_rear  = 1; //ptMethods.chargeValid(rear_pt, quality, eta, pt_method);
00898 
00899 
00900   /*  if (mode == 1) { 
00901     std::cout << "F_pt: "      << front_pt      << std::endl;
00902     std::cout << "R_pt: "      << rear_pt       << std::endl;
00903     std::cout << "F_quality: " << front_quality << std::endl;
00904     std::cout << "R_quality: " << rear_quality  << std::endl;
00905     std::cout << "F_rank: " << std::hex << result.front_rank << std::endl;
00906     std::cout << "R_rank: " << std::hex << result.rear_rank  << std::endl;
00907   }
00908   */
00909   return result;
00910 }
00911 
00912 
00913 unsigned CSCTFPtLUT::trackQuality(const unsigned& eta, const unsigned& mode, const unsigned& fr) const
00914 {
00915  // eta and mode should be only 4-bits, since that is the input to the large LUT
00916     if (eta>15 || mode>15)
00917       {
00918         //std::cout << "Error: Eta or Mode out of range in AU quality assignment" << std::endl;
00919         edm::LogError("CSCTFPtLUT::trackQuality()")<<"Eta or Mode out of range in AU quality assignment";
00920         return 0;
00921       }
00922     unsigned int quality;
00923     switch (mode) {
00924     case 2:
00925       quality = 3;
00926       if(pt_method > 10 && eta < 3) quality = 1; //eta < 1.2  
00927       break;
00928     case 3:
00929     case 4:
00931       //        quality = 2;
00932       quality = 3;
00933       break;
00934     case 5:
00935       quality = 1;
00936       if (isBeamStartConf && eta >= 12 && pt_method < 20) // eta > 2.1
00937         quality = 3;
00938       break;
00939     case 6:
00940       if (eta>=3) // eta > 1.2
00941         quality = 2;
00942       else
00943         quality = 1;
00944       break;
00945     case 7:
00946       quality = 2;
00947       if(pt_method > 10 && eta < 3) quality = 1; //eta < 1.2  
00948       break;
00949     case 8:
00950       quality = 1;
00951       if (isBeamStartConf && eta >= 12 && pt_method < 20) // eta > 2.1
00952         quality = 2;
00953       break;
00954     case 9:
00955       quality = 1;
00956       if (isBeamStartConf && eta >= 12 && pt_method < 20) // eta > 2.1
00957         quality = 2;
00958       break;
00959     case 10:
00960       quality = 1;
00961       if (isBeamStartConf && eta >= 12 && pt_method < 20) // eta > 2.1
00962         quality = 2;
00963       break;
00964     case 11:
00965       // single LCTs
00966       quality = 1;
00967       // overlap region
00968       if(pt_method > 10 && fr == 0) quality = 2;
00969       if(pt_method > 10 && fr == 1) quality = 3;
00970       if(pt_method > 20 && fr == 0) quality = 3;
00971       break;
00972     case 12:
00973       quality = 3;
00974       // overlap region
00975       if(pt_method > 10 && fr == 0) quality = 2;
00976       if(pt_method > 10 && fr == 1) quality = 3;
00977       if(pt_method > 20 && fr == 0) quality = 3;
00978       break;
00979     case 13:
00980       quality = 2;
00981       break;
00982     case 14:
00983       quality = 2;
00984       // overlap region
00985       if(pt_method > 10 && fr == 0) quality = 2;
00986       if(pt_method > 10 && fr == 1) quality = 3;
00987       if(pt_method > 20 && fr == 0) quality = 3;
00988       break;
00989     case 15:
00990       // halo triggers
00991       quality = 1;
00992       break;
00993       //DEA: keep muons that fail delta phi cut
00994     case 1:
00995       quality = 1;
00996       break;
00997     default:
00998       quality = 0;
00999       break;
01000     }
01001 
01002     // allow quality = 1 only in overlap region or eta = 1.6 region
01003     //    if ((quality == 1) && (eta >= 4) && (eta != 6) && (eta != 7)) quality = 0;
01004     //    if ( (quality == 1) && (eta >= 4) ) quality = 0;
01005 
01006     if ( (quality == 1) && (eta >= 4) && (eta < 11)
01007          && ((lowQualityFlag&4)==0) ) quality = 0;
01008     if ( (quality == 1) && (eta < 4) && ((lowQualityFlag&1)==0)
01009          && ((lowQualityFlag&4)==0) ) quality = 0;
01010     if ( (quality == 1) && (eta >=11) && ((lowQualityFlag&2)==0)
01011          && ((lowQualityFlag&4)==0) ) quality = 0;
01012 
01013     return quality;
01014 
01015 }
01016 
01017 void CSCTFPtLUT::readLUT()
01018 {
01019   std::ifstream PtLUT;
01020 
01021   if(isBinary)
01022     {
01023       PtLUT.open(pt_lut_file.fullPath().c_str(), std::ios::binary);
01024       PtLUT.seekg(0, std::ios::end);
01025       int length = PtLUT.tellg();;
01026       if( length == (1<<CSCBitWidths::kPtAddressWidth)*sizeof(short) )
01027         {
01028           PtLUT.seekg(0, std::ios::beg);
01029           PtLUT.read(reinterpret_cast<char*>(pt_lut),length);
01030         }
01031       else
01032         {
01033           edm::LogError("CSCPtLUT") << "File " << pt_lut_file.fullPath() << " is incorrect size!\n";
01034         }
01035       PtLUT.close();
01036     }
01037   else
01038     {
01039       PtLUT.open(pt_lut_file.fullPath().c_str());
01040       unsigned i = 0;
01041       unsigned short temp = 0;
01042       while(!PtLUT.eof() && i < 1 << CSCBitWidths::kPtAddressWidth)
01043         {
01044           PtLUT >> temp;
01045           pt_lut[i++] = (*reinterpret_cast<ptdat*>(&temp));
01046         }
01047       PtLUT.close();
01048     }
01049 }
01050 
01051