00001
00002
00003
00004
00005
00006
00007
00008
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
00019
00020
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
00034
00035
00036
00037
00038
00039
00040
00041
00042 CSCTFPtLUT::CSCTFPtLUT(const edm::EventSetup& es)
00043 : read_pt_lut(true),
00044 isBinary(false)
00045 {
00046 pt_method = 28;
00047
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
00082 read_pt_lut = pset.getParameter<bool>("ReadPtLUT");
00083 if(read_pt_lut)
00084 {
00085 pt_lut_file = pset.getParameter<edm::FileInPath>("PtLUTFile");
00086
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
00096
00097
00098
00099
00100
00101
00102
00103
00104
00105
00106
00107
00108
00109
00110
00111
00112
00113
00114
00115
00116
00117
00118
00119 pt_method = pset.getUntrackedParameter<unsigned>("PtMethod",28);
00120
00121
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){
00207
00208
00209
00210
00211
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)
00234 {
00235 float dphi12Rmin = dphi12R - Pi*10/180/3;
00236 float dphi12Rmax = dphi12R + Pi*10/180/3;
00237 float dphi23Rmin = dphi23R;
00238 float dphi23Rmax = dphi23R;
00239
00240
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
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:
00253 case 7:
00254 case 13:
00255 int iME11;
00256 iME11 = int(charge);
00257 if(iME11 == 1 && etaR > 1.6) etaR = 1.55;
00258 if(iME11 == 0 && etaR < 1.6) etaR = 1.65;
00259 absPhi12 = address.delta_phi_12;
00260
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
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)
00269 {
00270 float dphi12Rmin = fabs(fabs(dphi12R) - Pi*10/180/3);
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
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
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
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
00300 case 11:
00301 case 12:
00302 case 14:
00303
00304
00305
00306
00307
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;
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:
00328 case 1:
00329 ptR_front = trigger_ptscale->getPtScale()->getLowEdge(3);
00330 ptR_rear = trigger_ptscale->getPtScale()->getLowEdge(3);
00331 break;
00332 default:
00333 ptR_front = trigger_ptscale->getPtScale()->getLowEdge(0);
00334 ptR_rear = trigger_ptscale->getPtScale()->getLowEdge(0);
00335 };
00336
00337 front_pt = trigger_ptscale->getPtScale()->getPacked(ptR_front);
00338 rear_pt = trigger_ptscale->getPtScale()->getPacked(ptR_rear);
00339
00340 }
00341
00342
00343
00344 if(pt_method == 21 || pt_method == 22){
00345
00346
00347
00348
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)
00371 {
00372 float dphi12Rmin = dphi12R - Pi*10/180/3;
00373 float dphi12Rmax = dphi12R + Pi*10/180/3;
00374 float dphi23Rmin = dphi23R;
00375 float dphi23Rmax = dphi23R;
00376
00377
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
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:
00390 case 7:
00391 case 13:
00392 int iME11;
00393 iME11 = int(charge);
00394 absPhi12 = address.delta_phi_12;
00395
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
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)
00405 {
00406 float dphi12Rmin = fabs(fabs(dphi12R) - Pi*10/180/3);
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
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
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:
00435 case 12:
00436 case 14:
00437
00438
00439
00440
00441
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;
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:
00462 case 1:
00463 ptR_front = trigger_ptscale->getPtScale()->getLowEdge(3);
00464 ptR_rear = trigger_ptscale->getPtScale()->getLowEdge(3);
00465 break;
00466 default:
00467 ptR_front = trigger_ptscale->getPtScale()->getLowEdge(0);
00468 ptR_rear = trigger_ptscale->getPtScale()->getLowEdge(0);
00469 };
00470
00471 front_pt = trigger_ptscale->getPtScale()->getPacked(ptR_front);
00472 rear_pt = trigger_ptscale->getPtScale()->getPacked(ptR_rear);
00473
00474 }
00475
00476
00477
00478 if(pt_method >= 11 && pt_method < 20){
00479
00480
00481
00482
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)
00505 {
00506 float dphi12Rmin = dphi12R - Pi*10/180/3;
00507 float dphi12Rmax = dphi12R + Pi*10/180/3;
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
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:
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
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)
00544 {
00545 float dphi12Rmin = fabs(fabs(dphi12R) - Pi*10/180/3);
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
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:
00555 case 12:
00556 case 14:
00557
00558 if(fr == 0){
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 }
00569 if(fr == 1){
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)
00584 {
00585 float dphi12Rmin = dphi12R - Pi*10/180/3;
00586 float dphi12Rmax = dphi12R + Pi*10/180/3;
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
00594 ptR_front = std::max(ptR_front, ptR_front_min);
00595 ptR_front = std::max(ptR_front, ptR_front_max);
00596 }
00597 }
00598
00599 break;
00600 case 15:
00601 case 1:
00602 ptR_front = trigger_ptscale->getPtScale()->getLowEdge(3);
00603 ptR_rear = trigger_ptscale->getPtScale()->getLowEdge(3);
00604 break;
00605 default:
00606 ptR_front = trigger_ptscale->getPtScale()->getLowEdge(0);
00607 ptR_rear = trigger_ptscale->getPtScale()->getLowEdge(0);
00608 };
00609
00610 front_pt = trigger_ptscale->getPtScale()->getPacked(ptR_front);
00611 rear_pt = trigger_ptscale->getPtScale()->getPacked(ptR_rear);
00612
00613 }
00614
00615 if(pt_method <= 5){
00616
00617
00618
00619
00620
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
00641
00642 if(pt_method == 4 || pt_method == 5)
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)
00652 {
00653 float dphi12Rmin = dphi12R - Pi*10/180/3;
00654 float dphi12Rmax = dphi12R + Pi*10/180/3;
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
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)
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)
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
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)
00751 {
00752 dphi12R = (static_cast<float>(absPhi12)) / (static_cast<float>(1<<12)) * CSCTFConstants::SECTOR_RAD;
00753
00754
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)
00758 {
00759 float dphi12Rmin = fabs(fabs(dphi12R) - Pi*10/180/3);
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
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:
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)
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)
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)
00830 {
00831 float dphi12Rmin = fabs(fabs(dphi12R) - Pi*10/180/3);
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
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
00843 ptR_front = trigger_ptscale->getPtScale()->getLowEdge(5);
00844 ptR_rear = trigger_ptscale->getPtScale()->getLowEdge(5);
00845
00846
00847 break;
00848 case 15:
00849
00850 ptR_front = trigger_ptscale->getPtScale()->getLowEdge(5);
00851 ptR_rear = trigger_ptscale->getPtScale()->getLowEdge(5);
00852 break;
00853 case 1:
00854
00855 ptR_front = trigger_ptscale->getPtScale()->getLowEdge(5);
00856 ptR_rear = trigger_ptscale->getPtScale()->getLowEdge(5);
00857 break;
00858 default:
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
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
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 }
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;
00901 result.charge_valid_rear = 1;
00902
00903
00904
00905
00906
00907
00908
00909
00910
00911
00912
00913 return result;
00914 }
00915
00916
00917 unsigned CSCTFPtLUT::trackQuality(const unsigned& eta, const unsigned& mode, const unsigned& fr) const
00918 {
00919
00920 if (eta>15 || mode>15)
00921 {
00922
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;
00931 break;
00932 case 3:
00933 case 4:
00935
00936 quality = 3;
00937 break;
00938 case 5:
00939 quality = 1;
00940 if (isBeamStartConf && eta >= 12 && pt_method < 20)
00941 quality = 3;
00942 if(pt_method == 27 || pt_method == 28) quality = 3;
00943 break;
00944 case 6:
00945 if (eta>=3)
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;
00953 break;
00954 case 8:
00955 quality = 1;
00956 if (isBeamStartConf && eta >= 12 && pt_method < 20)
00957 quality = 2;
00958 if((pt_method == 27 || pt_method == 28) && (eta >= 7 && eta < 9)) quality = 2;
00959 break;
00960 case 9:
00961 quality = 1;
00962 if (isBeamStartConf && eta >= 12 && pt_method < 20)
00963 quality = 2;
00964 if((pt_method == 27 || pt_method == 28) && (eta >= 7 && eta < 9)) quality = 2;
00965 break;
00966 case 10:
00967 quality = 1;
00968 if (isBeamStartConf && eta >= 12 && pt_method < 20)
00969 quality = 2;
00970 if((pt_method == 27 || pt_method == 28) && (eta >= 7 && eta < 9)) quality = 2;
00971 break;
00972 case 11:
00973
00974 quality = 1;
00975
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
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
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
00999 quality = 1;
01000 break;
01001
01002 case 1:
01003 quality = 1;
01004 break;
01005 default:
01006 quality = 0;
01007 break;
01008 }
01009
01010
01011
01012
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