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(false),
00044 isBinary(false)
00045 {
00046 pt_method = 26;
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 pt_method = pset.getUntrackedParameter<unsigned>("PtMethod",26);
00116
00117
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){
00203
00204
00205
00206
00207
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)
00230 {
00231 float dphi12Rmin = dphi12R - Pi*10/180/3;
00232 float dphi12Rmax = dphi12R + Pi*10/180/3;
00233 float dphi23Rmin = dphi23R;
00234 float dphi23Rmax = dphi23R;
00235
00236
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
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:
00249 case 7:
00250 case 13:
00251 int iME11;
00252 iME11 = int(charge);
00253 if(iME11 == 1 && etaR > 1.6) etaR = 1.55;
00254 if(iME11 == 0 && etaR < 1.6) etaR = 1.65;
00255 absPhi12 = address.delta_phi_12;
00256
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
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)
00265 {
00266 float dphi12Rmin = fabs(fabs(dphi12R) - Pi*10/180/3);
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
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
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
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
00296 case 11:
00297 case 12:
00298 case 14:
00299
00300
00301
00302
00303
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;
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:
00324 case 1:
00325 ptR_front = trigger_ptscale->getPtScale()->getLowEdge(3);
00326 ptR_rear = trigger_ptscale->getPtScale()->getLowEdge(3);
00327 break;
00328 default:
00329 ptR_front = trigger_ptscale->getPtScale()->getLowEdge(0);
00330 ptR_rear = trigger_ptscale->getPtScale()->getLowEdge(0);
00331 };
00332
00333 front_pt = trigger_ptscale->getPtScale()->getPacked(ptR_front);
00334 rear_pt = trigger_ptscale->getPtScale()->getPacked(ptR_rear);
00335
00336 }
00337
00338
00339
00340 if(pt_method == 21 || pt_method == 22){
00341
00342
00343
00344
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)
00367 {
00368 float dphi12Rmin = dphi12R - Pi*10/180/3;
00369 float dphi12Rmax = dphi12R + Pi*10/180/3;
00370 float dphi23Rmin = dphi23R;
00371 float dphi23Rmax = dphi23R;
00372
00373
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
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:
00386 case 7:
00387 case 13:
00388 int iME11;
00389 iME11 = int(charge);
00390 absPhi12 = address.delta_phi_12;
00391
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
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)
00401 {
00402 float dphi12Rmin = fabs(fabs(dphi12R) - Pi*10/180/3);
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
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
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:
00431 case 12:
00432 case 14:
00433
00434
00435
00436
00437
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;
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:
00458 case 1:
00459 ptR_front = trigger_ptscale->getPtScale()->getLowEdge(3);
00460 ptR_rear = trigger_ptscale->getPtScale()->getLowEdge(3);
00461 break;
00462 default:
00463 ptR_front = trigger_ptscale->getPtScale()->getLowEdge(0);
00464 ptR_rear = trigger_ptscale->getPtScale()->getLowEdge(0);
00465 };
00466
00467 front_pt = trigger_ptscale->getPtScale()->getPacked(ptR_front);
00468 rear_pt = trigger_ptscale->getPtScale()->getPacked(ptR_rear);
00469
00470 }
00471
00472
00473
00474 if(pt_method >= 11 && pt_method < 20){
00475
00476
00477
00478
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)
00501 {
00502 float dphi12Rmin = dphi12R - Pi*10/180/3;
00503 float dphi12Rmax = dphi12R + Pi*10/180/3;
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
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:
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
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)
00540 {
00541 float dphi12Rmin = fabs(fabs(dphi12R) - Pi*10/180/3);
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
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:
00551 case 12:
00552 case 14:
00553
00554 if(fr == 0){
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 }
00565 if(fr == 1){
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)
00580 {
00581 float dphi12Rmin = dphi12R - Pi*10/180/3;
00582 float dphi12Rmax = dphi12R + Pi*10/180/3;
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
00590 ptR_front = std::max(ptR_front, ptR_front_min);
00591 ptR_front = std::max(ptR_front, ptR_front_max);
00592 }
00593 }
00594
00595 break;
00596 case 15:
00597 case 1:
00598 ptR_front = trigger_ptscale->getPtScale()->getLowEdge(3);
00599 ptR_rear = trigger_ptscale->getPtScale()->getLowEdge(3);
00600 break;
00601 default:
00602 ptR_front = trigger_ptscale->getPtScale()->getLowEdge(0);
00603 ptR_rear = trigger_ptscale->getPtScale()->getLowEdge(0);
00604 };
00605
00606 front_pt = trigger_ptscale->getPtScale()->getPacked(ptR_front);
00607 rear_pt = trigger_ptscale->getPtScale()->getPacked(ptR_rear);
00608
00609 }
00610
00611 if(pt_method <= 5){
00612
00613
00614
00615
00616
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
00637
00638 if(pt_method == 4 || pt_method == 5)
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)
00648 {
00649 float dphi12Rmin = dphi12R - Pi*10/180/3;
00650 float dphi12Rmax = dphi12R + Pi*10/180/3;
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
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)
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)
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
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)
00747 {
00748 dphi12R = (static_cast<float>(absPhi12)) / (static_cast<float>(1<<12)) * CSCTFConstants::SECTOR_RAD;
00749
00750
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)
00754 {
00755 float dphi12Rmin = fabs(fabs(dphi12R) - Pi*10/180/3);
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
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:
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)
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)
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)
00826 {
00827 float dphi12Rmin = fabs(fabs(dphi12R) - Pi*10/180/3);
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
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
00839 ptR_front = trigger_ptscale->getPtScale()->getLowEdge(5);
00840 ptR_rear = trigger_ptscale->getPtScale()->getLowEdge(5);
00841
00842
00843 break;
00844 case 15:
00845
00846 ptR_front = trigger_ptscale->getPtScale()->getLowEdge(5);
00847 ptR_rear = trigger_ptscale->getPtScale()->getLowEdge(5);
00848 break;
00849 case 1:
00850
00851 ptR_front = trigger_ptscale->getPtScale()->getLowEdge(5);
00852 ptR_rear = trigger_ptscale->getPtScale()->getLowEdge(5);
00853 break;
00854 default:
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
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
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 }
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;
00897 result.charge_valid_rear = 1;
00898
00899
00900
00901
00902
00903
00904
00905
00906
00907
00908
00909 return result;
00910 }
00911
00912
00913 unsigned CSCTFPtLUT::trackQuality(const unsigned& eta, const unsigned& mode, const unsigned& fr) const
00914 {
00915
00916 if (eta>15 || mode>15)
00917 {
00918
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;
00927 break;
00928 case 3:
00929 case 4:
00931
00932 quality = 3;
00933 break;
00934 case 5:
00935 quality = 1;
00936 if (isBeamStartConf && eta >= 12 && pt_method < 20)
00937 quality = 3;
00938 break;
00939 case 6:
00940 if (eta>=3)
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;
00948 break;
00949 case 8:
00950 quality = 1;
00951 if (isBeamStartConf && eta >= 12 && pt_method < 20)
00952 quality = 2;
00953 break;
00954 case 9:
00955 quality = 1;
00956 if (isBeamStartConf && eta >= 12 && pt_method < 20)
00957 quality = 2;
00958 break;
00959 case 10:
00960 quality = 1;
00961 if (isBeamStartConf && eta >= 12 && pt_method < 20)
00962 quality = 2;
00963 break;
00964 case 11:
00965
00966 quality = 1;
00967
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
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
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
00991 quality = 1;
00992 break;
00993
00994 case 1:
00995 quality = 1;
00996 break;
00997 default:
00998 quality = 0;
00999 break;
01000 }
01001
01002
01003
01004
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