237 double Pi = acos(-1.);
238 float etaR = 0, ptR_front = 0, ptR_rear = 0, dphi12R = 0, dphi23R = 0;
239 int charge12, charge23;
242 mode = address.track_mode;
244 int usedetaCUT =
true;
248 int EtaCutLevel_1 = 2;
251 for (
int i=0;
i<24;
i++)
254 if (EtaCutLevel_1 == 1)
256 else if (EtaCutLevel_1 == 2)
258 else if (EtaCutLevel_1 == 3)
260 else if (EtaCutLevel_1 == 4)
262 else if (EtaCutLevel_1 == 5)
264 else if (EtaCutLevel_1 == 6)
268 int EtaCutLevel_2 = 2;
271 for (
int i=0;
i<24;
i++)
274 if (EtaCutLevel_2 == 1)
276 else if (EtaCutLevel_2 == 2)
278 else if (EtaCutLevel_2 == 3)
280 else if (EtaCutLevel_2 == 4)
282 else if (EtaCutLevel_2 == 5)
284 else if (EtaCutLevel_2 == 6)
288 if (mode == 8 || mode == 10)
289 dEtaCut_2[
i] = scalef*dEtaCut_2[
i];
295 eta = address.track_eta;
297 fr = address.track_fr;
298 charge = address.delta_phi_sign;
300 unsigned front_pt, rear_pt;
301 front_pt = 0.; rear_pt = 0.;
302 unsigned front_quality, rear_quality;
306 front_quality = rear_quality =
quality;
308 unsigned int remerged;
314 float bestLH_front = -999.0;
315 float bestLH_rear = -999.0;
344 remerged = (address.delta_phi_12 | (address.delta_phi_23 << 8 ) );
347 absPhi12 = ((1<<7)-1) & remerged;
348 absPhi23 = ((1<<5)-1) & (remerged >> 7);
354 if(charge) charge23 = 1;
359 if(charge12 * charge23 < 0) dphi23R = -dphi23R;
362 bestLH_front = bestLH;
364 bestLH_rear = bestLH;
368 float dphi12Rmin = dphi12R - Pi*10/180/3;
369 float dphi12Rmax = dphi12R + Pi*10/180/3;
370 float dphi23Rmin = dphi23R;
371 float dphi23Rmax = dphi23R;
375 float bestLH_front_min = bestLH;
377 float bestLH_rear_min = bestLH;
379 float bestLH_front_max = bestLH;
381 float bestLH_rear_max = bestLH;
385 float best_pt_front = ptR_front;
386 float best_LH_front = bestLH_front;
387 if (bestLH_front_min > best_LH_front)
389 best_pt_front = ptR_front_min;
390 best_LH_front = bestLH_front_min;
392 if (bestLH_front_max > best_LH_front)
394 best_pt_front = ptR_front_max;
395 best_LH_front = bestLH_front_max;
397 ptR_front = best_pt_front;
399 float best_pt_rear = ptR_rear;
400 float best_LH_rear = bestLH_rear;
401 if (bestLH_rear_min > best_LH_rear)
403 best_pt_rear = ptR_rear_min;
404 best_LH_rear = bestLH_rear_min;
406 if (bestLH_rear_max > best_LH_rear)
408 best_pt_rear = ptR_rear_max;
409 best_LH_rear = bestLH_rear_max;
411 ptR_rear = best_pt_rear;
416 ptR_front =
std::max(ptR_front, ptR_front_min);
417 ptR_front =
std::max(ptR_front, ptR_front_max);
418 ptR_rear =
std::max(ptR_rear, ptR_rear_min);
419 ptR_rear =
std::max(ptR_rear, ptR_rear_max);
428 remerged = (address.delta_phi_12 | (address.delta_phi_23 << 8 ) );
430 absPhi12 = ((1<<8)-1) & remerged;
432 dEta = ((1<<3)-1) & (remerged >> 8);
434 CLCT_pattern = 0x1 & (remerged >> 11);
437 if(iME11 == 1 && etaR > 1.6) etaR = 1.55;
438 if(iME11 == 0 && etaR < 1.6) etaR = 1.65;
441 absPhi12 = ((1<<8)-1) & address.delta_phi_12;
452 bestLH_front = bestLH;
454 bestLH_rear = bestLH;
457 float dphi12Rmin = fabs(fabs(dphi12R) - Pi*10/180/3);
459 float bestLH_front_min = bestLH;
461 float bestLH_rear_min = bestLH;
465 ptR_front = bestLH_front > bestLH_front_min ? ptR_front : ptR_front_min;
466 ptR_rear = bestLH_rear > bestLH_rear_min ? ptR_rear : ptR_rear_min;
471 ptR_front =
std::max(ptR_front, ptR_front_min);
472 ptR_rear =
std::max(ptR_rear, ptR_rear_min);
476 if( (!CLCT_pattern) && (ptR_front > 5.)) ptR_front = 5.;
477 if( (!CLCT_pattern) && (ptR_rear > 5.)) ptR_rear = 5.;
481 if (mode == 6) index = 0;
482 if (mode == 7) index = 4;
483 if (mode == 13) index = 8;
487 if (fabs(etaR)>1.2 && fabs(etaR)<=1.5)
488 if (dEta>dEtaCut_1[index+0] )
490 if (ptR_front > 5) ptR_front = 5;
491 if (ptR_rear > 5) ptR_rear = 5;
493 if (fabs(etaR)>1.5 && fabs(etaR)<=1.65)
494 if (dEta>dEtaCut_1[index+1])
496 if (ptR_front > 5) ptR_front = 5;
497 if (ptR_rear > 5) ptR_rear = 5;
500 if (fabs(etaR)>1.65 && fabs(etaR)<=2.1)
501 if (dEta>dEtaCut_1[index+2] )
503 if (ptR_front > 5) ptR_front = 5;
504 if (ptR_rear > 5) ptR_rear = 5;
507 if (dEta>dEtaCut_1[index+3] )
509 if (ptR_front > 5) ptR_front = 5;
510 if (ptR_rear > 5) ptR_rear = 5;
522 remerged = (address.delta_phi_12 | (address.delta_phi_23 << 8 ) );
524 absPhi12 = ((1<<9)-1) & remerged;
526 dEta = ((1<<3)-1) & (remerged >> 9);
535 if (mode == 8) index = 12;
536 if (mode == 9) index = 16;
537 if (mode == 10) index = 20;
544 if (fabs(etaR)>1.2 && fabs(etaR)<=1.5)
545 if (dEta>dEtaCut_2[index+0] )
547 if (ptR_front > 5) ptR_front = 5;
548 if (ptR_rear > 5) ptR_rear = 5;
550 if (fabs(etaR)>1.5 && fabs(etaR)<=1.65)
551 if (dEta>dEtaCut_2[index+1])
553 if (ptR_front > 5) ptR_front = 5;
554 if (ptR_rear > 5) ptR_rear = 5;
557 if (fabs(etaR)>1.65 && fabs(etaR)<=2.1)
558 if (dEta>dEtaCut_2[index+2] )
560 if (ptR_front > 5) ptR_front = 5;
561 if (ptR_rear > 5) ptR_rear = 5;
564 if (dEta>dEtaCut_2[index+3] )
566 if (ptR_front > 5) ptR_front = 5;
567 if (ptR_rear > 5) ptR_rear = 5;
585 absPhi12 = address.delta_phi_12;
586 absPhi23 = address.delta_phi_23;
588 if(charge) charge23 = -1;
592 dphi23R =
float(absPhi23);
593 if(charge12 * charge23 < 0) dphi23R = -dphi23R;
597 if(fr == 1 && mode1 == 11) mode1 = 14;
634 absPhi12 = address.delta_phi_12;
635 absPhi23 = address.delta_phi_23;
637 if(charge) charge23 = 1;
642 if(charge12 * charge23 < 0) dphi23R = -dphi23R;
649 float dphi12Rmin = dphi12R - Pi*10/180/3;
650 float dphi12Rmax = dphi12R + Pi*10/180/3;
651 float dphi23Rmin = dphi23R;
652 float dphi23Rmax = dphi23R;
660 ptR_front =
std::max(ptR_front, ptR_front_min);
661 ptR_front =
std::max(ptR_front, ptR_front_max);
662 ptR_rear =
std::max(ptR_rear, ptR_rear_min);
663 ptR_rear =
std::max(ptR_rear, ptR_rear_max);
671 if(iME11 == 1 && etaR > 1.6) etaR = 1.55;
672 if(iME11 == 0 && etaR < 1.6) etaR = 1.65;
673 absPhi12 = address.delta_phi_12;
676 CLCT_pattern =
int(address.delta_phi_23);
684 float dphi12Rmin = fabs(fabs(dphi12R) - Pi*10/180/3);
688 ptR_front =
std::max(ptR_front, ptR_front_min);
689 ptR_rear =
std::max(ptR_rear, ptR_rear_min);
691 if( ((CLCT_pattern < 8) || (CLCT_pattern > 10)) && (ptR_front > 5.)) ptR_front = 5.;
692 if( ((CLCT_pattern < 8) || (CLCT_pattern > 10)) && (ptR_rear > 5.)) ptR_rear = 5.;
699 if(charge) absPhi12 = address.delta_phi();
702 int temp_phi = address.delta_phi();
703 absPhi12 =
static_cast<unsigned>(-temp_phi) & 0xfff;
723 absPhi12 = address.delta_phi_12;
724 absPhi23 = address.delta_phi_23;
726 if(charge) charge23 = -1;
730 dphi23R =
float(absPhi23);
731 if(charge12 * charge23 < 0) dphi23R = -dphi23R;
735 if(fr == 1 && mode1 == 11) mode1 = 14;
771 absPhi12 = address.delta_phi_12;
772 absPhi23 = address.delta_phi_23;
774 if(charge) charge23 = 1;
779 if(charge12 * charge23 < 0) dphi23R = -dphi23R;
784 if(
pt_method == 22 && mode != 5 && etaR > 2.1)
786 float dphi12Rmin = dphi12R - Pi*10/180/3;
787 float dphi12Rmax = dphi12R + Pi*10/180/3;
788 float dphi23Rmin = dphi23R;
789 float dphi23Rmax = dphi23R;
797 ptR_front =
std::max(ptR_front, ptR_front_min);
798 ptR_front =
std::max(ptR_front, ptR_front_max);
799 ptR_rear =
std::max(ptR_rear, ptR_rear_min);
800 ptR_rear =
std::max(ptR_rear, ptR_rear_max);
808 absPhi12 = address.delta_phi_12;
811 CLCT_pattern =
int(address.delta_phi_23);
820 float dphi12Rmin = fabs(fabs(dphi12R) - Pi*10/180/3);
824 ptR_front =
std::max(ptR_front, ptR_front_min);
825 ptR_rear =
std::max(ptR_rear, ptR_rear_min);
827 if( ((CLCT_pattern < 8) || (CLCT_pattern > 10)) && (ptR_front > 5.)) ptR_front = 5.;
828 if( ((CLCT_pattern < 8) || (CLCT_pattern > 10)) && (ptR_rear > 5.)) ptR_rear = 5.;
834 if(charge) absPhi12 = address.delta_phi();
837 int temp_phi = address.delta_phi();
838 absPhi12 =
static_cast<unsigned>(-temp_phi) & 0xfff;
857 absPhi12 = address.delta_phi_12;
858 absPhi23 = address.delta_phi_23;
860 if(charge) charge23 = -1;
864 dphi23R =
float(absPhi23);
865 if(charge12 * charge23 < 0) dphi23R = -dphi23R;
869 if(fr == 1 && mode1 == 11) mode1 = 14;
905 absPhi12 = address.delta_phi_12;
906 absPhi23 = address.delta_phi_23;
908 if(charge) charge23 = 1;
913 if(charge12 * charge23 < 0) dphi23R = -dphi23R;
918 if(
pt_method == 12 && mode != 5 && etaR > 2.1)
920 float dphi12Rmin = dphi12R - Pi*10/180/3;
921 float dphi12Rmax = dphi12R + Pi*10/180/3;
922 float dphi23Rmin = dphi23R;
923 float dphi23Rmax = dphi23R;
924 if(dphi12Rmin*dphi12R < 0) dphi23Rmin = -dphi23R;
925 if(dphi12Rmax*dphi12R < 0) dphi23Rmax = -dphi23R;
931 ptR_front =
std::max(ptR_front, ptR_front_min);
932 ptR_front =
std::max(ptR_front, ptR_front_max);
933 ptR_rear =
std::max(ptR_rear, ptR_rear_min);
934 ptR_rear =
std::max(ptR_rear, ptR_rear_max);
945 if(charge) absPhi12 = address.delta_phi();
948 int temp_phi = address.delta_phi();
949 absPhi12 =
static_cast<unsigned>(-temp_phi) & 0xfff;
957 if((
pt_method == 12) && etaR > 2.1 && mode != 8 && mode !=9 && mode !=10)
959 float dphi12Rmin = fabs(fabs(dphi12R) - Pi*10/180/3);
963 ptR_front =
std::max(ptR_front, ptR_front_min);
964 ptR_rear =
std::max(ptR_rear, ptR_rear_min);
973 if(charge) absPhi12 = address.delta_phi();
976 int temp_phi = address.delta_phi();
977 absPhi12 =
static_cast<unsigned>(-temp_phi) & 0xfff;
985 absPhi12 = address.delta_phi_12;
986 absPhi23 = address.delta_phi_23;
988 if(charge) charge23 = 1;
993 if(charge12 * charge23 < 0) dphi23R = -dphi23R;
997 if(
pt_method == 12 && mode != 5 && etaR > 2.1)
999 float dphi12Rmin = dphi12R - Pi*10/180/3;
1000 float dphi12Rmax = dphi12R + Pi*10/180/3;
1001 float dphi23Rmin = dphi23R;
1002 float dphi23Rmax = dphi23R;
1003 if(dphi12Rmin*dphi12R < 0) dphi23Rmin = -dphi23R;
1004 if(dphi12Rmax*dphi12R < 0) dphi23Rmax = -dphi23R;
1008 ptR_front =
std::max(ptR_front, ptR_front_min);
1009 ptR_front =
std::max(ptR_front, ptR_front_max);
1036 && (mode == 2 || mode == 3 || mode == 4) && (eta<3)) mode = 6;
1038 && (eta<3)) mode = 8;
1048 absPhi12 = address.delta_phi_12;
1049 absPhi23 = address.delta_phi_23;
1051 if(charge) charge23 = 1;
1060 if(charge12 * charge23 < 0) dphi23R = -dphi23R;
1065 if(
pt_method == 5 && mode != 5 && etaR > 2.1)
1067 float dphi12Rmin = dphi12R - Pi*10/180/3;
1068 float dphi12Rmax = dphi12R + Pi*10/180/3;
1069 float dphi23Rmin = dphi23R;
1070 float dphi23Rmax = dphi23R;
1071 if(dphi12Rmin*dphi12R < 0) dphi23Rmin = -dphi23R;
1072 if(dphi12Rmax*dphi12R < 0) dphi23Rmax = -dphi23R;
1078 ptR_front =
std::max(ptR_front, ptR_front_min);
1079 ptR_front =
std::max(ptR_front, ptR_front_max);
1080 ptR_rear =
std::max(ptR_rear, ptR_rear_min);
1081 ptR_rear =
std::max(ptR_rear, ptR_rear_max);
1088 if(charge12 * charge23 < 0) dphi23R = -dphi23R;
1098 ptR_front =
ptMethods.
Pt3StnChiSq(type+3, etaR, absPhi12<<1, ((charge == 0) ? -(absPhi23<<4) : (absPhi23<<4)), 1);
1099 ptR_rear =
ptMethods.
Pt3StnChiSq(type+3, etaR, absPhi12<<1, ((charge == 0) ? -(absPhi23<<4) : (absPhi23<<4)), 0);
1113 ptR_front =
ptMethods.
Pt3StnHybrid(type+3, etaR, absPhi12<<1, ((charge == 0) ? -(absPhi23<<4) : (absPhi23<<4)), 1);
1114 ptR_rear =
ptMethods.
Pt3StnHybrid(type+3, etaR, absPhi12<<1, ((charge == 0) ? -(absPhi23<<4) : (absPhi23<<4)), 0);
1131 if(charge) absPhi12 = address.delta_phi();
1134 int temp_phi = address.delta_phi();
1135 absPhi12 =
static_cast<unsigned>(-temp_phi) & 0xfff;
1138 if(absPhi12 < (1<<9))
1171 if((
pt_method == 5) && etaR > 2.1 && mode != 8 && mode !=9 && mode !=10)
1173 float dphi12Rmin = fabs(fabs(dphi12R) - Pi*10/180/3);
1177 ptR_front =
std::max(ptR_front, ptR_front_min);
1178 ptR_rear =
std::max(ptR_rear, ptR_rear_min);
1187 if(charge) absPhi12 = address.delta_phi();
1190 int temp_phi = address.delta_phi();
1191 absPhi12 =
static_cast<unsigned>(-temp_phi) & 0xfff;
1193 if(absPhi12 < (1<<9))
1211 if(fabs(dphi12R)<0.01 && (ptR_rear < 10 || ptR_front < 10))
1212 std::cout <<
"dphi12R = " << dphi12R <<
" ptR_rear = " << ptR_rear
1213 <<
" ptR_front = " << ptR_front <<
" etaR = " << etaR <<
" mode = " << mode << std::endl;
1219 if(charge) absPhi12 = address.delta_phi();
1222 int temp_phi = address.delta_phi();
1223 absPhi12 =
static_cast<unsigned>(-temp_phi) & 0xfff;
1225 if(absPhi12 < (1<<9))
1245 float dphi12Rmin = fabs(fabs(dphi12R) - Pi*10/180/3);
1249 ptR_front =
std::max(ptR_front, ptR_front_min);
1250 ptR_rear =
std::max(ptR_rear, ptR_rear_min);
1283 if ((front_pt==0 || front_pt==1) && (eta<3) && quality==1 &&
pt_method != 2) front_pt = 31;
1284 if ((rear_pt==0 || rear_pt==1) && (eta<3) && quality==1 &&
pt_method != 2) rear_pt = 31;
1288 if (front_pt < 5) front_pt = 5;
1289 if (rear_pt < 5) rear_pt = 5;
1294 if(quality == 3 && mode == 5) {
1296 if (front_pt < 5) front_pt = 5;
1297 if (rear_pt < 5) rear_pt = 5;
1300 if(quality == 2 && mode > 7 && mode < 11) {
1302 if (front_pt < 5) front_pt = 5;
1303 if (rear_pt < 5) rear_pt = 5;
1311 result.front_rank = front_pt | front_quality << 5;
1312 result.rear_rank = rear_pt | rear_quality << 5;
1314 result.charge_valid_front = 1;
1315 result.charge_valid_rear = 1;
float Pt3Stn2012_DT(int type, float eta, float dphi1, float dphi2, int PtbyMLH, float &theLH, int fr=-1, int method=11) const
const L1MuTriggerScales * trigger_scale
float Pt3StnHybrid(int type, float eta, int dphi1, int dphi2, int fr) const
const L1MuScale * getPtScale() const
get the Pt scale
float Pt2Stn2010(int type, float eta, float dphi, int fr=-1, int method=11) const
static const int getPtbyMLH
float Pt2StnChiSq(int type, float eta, int dphi, int fr) const
float Pt2Stn2011(int type, float eta, float dphi, int fr=-1, int method=11, int phiSign=2) const
float Pt3Stn2011(int type, float eta, float dphi1, float dphi2, int fr=-1, int method=11) const
float Pt3StnChiSq(int type, float eta, int dphi1, int dphi2, int fr) const
static const int dEtaCut_High_C[24]
float Pt3Stn(int type, float eta, float dphi1, float dphi2, int fr=-1) const
static const int dPhiNLBMap_8bit[256]
static const int dEtaCut_Mid[24]
static const int dEtaCut_Low[24]
float Pt2StnHybrid(int type, float eta, int dphi, int fr) const
float Pt3Stn2010(int type, float eta, float dphi1, float dphi2, int fr=-1, int method=11) const
float Pt3Stn2012(int type, float eta, float dphi1, float dphi2, int PtbyMLH, float &theLH, int fr=-1, int method=11) const
static const int dEtaCut_High_A[24]
unsigned trackQuality(const unsigned &eta, const unsigned &mode, const unsigned &fr) const
const L1MuScale * getRegionalEtaScale(int isys) const
get the regioanl muon trigger eta scale, isys = 0(DT), 1(bRPC), 2(CSC), 3(fwdRPC) ...
static const int dEtaCut_Open[24]
virtual float getLowEdge(unsigned packed) const =0
get the low edge of bin represented by packed
float Pt2Stn2012(int type, float eta, float dphi, int PtbyMLH, float &theLH, int fr=-1, int method=11) const
static const int dPhiNLBMap_7bit[128]
static const double SECTOR_RAD
virtual unsigned getPacked(float value) const =0
pack a value
float Pt2Stn(int type, float eta, float dphi, int fr=-1) const
const L1MuTriggerPtScale * trigger_ptscale
static const int dEtaCut_High_B[24]
static const int dPhiNLBMap_5bit[32]
KK.