Skip to content

Commit

Permalink
adding automated code checks
Browse files Browse the repository at this point in the history
  • Loading branch information
tajrussell committed Jun 12, 2024
1 parent 8c1b512 commit 75b75e0
Show file tree
Hide file tree
Showing 2 changed files with 194 additions and 126 deletions.
53 changes: 28 additions & 25 deletions RecoBTag/FeatureTools/interface/paired_helper.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,11 @@ double deltaR(double eta1, double phi1, double eta2, double phi2) {
}

double shiftpi(double phi, double shift, double lim) {
if (shift == 0) return phi;
if (shift == 0)
return phi;
if (shift > 0) {
if (phi < lim) return phi + shift;
if (phi < lim)
return phi + shift;
} else if (phi > lim) {
return phi + shift;
}
Expand All @@ -60,24 +62,25 @@ bool inEllipse(double jet1_eta, double jet1_phi, double jet2_eta, double jet2_ph
float eta0 = static_cast<float>(cand_eta);
float phi0 = static_cast<float>(cand_phi);
float semimajoradd = 1.0;
float djet, semimajor, focus, eta_center, phi_center, eta_f1,phi_f1,eta_f2,phi_f2, f1dist, f2dist, distsum; //, phi_m1, phi_m2;
float djet, semimajor, focus, eta_center, phi_center, eta_f1, phi_f1, eta_f2, phi_f2, f1dist, f2dist,
distsum; //, phi_m1, phi_m2;
double semiminor;

djet = deltaR(eta1, phi1, eta2, phi2);
semiminor = 1.5;
semimajor = std::max({semiminor,double(djet/2+semimajoradd)});
focus = pow(pow(semimajor,2)-pow(semiminor,2),0.5); // Distance of focus to center
semimajor = std::max({semiminor, double(djet / 2 + semimajoradd)});
focus = pow(pow(semimajor, 2) - pow(semiminor, 2), 0.5); // Distance of focus to center

eta_center = (eta1 + eta2) / 2;
phi_center = TVector2::Phi_mpi_pi(phi1 + TVector2::Phi_mpi_pi(phi2 - phi1) / 2);

eta_center = (eta1+eta2)/2;
phi_center = TVector2::Phi_mpi_pi(phi1 + TVector2::Phi_mpi_pi(phi2 - phi1)/2);

//focus 1
eta_f1 = eta_center + focus/(djet/2) * (eta1-eta_center);
phi_f1 = TVector2::Phi_mpi_pi(phi_center + focus/(djet/2) *TVector2::Phi_mpi_pi(phi1-phi_center));
eta_f1 = eta_center + focus / (djet / 2) * (eta1 - eta_center);
phi_f1 = TVector2::Phi_mpi_pi(phi_center + focus / (djet / 2) * TVector2::Phi_mpi_pi(phi1 - phi_center));

//focus 2
eta_f2 = eta_center + focus/(djet/2) * (eta2-eta_center);
phi_f2 = TVector2::Phi_mpi_pi(phi_center + focus/(djet/2) *TVector2::Phi_mpi_pi(phi2-phi_center));
eta_f2 = eta_center + focus / (djet / 2) * (eta2 - eta_center);
phi_f2 = TVector2::Phi_mpi_pi(phi_center + focus / (djet / 2) * TVector2::Phi_mpi_pi(phi2 - phi_center));

// Two ends of major axis. This is necesssary to make sure that the point p is not in between the foci on the wrong side of the phi axis
// phi_m1 = TVector2::Phi_mpi_pi(phi_center + semimajor/(djet/2) *TVector2::Phi_mpi_pi(phi1-phi_center));
Expand All @@ -86,25 +89,25 @@ bool inEllipse(double jet1_eta, double jet1_phi, double jet2_eta, double jet2_ph
double shift = 0, lim = 0;
// if (phi_center > phi_m1 && phi_center > phi_m2) shift = 2*pi;
// if (phi_center < phi_m1 && phi_center < phi_m2) shift = -2*pi;

if (phi_center >= 0) {
shift = 2*pi;
shift = 2 * pi;
lim = phi_center - pi;
}
else {
shift = -2*pi;
} else {
shift = -2 * pi;
lim = phi_center + pi;
}

// if (abs(phi1-phi2) > 3.4) cout << "(" << eta1 << "," << phi1 << "), " << "(" << eta2 << "," << phi2 << "), " << "(" << eta_f1 << "," << phi_f1 << "), "<< "(" << eta_f2 << "," << phi_f2 << "), " << "(" << eta_center << "," << phi_center << ")" << endl;
float phi0_s = shiftpi(phi0,shift,lim);
float phi0_s = shiftpi(phi0, shift, lim);

f1dist = std::hypot(eta0-eta_f1,phi0_s-shiftpi(phi_f1,shift,lim));
f2dist = std::hypot(eta0-eta_f2,phi0_s-shiftpi(phi_f2,shift,lim));
distsum = f1dist+f2dist;
f1dist = std::hypot(eta0 - eta_f1, phi0_s - shiftpi(phi_f1, shift, lim));
f2dist = std::hypot(eta0 - eta_f2, phi0_s - shiftpi(phi_f2, shift, lim));
distsum = f1dist + f2dist;

//if in ellipse, the sum of the distances will be less than 2*semimajor
if (distsum < 2*semimajor) return true;
else return false;

if (distsum < 2 * semimajor)
return true;
else
return false;
}
Loading

0 comments on commit 75b75e0

Please sign in to comment.