CMS 3D CMS Logo

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