235 double Pi = acos(-1.);
236 float etaR = 0, ptR_front = 0, ptR_rear = 0, dphi12R = 0, dphi23R = 0;
237 int charge12, charge23;
242 int usedetaCUT =
true;
246 int EtaCutLevel_1 = 2;
249 for (
int i=0;
i<24;
i++)
252 if (EtaCutLevel_1 == 1)
254 else if (EtaCutLevel_1 == 2)
256 else if (EtaCutLevel_1 == 3)
258 else if (EtaCutLevel_1 == 4)
260 else if (EtaCutLevel_1 == 5)
262 else if (EtaCutLevel_1 == 6)
266 int EtaCutLevel_2 = 2;
269 for (
int i=0;
i<24;
i++)
272 if (EtaCutLevel_2 == 1)
274 else if (EtaCutLevel_2 == 2)
276 else if (EtaCutLevel_2 == 3)
278 else if (EtaCutLevel_2 == 4)
280 else if (EtaCutLevel_2 == 5)
282 else if (EtaCutLevel_2 == 6)
286 if (mode == 8 || mode == 10)
287 dEtaCut_2[
i] = scalef*dEtaCut_2[
i];
296 charge =
address.delta_phi_sign;
298 unsigned front_pt, rear_pt;
299 front_pt = 0.; rear_pt = 0.;
300 unsigned front_quality, rear_quality;
304 front_quality = rear_quality = quality;
306 unsigned int remerged;
312 float bestLH_front = -999.0;
313 float bestLH_rear = -999.0;
341 remerged = (
address.delta_phi_12 | (
address.delta_phi_23 << 8 ) );
344 absPhi12 = ((1<<7)-1) & remerged;
345 absPhi23 = ((1<<5)-1) & (remerged >> 7);
351 if(charge) charge23 = 1;
356 if(charge12 * charge23 < 0) dphi23R = -dphi23R;
359 bestLH_front = bestLH;
361 bestLH_rear = bestLH;
365 float dphi12Rmin = dphi12R - Pi*10/180/3;
366 float dphi12Rmax = dphi12R + Pi*10/180/3;
367 float dphi23Rmin = dphi23R;
368 float dphi23Rmax = dphi23R;
372 float bestLH_front_min = bestLH;
374 float bestLH_rear_min = bestLH;
376 float bestLH_front_max = bestLH;
378 float bestLH_rear_max = bestLH;
382 float best_pt_front = ptR_front;
383 float best_LH_front = bestLH_front;
384 if (bestLH_front_min > best_LH_front)
386 best_pt_front = ptR_front_min;
387 best_LH_front = bestLH_front_min;
389 if (bestLH_front_max > best_LH_front)
391 best_pt_front = ptR_front_max;
392 best_LH_front = bestLH_front_max;
394 ptR_front = best_pt_front;
396 float best_pt_rear = ptR_rear;
397 float best_LH_rear = bestLH_rear;
398 if (bestLH_rear_min > best_LH_rear)
400 best_pt_rear = ptR_rear_min;
401 best_LH_rear = bestLH_rear_min;
403 if (bestLH_rear_max > best_LH_rear)
405 best_pt_rear = ptR_rear_max;
406 best_LH_rear = bestLH_rear_max;
408 ptR_rear = best_pt_rear;
413 ptR_front =
std::max(ptR_front, ptR_front_min);
414 ptR_front =
std::max(ptR_front, ptR_front_max);
415 ptR_rear =
std::max(ptR_rear, ptR_rear_min);
416 ptR_rear =
std::max(ptR_rear, ptR_rear_max);
425 remerged = (
address.delta_phi_12 | (
address.delta_phi_23 << 8 ) );
427 absPhi12 = ((1<<8)-1) & remerged;
429 dEta = ((1<<3)-1) & (remerged >> 8);
431 CLCT_pattern = 0x1 & (remerged >> 11);
434 if(iME11 == 1 && etaR > 1.6) etaR = 1.55;
435 if(iME11 == 0 && etaR < 1.6) etaR = 1.65;
438 absPhi12 = ((1<<8)-1) &
address.delta_phi_12;
449 bestLH_front = bestLH;
451 bestLH_rear = bestLH;
454 float dphi12Rmin = fabs(fabs(dphi12R) - Pi*10/180/3);
456 float bestLH_front_min = bestLH;
458 float bestLH_rear_min = bestLH;
462 ptR_front = bestLH_front > bestLH_front_min ? ptR_front : ptR_front_min;
463 ptR_rear = bestLH_rear > bestLH_rear_min ? ptR_rear : ptR_rear_min;
468 ptR_front =
std::max(ptR_front, ptR_front_min);
469 ptR_rear =
std::max(ptR_rear, ptR_rear_min);
473 if( (!CLCT_pattern) && (ptR_front > 5.)) ptR_front = 5.;
474 if( (!CLCT_pattern) && (ptR_rear > 5.)) ptR_rear = 5.;
478 if (mode == 6) index = 0;
479 if (mode == 7) index = 4;
480 if (mode == 13) index = 8;
484 if (fabs(etaR)>1.2 && fabs(etaR)<=1.5)
485 if (dEta>dEtaCut_1[index+0] )
487 if (ptR_front > 5) ptR_front = 5;
488 if (ptR_rear > 5) ptR_rear = 5;
490 if (fabs(etaR)>1.5 && fabs(etaR)<=1.65)
491 if (dEta>dEtaCut_1[index+1])
493 if (ptR_front > 5) ptR_front = 5;
494 if (ptR_rear > 5) ptR_rear = 5;
497 if (fabs(etaR)>1.65 && fabs(etaR)<=2.1)
498 if (dEta>dEtaCut_1[index+2] )
500 if (ptR_front > 5) ptR_front = 5;
501 if (ptR_rear > 5) ptR_rear = 5;
504 if (dEta>dEtaCut_1[index+3] )
506 if (ptR_front > 5) ptR_front = 5;
507 if (ptR_rear > 5) ptR_rear = 5;
519 remerged = (
address.delta_phi_12 | (
address.delta_phi_23 << 8 ) );
521 absPhi12 = ((1<<9)-1) & remerged;
523 dEta = ((1<<3)-1) & (remerged >> 9);
532 if (mode == 8) index = 12;
533 if (mode == 9) index = 16;
534 if (mode == 10) index = 20;
541 if (fabs(etaR)>1.2 && fabs(etaR)<=1.5)
542 if (dEta>dEtaCut_2[index+0] )
544 if (ptR_front > 5) ptR_front = 5;
545 if (ptR_rear > 5) ptR_rear = 5;
547 if (fabs(etaR)>1.5 && fabs(etaR)<=1.65)
548 if (dEta>dEtaCut_2[index+1])
550 if (ptR_front > 5) ptR_front = 5;
551 if (ptR_rear > 5) ptR_rear = 5;
554 if (fabs(etaR)>1.65 && fabs(etaR)<=2.1)
555 if (dEta>dEtaCut_2[index+2] )
557 if (ptR_front > 5) ptR_front = 5;
558 if (ptR_rear > 5) ptR_rear = 5;
561 if (dEta>dEtaCut_2[index+3] )
563 if (ptR_front > 5) ptR_front = 5;
564 if (ptR_rear > 5) ptR_rear = 5;
582 absPhi12 =
address.delta_phi_12;
583 absPhi23 =
address.delta_phi_23;
585 if(charge) charge23 = -1;
589 dphi23R = float(absPhi23);
590 if(charge12 * charge23 < 0) dphi23R = -dphi23R;
594 if(fr == 1 && mode1 == 11) mode1 = 14;
631 absPhi12 =
address.delta_phi_12;
632 absPhi23 =
address.delta_phi_23;
634 if(charge) charge23 = 1;
639 if(charge12 * charge23 < 0) dphi23R = -dphi23R;
646 float dphi12Rmin = dphi12R - Pi*10/180/3;
647 float dphi12Rmax = dphi12R + Pi*10/180/3;
648 float dphi23Rmin = dphi23R;
649 float dphi23Rmax = dphi23R;
657 ptR_front =
std::max(ptR_front, ptR_front_min);
658 ptR_front =
std::max(ptR_front, ptR_front_max);
659 ptR_rear =
std::max(ptR_rear, ptR_rear_min);
660 ptR_rear =
std::max(ptR_rear, ptR_rear_max);
668 if(iME11 == 1 && etaR > 1.6) etaR = 1.55;
669 if(iME11 == 0 && etaR < 1.6) etaR = 1.65;
670 absPhi12 =
address.delta_phi_12;
673 CLCT_pattern = int(
address.delta_phi_23);
681 float dphi12Rmin = fabs(fabs(dphi12R) - Pi*10/180/3);
685 ptR_front =
std::max(ptR_front, ptR_front_min);
686 ptR_rear =
std::max(ptR_rear, ptR_rear_min);
688 if( ((CLCT_pattern < 8) || (CLCT_pattern > 10)) && (ptR_front > 5.)) ptR_front = 5.;
689 if( ((CLCT_pattern < 8) || (CLCT_pattern > 10)) && (ptR_rear > 5.)) ptR_rear = 5.;
696 if(charge) absPhi12 =
address.delta_phi();
699 int temp_phi =
address.delta_phi();
700 absPhi12 =
static_cast<unsigned>(-temp_phi) & 0xfff;
720 absPhi12 =
address.delta_phi_12;
721 absPhi23 =
address.delta_phi_23;
723 if(charge) charge23 = -1;
727 dphi23R = float(absPhi23);
728 if(charge12 * charge23 < 0) dphi23R = -dphi23R;
732 if(fr == 1 && mode1 == 11) mode1 = 14;
768 absPhi12 =
address.delta_phi_12;
769 absPhi23 =
address.delta_phi_23;
771 if(charge) charge23 = 1;
776 if(charge12 * charge23 < 0) dphi23R = -dphi23R;
781 if(
pt_method == 22 && mode != 5 && etaR > 2.1)
783 float dphi12Rmin = dphi12R - Pi*10/180/3;
784 float dphi12Rmax = dphi12R + Pi*10/180/3;
785 float dphi23Rmin = dphi23R;
786 float dphi23Rmax = dphi23R;
794 ptR_front =
std::max(ptR_front, ptR_front_min);
795 ptR_front =
std::max(ptR_front, ptR_front_max);
796 ptR_rear =
std::max(ptR_rear, ptR_rear_min);
797 ptR_rear =
std::max(ptR_rear, ptR_rear_max);
805 absPhi12 =
address.delta_phi_12;
808 CLCT_pattern = int(
address.delta_phi_23);
817 float dphi12Rmin = fabs(fabs(dphi12R) - Pi*10/180/3);
821 ptR_front =
std::max(ptR_front, ptR_front_min);
822 ptR_rear =
std::max(ptR_rear, ptR_rear_min);
824 if( ((CLCT_pattern < 8) || (CLCT_pattern > 10)) && (ptR_front > 5.)) ptR_front = 5.;
825 if( ((CLCT_pattern < 8) || (CLCT_pattern > 10)) && (ptR_rear > 5.)) ptR_rear = 5.;
831 if(charge) absPhi12 =
address.delta_phi();
834 int temp_phi =
address.delta_phi();
835 absPhi12 =
static_cast<unsigned>(-temp_phi) & 0xfff;
854 absPhi12 =
address.delta_phi_12;
855 absPhi23 =
address.delta_phi_23;
857 if(charge) charge23 = -1;
861 dphi23R = float(absPhi23);
862 if(charge12 * charge23 < 0) dphi23R = -dphi23R;
866 if(fr == 1 && mode1 == 11) mode1 = 14;
902 absPhi12 =
address.delta_phi_12;
903 absPhi23 =
address.delta_phi_23;
905 if(charge) charge23 = 1;
910 if(charge12 * charge23 < 0) dphi23R = -dphi23R;
915 if(
pt_method == 12 && mode != 5 && etaR > 2.1)
917 float dphi12Rmin = dphi12R - Pi*10/180/3;
918 float dphi12Rmax = dphi12R + Pi*10/180/3;
919 float dphi23Rmin = dphi23R;
920 float dphi23Rmax = dphi23R;
921 if(dphi12Rmin*dphi12R < 0) dphi23Rmin = -dphi23R;
922 if(dphi12Rmax*dphi12R < 0) dphi23Rmax = -dphi23R;
928 ptR_front =
std::max(ptR_front, ptR_front_min);
929 ptR_front =
std::max(ptR_front, ptR_front_max);
930 ptR_rear =
std::max(ptR_rear, ptR_rear_min);
931 ptR_rear =
std::max(ptR_rear, ptR_rear_max);
942 if(charge) absPhi12 =
address.delta_phi();
945 int temp_phi =
address.delta_phi();
946 absPhi12 =
static_cast<unsigned>(-temp_phi) & 0xfff;
954 if((
pt_method == 12) && etaR > 2.1 && mode != 8 && mode !=9 && mode !=10)
956 float dphi12Rmin = fabs(fabs(dphi12R) - Pi*10/180/3);
960 ptR_front =
std::max(ptR_front, ptR_front_min);
961 ptR_rear =
std::max(ptR_rear, ptR_rear_min);
970 if(charge) absPhi12 =
address.delta_phi();
973 int temp_phi =
address.delta_phi();
974 absPhi12 =
static_cast<unsigned>(-temp_phi) & 0xfff;
982 absPhi12 =
address.delta_phi_12;
983 absPhi23 =
address.delta_phi_23;
985 if(charge) charge23 = 1;
990 if(charge12 * charge23 < 0) dphi23R = -dphi23R;
994 if(
pt_method == 12 && mode != 5 && etaR > 2.1)
996 float dphi12Rmin = dphi12R - Pi*10/180/3;
997 float dphi12Rmax = dphi12R + Pi*10/180/3;
998 float dphi23Rmin = dphi23R;
999 float dphi23Rmax = dphi23R;
1000 if(dphi12Rmin*dphi12R < 0) dphi23Rmin = -dphi23R;
1001 if(dphi12Rmax*dphi12R < 0) dphi23Rmax = -dphi23R;
1005 ptR_front =
std::max(ptR_front, ptR_front_min);
1006 ptR_front =
std::max(ptR_front, ptR_front_max);
1033 && (mode == 2 || mode == 3 || mode == 4) && (eta<3)) mode = 6;
1035 && (eta<3)) mode = 8;
1045 absPhi12 =
address.delta_phi_12;
1046 absPhi23 =
address.delta_phi_23;
1048 if(charge) charge23 = 1;
1057 if(charge12 * charge23 < 0) dphi23R = -dphi23R;
1062 if(
pt_method == 5 && mode != 5 && etaR > 2.1)
1064 float dphi12Rmin = dphi12R - Pi*10/180/3;
1065 float dphi12Rmax = dphi12R + Pi*10/180/3;
1066 float dphi23Rmin = dphi23R;
1067 float dphi23Rmax = dphi23R;
1068 if(dphi12Rmin*dphi12R < 0) dphi23Rmin = -dphi23R;
1069 if(dphi12Rmax*dphi12R < 0) dphi23Rmax = -dphi23R;
1075 ptR_front =
std::max(ptR_front, ptR_front_min);
1076 ptR_front =
std::max(ptR_front, ptR_front_max);
1077 ptR_rear =
std::max(ptR_rear, ptR_rear_min);
1078 ptR_rear =
std::max(ptR_rear, ptR_rear_max);
1085 if(charge12 * charge23 < 0) dphi23R = -dphi23R;
1095 ptR_front =
ptMethods.
Pt3StnChiSq(type+3, etaR, absPhi12<<1, ((charge == 0) ? -(absPhi23<<4) : (absPhi23<<4)), 1);
1096 ptR_rear =
ptMethods.
Pt3StnChiSq(type+3, etaR, absPhi12<<1, ((charge == 0) ? -(absPhi23<<4) : (absPhi23<<4)), 0);
1110 ptR_front =
ptMethods.
Pt3StnHybrid(type+3, etaR, absPhi12<<1, ((charge == 0) ? -(absPhi23<<4) : (absPhi23<<4)), 1);
1111 ptR_rear =
ptMethods.
Pt3StnHybrid(type+3, etaR, absPhi12<<1, ((charge == 0) ? -(absPhi23<<4) : (absPhi23<<4)), 0);
1128 if(charge) absPhi12 =
address.delta_phi();
1131 int temp_phi =
address.delta_phi();
1132 absPhi12 =
static_cast<unsigned>(-temp_phi) & 0xfff;
1135 if(absPhi12 < (1<<9))
1168 if((
pt_method == 5) && etaR > 2.1 && mode != 8 && mode !=9 && mode !=10)
1170 float dphi12Rmin = fabs(fabs(dphi12R) - Pi*10/180/3);
1174 ptR_front =
std::max(ptR_front, ptR_front_min);
1175 ptR_rear =
std::max(ptR_rear, ptR_rear_min);
1184 if(charge) absPhi12 =
address.delta_phi();
1187 int temp_phi =
address.delta_phi();
1188 absPhi12 =
static_cast<unsigned>(-temp_phi) & 0xfff;
1190 if(absPhi12 < (1<<9))
1208 if(fabs(dphi12R)<0.01 && (ptR_rear < 10 || ptR_front < 10))
1209 std::cout <<
"dphi12R = " << dphi12R <<
" ptR_rear = " << ptR_rear
1210 <<
" ptR_front = " << ptR_front <<
" etaR = " << etaR <<
" mode = " << mode << std::endl;
1216 if(charge) absPhi12 =
address.delta_phi();
1219 int temp_phi =
address.delta_phi();
1220 absPhi12 =
static_cast<unsigned>(-temp_phi) & 0xfff;
1222 if(absPhi12 < (1<<9))
1242 float dphi12Rmin = fabs(fabs(dphi12R) - Pi*10/180/3);
1246 ptR_front =
std::max(ptR_front, ptR_front_min);
1247 ptR_rear =
std::max(ptR_rear, ptR_rear_min);
1280 if ((front_pt==0 || front_pt==1) && (eta<3) && quality==1 &&
pt_method != 2) front_pt = 31;
1281 if ((rear_pt==0 || rear_pt==1) && (eta<3) && quality==1 &&
pt_method != 2) rear_pt = 31;
1285 if (front_pt < 5) front_pt = 5;
1286 if (rear_pt < 5) rear_pt = 5;
1291 if(quality == 3 && mode == 5) {
1293 if (front_pt < 5) front_pt = 5;
1294 if (rear_pt < 5) rear_pt = 5;
1297 if(quality == 2 && mode > 7 && mode < 11) {
1299 if (front_pt < 5) front_pt = 5;
1300 if (rear_pt < 5) rear_pt = 5;
1308 result.front_rank = front_pt | front_quality << 5;
1309 result.rear_rank = rear_pt | rear_quality << 5;
1311 result.charge_valid_front = 1;
1312 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]
const T & max(const T &a, const T &b)
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]