236 double Pi = acos(-1.);
237 float etaR = 0, ptR_front = 0, ptR_rear = 0, dphi12R = 0, dphi23R = 0;
238 int charge12, charge23;
239 unsigned type,
mode,
eta, fr, quality, charge, absPhi12, absPhi23;
241 mode = address.track_mode;
243 int usedetaCUT =
true;
247 int EtaCutLevel_1 = 2;
250 for (
int i=0;
i<24;
i++)
253 if (EtaCutLevel_1 == 1)
255 else if (EtaCutLevel_1 == 2)
257 else if (EtaCutLevel_1 == 3)
259 else if (EtaCutLevel_1 == 4)
261 else if (EtaCutLevel_1 == 5)
263 else if (EtaCutLevel_1 == 6)
267 int EtaCutLevel_2 = 2;
270 for (
int i=0;
i<24;
i++)
273 if (EtaCutLevel_2 == 1)
275 else if (EtaCutLevel_2 == 2)
277 else if (EtaCutLevel_2 == 3)
279 else if (EtaCutLevel_2 == 4)
281 else if (EtaCutLevel_2 == 5)
283 else if (EtaCutLevel_2 == 6)
287 if (mode == 8 || mode == 10)
288 dEtaCut_2[
i] = scalef*dEtaCut_2[
i];
294 eta = address.track_eta;
296 fr = address.track_fr;
297 charge = address.delta_phi_sign;
299 unsigned front_pt, rear_pt;
300 front_pt = 0.; rear_pt = 0.;
301 unsigned front_quality, rear_quality;
305 front_quality = rear_quality = quality;
307 unsigned int remerged;
313 float bestLH_front = -999.0;
314 float bestLH_rear = -999.0;
343 remerged = (address.delta_phi_12 | (address.delta_phi_23 << 8 ) );
346 absPhi12 = ((1<<7)-1) & remerged;
347 absPhi23 = ((1<<5)-1) & (remerged >> 7);
353 if(charge) charge23 = 1;
358 if(charge12 * charge23 < 0) dphi23R = -dphi23R;
361 bestLH_front = bestLH;
363 bestLH_rear = bestLH;
367 float dphi12Rmin = dphi12R - Pi*10/180/3;
368 float dphi12Rmax = dphi12R + Pi*10/180/3;
369 float dphi23Rmin = dphi23R;
370 float dphi23Rmax = dphi23R;
374 float bestLH_front_min = bestLH;
376 float bestLH_rear_min = bestLH;
378 float bestLH_front_max = bestLH;
380 float bestLH_rear_max = bestLH;
384 float best_pt_front = ptR_front;
385 float best_LH_front = bestLH_front;
386 if (bestLH_front_min > best_LH_front)
388 best_pt_front = ptR_front_min;
389 best_LH_front = bestLH_front_min;
391 if (bestLH_front_max > best_LH_front)
393 best_pt_front = ptR_front_max;
394 best_LH_front = bestLH_front_max;
396 ptR_front = best_pt_front;
398 float best_pt_rear = ptR_rear;
399 float best_LH_rear = bestLH_rear;
400 if (bestLH_rear_min > best_LH_rear)
402 best_pt_rear = ptR_rear_min;
403 best_LH_rear = bestLH_rear_min;
405 if (bestLH_rear_max > best_LH_rear)
407 best_pt_rear = ptR_rear_max;
408 best_LH_rear = bestLH_rear_max;
410 ptR_rear = best_pt_rear;
415 ptR_front =
std::max(ptR_front, ptR_front_min);
416 ptR_front =
std::max(ptR_front, ptR_front_max);
417 ptR_rear =
std::max(ptR_rear, ptR_rear_min);
418 ptR_rear =
std::max(ptR_rear, ptR_rear_max);
427 remerged = (address.delta_phi_12 | (address.delta_phi_23 << 8 ) );
429 absPhi12 = ((1<<8)-1) & remerged;
431 dEta = ((1<<3)-1) & (remerged >> 8);
433 CLCT_pattern = 0x1 & (remerged >> 11);
436 if(iME11 == 1 && etaR > 1.6) etaR = 1.55;
437 if(iME11 == 0 && etaR < 1.6) etaR = 1.65;
440 absPhi12 = ((1<<8)-1) & address.delta_phi_12;
451 bestLH_front = bestLH;
453 bestLH_rear = bestLH;
456 float dphi12Rmin = fabs(fabs(dphi12R) - Pi*10/180/3);
458 float bestLH_front_min = bestLH;
460 float bestLH_rear_min = bestLH;
464 ptR_front = bestLH_front > bestLH_front_min ? ptR_front : ptR_front_min;
465 ptR_rear = bestLH_rear > bestLH_rear_min ? ptR_rear : ptR_rear_min;
470 ptR_front =
std::max(ptR_front, ptR_front_min);
471 ptR_rear =
std::max(ptR_rear, ptR_rear_min);
475 if( (!CLCT_pattern) && (ptR_front > 5.)) ptR_front = 5.;
476 if( (!CLCT_pattern) && (ptR_rear > 5.)) ptR_rear = 5.;
480 if (mode == 6) index = 0;
481 if (mode == 7) index = 4;
482 if (mode == 13) index = 8;
486 if (fabs(etaR)>1.2 && fabs(etaR)<=1.5)
487 if (dEta>dEtaCut_1[index+0] )
489 if (ptR_front > 5) ptR_front = 5;
490 if (ptR_rear > 5) ptR_rear = 5;
492 if (fabs(etaR)>1.5 && fabs(etaR)<=1.65)
493 if (dEta>dEtaCut_1[index+1])
495 if (ptR_front > 5) ptR_front = 5;
496 if (ptR_rear > 5) ptR_rear = 5;
499 if (fabs(etaR)>1.65 && fabs(etaR)<=2.1)
500 if (dEta>dEtaCut_1[index+2] )
502 if (ptR_front > 5) ptR_front = 5;
503 if (ptR_rear > 5) ptR_rear = 5;
506 if (dEta>dEtaCut_1[index+3] )
508 if (ptR_front > 5) ptR_front = 5;
509 if (ptR_rear > 5) ptR_rear = 5;
521 remerged = (address.delta_phi_12 | (address.delta_phi_23 << 8 ) );
523 absPhi12 = ((1<<9)-1) & remerged;
525 dEta = ((1<<3)-1) & (remerged >> 9);
534 if (mode == 8) index = 12;
535 if (mode == 9) index = 16;
536 if (mode == 10) index = 20;
543 if (fabs(etaR)>1.2 && fabs(etaR)<=1.5)
544 if (dEta>dEtaCut_2[index+0] )
546 if (ptR_front > 5) ptR_front = 5;
547 if (ptR_rear > 5) ptR_rear = 5;
549 if (fabs(etaR)>1.5 && fabs(etaR)<=1.65)
550 if (dEta>dEtaCut_2[index+1])
552 if (ptR_front > 5) ptR_front = 5;
553 if (ptR_rear > 5) ptR_rear = 5;
556 if (fabs(etaR)>1.65 && fabs(etaR)<=2.1)
557 if (dEta>dEtaCut_2[index+2] )
559 if (ptR_front > 5) ptR_front = 5;
560 if (ptR_rear > 5) ptR_rear = 5;
563 if (dEta>dEtaCut_2[index+3] )
565 if (ptR_front > 5) ptR_front = 5;
566 if (ptR_rear > 5) ptR_rear = 5;
584 absPhi12 = address.delta_phi_12;
585 absPhi23 = address.delta_phi_23;
587 if(charge) charge23 = -1;
591 dphi23R = float(absPhi23);
592 if(charge12 * charge23 < 0) dphi23R = -dphi23R;
596 if(fr == 1 && mode1 == 11) mode1 = 14;
633 absPhi12 = address.delta_phi_12;
634 absPhi23 = address.delta_phi_23;
636 if(charge) charge23 = 1;
641 if(charge12 * charge23 < 0) dphi23R = -dphi23R;
648 float dphi12Rmin = dphi12R - Pi*10/180/3;
649 float dphi12Rmax = dphi12R + Pi*10/180/3;
650 float dphi23Rmin = dphi23R;
651 float dphi23Rmax = dphi23R;
659 ptR_front =
std::max(ptR_front, ptR_front_min);
660 ptR_front =
std::max(ptR_front, ptR_front_max);
661 ptR_rear =
std::max(ptR_rear, ptR_rear_min);
662 ptR_rear =
std::max(ptR_rear, ptR_rear_max);
670 if(iME11 == 1 && etaR > 1.6) etaR = 1.55;
671 if(iME11 == 0 && etaR < 1.6) etaR = 1.65;
672 absPhi12 = address.delta_phi_12;
675 CLCT_pattern = int(address.delta_phi_23);
683 float dphi12Rmin = fabs(fabs(dphi12R) - Pi*10/180/3);
687 ptR_front =
std::max(ptR_front, ptR_front_min);
688 ptR_rear =
std::max(ptR_rear, ptR_rear_min);
690 if( ((CLCT_pattern < 8) || (CLCT_pattern > 10)) && (ptR_front > 5.)) ptR_front = 5.;
691 if( ((CLCT_pattern < 8) || (CLCT_pattern > 10)) && (ptR_rear > 5.)) ptR_rear = 5.;
698 if(charge) absPhi12 = address.delta_phi();
701 int temp_phi = address.delta_phi();
702 absPhi12 =
static_cast<unsigned>(-temp_phi) & 0xfff;
722 absPhi12 = address.delta_phi_12;
723 absPhi23 = address.delta_phi_23;
725 if(charge) charge23 = -1;
729 dphi23R = float(absPhi23);
730 if(charge12 * charge23 < 0) dphi23R = -dphi23R;
734 if(fr == 1 && mode1 == 11) mode1 = 14;
770 absPhi12 = address.delta_phi_12;
771 absPhi23 = address.delta_phi_23;
773 if(charge) charge23 = 1;
778 if(charge12 * charge23 < 0) dphi23R = -dphi23R;
783 if(
pt_method == 22 && mode != 5 && etaR > 2.1)
785 float dphi12Rmin = dphi12R - Pi*10/180/3;
786 float dphi12Rmax = dphi12R + Pi*10/180/3;
787 float dphi23Rmin = dphi23R;
788 float dphi23Rmax = dphi23R;
796 ptR_front =
std::max(ptR_front, ptR_front_min);
797 ptR_front =
std::max(ptR_front, ptR_front_max);
798 ptR_rear =
std::max(ptR_rear, ptR_rear_min);
799 ptR_rear =
std::max(ptR_rear, ptR_rear_max);
807 absPhi12 = address.delta_phi_12;
810 CLCT_pattern = int(address.delta_phi_23);
819 float dphi12Rmin = fabs(fabs(dphi12R) - Pi*10/180/3);
823 ptR_front =
std::max(ptR_front, ptR_front_min);
824 ptR_rear =
std::max(ptR_rear, ptR_rear_min);
826 if( ((CLCT_pattern < 8) || (CLCT_pattern > 10)) && (ptR_front > 5.)) ptR_front = 5.;
827 if( ((CLCT_pattern < 8) || (CLCT_pattern > 10)) && (ptR_rear > 5.)) ptR_rear = 5.;
833 if(charge) absPhi12 = address.delta_phi();
836 int temp_phi = address.delta_phi();
837 absPhi12 =
static_cast<unsigned>(-temp_phi) & 0xfff;
856 absPhi12 = address.delta_phi_12;
857 absPhi23 = address.delta_phi_23;
859 if(charge) charge23 = -1;
863 dphi23R = float(absPhi23);
864 if(charge12 * charge23 < 0) dphi23R = -dphi23R;
868 if(fr == 1 && mode1 == 11) mode1 = 14;
904 absPhi12 = address.delta_phi_12;
905 absPhi23 = address.delta_phi_23;
907 if(charge) charge23 = 1;
912 if(charge12 * charge23 < 0) dphi23R = -dphi23R;
917 if(
pt_method == 12 && mode != 5 && etaR > 2.1)
919 float dphi12Rmin = dphi12R - Pi*10/180/3;
920 float dphi12Rmax = dphi12R + Pi*10/180/3;
921 float dphi23Rmin = dphi23R;
922 float dphi23Rmax = dphi23R;
923 if(dphi12Rmin*dphi12R < 0) dphi23Rmin = -dphi23R;
924 if(dphi12Rmax*dphi12R < 0) dphi23Rmax = -dphi23R;
930 ptR_front =
std::max(ptR_front, ptR_front_min);
931 ptR_front =
std::max(ptR_front, ptR_front_max);
932 ptR_rear =
std::max(ptR_rear, ptR_rear_min);
933 ptR_rear =
std::max(ptR_rear, ptR_rear_max);
944 if(charge) absPhi12 = address.delta_phi();
947 int temp_phi = address.delta_phi();
948 absPhi12 =
static_cast<unsigned>(-temp_phi) & 0xfff;
956 if((
pt_method == 12) && etaR > 2.1 && mode != 8 && mode !=9 && mode !=10)
958 float dphi12Rmin = fabs(fabs(dphi12R) - Pi*10/180/3);
962 ptR_front =
std::max(ptR_front, ptR_front_min);
963 ptR_rear =
std::max(ptR_rear, ptR_rear_min);
972 if(charge) absPhi12 = address.delta_phi();
975 int temp_phi = address.delta_phi();
976 absPhi12 =
static_cast<unsigned>(-temp_phi) & 0xfff;
984 absPhi12 = address.delta_phi_12;
985 absPhi23 = address.delta_phi_23;
987 if(charge) charge23 = 1;
992 if(charge12 * charge23 < 0) dphi23R = -dphi23R;
996 if(
pt_method == 12 && mode != 5 && etaR > 2.1)
998 float dphi12Rmin = dphi12R - Pi*10/180/3;
999 float dphi12Rmax = dphi12R + Pi*10/180/3;
1000 float dphi23Rmin = dphi23R;
1001 float dphi23Rmax = dphi23R;
1002 if(dphi12Rmin*dphi12R < 0) dphi23Rmin = -dphi23R;
1003 if(dphi12Rmax*dphi12R < 0) dphi23Rmax = -dphi23R;
1007 ptR_front =
std::max(ptR_front, ptR_front_min);
1008 ptR_front =
std::max(ptR_front, ptR_front_max);
1035 && (mode == 2 || mode == 3 || mode == 4) && (eta<3)) mode = 6;
1037 && (eta<3)) mode = 8;
1047 absPhi12 = address.delta_phi_12;
1048 absPhi23 = address.delta_phi_23;
1050 if(charge) charge23 = 1;
1059 if(charge12 * charge23 < 0) dphi23R = -dphi23R;
1064 if(
pt_method == 5 && mode != 5 && etaR > 2.1)
1066 float dphi12Rmin = dphi12R - Pi*10/180/3;
1067 float dphi12Rmax = dphi12R + Pi*10/180/3;
1068 float dphi23Rmin = dphi23R;
1069 float dphi23Rmax = dphi23R;
1070 if(dphi12Rmin*dphi12R < 0) dphi23Rmin = -dphi23R;
1071 if(dphi12Rmax*dphi12R < 0) dphi23Rmax = -dphi23R;
1077 ptR_front =
std::max(ptR_front, ptR_front_min);
1078 ptR_front =
std::max(ptR_front, ptR_front_max);
1079 ptR_rear =
std::max(ptR_rear, ptR_rear_min);
1080 ptR_rear =
std::max(ptR_rear, ptR_rear_max);
1087 if(charge12 * charge23 < 0) dphi23R = -dphi23R;
1097 ptR_front =
ptMethods.
Pt3StnChiSq(type+3, etaR, absPhi12<<1, ((charge == 0) ? -(absPhi23<<4) : (absPhi23<<4)), 1);
1098 ptR_rear =
ptMethods.
Pt3StnChiSq(type+3, etaR, absPhi12<<1, ((charge == 0) ? -(absPhi23<<4) : (absPhi23<<4)), 0);
1112 ptR_front =
ptMethods.
Pt3StnHybrid(type+3, etaR, absPhi12<<1, ((charge == 0) ? -(absPhi23<<4) : (absPhi23<<4)), 1);
1113 ptR_rear =
ptMethods.
Pt3StnHybrid(type+3, etaR, absPhi12<<1, ((charge == 0) ? -(absPhi23<<4) : (absPhi23<<4)), 0);
1130 if(charge) absPhi12 = address.delta_phi();
1133 int temp_phi = address.delta_phi();
1134 absPhi12 =
static_cast<unsigned>(-temp_phi) & 0xfff;
1137 if(absPhi12 < (1<<9))
1170 if((
pt_method == 5) && etaR > 2.1 && mode != 8 && mode !=9 && mode !=10)
1172 float dphi12Rmin = fabs(fabs(dphi12R) - Pi*10/180/3);
1176 ptR_front =
std::max(ptR_front, ptR_front_min);
1177 ptR_rear =
std::max(ptR_rear, ptR_rear_min);
1186 if(charge) absPhi12 = address.delta_phi();
1189 int temp_phi = address.delta_phi();
1190 absPhi12 =
static_cast<unsigned>(-temp_phi) & 0xfff;
1192 if(absPhi12 < (1<<9))
1210 if(fabs(dphi12R)<0.01 && (ptR_rear < 10 || ptR_front < 10))
1211 std::cout <<
"dphi12R = " << dphi12R <<
" ptR_rear = " << ptR_rear
1212 <<
" ptR_front = " << ptR_front <<
" etaR = " << etaR <<
" mode = " << mode << std::endl;
1218 if(charge) absPhi12 = address.delta_phi();
1221 int temp_phi = address.delta_phi();
1222 absPhi12 =
static_cast<unsigned>(-temp_phi) & 0xfff;
1224 if(absPhi12 < (1<<9))
1244 float dphi12Rmin = fabs(fabs(dphi12R) - Pi*10/180/3);
1248 ptR_front =
std::max(ptR_front, ptR_front_min);
1249 ptR_rear =
std::max(ptR_rear, ptR_rear_min);
1282 if ((front_pt==0 || front_pt==1) && (eta<3) && quality==1 &&
pt_method != 2) front_pt = 31;
1283 if ((rear_pt==0 || rear_pt==1) && (eta<3) && quality==1 &&
pt_method != 2) rear_pt = 31;
1287 if (front_pt < 5) front_pt = 5;
1288 if (rear_pt < 5) rear_pt = 5;
1293 if(quality == 3 && mode == 5) {
1295 if (front_pt < 5) front_pt = 5;
1296 if (rear_pt < 5) rear_pt = 5;
1299 if(quality == 2 && mode > 7 && mode < 11) {
1301 if (front_pt < 5) front_pt = 5;
1302 if (rear_pt < 5) rear_pt = 5;
1310 result.front_rank = front_pt | front_quality << 5;
1311 result.rear_rank = rear_pt | rear_quality << 5;
1313 result.charge_valid_front = 1;
1314 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
virtual float getLowEdge(unsigned packed) const =0
get the low edge of bin represented by packed
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]
float Pt2Stn2012(int type, float eta, float dphi, int PtbyMLH, float &theLH, int fr=-1, int method=11) const
virtual unsigned getPacked(float value) const =0
pack a value
static const int dPhiNLBMap_7bit[128]
static const double SECTOR_RAD
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.