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
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052 const int CSCTFPtLUT::dPhiNLBMap_5bit[32] =
00053 { 0 , 1 , 2 , 4 , 5 , 7 , 9 , 11 , 13 , 15 , 18 , 21 , 24 , 28 , 32 , 37 , 41 , 47 , 53 , 60 , 67 , 75 , 84 , 94 , 105 , 117 , 131 , 145 , 162 , 180 , 200 , 222};
00054
00055
00056
00057 const int CSCTFPtLUT::dPhiNLBMap_7bit[128] =
00058 { 0 , 1 , 2 , 3 , 4 , 5 , 6 , 8 , 9 , 10 , 11 , 12 , 14 , 15 , 16 , 17 , 19 , 20 , 21 , 23 , 24 , 26 , 27 , 29 , 30 , 32 , 33 , 35 , 37 , 38 , 40 , 42 , 44 , 45 , 47 , 49 , 51 , 53 , 55 , 57 , 59 , 61 , 63 , 65 , 67 , 70 , 72 , 74 , 77 , 79 , 81 , 84 , 86 , 89 , 92 , 94 , 97 , 100 , 103 , 105 , 108 , 111 , 114 , 117 , 121 , 124 , 127 , 130 , 134 , 137 , 141 , 144 , 148 , 151 , 155 , 159 , 163 , 167 , 171 , 175 , 179 , 183 , 188 , 192 , 197 , 201 , 206 , 210 , 215 , 220 , 225 , 230 , 235 , 241 , 246 , 251 , 257 , 263 , 268 , 274 , 280 , 286 , 292 , 299 , 305 , 312 , 318 , 325 , 332 , 339 , 346 , 353 , 361 , 368 , 376 , 383 , 391 , 399 , 408 , 416 , 425 , 433 , 442 , 451 , 460 , 469 , 479 , 489 };
00059
00060
00061
00062 const int CSCTFPtLUT::dPhiNLBMap_8bit[256] =
00063 { 0 , 1 , 2 , 3 , 4 , 5 , 6 , 7 , 8 , 9 , 10 , 11 , 12 , 13 , 14 , 16 , 17 , 18 , 19 , 20 , 21 , 22 , 23 , 24 , 25 , 27 , 28 , 29 , 30 , 31 , 32 , 33 , 35 , 36 , 37 , 38 , 39 , 40 , 42 , 43 , 44 , 45 , 46 , 48 , 49 , 50 , 51 , 53 , 54 , 55 , 56 , 58 , 59 , 60 , 61 , 63 , 64 , 65 , 67 , 68 , 69 , 70 , 72 , 73 , 74 , 76 , 77 , 79 , 80 , 81 , 83 , 84 , 85 , 87 , 88 , 90 , 91 , 92 , 94 , 95 , 97 , 98 , 100 , 101 , 103 , 104 , 105 , 107 , 108 , 110 , 111 , 113 , 115 , 116 , 118 , 119 , 121 , 122 , 124 , 125 , 127 , 129 , 130 , 132 , 133 , 135 , 137 , 138 , 140 , 141 , 143 , 145 , 146 , 148 , 150 , 151 , 153 , 155 , 157 , 158 , 160 , 162 , 163 , 165 , 167 , 169 , 171 , 172 , 174 , 176 , 178 , 180 , 181 , 183 , 185 , 187 , 189 , 191 , 192 , 194 , 196 , 198 , 200 , 202 , 204 , 206 , 208 , 210 , 212 , 214 , 216 , 218 , 220 , 222 , 224 , 226 , 228 , 230 , 232 , 234 , 236 , 238 , 240 , 242 , 244 , 246 , 249 , 251 , 253 , 255 , 257 , 259 , 261 , 264 , 266 , 268 , 270 , 273 , 275 , 277 , 279 , 282 , 284 , 286 , 289 , 291 , 293 , 296 , 298 , 300 , 303 , 305 , 307 , 310 , 312 , 315 , 317 , 320 , 322 , 324 , 327 , 329 , 332 , 334 , 337 , 340 , 342 , 345 , 347 , 350 , 352 , 355 , 358 , 360 , 363 , 366 , 368 , 371 , 374 , 376 , 379 , 382 , 385 , 387 , 390 , 393 , 396 , 398 , 401 , 404 , 407 , 410 , 413 , 416 , 419 , 421 , 424 , 427 , 430 , 433 , 436 , 439 , 442 , 445 , 448 , 451 , 454 , 457 , 461 , 464 , 467 , 470 , 473 , 476 , 479 , 483 };
00064
00065
00066
00067
00068
00069
00070
00071 const int CSCTFPtLUT::dEtaCut_Low[24] = {2,2,2,7,2,1,2,7,3,3,3,7,1,1,1,1,2,2,2,2,1,1,1,1};
00072 const int CSCTFPtLUT::dEtaCut_Mid[24] = {2,2,3,7,2,2,3,7,4,4,4,7,2,2,2,2,2,2,2,2,2,2,2,2};
00073 const int CSCTFPtLUT::dEtaCut_High_A[24] = {3,3,4,7,3,2,4,7,5,5,5,7,2,2,2,2,3,3,3,3,2,2,2,2};
00074 const int CSCTFPtLUT::dEtaCut_High_B[24] = {3,3,4,7,3,3,5,7,6,6,6,7,2,2,3,3,3,3,3,3,3,3,3,2};
00075 const int CSCTFPtLUT::dEtaCut_High_C[24] = {4,4,5,7,4,3,6,7,7,7,7,7,3,3,3,3,4,4,4,4,3,3,3,3};
00076 const int CSCTFPtLUT::dEtaCut_Open[24] = {7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7};
00077
00078 const int CSCTFPtLUT::getPtbyMLH = 0xFFFF;
00079
00080
00081 CSCTFPtLUT::CSCTFPtLUT(const edm::EventSetup& es)
00082 : read_pt_lut(true),
00083 isBinary(false)
00084 {
00085 pt_method = 29;
00086
00087 lowQualityFlag = 4;
00088 isBeamStartConf = true;
00089 pt_lut = new ptdat[1<<21];
00090
00091 edm::ESHandle<L1MuCSCPtLut> ptLUT;
00092 es.get<L1MuCSCPtLutRcd>().get(ptLUT);
00093 const L1MuCSCPtLut *myConfigPt_ = ptLUT.product();
00094
00095 memcpy((void*)pt_lut,(void*)myConfigPt_->lut(),(1<<21)*sizeof(ptdat));
00096
00097 lut_read_in = true;
00098
00099 edm::ESHandle< L1MuTriggerScales > scales ;
00100 es.get< L1MuTriggerScalesRcd >().get( scales ) ;
00101 trigger_scale = scales.product() ;
00102
00103 edm::ESHandle< L1MuTriggerPtScale > ptScale ;
00104 es.get< L1MuTriggerPtScaleRcd >().get( ptScale ) ;
00105 trigger_ptscale = ptScale.product() ;
00106
00107 ptMethods = CSCTFPtMethods( ptScale.product() ) ;
00108
00109 }
00111
00112 CSCTFPtLUT::CSCTFPtLUT(const edm::ParameterSet& pset,
00113 const L1MuTriggerScales* scales,
00114 const L1MuTriggerPtScale* ptScale)
00115 : trigger_scale( scales ),
00116 trigger_ptscale( ptScale ),
00117 ptMethods( ptScale ),
00118 read_pt_lut(false),
00119 isBinary(false)
00120 {
00121
00122 read_pt_lut = pset.getParameter<bool>("ReadPtLUT");
00123 if(read_pt_lut)
00124 {
00125 pt_lut_file = pset.getParameter<edm::FileInPath>("PtLUTFile");
00126
00127 isBinary = pset.getParameter<bool>("isBinary");
00128
00129 edm::LogInfo("CSCTFPtLUT::CSCTFPtLUT") << "Reading file: "
00130 << pt_lut_file.fullPath().c_str()
00131 << " isBinary?(1/0): "
00132 << isBinary;
00133 }
00134
00135
00136
00137
00138
00139
00140
00141
00142
00143
00144
00145
00146
00147
00148
00149
00150
00151
00152
00153
00154
00155
00156
00157
00158
00159
00160
00161
00162 pt_method = pset.getUntrackedParameter<unsigned>("PtMethod",29);
00163
00164
00165 lowQualityFlag = pset.getUntrackedParameter<unsigned>("LowQualityFlag",4);
00166
00167 if(read_pt_lut && !lut_read_in)
00168 {
00169 pt_lut = new ptdat[1<<21];
00170 readLUT();
00171 lut_read_in = true;
00172 }
00173
00174 isBeamStartConf = pset.getUntrackedParameter<bool>("isBeamStartConf", true);
00175
00176 }
00177
00178 ptdat CSCTFPtLUT::Pt(const ptadd& address) const
00179 {
00180 ptdat result;
00181 if(read_pt_lut)
00182 {
00183 int shortAdd = (address.toint()& 0x1fffff);
00184 result = pt_lut[shortAdd];
00185 } else
00186 result = calcPt(address);
00187 return result;
00188 }
00189
00190 ptdat CSCTFPtLUT::Pt(const unsigned& address) const
00191 {
00192 return Pt(ptadd(address));
00193 }
00194
00195 ptdat CSCTFPtLUT::Pt(const unsigned& delta_phi_12, const unsigned& delta_phi_23,
00196 const unsigned& track_eta, const unsigned& track_mode,
00197 const unsigned& track_fr, const unsigned& delta_phi_sign) const
00198 {
00199 ptadd address;
00200 address.delta_phi_12 = delta_phi_12;
00201 address.delta_phi_23 = delta_phi_23;
00202 address.track_eta = track_eta;
00203 address.track_mode = track_mode;
00204 address.track_fr = track_fr;
00205 address.delta_phi_sign = delta_phi_sign;
00206
00207 return Pt(address);
00208 }
00209
00210 ptdat CSCTFPtLUT::Pt(const unsigned& delta_phi_12, const unsigned& track_eta,
00211 const unsigned& track_mode, const unsigned& track_fr,
00212 const unsigned& delta_phi_sign) const
00213 {
00214 ptadd address;
00215 address.delta_phi_12 = ((1<<8)-1)&delta_phi_12;
00216 address.delta_phi_23 = ((1<<4)-1)&(delta_phi_12>>8);
00217 address.track_eta = track_eta;
00218 address.track_mode = track_mode;
00219 address.track_fr = track_fr;
00220 address.delta_phi_sign = delta_phi_sign;
00221
00222 return Pt(address);
00223 }
00224
00225
00226 ptdat CSCTFPtLUT::calcPt(const ptadd& address) const
00227 {
00228 ptdat result;
00229
00230 double Pi = acos(-1.);
00231 float etaR = 0, ptR_front = 0, ptR_rear = 0, dphi12R = 0, dphi23R = 0;
00232 int charge12, charge23;
00233 unsigned type, mode, eta, fr, quality, charge, absPhi12, absPhi23;
00234
00235 mode = address.track_mode;
00236
00237 int usedetaCUT = true;
00238
00239
00240
00241 int EtaCutLevel_1 = 2;
00242 int dEtaCut_1[24];
00243
00244 for (int i=0;i<24;i++)
00245 {
00246 dEtaCut_1[i] = 10;
00247 if (EtaCutLevel_1 == 1)
00248 dEtaCut_1[i] = dEtaCut_Low[i];
00249 else if (EtaCutLevel_1 == 2)
00250 dEtaCut_1[i] = dEtaCut_Mid[i];
00251 else if (EtaCutLevel_1 == 3)
00252 dEtaCut_1[i] = dEtaCut_High_A[i];
00253 else if (EtaCutLevel_1 == 4)
00254 dEtaCut_1[i] = dEtaCut_High_B[i];
00255 else if (EtaCutLevel_1 == 5)
00256 dEtaCut_1[i] = dEtaCut_High_C[i];
00257 else if (EtaCutLevel_1 == 6)
00258 dEtaCut_1[i] = dEtaCut_Open[i];
00259 }
00260
00261 int EtaCutLevel_2 = 2;
00262 int dEtaCut_2[24];
00263
00264 for (int i=0;i<24;i++)
00265 {
00266 dEtaCut_2[i] = 10;
00267 if (EtaCutLevel_2 == 1)
00268 dEtaCut_2[i] = dEtaCut_Low[i];
00269 else if (EtaCutLevel_2 == 2)
00270 dEtaCut_2[i] = dEtaCut_Mid[i];
00271 else if (EtaCutLevel_2 == 3)
00272 dEtaCut_2[i] = dEtaCut_High_A[i];
00273 else if (EtaCutLevel_2 == 4)
00274 dEtaCut_2[i] = dEtaCut_High_B[i];
00275 else if (EtaCutLevel_2 == 5)
00276 dEtaCut_2[i] = dEtaCut_High_C[i];
00277 else if (EtaCutLevel_2 == 6)
00278 dEtaCut_2[i] = dEtaCut_Open[i];
00279
00280 float scalef = 1.0;
00281 if (mode == 8 || mode == 10)
00282 dEtaCut_2[i] = scalef*dEtaCut_2[i];
00283
00284 }
00285
00286
00287
00288 eta = address.track_eta;
00289
00290 fr = address.track_fr;
00291 charge = address.delta_phi_sign;
00292 quality = trackQuality(eta, mode, fr);
00293 unsigned front_pt, rear_pt;
00294 front_pt = 0.; rear_pt = 0.;
00295 unsigned front_quality, rear_quality;
00296
00297 etaR = trigger_scale->getRegionalEtaScale(2)->getLowEdge(2*eta+1);
00298
00299 front_quality = rear_quality = quality;
00300
00301 unsigned int remerged;
00302 int iME11;
00303 int CLCT_pattern;
00304 int dEta;
00305 int index = 0;
00306 float bestLH = -999;
00307 float bestLH_front = -999.0;
00308 float bestLH_rear = -999.0;
00309
00310 int PtbyMLH = false;
00311
00312
00313 if(pt_method >= 29 && pt_method <= 31)
00314 {
00315
00316 PtbyMLH = 0x1 & (getPtbyMLH >> (int)mode);
00318
00319 if(etaR > 2.1){
00320 usedetaCUT = false;
00321 PtbyMLH = 0x0;
00322 }
00324
00325 switch(mode)
00326 {
00327 case 2:
00328 case 3:
00329 case 4:
00330 case 5:
00331
00332
00333 charge12 = 1;
00334
00335
00336 remerged = (address.delta_phi_12 | (address.delta_phi_23 << 8 ) );
00337
00338
00339 absPhi12 = ((1<<7)-1) & remerged;
00340 absPhi23 = ((1<<5)-1) & (remerged >> 7);
00341
00342
00343 absPhi12 = dPhiNLBMap_7bit[absPhi12];
00344 absPhi23 = dPhiNLBMap_5bit[absPhi23];
00345
00346 if(charge) charge23 = 1;
00347 else charge23 = -1;
00348
00349 dphi12R = (static_cast<float>(absPhi12)) / (static_cast<float>(1<<12)) * CSCTFConstants::SECTOR_RAD;
00350 dphi23R = (static_cast<float>(absPhi23)) / (static_cast<float>(1<<12)) * CSCTFConstants::SECTOR_RAD;
00351 if(charge12 * charge23 < 0) dphi23R = -dphi23R;
00352
00353 ptR_front = ptMethods.Pt3Stn2012(int(mode), etaR, dphi12R, dphi23R, PtbyMLH, bestLH, 1, int(pt_method));
00354 bestLH_front = bestLH;
00355 ptR_rear = ptMethods.Pt3Stn2012(int(mode), etaR, dphi12R, dphi23R, PtbyMLH, bestLH, 0, int(pt_method));
00356 bestLH_rear = bestLH;
00357
00358 if((pt_method == 29 || pt_method == 30 || pt_method == 31) && mode != 5 && etaR > 2.1)
00359 {
00360 float dphi12Rmin = dphi12R - Pi*10/180/3;
00361 float dphi12Rmax = dphi12R + Pi*10/180/3;
00362 float dphi23Rmin = dphi23R;
00363 float dphi23Rmax = dphi23R;
00364
00365
00366 float ptR_front_min = ptMethods.Pt3Stn2012(int(mode), etaR, dphi12Rmin, dphi23Rmin, PtbyMLH, bestLH, 1, int(pt_method));
00367 float bestLH_front_min = bestLH;
00368 float ptR_rear_min = ptMethods.Pt3Stn2012(int(mode), etaR, dphi12Rmin, dphi23Rmin, PtbyMLH, bestLH, 0, int(pt_method));
00369 float bestLH_rear_min = bestLH;
00370 float ptR_front_max = ptMethods.Pt3Stn2012(int(mode), etaR, dphi12Rmax, dphi23Rmax, PtbyMLH, bestLH, 1, int(pt_method));
00371 float bestLH_front_max = bestLH;
00372 float ptR_rear_max = ptMethods.Pt3Stn2012(int(mode), etaR, dphi12Rmax, dphi23Rmax, PtbyMLH, bestLH, 0, int(pt_method));
00373 float bestLH_rear_max = bestLH;
00374
00375 if (PtbyMLH)
00376 {
00377 float best_pt_front = ptR_front;
00378 float best_LH_front = bestLH_front;
00379 if (bestLH_front_min > best_LH_front)
00380 {
00381 best_pt_front = ptR_front_min;
00382 best_LH_front = bestLH_front_min;
00383 }
00384 if (bestLH_front_max > best_LH_front)
00385 {
00386 best_pt_front = ptR_front_max;
00387 best_LH_front = bestLH_front_max;
00388 }
00389 ptR_front = best_pt_front;
00390
00391 float best_pt_rear = ptR_rear;
00392 float best_LH_rear = bestLH_rear;
00393 if (bestLH_rear_min > best_LH_rear)
00394 {
00395 best_pt_rear = ptR_rear_min;
00396 best_LH_rear = bestLH_rear_min;
00397 }
00398 if (bestLH_rear_max > best_LH_rear)
00399 {
00400 best_pt_rear = ptR_rear_max;
00401 best_LH_rear = bestLH_rear_max;
00402 }
00403 ptR_rear = best_pt_rear;
00404 }
00405 else
00406 {
00407
00408 ptR_front = std::max(ptR_front, ptR_front_min);
00409 ptR_front = std::max(ptR_front, ptR_front_max);
00410 ptR_rear = std::max(ptR_rear, ptR_rear_min);
00411 ptR_rear = std::max(ptR_rear, ptR_rear_max);
00412 }
00413 }
00414 break;
00415 case 6:
00416 case 7:
00417 case 13:
00418
00419
00420 remerged = (address.delta_phi_12 | (address.delta_phi_23 << 8 ) );
00421
00422 absPhi12 = ((1<<8)-1) & remerged;
00423
00424 dEta = ((1<<3)-1) & (remerged >> 8);
00425
00426 CLCT_pattern = 0x1 & (remerged >> 11);
00427
00428 iME11 = int(charge);
00429 if(iME11 == 1 && etaR > 1.6) etaR = 1.55;
00430 if(iME11 == 0 && etaR < 1.6) etaR = 1.65;
00431
00432
00433 absPhi12 = ((1<<8)-1) & address.delta_phi_12;
00434
00435
00436 absPhi12 = dPhiNLBMap_8bit[absPhi12];
00437
00438
00439
00440 dphi12R = (static_cast<float>(absPhi12)) / (static_cast<float>(1<<12)) * CSCTFConstants::SECTOR_RAD;
00441
00442
00443 ptR_front = ptMethods.Pt2Stn2012(int(mode), etaR, dphi12R, PtbyMLH, bestLH, 1, int(pt_method));
00444 bestLH_front = bestLH;
00445 ptR_rear = ptMethods.Pt2Stn2012(int(mode), etaR, dphi12R, PtbyMLH, bestLH, 0, int(pt_method));
00446 bestLH_rear = bestLH;
00447 if((pt_method == 29 || pt_method == 30 || pt_method == 31) && etaR > 2.1)
00448 {
00449 float dphi12Rmin = fabs(fabs(dphi12R) - Pi*10/180/3);
00450 float ptR_front_min = ptMethods.Pt2Stn2012(int(mode), etaR, dphi12Rmin, PtbyMLH, bestLH, 1, int(pt_method));
00451 float bestLH_front_min = bestLH;
00452 float ptR_rear_min = ptMethods.Pt2Stn2012(int(mode), etaR, dphi12Rmin, PtbyMLH, bestLH, 0, int(pt_method));
00453 float bestLH_rear_min = bestLH;
00454
00455 if (PtbyMLH)
00456 {
00457 ptR_front = bestLH_front > bestLH_front_min ? ptR_front : ptR_front_min;
00458 ptR_rear = bestLH_rear > bestLH_rear_min ? ptR_rear : ptR_rear_min;
00459 }
00460 else
00461 {
00462
00463 ptR_front = std::max(ptR_front, ptR_front_min);
00464 ptR_rear = std::max(ptR_rear, ptR_rear_min);
00465 }
00466 }
00467
00468 if( (!CLCT_pattern) && (ptR_front > 5.)) ptR_front = 5.;
00469 if( (!CLCT_pattern) && (ptR_rear > 5.)) ptR_rear = 5.;
00470
00471
00472 index = 0;
00473 if (mode == 6) index = 0;
00474 if (mode == 7) index = 4;
00475 if (mode == 13) index = 8;
00476
00477 if (usedetaCUT)
00478 {
00479 if (fabs(etaR)>1.2 && fabs(etaR)<=1.5)
00480 if (dEta>dEtaCut_1[index+0] )
00481 {
00482 if (ptR_front > 5) ptR_front = 5;
00483 if (ptR_rear > 5) ptR_rear = 5;
00484 }
00485 if (fabs(etaR)>1.5 && fabs(etaR)<=1.65)
00486 if (dEta>dEtaCut_1[index+1])
00487 {
00488 if (ptR_front > 5) ptR_front = 5;
00489 if (ptR_rear > 5) ptR_rear = 5;
00490 }
00491
00492 if (fabs(etaR)>1.65 && fabs(etaR)<=2.1)
00493 if (dEta>dEtaCut_1[index+2] )
00494 {
00495 if (ptR_front > 5) ptR_front = 5;
00496 if (ptR_rear > 5) ptR_rear = 5;
00497 }
00498 if (fabs(etaR)>2.1)
00499 if (dEta>dEtaCut_1[index+3] )
00500 {
00501 if (ptR_front > 5) ptR_front = 5;
00502 if (ptR_rear > 5) ptR_rear = 5;
00503 }
00504 }
00505
00506 break;
00507
00508 case 8:
00509 case 9:
00510 case 10:
00511
00512
00513
00514 remerged = (address.delta_phi_12 | (address.delta_phi_23 << 8 ) );
00515
00516 absPhi12 = ((1<<9)-1) & remerged;
00517
00518 dEta = ((1<<3)-1) & (remerged >> 9);
00519
00520 dphi12R = (static_cast<float>(absPhi12)) / (static_cast<float>(1<<12)) * CSCTFConstants::SECTOR_RAD;
00521
00522
00523 ptR_front = ptMethods.Pt2Stn2012(int(mode), etaR, dphi12R, PtbyMLH, bestLH, 1, int(pt_method));
00524 ptR_rear = ptMethods.Pt2Stn2012(int(mode), etaR, dphi12R, PtbyMLH, bestLH, 0, int(pt_method));
00525
00526 index = 0;
00527 if (mode == 8) index = 12;
00528 if (mode == 9) index = 16;
00529 if (mode == 10) index = 20;
00530
00531
00532
00533
00534 if (usedetaCUT)
00535 {
00536 if (fabs(etaR)>1.2 && fabs(etaR)<=1.5)
00537 if (dEta>dEtaCut_2[index+0] )
00538 {
00539 if (ptR_front > 5) ptR_front = 5;
00540 if (ptR_rear > 5) ptR_rear = 5;
00541 }
00542 if (fabs(etaR)>1.5 && fabs(etaR)<=1.65)
00543 if (dEta>dEtaCut_2[index+1])
00544 {
00545 if (ptR_front > 5) ptR_front = 5;
00546 if (ptR_rear > 5) ptR_rear = 5;
00547 }
00548
00549 if (fabs(etaR)>1.65 && fabs(etaR)<=2.1)
00550 if (dEta>dEtaCut_2[index+2] )
00551 {
00552 if (ptR_front > 5) ptR_front = 5;
00553 if (ptR_rear > 5) ptR_rear = 5;
00554 }
00555 if (fabs(etaR)>2.1)
00556 if (dEta>dEtaCut_2[index+3] )
00557 {
00558 if (ptR_front > 5) ptR_front = 5;
00559 if (ptR_rear > 5) ptR_rear = 5;
00560 }
00561 }
00562
00563 break;
00564
00565 case 11:
00566 case 12:
00567 case 14:
00568
00569
00570
00571
00572
00573
00574 charge12 = 1;
00575
00576
00577 absPhi12 = address.delta_phi_12;
00578 absPhi23 = address.delta_phi_23;
00579
00580 if(charge) charge23 = -1;
00581 else charge23 = 1;
00582
00583 dphi12R = (static_cast<float>(absPhi12<<1)) / (static_cast<float>(1<<12)) * CSCTFConstants::SECTOR_RAD;
00584 dphi23R = float(absPhi23);
00585 if(charge12 * charge23 < 0) dphi23R = -dphi23R;
00586
00587 int mode1;
00588 mode1 = int(mode);
00589 if(fr == 1 && mode1 == 11) mode1 = 14;
00590
00591 ptR_front = ptMethods.Pt3Stn2012_DT(mode1, etaR, dphi12R, dphi23R, PtbyMLH, bestLH, int(0), int(pt_method));
00592 ptR_rear = ptMethods.Pt3Stn2012_DT(mode1, etaR, dphi12R, dphi23R, PtbyMLH, bestLH, int(0), int(pt_method));
00593
00594 break;
00595 case 15:
00596 case 1:
00597 ptR_front = trigger_ptscale->getPtScale()->getLowEdge(3);
00598 ptR_rear = trigger_ptscale->getPtScale()->getLowEdge(3);
00599 break;
00600 default:
00601 ptR_front = trigger_ptscale->getPtScale()->getLowEdge(0);
00602 ptR_rear = trigger_ptscale->getPtScale()->getLowEdge(0);
00603 };
00604
00605 front_pt = trigger_ptscale->getPtScale()->getPacked(ptR_front);
00606 rear_pt = trigger_ptscale->getPtScale()->getPacked(ptR_rear);
00607
00608 }
00609
00610
00611
00612 if(pt_method >= 23 && pt_method <= 28){
00613
00614
00615
00616
00617
00618 switch(mode)
00619 {
00620 case 2:
00621 case 3:
00622 case 4:
00623 case 5:
00624
00625 charge12 = 1;
00626 absPhi12 = address.delta_phi_12;
00627 absPhi23 = address.delta_phi_23;
00628
00629 if(charge) charge23 = 1;
00630 else charge23 = -1;
00631
00632 dphi12R = (static_cast<float>(absPhi12<<1)) / (static_cast<float>(1<<12)) * CSCTFConstants::SECTOR_RAD;
00633 dphi23R = (static_cast<float>(absPhi23<<4)) / (static_cast<float>(1<<12)) * CSCTFConstants::SECTOR_RAD;
00634 if(charge12 * charge23 < 0) dphi23R = -dphi23R;
00635
00636 ptR_front = ptMethods.Pt3Stn2010(int(mode), etaR, dphi12R, dphi23R, 1, int(pt_method));
00637 ptR_rear = ptMethods.Pt3Stn2010(int(mode), etaR, dphi12R, dphi23R, 0, int(pt_method));
00638
00639 if((pt_method == 24 || pt_method == 26 || pt_method == 28) && mode != 5 && etaR > 2.1)
00640 {
00641 float dphi12Rmin = dphi12R - Pi*10/180/3;
00642 float dphi12Rmax = dphi12R + Pi*10/180/3;
00643 float dphi23Rmin = dphi23R;
00644 float dphi23Rmax = dphi23R;
00645
00646
00647 float ptR_front_min = ptMethods.Pt3Stn2010(int(mode), etaR, dphi12Rmin, dphi23Rmin, 1, int(pt_method));
00648 float ptR_rear_min = ptMethods.Pt3Stn2010(int(mode), etaR, dphi12Rmin, dphi23Rmin, 0, int(pt_method));
00649 float ptR_front_max = ptMethods.Pt3Stn2010(int(mode), etaR, dphi12Rmax, dphi23Rmax, 1, int(pt_method));
00650 float ptR_rear_max = ptMethods.Pt3Stn2010(int(mode), etaR, dphi12Rmax, dphi23Rmax, 0, int(pt_method));
00651
00652 ptR_front = std::max(ptR_front, ptR_front_min);
00653 ptR_front = std::max(ptR_front, ptR_front_max);
00654 ptR_rear = std::max(ptR_rear, ptR_rear_min);
00655 ptR_rear = std::max(ptR_rear, ptR_rear_max);
00656 }
00657 break;
00658 case 6:
00659 case 7:
00660 case 13:
00661 int iME11;
00662 iME11 = int(charge);
00663 if(iME11 == 1 && etaR > 1.6) etaR = 1.55;
00664 if(iME11 == 0 && etaR < 1.6) etaR = 1.65;
00665 absPhi12 = address.delta_phi_12;
00666
00667 int CLCT_pattern;
00668 CLCT_pattern = int(address.delta_phi_23);
00669 dphi12R = (static_cast<float>(absPhi12<<1)) / (static_cast<float>(1<<12)) * CSCTFConstants::SECTOR_RAD;
00670
00671
00672 ptR_front = ptMethods.Pt2Stn2010(int(mode), etaR, dphi12R, 1, int(pt_method));
00673 ptR_rear = ptMethods.Pt2Stn2010(int(mode), etaR, dphi12R, 0, int(pt_method));
00674 if((pt_method == 24 || pt_method == 26 || pt_method == 28) && etaR > 2.1)
00675 {
00676 float dphi12Rmin = fabs(fabs(dphi12R) - Pi*10/180/3);
00677 float ptR_front_min = ptMethods.Pt2Stn2010(int(mode), etaR, dphi12Rmin, 1, int(pt_method));
00678 float ptR_rear_min = ptMethods.Pt2Stn2010(int(mode), etaR, dphi12Rmin, 0, int(pt_method));
00679
00680 ptR_front = std::max(ptR_front, ptR_front_min);
00681 ptR_rear = std::max(ptR_rear, ptR_rear_min);
00682 }
00683 if( ((CLCT_pattern < 8) || (CLCT_pattern > 10)) && (ptR_front > 5.)) ptR_front = 5.;
00684 if( ((CLCT_pattern < 8) || (CLCT_pattern > 10)) && (ptR_rear > 5.)) ptR_rear = 5.;
00685
00686
00687 break;
00688 case 8:
00689 case 9:
00690 case 10:
00691 if(charge) absPhi12 = address.delta_phi();
00692 else
00693 {
00694 int temp_phi = address.delta_phi();
00695 absPhi12 = static_cast<unsigned>(-temp_phi) & 0xfff;
00696 }
00697
00698 dphi12R = (static_cast<float>(absPhi12)) / (static_cast<float>(1<<12)) * CSCTFConstants::SECTOR_RAD;
00699
00700
00701 ptR_front = ptMethods.Pt2Stn2010(int(mode), etaR, dphi12R, 1, int(pt_method));
00702 ptR_rear = ptMethods.Pt2Stn2010(int(mode), etaR, dphi12R, 0, int(pt_method));
00703
00704 break;
00705
00706 case 11:
00707 case 12:
00708 case 14:
00709
00710
00711
00712
00713
00714 charge12 = 1;
00715 absPhi12 = address.delta_phi_12;
00716 absPhi23 = address.delta_phi_23;
00717
00718 if(charge) charge23 = -1;
00719 else charge23 = 1;
00720
00721 dphi12R = (static_cast<float>(absPhi12<<1)) / (static_cast<float>(1<<12)) * CSCTFConstants::SECTOR_RAD;
00722 dphi23R = float(absPhi23);
00723 if(charge12 * charge23 < 0) dphi23R = -dphi23R;
00724
00725 int mode1;
00726 mode1 = int(mode);
00727 if(fr == 1 && mode1 == 11) mode1 = 14;
00728
00729 ptR_front = ptMethods.Pt3Stn2011(mode1, etaR, dphi12R, dphi23R, int(0), int(pt_method));
00730 ptR_rear = ptMethods.Pt3Stn2011(mode1, etaR, dphi12R, dphi23R, int(0), int(pt_method));
00731
00732 break;
00733 case 15:
00734 case 1:
00735 ptR_front = trigger_ptscale->getPtScale()->getLowEdge(3);
00736 ptR_rear = trigger_ptscale->getPtScale()->getLowEdge(3);
00737 break;
00738 default:
00739 ptR_front = trigger_ptscale->getPtScale()->getLowEdge(0);
00740 ptR_rear = trigger_ptscale->getPtScale()->getLowEdge(0);
00741 };
00742
00743 front_pt = trigger_ptscale->getPtScale()->getPacked(ptR_front);
00744 rear_pt = trigger_ptscale->getPtScale()->getPacked(ptR_rear);
00745
00746 }
00747
00748
00749
00750 if(pt_method == 21 || pt_method == 22){
00751
00752
00753
00754
00755 switch(mode)
00756 {
00757 case 2:
00758 case 3:
00759 case 4:
00760 case 5:
00761
00762 charge12 = 1;
00763 absPhi12 = address.delta_phi_12;
00764 absPhi23 = address.delta_phi_23;
00765
00766 if(charge) charge23 = 1;
00767 else charge23 = -1;
00768
00769 dphi12R = (static_cast<float>(absPhi12<<1)) / (static_cast<float>(1<<12)) * CSCTFConstants::SECTOR_RAD;
00770 dphi23R = (static_cast<float>(absPhi23<<4)) / (static_cast<float>(1<<12)) * CSCTFConstants::SECTOR_RAD;
00771 if(charge12 * charge23 < 0) dphi23R = -dphi23R;
00772
00773 ptR_front = ptMethods.Pt3Stn2011(int(mode), etaR, dphi12R, dphi23R, 1, int(pt_method));
00774 ptR_rear = ptMethods.Pt3Stn2011(int(mode), etaR, dphi12R, dphi23R, 0, int(pt_method));
00775
00776 if(pt_method == 22 && mode != 5 && etaR > 2.1)
00777 {
00778 float dphi12Rmin = dphi12R - Pi*10/180/3;
00779 float dphi12Rmax = dphi12R + Pi*10/180/3;
00780 float dphi23Rmin = dphi23R;
00781 float dphi23Rmax = dphi23R;
00782
00783
00784 float ptR_front_min = ptMethods.Pt3Stn2011(int(mode), etaR, dphi12Rmin, dphi23Rmin, 1, int(pt_method));
00785 float ptR_rear_min = ptMethods.Pt3Stn2011(int(mode), etaR, dphi12Rmin, dphi23Rmin, 0, int(pt_method));
00786 float ptR_front_max = ptMethods.Pt3Stn2011(int(mode), etaR, dphi12Rmax, dphi23Rmax, 1, int(pt_method));
00787 float ptR_rear_max = ptMethods.Pt3Stn2011(int(mode), etaR, dphi12Rmax, dphi23Rmax, 0, int(pt_method));
00788
00789 ptR_front = std::max(ptR_front, ptR_front_min);
00790 ptR_front = std::max(ptR_front, ptR_front_max);
00791 ptR_rear = std::max(ptR_rear, ptR_rear_min);
00792 ptR_rear = std::max(ptR_rear, ptR_rear_max);
00793 }
00794 break;
00795 case 6:
00796 case 7:
00797 case 13:
00798 int iME11;
00799 iME11 = int(charge);
00800 absPhi12 = address.delta_phi_12;
00801
00802 int CLCT_pattern;
00803 CLCT_pattern = int(address.delta_phi_23);
00804
00805 dphi12R = (static_cast<float>(absPhi12<<1)) / (static_cast<float>(1<<12)) * CSCTFConstants::SECTOR_RAD;
00806
00807
00808 ptR_front = ptMethods.Pt2Stn2011(int(mode), etaR, dphi12R, 1, int(pt_method), iME11);
00809 ptR_rear = ptMethods.Pt2Stn2011(int(mode), etaR, dphi12R, 0, int(pt_method), iME11);
00810 if((pt_method == 22) && etaR > 2.1)
00811 {
00812 float dphi12Rmin = fabs(fabs(dphi12R) - Pi*10/180/3);
00813 float ptR_front_min = ptMethods.Pt2Stn2011(int(mode), etaR, dphi12Rmin, 1, int(pt_method), iME11);
00814 float ptR_rear_min = ptMethods.Pt2Stn2011(int(mode), etaR, dphi12Rmin, 0, int(pt_method), iME11);
00815
00816 ptR_front = std::max(ptR_front, ptR_front_min);
00817 ptR_rear = std::max(ptR_rear, ptR_rear_min);
00818 }
00819 if( ((CLCT_pattern < 8) || (CLCT_pattern > 10)) && (ptR_front > 5.)) ptR_front = 5.;
00820 if( ((CLCT_pattern < 8) || (CLCT_pattern > 10)) && (ptR_rear > 5.)) ptR_rear = 5.;
00821
00822 break;
00823 case 8:
00824 case 9:
00825 case 10:
00826 if(charge) absPhi12 = address.delta_phi();
00827 else
00828 {
00829 int temp_phi = address.delta_phi();
00830 absPhi12 = static_cast<unsigned>(-temp_phi) & 0xfff;
00831 }
00832
00833 dphi12R = (static_cast<float>(absPhi12)) / (static_cast<float>(1<<12)) * CSCTFConstants::SECTOR_RAD;
00834
00835
00836 ptR_front = ptMethods.Pt2Stn2011(int(mode), etaR, dphi12R, 1, int(pt_method), int(2));
00837 ptR_rear = ptMethods.Pt2Stn2011(int(mode), etaR, dphi12R, 0, int(pt_method), int(2));
00838
00839 break;
00840 case 11:
00841 case 12:
00842 case 14:
00843
00844
00845
00846
00847
00848 charge12 = 1;
00849 absPhi12 = address.delta_phi_12;
00850 absPhi23 = address.delta_phi_23;
00851
00852 if(charge) charge23 = -1;
00853 else charge23 = 1;
00854
00855 dphi12R = (static_cast<float>(absPhi12<<1)) / (static_cast<float>(1<<12)) * CSCTFConstants::SECTOR_RAD;
00856 dphi23R = float(absPhi23);
00857 if(charge12 * charge23 < 0) dphi23R = -dphi23R;
00858
00859 int mode1;
00860 mode1 = int(mode);
00861 if(fr == 1 && mode1 == 11) mode1 = 14;
00862
00863 ptR_front = ptMethods.Pt3Stn2011(mode1, etaR, dphi12R, dphi23R, int(0), int(pt_method));
00864 ptR_rear = ptMethods.Pt3Stn2011(mode1, etaR, dphi12R, dphi23R, int(0), int(pt_method));
00865
00866 break;
00867 case 15:
00868 case 1:
00869 ptR_front = trigger_ptscale->getPtScale()->getLowEdge(3);
00870 ptR_rear = trigger_ptscale->getPtScale()->getLowEdge(3);
00871 break;
00872 default:
00873 ptR_front = trigger_ptscale->getPtScale()->getLowEdge(0);
00874 ptR_rear = trigger_ptscale->getPtScale()->getLowEdge(0);
00875 };
00876
00877 front_pt = trigger_ptscale->getPtScale()->getPacked(ptR_front);
00878 rear_pt = trigger_ptscale->getPtScale()->getPacked(ptR_rear);
00879
00880 }
00881
00882
00883
00884 if(pt_method >= 11 && pt_method < 20){
00885
00886
00887
00888
00889 switch(mode)
00890 {
00891 case 2:
00892 case 3:
00893 case 4:
00894 case 5:
00895
00896 charge12 = 1;
00897 absPhi12 = address.delta_phi_12;
00898 absPhi23 = address.delta_phi_23;
00899
00900 if(charge) charge23 = 1;
00901 else charge23 = -1;
00902
00903 dphi12R = (static_cast<float>(absPhi12<<1)) / (static_cast<float>(1<<12)) * CSCTFConstants::SECTOR_RAD;
00904 dphi23R = (static_cast<float>(absPhi23<<4)) / (static_cast<float>(1<<12)) * CSCTFConstants::SECTOR_RAD;
00905 if(charge12 * charge23 < 0) dphi23R = -dphi23R;
00906
00907 ptR_front = ptMethods.Pt3Stn2010(mode, etaR, dphi12R, dphi23R, 1, int(pt_method));
00908 ptR_rear = ptMethods.Pt3Stn2010(mode, etaR, dphi12R, dphi23R, 0, int(pt_method));
00909
00910 if(pt_method == 12 && mode != 5 && etaR > 2.1)
00911 {
00912 float dphi12Rmin = dphi12R - Pi*10/180/3;
00913 float dphi12Rmax = dphi12R + Pi*10/180/3;
00914 float dphi23Rmin = dphi23R;
00915 float dphi23Rmax = dphi23R;
00916 if(dphi12Rmin*dphi12R < 0) dphi23Rmin = -dphi23R;
00917 if(dphi12Rmax*dphi12R < 0) dphi23Rmax = -dphi23R;
00918 float ptR_front_min = ptMethods.Pt3Stn2010(mode, etaR, dphi12Rmin, dphi23Rmin, 1, int(pt_method));
00919 float ptR_rear_min = ptMethods.Pt3Stn2010(mode, etaR, dphi12Rmin, dphi23Rmin, 0, int(pt_method));
00920 float ptR_front_max = ptMethods.Pt3Stn2010(mode, etaR, dphi12Rmax, dphi23Rmax, 1, int(pt_method));
00921 float ptR_rear_max = ptMethods.Pt3Stn2010(mode, etaR, dphi12Rmax, dphi23Rmax, 0, int(pt_method));
00922
00923 ptR_front = std::max(ptR_front, ptR_front_min);
00924 ptR_front = std::max(ptR_front, ptR_front_max);
00925 ptR_rear = std::max(ptR_rear, ptR_rear_min);
00926 ptR_rear = std::max(ptR_rear, ptR_rear_max);
00927 }
00928 break;
00929 case 6:
00930 case 7:
00931 case 8:
00932 case 9:
00933 case 10:
00934 case 13:
00935 type = mode - 5;
00936
00937 if(charge) absPhi12 = address.delta_phi();
00938 else
00939 {
00940 int temp_phi = address.delta_phi();
00941 absPhi12 = static_cast<unsigned>(-temp_phi) & 0xfff;
00942 }
00943
00944 dphi12R = (static_cast<float>(absPhi12)) / (static_cast<float>(1<<12)) * CSCTFConstants::SECTOR_RAD;
00945
00946
00947 ptR_front = ptMethods.Pt2Stn2010(mode, etaR, dphi12R, 1, int(pt_method));
00948 ptR_rear = ptMethods.Pt2Stn2010(mode, etaR, dphi12R, 0, int(pt_method));
00949 if((pt_method == 12) && etaR > 2.1 && mode != 8 && mode !=9 && mode !=10)
00950 {
00951 float dphi12Rmin = fabs(fabs(dphi12R) - Pi*10/180/3);
00952 float ptR_front_min = ptMethods.Pt2Stn2010(mode, etaR, dphi12Rmin, 1, int(pt_method));
00953 float ptR_rear_min = ptMethods.Pt2Stn2010(mode, etaR, dphi12Rmin, 0, int(pt_method));
00954
00955 ptR_front = std::max(ptR_front, ptR_front_min);
00956 ptR_rear = std::max(ptR_rear, ptR_rear_min);
00957 }
00958
00959 break;
00960 case 11:
00961 case 12:
00962 case 14:
00963
00964 if(fr == 0){
00965 if(charge) absPhi12 = address.delta_phi();
00966 else
00967 {
00968 int temp_phi = address.delta_phi();
00969 absPhi12 = static_cast<unsigned>(-temp_phi) & 0xfff;
00970 }
00971 dphi12R = (static_cast<float>(absPhi12)) / (static_cast<float>(1<<12)) * CSCTFConstants::SECTOR_RAD;
00972 ptR_rear = ptMethods.Pt2Stn2010(mode, etaR, dphi12R, 0, int(pt_method));
00973
00974 }
00975 if(fr == 1){
00976 charge12 = 1;
00977 absPhi12 = address.delta_phi_12;
00978 absPhi23 = address.delta_phi_23;
00979
00980 if(charge) charge23 = 1;
00981 else charge23 = -1;
00982
00983 dphi12R = (static_cast<float>(absPhi12<<1)) / (static_cast<float>(1<<12)) * CSCTFConstants::SECTOR_RAD;
00984 dphi23R = (static_cast<float>(absPhi23<<4)) / (static_cast<float>(1<<12)) * CSCTFConstants::SECTOR_RAD;
00985 if(charge12 * charge23 < 0) dphi23R = -dphi23R;
00986
00987 ptR_front = ptMethods.Pt3Stn2010(mode, etaR, dphi12R, dphi23R, 1, int(pt_method));
00988
00989 if(pt_method == 12 && mode != 5 && etaR > 2.1)
00990 {
00991 float dphi12Rmin = dphi12R - Pi*10/180/3;
00992 float dphi12Rmax = dphi12R + Pi*10/180/3;
00993 float dphi23Rmin = dphi23R;
00994 float dphi23Rmax = dphi23R;
00995 if(dphi12Rmin*dphi12R < 0) dphi23Rmin = -dphi23R;
00996 if(dphi12Rmax*dphi12R < 0) dphi23Rmax = -dphi23R;
00997 float ptR_front_min = ptMethods.Pt3Stn2010(mode, etaR, dphi12Rmin, dphi23Rmin, 1, int(pt_method));
00998 float ptR_front_max = ptMethods.Pt3Stn2010(mode, etaR, dphi12Rmax, dphi23Rmax, 1, int(pt_method));
00999
01000 ptR_front = std::max(ptR_front, ptR_front_min);
01001 ptR_front = std::max(ptR_front, ptR_front_max);
01002 }
01003 }
01004
01005 break;
01006 case 15:
01007 case 1:
01008 ptR_front = trigger_ptscale->getPtScale()->getLowEdge(3);
01009 ptR_rear = trigger_ptscale->getPtScale()->getLowEdge(3);
01010 break;
01011 default:
01012 ptR_front = trigger_ptscale->getPtScale()->getLowEdge(0);
01013 ptR_rear = trigger_ptscale->getPtScale()->getLowEdge(0);
01014 };
01015
01016 front_pt = trigger_ptscale->getPtScale()->getPacked(ptR_front);
01017 rear_pt = trigger_ptscale->getPtScale()->getPacked(ptR_rear);
01018
01019 }
01020
01021 if(pt_method <= 5){
01022
01023
01024
01025
01026
01027 if (pt_method != 4 && pt_method !=5
01028 && (mode == 2 || mode == 3 || mode == 4) && (eta<3)) mode = 6;
01029 if (pt_method != 4 && pt_method !=5 && (mode == 5)
01030 && (eta<3)) mode = 8;
01031
01032 switch(mode)
01033 {
01034 case 2:
01035 case 3:
01036 case 4:
01037 case 5:
01038 type = mode - 1;
01039 charge12 = 1;
01040 absPhi12 = address.delta_phi_12;
01041 absPhi23 = address.delta_phi_23;
01042
01043 if(charge) charge23 = 1;
01044 else charge23 = -1;
01045
01046
01047
01048 if(pt_method == 4 || pt_method == 5)
01049 {
01050 dphi12R = (static_cast<float>(absPhi12<<1)) / (static_cast<float>(1<<12)) * CSCTFConstants::SECTOR_RAD;
01051 dphi23R = (static_cast<float>(absPhi23<<4)) / (static_cast<float>(1<<12)) * CSCTFConstants::SECTOR_RAD;
01052 if(charge12 * charge23 < 0) dphi23R = -dphi23R;
01053
01054 ptR_front = ptMethods.Pt3Stn2010(mode, etaR, dphi12R, dphi23R, 1, int(pt_method));
01055 ptR_rear = ptMethods.Pt3Stn2010(mode, etaR, dphi12R, dphi23R, 0, int(pt_method));
01056
01057 if(pt_method == 5 && mode != 5 && etaR > 2.1)
01058 {
01059 float dphi12Rmin = dphi12R - Pi*10/180/3;
01060 float dphi12Rmax = dphi12R + Pi*10/180/3;
01061 float dphi23Rmin = dphi23R;
01062 float dphi23Rmax = dphi23R;
01063 if(dphi12Rmin*dphi12R < 0) dphi23Rmin = -dphi23R;
01064 if(dphi12Rmax*dphi12R < 0) dphi23Rmax = -dphi23R;
01065 float ptR_front_min = ptMethods.Pt3Stn2010(mode, etaR, dphi12Rmin, dphi23Rmin, 1, int(pt_method));
01066 float ptR_rear_min = ptMethods.Pt3Stn2010(mode, etaR, dphi12Rmin, dphi23Rmin, 0, int(pt_method));
01067 float ptR_front_max = ptMethods.Pt3Stn2010(mode, etaR, dphi12Rmax, dphi23Rmax, 1, int(pt_method));
01068 float ptR_rear_max = ptMethods.Pt3Stn2010(mode, etaR, dphi12Rmax, dphi23Rmax, 0, int(pt_method));
01069
01070 ptR_front = std::max(ptR_front, ptR_front_min);
01071 ptR_front = std::max(ptR_front, ptR_front_max);
01072 ptR_rear = std::max(ptR_rear, ptR_rear_min);
01073 ptR_rear = std::max(ptR_rear, ptR_rear_max);
01074 }
01075 }
01076 else if(pt_method == 1)
01077 {
01078 dphi12R = (static_cast<float>(absPhi12<<1)) / (static_cast<float>(1<<12)) * CSCTFConstants::SECTOR_RAD;
01079 dphi23R = (static_cast<float>(absPhi23<<4)) / (static_cast<float>(1<<12)) * CSCTFConstants::SECTOR_RAD;
01080 if(charge12 * charge23 < 0) dphi23R = -dphi23R;
01081
01082 ptR_front = ptMethods.Pt3Stn(type, etaR, dphi12R, dphi23R, 1);
01083 ptR_rear = ptMethods.Pt3Stn(type, etaR, dphi12R, dphi23R, 0);
01084
01085 }
01086 else if(pt_method == 2)
01087 {
01088 if(type <= 2)
01089 {
01090 ptR_front = ptMethods.Pt3StnChiSq(type+3, etaR, absPhi12<<1, ((charge == 0) ? -(absPhi23<<4) : (absPhi23<<4)), 1);
01091 ptR_rear = ptMethods.Pt3StnChiSq(type+3, etaR, absPhi12<<1, ((charge == 0) ? -(absPhi23<<4) : (absPhi23<<4)), 0);
01092 }
01093 else
01094 {
01095 ptR_front = ptMethods.Pt2StnChiSq(type-2, etaR, absPhi12<<1, 1);
01096 ptR_rear = ptMethods.Pt2StnChiSq(type-2, etaR, absPhi12<<1, 0);
01097 }
01098
01099 }
01100 else
01101 {
01102
01103 if(type <= 2)
01104 {
01105 ptR_front = ptMethods.Pt3StnHybrid(type+3, etaR, absPhi12<<1, ((charge == 0) ? -(absPhi23<<4) : (absPhi23<<4)), 1);
01106 ptR_rear = ptMethods.Pt3StnHybrid(type+3, etaR, absPhi12<<1, ((charge == 0) ? -(absPhi23<<4) : (absPhi23<<4)), 0);
01107 }
01108 else
01109 {
01110 ptR_front = ptMethods.Pt2StnHybrid(type-2, etaR, absPhi12<<1, 1);
01111 ptR_rear = ptMethods.Pt2StnHybrid(type-2, etaR, absPhi12<<1, 0);
01112 }
01113
01114 }
01115 break;
01116 case 6:
01117 case 7:
01118 case 8:
01119 case 9:
01120 case 10:
01121 type = mode - 5;
01122
01123 if(charge) absPhi12 = address.delta_phi();
01124 else
01125 {
01126 int temp_phi = address.delta_phi();
01127 absPhi12 = static_cast<unsigned>(-temp_phi) & 0xfff;
01128 }
01129
01130 if(absPhi12 < (1<<9))
01131 {
01132 if(pt_method == 1 || type == 5)
01133 {
01134 dphi12R = (static_cast<float>(absPhi12)) / (static_cast<float>(1<<12)) * CSCTFConstants::SECTOR_RAD;
01135
01136 ptR_front = ptMethods.Pt2Stn(type, etaR, dphi12R, 1);
01137 ptR_rear = ptMethods.Pt2Stn(type, etaR, dphi12R, 0);
01138
01139 }
01140 else if(pt_method == 2)
01141 {
01142 ptR_front = ptMethods.Pt2StnChiSq(type-1, etaR, absPhi12, 1);
01143 ptR_rear = ptMethods.Pt2StnChiSq(type-1, etaR, absPhi12, 0);
01144 }
01145 else
01146 {
01147 ptR_front = ptMethods.Pt2StnHybrid(type-1, etaR, absPhi12, 1);
01148 ptR_rear = ptMethods.Pt2StnHybrid(type-1, etaR, absPhi12, 0);
01149 }
01150 }
01151 else
01152 {
01153 ptR_front = trigger_ptscale->getPtScale()->getLowEdge(1);
01154 ptR_rear = trigger_ptscale->getPtScale()->getLowEdge(1);
01155 }
01156 if(pt_method == 4 || pt_method == 5)
01157 {
01158 dphi12R = (static_cast<float>(absPhi12)) / (static_cast<float>(1<<12)) * CSCTFConstants::SECTOR_RAD;
01159
01160
01161 ptR_front = ptMethods.Pt2Stn2010(mode, etaR, dphi12R, 1, int(pt_method));
01162 ptR_rear = ptMethods.Pt2Stn2010(mode, etaR, dphi12R, 0, int(pt_method));
01163 if((pt_method == 5) && etaR > 2.1 && mode != 8 && mode !=9 && mode !=10)
01164 {
01165 float dphi12Rmin = fabs(fabs(dphi12R) - Pi*10/180/3);
01166 float ptR_front_min = ptMethods.Pt2Stn2010(mode, etaR, dphi12Rmin, 1, int(pt_method));
01167 float ptR_rear_min = ptMethods.Pt2Stn2010(mode, etaR, dphi12Rmin, 0, int(pt_method));
01168
01169 ptR_front = std::max(ptR_front, ptR_front_min);
01170 ptR_rear = std::max(ptR_rear, ptR_rear_min);
01171 }
01172 }
01173
01174 break;
01175 case 12:
01176 case 14:
01177 type = 2;
01178
01179 if(charge) absPhi12 = address.delta_phi();
01180 else
01181 {
01182 int temp_phi = address.delta_phi();
01183 absPhi12 = static_cast<unsigned>(-temp_phi) & 0xfff;
01184 }
01185 if(absPhi12 < (1<<9))
01186 {
01187 dphi12R = (static_cast<float>(absPhi12)) / (static_cast<float>(1<<12)) * CSCTFConstants::SECTOR_RAD;
01188 ptR_front = ptMethods.Pt2Stn(type, etaR, dphi12R, 1);
01189 ptR_rear = ptMethods.Pt2Stn(type, etaR, dphi12R, 0);
01190 }
01191 else
01192 {
01193 ptR_front = trigger_ptscale->getPtScale()->getLowEdge(1);
01194 ptR_rear = trigger_ptscale->getPtScale()->getLowEdge(1);
01195 }
01196 if(pt_method == 4 || pt_method == 5)
01197 {
01198 dphi12R = (static_cast<float>(absPhi12)) / (static_cast<float>(1<<12)) * CSCTFConstants::SECTOR_RAD;
01199
01200 ptR_front = ptMethods.Pt2Stn2010(mode, etaR, dphi12R, 1, int(pt_method));
01201 ptR_rear = ptMethods.Pt2Stn2010(mode, etaR, dphi12R, 0, int(pt_method));
01202
01203 if(fabs(dphi12R)<0.01 && (ptR_rear < 10 || ptR_front < 10))
01204 std::cout << "dphi12R = " << dphi12R << " ptR_rear = " << ptR_rear
01205 << " ptR_front = " << ptR_front << " etaR = " << etaR << " mode = " << mode << std::endl;
01206 }
01207 break;
01208 case 13:
01209 type = 4;
01210
01211 if(charge) absPhi12 = address.delta_phi();
01212 else
01213 {
01214 int temp_phi = address.delta_phi();
01215 absPhi12 = static_cast<unsigned>(-temp_phi) & 0xfff;
01216 }
01217 if(absPhi12 < (1<<9))
01218 {
01219 dphi12R = (static_cast<float>(absPhi12)) / (static_cast<float>(1<<12)) * CSCTFConstants::SECTOR_RAD;
01220 ptR_front = ptMethods.Pt2Stn(type, etaR, dphi12R, 1);
01221 ptR_rear = ptMethods.Pt2Stn(type, etaR, dphi12R, 0);
01222 }
01223 else
01224 {
01225 ptR_front = trigger_ptscale->getPtScale()->getLowEdge(1);
01226 ptR_rear = trigger_ptscale->getPtScale()->getLowEdge(1);
01227 }
01228
01229 if(pt_method == 4 || pt_method == 5)
01230 {
01231 dphi12R = (static_cast<float>(absPhi12)) / (static_cast<float>(1<<12)) * CSCTFConstants::SECTOR_RAD;
01232
01233 ptR_front = ptMethods.Pt2Stn2010(mode, etaR, dphi12R, 1, int(pt_method));
01234 ptR_rear = ptMethods.Pt2Stn2010(mode, etaR, dphi12R, 0, int(pt_method));
01235 if((pt_method == 5) && etaR > 2.1)
01236 {
01237 float dphi12Rmin = fabs(fabs(dphi12R) - Pi*10/180/3);
01238 float ptR_front_min = ptMethods.Pt2Stn2010(mode, etaR, dphi12Rmin, 1, int(pt_method));
01239 float ptR_rear_min = ptMethods.Pt2Stn2010(mode, etaR, dphi12Rmin, 0, int(pt_method));
01240
01241 ptR_front = std::max(ptR_front, ptR_front_min);
01242 ptR_rear = std::max(ptR_rear, ptR_rear_min);
01243 }
01244 }
01245
01246 break;
01247 case 11:
01248
01249 ptR_front = trigger_ptscale->getPtScale()->getLowEdge(5);
01250 ptR_rear = trigger_ptscale->getPtScale()->getLowEdge(5);
01251
01252
01253 break;
01254 case 15:
01255
01256 ptR_front = trigger_ptscale->getPtScale()->getLowEdge(5);
01257 ptR_rear = trigger_ptscale->getPtScale()->getLowEdge(5);
01258 break;
01259 case 1:
01260
01261 ptR_front = trigger_ptscale->getPtScale()->getLowEdge(5);
01262 ptR_rear = trigger_ptscale->getPtScale()->getLowEdge(5);
01263 break;
01264 default:
01265 ptR_front = trigger_ptscale->getPtScale()->getLowEdge(0);
01266 ptR_rear = trigger_ptscale->getPtScale()->getLowEdge(0);
01267 };
01268
01269 front_pt = trigger_ptscale->getPtScale()->getPacked(ptR_front);
01270 rear_pt = trigger_ptscale->getPtScale()->getPacked(ptR_rear);
01271
01272
01273 if(pt_method != 4 && pt_method != 5)
01274 {
01275 if ((front_pt==0 || front_pt==1) && (eta<3) && quality==1 && pt_method != 2) front_pt = 31;
01276 if ((rear_pt==0 || rear_pt==1) && (eta<3) && quality==1 && pt_method != 2) rear_pt = 31;
01277 }
01278 if(pt_method != 2 && pt_method != 4 && quality == 1)
01279 {
01280 if (front_pt < 5) front_pt = 5;
01281 if (rear_pt < 5) rear_pt = 5;
01282 }
01283
01284
01285 if(isBeamStartConf && pt_method != 2 && pt_method != 4 && pt_method !=5) {
01286 if(quality == 3 && mode == 5) {
01287
01288 if (front_pt < 5) front_pt = 5;
01289 if (rear_pt < 5) rear_pt = 5;
01290 }
01291
01292 if(quality == 2 && mode > 7 && mode < 11) {
01293
01294 if (front_pt < 5) front_pt = 5;
01295 if (rear_pt < 5) rear_pt = 5;
01296 }
01297 }
01298
01299 }
01300
01301
01302
01303 result.front_rank = front_pt | front_quality << 5;
01304 result.rear_rank = rear_pt | rear_quality << 5;
01305
01306 result.charge_valid_front = 1;
01307 result.charge_valid_rear = 1;
01308
01309
01310
01311
01312
01313
01314
01315
01316
01317
01318
01319 return result;
01320 }
01321
01322
01323 unsigned CSCTFPtLUT::trackQuality(const unsigned& eta, const unsigned& mode, const unsigned& fr) const
01324 {
01325
01326 if (eta>15 || mode>15)
01327 {
01328
01329 edm::LogError("CSCTFPtLUT::trackQuality()")<<"Eta or Mode out of range in AU quality assignment";
01330 return 0;
01331 }
01332 unsigned int quality;
01333 switch (mode) {
01334 case 2:
01335 quality = 3;
01336 if(pt_method > 10 && eta < 3) quality = 1;
01337 break;
01338 case 3:
01339 case 4:
01341
01342 quality = 3;
01343 break;
01344 case 5:
01345 quality = 1;
01346 if (isBeamStartConf && eta >= 12 && pt_method < 20)
01347 quality = 3;
01348 if(pt_method == 27 || pt_method == 28 || pt_method == 29 || pt_method == 30) quality = 3;
01349 break;
01350 case 6:
01351 if (eta>=3)
01352 quality = 2;
01353 else
01354 quality = 1;
01355 break;
01356 case 7:
01357 quality = 2;
01358 if(pt_method > 10 && eta < 3) quality = 1;
01359 break;
01360 case 8:
01361 case 9:
01362 case 10:
01363 quality = 1;
01364 if (isBeamStartConf && eta >= 12 && pt_method < 20)
01365 quality = 2;
01366 if((pt_method == 27 || pt_method == 28 || pt_method == 30) && (eta >= 7 && eta < 9)) quality = 2;
01367 break;
01368 case 11:
01369
01370 quality = 1;
01371
01372 if(pt_method > 10 && fr == 0) quality = 2;
01373 if(pt_method > 10 && fr == 1) quality = 3;
01374 if(pt_method > 20 && fr == 0) quality = 3;
01375 break;
01376 case 12:
01377 quality = 3;
01378
01379 if(pt_method > 10 && fr == 0) quality = 2;
01380 if(pt_method > 10 && fr == 1) quality = 3;
01381 if(pt_method > 20 && fr == 0) quality = 3;
01382 break;
01383 case 13:
01384 quality = 2;
01385 break;
01386 case 14:
01387 quality = 2;
01388
01389 if(pt_method > 10 && fr == 0) quality = 2;
01390 if(pt_method > 10 && fr == 1) quality = 3;
01391 if(pt_method > 20 && fr == 0) quality = 3;
01392 break;
01393 case 15:
01394
01395 quality = 1;
01396 break;
01397
01398 case 1:
01399 quality = 1;
01400 break;
01401 default:
01402 quality = 0;
01403 break;
01404 }
01405
01406
01407
01408
01409
01410 if ( (quality == 1) && (eta >= 4) && (eta < 11)
01411 && ((lowQualityFlag&4)==0) ) quality = 0;
01412 if ( (quality == 1) && (eta < 4) && ((lowQualityFlag&1)==0)
01413 && ((lowQualityFlag&4)==0) ) quality = 0;
01414 if ( (quality == 1) && (eta >=11) && ((lowQualityFlag&2)==0)
01415 && ((lowQualityFlag&4)==0) ) quality = 0;
01416
01417 return quality;
01418
01419 }
01420
01421 void CSCTFPtLUT::readLUT()
01422 {
01423 std::ifstream PtLUT;
01424
01425 if(isBinary)
01426 {
01427 PtLUT.open(pt_lut_file.fullPath().c_str(), std::ios::binary);
01428 PtLUT.seekg(0, std::ios::end);
01429 int length = PtLUT.tellg();;
01430 if( length == (1<<CSCBitWidths::kPtAddressWidth)*sizeof(short) )
01431 {
01432 PtLUT.seekg(0, std::ios::beg);
01433 PtLUT.read(reinterpret_cast<char*>(pt_lut),length);
01434 }
01435 else
01436 {
01437 edm::LogError("CSCPtLUT") << "File " << pt_lut_file.fullPath() << " is incorrect size!\n";
01438 }
01439 PtLUT.close();
01440 }
01441 else
01442 {
01443 PtLUT.open(pt_lut_file.fullPath().c_str());
01444 unsigned i = 0;
01445 unsigned short temp = 0;
01446 while(!PtLUT.eof() && i < 1 << CSCBitWidths::kPtAddressWidth)
01447 {
01448 PtLUT >> temp;
01449 pt_lut[i++] = (*reinterpret_cast<ptdat*>(&temp));
01450 }
01451 PtLUT.close();
01452 }
01453 }
01454
01455