26 #include <TFitResult.h>
27 #include <TFitResultPtr.h>
28 #include <TMatrixDSym.h>
31 #include "Math/VectorUtil.h"
34 using ROOT::Math::PtEtaPhiMVector;
35 using ROOT::Math::PxPyPzMVector;
36 using ROOT::Math::XYVector;
123 float hEmax = 3000.0;
133 m_fMfit_all = std::make_shared<TH1F>(
"MMC_h1",
"M", hNbins, 0.0,
136 m_fMEtP_all = std::make_shared<TH1F>(
"MEtP_h1",
"M", hNbins, -100.0,
138 m_fMEtL_all = std::make_shared<TH1F>(
"MEtL_h1",
"M", hNbins, -100.0,
140 m_fMnu1_all = std::make_shared<TH1F>(
"Mnu1_h1",
"M", hNbins, 0.0,
142 m_fMnu2_all = std::make_shared<TH1F>(
"Mnu2_h1",
"M", hNbins, 0.0,
144 m_fPhi1_all = std::make_shared<TH1F>(
"Phi1_h1",
"M", hNbins, -10.0,
146 m_fPhi2_all = std::make_shared<TH1F>(
"Phi2_h1",
"M", hNbins, -10.0,
155 m_fMmass_split1 = std::make_shared<TH1F>(
"mass_h1_1",
"M", hNbins, 0.0, hEmax);
156 m_fMEtP_split1 = std::make_shared<TH1F>(
"MEtP_h1_1",
"M", hNbins, -100.0, 100.0);
157 m_fMEtL_split1 = std::make_shared<TH1F>(
"MEtL_h1_1",
"M", hNbins, -100.0, 100.0);
158 m_fMnu1_split1 = std::make_shared<TH1F>(
"Mnu1_h1_1",
"M", hNbins, 0.0, hEmax);
159 m_fMnu2_split1 = std::make_shared<TH1F>(
"Mnu2_h1_1",
"M", hNbins, 0.0, hEmax);
160 m_fPhi1_split1 = std::make_shared<TH1F>(
"Phi1_h1_1",
"M", hNbins, -10.0, 10.0);
161 m_fPhi2_split1 = std::make_shared<TH1F>(
"Phi2_h1_1",
"M", hNbins, -10.0, 10.0);
162 m_fMmass_split2 = std::make_shared<TH1F>(
"mass_h1_2",
"M", hNbins, 0.0, hEmax);
163 m_fMEtP_split2 = std::make_shared<TH1F>(
"MEtP_h1_2",
"M", hNbins, -100.0, 100.0);
164 m_fMEtL_split2 = std::make_shared<TH1F>(
"MEtL_h1_2",
"M", hNbins, -100.0, 100.0);
165 m_fMnu1_split2 = std::make_shared<TH1F>(
"Mnu1_h1_2",
"M", hNbins, 0.0, hEmax);
166 m_fMnu2_split2 = std::make_shared<TH1F>(
"Mnu2_h1_2",
"M", hNbins, 0.0, hEmax);
167 m_fPhi1_split2 = std::make_shared<TH1F>(
"Phi1_h1_2",
"M", hNbins, -10.0, 10.0);
168 m_fPhi2_split2 = std::make_shared<TH1F>(
"Phi2_h1_2",
"M", hNbins, -10.0, 10.0);
200 std::make_shared<TH1F>(
"MMC_h1NoW",
"M no weight", hNbins, 0.0, hEmax);
202 m_fPXfit1 = std::make_shared<TH1F>(
"MMC_h2",
"Px1", 4 * hNbins, -hEmax,
204 m_fPYfit1 = std::make_shared<TH1F>(
"MMC_h3",
"Py1", 4 * hNbins, -hEmax,
206 m_fPZfit1 = std::make_shared<TH1F>(
"MMC_h4",
"Pz1", 4 * hNbins, -hEmax,
208 m_fPXfit2 = std::make_shared<TH1F>(
"MMC_h5",
"Px2", 4 * hNbins, -hEmax,
210 m_fPYfit2 = std::make_shared<TH1F>(
"MMC_h6",
"Py2", 4 * hNbins, -hEmax,
212 m_fPZfit2 = std::make_shared<TH1F>(
"MMC_h7",
"Pz2", 4 * hNbins, -hEmax,
256 m_fFitting->SetParNames(
"Max",
"Mean",
"InvWidth2");
281 Info(
"DiTauMassTools",
"------------- Raw Input for MissingMassCalculator --------------");
286 Info(
"DiTauMassTools",
"------------- Prepared Input for MissingMassCalculator--------------");
305 double dummy_METres =
326 Info(
"DiTauMassTools",
"Calling DitauMassCalculatorV9lfv");
332 TFile *
outFile = TFile::Open(
"MMC_likelihoods.root",
"UPDATE");
347 TH1D *nosol =
new TH1D(
"nosol",
"nosol", 7, 0, 7);
355 nosol->Write(nosol->GetName(), TObject::kOverwrite);
370 fStuff.
nutau1 = PtEtaPhiMVector(0., 0., 0., 0.);
371 fStuff.
nutau2 = PtEtaPhiMVector(0., 0., 0., 0.);
372 fStuff.
vistau1 = PtEtaPhiMVector(0., 0., 0., 0.);
373 fStuff.
vistau2 = PtEtaPhiMVector(0., 0., 0., 0.);
385 Info(
"DiTauMassTools",
"Retrieving output from fDitauStuffFit");
390 double q1 = (1. - 0.68) / 2.;
417 PtEtaPhiMVector tlvdummy(0., 0., 0., 0.);
418 XYVector metdummy(0., 0.);
459 PtEtaPhiMVector dummy_vec1(0.0, 0.0, 0.0, 0.0);
460 PtEtaPhiMVector dummy_vec2(0.0, 0.0, 0.0, 0.0);
461 for (
int i = 0;
i < 3;
i++) {
483 Info(
"DiTauMassTools",
484 ".........................Other input.....................................");
485 Info(
"DiTauMassTools",
"%s",
489 Info(
"DiTauMassTools",
"%s",
492 Info(
"DiTauMassTools",
"%s",
500 Info(
"DiTauMassTools",
501 "tau1 and tau2 were internally swapped (visible on prepared input printout)");
503 Info(
"DiTauMassTools",
"tau1 and tau2 were NOT internally swapped");
506 Info(
"DiTauMassTools",
"%s",
508 Info(
"DiTauMassTools",
"%s",
510 Info(
"DiTauMassTools",
"%s",
512 Info(
"DiTauMassTools",
"%s",
514 Info(
"DiTauMassTools",
"%s",
516 Info(
"DiTauMassTools",
"%s",
526 const PtEtaPhiMVector *origVisTau1 = 0;
527 const PtEtaPhiMVector *origVisTau2 = 0;
540 Info(
"DiTauMassTools",
541 "------------- Printing Final Results for MissingMassCalculator --------------");
542 Info(
"DiTauMassTools",
543 ".............................................................................");
547 Info(
"DiTauMassTools",
"%s",
550 Info(
"DiTauMassTools",
"%s",
556 Info(
"DiTauMassTools",
" no 4-momentum or MET from this method ");
561 Info(
"DiTauMassTools",
" fit failed ");
570 Info(
"DiTauMassTools",
"%s",
576 Info(
"DiTauMassTools",
"%s",
582 Info(
"DiTauMassTools",
"%s",
588 Info(
"DiTauMassTools",
"%s",
595 Info(
"DiTauMassTools",
"%s",
597 Info(
"DiTauMassTools",
"%s",
600 Info(
"DiTauMassTools",
"%s",
627 const double &phi1,
const double &phi2,
628 int &nsol1,
int &nsol2) {
649 int solution_code = 0;
667 if (pTmiss2 * dPhiSign < 0) {
669 return solution_code;
675 if (pTmiss1 * (-dPhiSign) < 0) {
677 return solution_code;
686 double m4noma1 = m2noma1 * m2noma1;
688 double p2v1proj =
std::pow(pv1proj, 2);
690 double pTmiss2CscDPhi = pTmiss2 / sinDPhi2;
691 double &pTn1 = pTmiss2CscDPhi;
692 double pT2miss2CscDPhi = pTmiss2CscDPhi * pTmiss2CscDPhi;
695 const double discri1 = m4noma1 + 4 * m2noma1 * pTmiss2CscDPhi * pv1proj -
696 4 * (
m_ET2v1 * (
m_m2Nu1 + pT2miss2CscDPhi) - (pT2miss2CscDPhi * p2v1proj));
701 return solution_code;
709 double m4noma2 = m2noma2 * m2noma2;
711 double p2v2proj =
std::pow(pv2proj, 2);
712 double sinDPhi1 = -sinDPhi2;
713 double pTmiss1CscDPhi = pTmiss1 / sinDPhi1;
714 double &pTn2 = pTmiss1CscDPhi;
715 double pT2miss1CscDPhi = pTmiss1CscDPhi * pTmiss1CscDPhi;
717 const double discri2 = m4noma2 + 4 * m2noma2 * pTmiss1CscDPhi * pv2proj -
718 4 * (
m_ET2v2 * (
m_m2Nu2 + pT2miss1CscDPhi) - (pT2miss1CscDPhi * p2v2proj));
723 return solution_code;
729 double sqdiscri1 = sqrt(discri1);
735 double pn1Z = first1 + second1;
737 if (m2noma1 + 2 * pTmiss2CscDPhi * pv1proj + 2 * pn1Z *
m_tauVec1Pz >
746 pn1Z = first1 - second1;
748 if (m2noma1 + 2 * pTmiss2CscDPhi * pv1proj + 2 * pn1Z *
m_tauVec1Pz >
760 return solution_code;
765 double sqdiscri2 = sqrt(discri2);
771 double pn2Z = first2 + second2;
773 if (m2noma2 + 2 * pTmiss1CscDPhi * pv2proj + 2 * pn2Z *
m_tauVec2Pz >
782 pn2Z = first2 - second2;
785 if (m2noma2 + 2 * pTmiss1CscDPhi * pv2proj + 2 * pn2Z *
m_tauVec2Pz >
796 return solution_code;
812 if (std::abs(pnux - pTmissx) > 0.001 || std::abs(pnuy - pTmissy) > 0.001) {
813 Info(
"DiTauMassTools",
"%s", (
"NuPsolutionV3 ERROR Pnux-Met.X or Pnuy-Met.Y > 0.001 : " +
818 if (std::abs(mtau1plus -
m_mTau) > 0.001 || std::abs(mtau1moins -
m_mTau) > 0.001 ||
819 std::abs(mtau2plus -
m_mTau) > 0.001 || std::abs(mtau2moins -
m_mTau) > 0.001) {
820 Info(
"DiTauMassTools",
"%s", (
"NuPsolutionV3 ERROR tau mass not recovered : " +
827 return solution_code;
832 const PtEtaPhiMVector &tau,
const double &l_nu,
833 std::vector<PtEtaPhiMVector> &nu_vec) {
834 int solution_code = 0;
837 PxPyPzMVector nu(met_vec.X(), met_vec.Y(), 0.0, l_nu);
838 PxPyPzMVector nu2(met_vec.X(), met_vec.Y(), 0.0, l_nu);
840 const double Mtau = 1.777;
842 double msq = (Mtau * Mtau - tau.M() * tau.M() - l_nu * l_nu) /
844 double gamma = nu.Px() * nu.Px() + nu.Py() * nu.Py();
845 double beta = tau.Px() * nu.Px() + tau.Py() * nu.Py() + msq;
846 double a = tau.E() * tau.E() - tau.Pz() * tau.Pz();
847 double b = -2 * tau.Pz() *
beta;
849 if ((
b *
b - 4 *
a *
c) < 0)
850 return solution_code;
853 double pvz1 = (-
b + sqrt(
b *
b - 4 *
a *
c)) / (2 *
a);
854 double pvz2 = (-
b - sqrt(
b *
b - 4 *
a *
c)) / (2 *
a);
856 nu.SetCoordinates(met_vec.X(), met_vec.Y(), pvz1, l_nu);
857 nu2.SetCoordinates(met_vec.X(), met_vec.Y(), pvz2, l_nu);
859 PtEtaPhiMVector return_nu(nu.Pt(), nu.Eta(), nu.Phi(), nu.M());
860 PtEtaPhiMVector return_nu2(nu2.Pt(), nu2.Eta(), nu2.Phi(), nu2.M());
861 nu_vec.push_back(return_nu);
862 nu_vec.push_back(return_nu2);
863 return solution_code;
921 XYVector deltamet_vec;
928 bool paramInsideRange =
false;
947 if (paramInsideRange)
971 if (nsuccesses > 0) {
977 double Px1, Py1, Pz1;
978 double Px2, Py2, Pz2;
979 if (nsuccesses > 0) {
1000 if (prob_hist != 0.0)
1024 PxPyPzMVector fulltau1, fulltau2;
1025 fulltau1.SetCoordinates(Px1, Py1, Pz1, 1.777);
1026 fulltau2.SetCoordinates(Px2, Py2, Pz2, 1.777);
1046 Info(
"DiTauMassTools",
"Scanning ");
1047 Info(
"DiTauMassTools",
" Markov ");
1048 Info(
"DiTauMassTools",
"%s",
1054 Info(
"DiTauMassTools",
"%s",
1060 if (fit_code == 0) {
1061 Info(
"DiTauMassTools",
"%s", (
"!!!----> Warning-3 in "
1062 "MissingMassCalculator::DitauMassCalculatorV9Walk() : fit status=" +
1065 Info(
"DiTauMassTools",
"%s",
"....... No solution is found. Printing input info .......");
1083 Info(
"DiTauMassTools",
" ---------------------------------------------------------- ");
1105 const double Mtau = 1.777;
1125 double METresX_binSize = 2 * N_METsigma * METresX / NiterMET;
1126 double METresY_binSize = 2 * N_METsigma * METresY / NiterMET;
1130 std::vector<PtEtaPhiMVector> nu_vec;
1135 double metprob = 1.0;
1136 double sign_tmp = 0.0;
1137 double tauprob = 1.0;
1138 double totalProb = 0.0;
1142 double met_smear_x = 0.0;
1143 double met_smear_y = 0.0;
1144 double met_smearL = 0.0;
1145 double met_smearP = 0.0;
1147 double angle1 = 0.0;
1187 Info(
"DiTauMassTools",
"Running in dilepton mode");
1192 PtEtaPhiMVector tau_tmp(0.0, 0.0, 0.0, 0.0);
1193 PtEtaPhiMVector lep_tmp(0.0, 0.0, 0.0, 0.0);
1233 double Mlep = tau_tmp.M();
1240 double MnuProb = 1.0;
1242 for (
int i3 = 0; i3 < NiterMnu; i3++)
1244 M_nu = Mnu_binSize * i3;
1245 if (M_nu >= (Mtau - Mlep))
1251 for (
int i4 = 0; i4 < NiterMET + 1; i4++)
1253 met_smearL = METresX_binSize * i4 - N_METsigma * METresX;
1254 for (
int i5 = 0; i5 < NiterMET + 1; i5++)
1256 met_smearP = METresY_binSize * i5 - N_METsigma * METresY;
1257 if (
pow(met_smearL / METresX, 2) +
pow(met_smearP / METresY, 2) >
pow(N_METsigma, 2))
1259 met_smear_x = met_smearL * met_coscovphi - met_smearP * met_sincovphi;
1260 met_smear_y = met_smearL * met_sincovphi + met_smearP * met_coscovphi;
1261 metvec_tmp.SetXY(input_metX + met_smear_x, input_metY + met_smear_y);
1279 for (
unsigned int j1 = 0;
j1 < nu_vec.size();
j1++) {
1282 const double tau1_tmpp = (tau_tmp + nu_vec[
j1]).
P();
1283 angle1 =
Angle(nu_vec[
j1], tau_tmp);
1293 double tauvecprob1j =
1295 if (tauvecprob1j == 0.)
1298 totalProb = tauvecprob1j * metprob * MnuProb * tauprob;
1315 m_fPXfit1->Fill((tau_tmp + nu_vec[
j1]).Px(), totalProb);
1316 m_fPYfit1->Fill((tau_tmp + nu_vec[
j1]).Py(), totalProb);
1317 m_fPZfit1->Fill((tau_tmp + nu_vec[
j1]).Pz(), totalProb);
1321 sign_tmp = -log10(totalProb);
1345 Info(
"DiTauMassTools",
"Running in lepton+tau mode");
1371 PtEtaPhiMVector tau_tmp(0.0, 0.0, 0.0, 0.0);
1372 PtEtaPhiMVector lep_tmp(0.0, 0.0, 0.0, 0.0);
1386 for (
int i4 = 0; i4 < NiterMET + 1; i4++)
1388 met_smearL = METresX_binSize * i4 - N_METsigma * METresX;
1389 for (
int i5 = 0; i5 < NiterMET + 1; i5++)
1391 met_smearP = METresY_binSize * i5 - N_METsigma * METresY;
1392 if (
pow(met_smearL / METresX, 2) +
pow(met_smearP / METresY, 2) >
pow(N_METsigma, 2))
1396 metvec_tmp.SetXY(input_metX + met_smear_x, input_metY + met_smear_y);
1414 for (
unsigned int j1 = 0;
j1 < nu_vec.size();
j1++) {
1417 const double tau1_tmpp = (tau_tmp + nu_vec[
j1]).
P();
1418 angle1 =
Angle(nu_vec[
j1], tau_tmp);
1428 double tauvecprob1j =
1430 if (tauvecprob1j == 0.)
1433 totalProb = tauvecprob1j * metprob * tauprob;
1456 sign_tmp = -log10(totalProb);
1482 Info(
"DiTauMassTools",
"Running in an unknown mode?!?!");
1489 Info(
"DiTauMassTools",
"%s",
1511 if (prob_hist != 0.0)
1529 PxPyPzMVector nu1_tmp(0.0, 0.0, 0.0, 0.0);
1530 PxPyPzMVector nu2_tmp(0.0, 0.0, 0.0, 0.0);
1533 nu2_tmp.SetCoordinates(Px1, Py1, Pz1, 1.777);
1537 nu1_tmp.SetCoordinates(Px1, Py1, Pz1, 1.777);
1550 if (fit_code == 0) {
1552 "DiTauMassTools",
"%s",
1553 (
"!!!----> Warning-3 in MissingMassCalculator::DitauMassCalculatorV9lfv() : fit status=" +
1556 Info(
"DiTauMassTools",
"....... No solution is found. Printing input info .......");
1568 Info(
"DiTauMassTools",
" ---------------------------------------------------------- ");
1579 const double mM =
x[0];
1580 const double mMax =
par[0];
1581 const double mMean =
par[1];
1582 const double mInvWidth2 =
par[2];
1584 const double fitval = mMax * (1 - 4 * mInvWidth2 *
std::pow(mM - mMean, 2));
1597 const int winHalfWidth,
bool debug) {
1614 winHalfWidth == 0)) {
1618 int max_bin = theHist->GetMaximumBin();
1619 maxPos = theHist->GetBinCenter(max_bin);
1622 prob = theHist->GetBinContent(max_bin) /
double(theHist->GetEntries());
1629 int hNbins = theHist->GetNbinsX();
1634 int max_bin = theHist->GetMaximumBin();
1635 int iBinMin = max_bin - winHalfWidth;
1638 int iBinMax = max_bin + winHalfWidth;
1639 if (iBinMax > hNbins)
1640 iBinMax = hNbins - 1;
1643 for (
int iBin = iBinMin; iBin <= iBinMax; ++iBin) {
1644 const double weight = theHist->GetBinContent(iBin);
1646 sumx +=
weight * theHist->GetBinCenter(iBin);
1648 maxPos = sumx /
sumw;
1651 prob =
sumw / theHist->GetEntries();
1661 Error(
"DiTauMassTools",
"%s",
1662 (
"ERROR undefined maxHistStrategy:" +
std::to_string(maxHistStrategy)).c_str());
1668 int lastNonZeroBin = -1;
1669 int firstNonZeroBin = -1;
1670 double totalSumw = 0.;
1671 bool firstNullPart =
true;
1672 for (
int iBin = 0; iBin < hNbins; ++iBin) {
1673 const double weight = theHist->GetBinContent(iBin);
1676 lastNonZeroBin = iBin;
1677 if (firstNullPart) {
1678 firstNullPart =
false;
1679 firstNonZeroBin = iBin;
1686 firstNonZeroBin =
std::max(0, firstNonZeroBin - winHalfWidth - 1);
1687 lastNonZeroBin =
std::min(hNbins - 1, lastNonZeroBin + winHalfWidth + 1);
1696 const int nwidth = 2 * winHalfWidth + 1;
1699 for (
int ibin = 0; ibin < nwidth; ++ibin) {
1700 winsum += theHist->GetBinContent(ibin);
1702 double winmax = winsum;
1705 int iBinL = firstNonZeroBin;
1706 int iBinR = iBinL + 2 * winHalfWidth;
1707 bool goingUp =
true;
1712 const double deltawin = theHist->GetBinContent(iBinR) - theHist->GetBinContent(iBinL - 1);
1718 if (winsum > winmax) {
1721 max_bin = (iBinR + iBinL) / 2 - 1;
1732 }
while (iBinR < lastNonZeroBin);
1735 int iBinMin = max_bin - winHalfWidth;
1738 int iBinMax = max_bin + winHalfWidth;
1739 if (iBinMax >= hNbins)
1740 iBinMax = hNbins - 1;
1743 for (
int iBin = iBinMin; iBin <= iBinMax; ++iBin) {
1744 const double weight = theHist->GetBinContent(iBin);
1746 sumx +=
weight * theHist->GetBinCenter(iBin);
1749 double maxPosWin = -1.;
1752 maxPosWin = sumx /
sumw;
1759 const double h_rms = theHist->GetRMS(1);
1763 double numerator = 0;
1765 bool nullBin =
false;
1767 for (
int i = iBinMin;
i < iBinMax; ++
i) {
1768 double binError = theHist->GetBinError(
i);
1769 if (binError < 1
e-10) {
1772 double binErrorSquare =
std::pow(binError, 2);
1773 num = theHist->GetBinContent(
i) / (binErrorSquare);
1774 numerator = numerator +
num;
1777 if (numerator < 1
e-10 ||
denominator < 1
e-10 || nullBin ==
true) {
1793 const double binWidth = theHist->GetBinCenter(2) - theHist->GetBinCenter(1);
1794 double fitWidth = (winHalfWidth + 0.5) *
binWidth;
1807 TString fitOption =
debug ?
"QS" :
"QNS";
1813 TFitResultPtr fitRes =
1814 theHist->Fit(
m_fFitting, fitOption,
"", maxPos - fitWidth, maxPos + fitWidth);
1816 double maxPosFit = -1.;
1818 if (
int(fitRes) == 0) {
1821 const double mMax = fitRes->Parameter(0);
1822 const double mMean = fitRes->Parameter(1);
1823 const double mInvWidth2 = fitRes->Parameter(2);
1824 double mMaxError = fitRes->ParError(0);
1826 double mMeanError = fitRes->ParError(1);
1828 double mInvWidth2Error = fitRes->ParError(2);
1831 mInvWidth2Error = 0.;
1832 const double c = mMax * (1 - 4 * mMean * mMean * mInvWidth2);
1833 const double b = 8 * mMax * mMean * mInvWidth2;
1834 const double a = -4 * mMax * mInvWidth2;
1840 const double h_discri =
b *
b - 4 *
a *
c;
1842 const double sqrth_discri = sqrt(h_discri);
1843 const double h_fitLength = sqrth_discri /
a;
1850 maxPosFit = -
b / (2 *
a);
1854 if (maxPosFit >= 0. and std::abs(maxPosFit - maxPosWin) < 0.8 * fitWidth) {
1872 const double &M_nu1,
1873 const double &M_nu2) {
1879 const int solution =
NuPsolutionV3(M_nu1, M_nu2, phi1, phi2, nsol1, nsol2);
1898 const int nsol1,
const int nsol2,
1899 const double &Mvis,
const double &Meff)
1905 Error(
"DiTauMassTools",
"%s",
1909 Error(
"DiTauMassTools",
"%s",
1913 Error(
"DiTauMassTools",
"%s",
1917 Error(
"DiTauMassTools",
"%s",
1921 Error(
"DiTauMassTools",
"%s", (
"refineSolutions ERROR nsol1 " +
std::to_string(nsol1) +
1925 Error(
"DiTauMassTools",
"%s", (
"refineSolutions ERROR nsol1 " +
std::to_string(nsol2) +
1932 Prob->
apply(
preparedInput, -99, -99, PtEtaPhiMVector(0, 0, 0, 0), PtEtaPhiMVector(0, 0, 0, 0),
1933 PtEtaPhiMVector(0, 0, 0, 0), PtEtaPhiMVector(0, 0, 0, 0),
true,
false,
false);
1935 for (
int j1 = 0;
j1 < nsol1; ++
j1) {
1945 const int pickInt = std::abs(10000 *
m_Phi1);
1946 const int pickDigit = pickInt - 10 * (pickInt / 10);
1954 nuvec1_tmpj.SetCoordinates(nuvec1_tmpj.Pt(), nuvec1_tmpj.Eta(), nuvec1_tmpj.Phi(), M_nu1);
1955 tauvecsol1j.SetPxPyPzE(0., 0., 0., 0.);
1956 tauvecsol1j += nuvec1_tmpj;
1961 PtEtaPhiMVector(0, 0, 0, 0), nuvec1_tmpj,
1962 PtEtaPhiMVector(0, 0, 0, 0),
false,
true,
false);
1966 for (
int j2 = 0;
j2 < nsol2; ++
j2) {
1977 const int pickInt = std::abs(10000 *
m_Phi2);
1978 const int pickDigit = pickInt - 10 *
int(pickInt / 10);
1986 nuvec2_tmpj.SetCoordinates(nuvec2_tmpj.Pt(), nuvec2_tmpj.Eta(), nuvec2_tmpj.Phi(), M_nu2);
1987 tauvecsol2j.SetPxPyPzE(0., 0., 0., 0.);
1988 tauvecsol2j += nuvec2_tmpj;
1994 PtEtaPhiMVector(0, 0, 0, 0), nuvec2_tmpj,
false,
true,
false);
1998 if (tauvecprob1j == 0.)
2000 if (tauvecprob2j == 0.)
2003 double totalProb = 1.;
2016 (constProb * tauvecprob1j * tauvecprob2j *
2020 if (totalProb <= 0) {
2022 Warning(
"DiTauMassTools",
"%s",
2023 (
"null proba solution, rejected "+
std::to_string(totalProb)).c_str());
2030 Error(
"DiTauMassTools",
"%s",
2031 (
"refineSolutions ERROR nsol getting larger than nsolfinalmax!!! " +
2034 Error(
"DiTauMassTools",
"%s",
2050 nu1Final.SetPxPyPzE(nuvec1_tmpj.Px(), nuvec1_tmpj.Py(), nuvec1_tmpj.Pz(), nuvec1_tmpj.E());
2051 nu2Final.SetPxPyPzE(nuvec2_tmpj.Px(), nuvec2_tmpj.Py(), nuvec2_tmpj.Pz(), nuvec2_tmpj.E());
2059 if (ngoodsol1 == 0) {
2062 if (ngoodsol2 == 0) {
2069 const PtEtaPhiMVector &nu1,
2070 const PtEtaPhiMVector &vis2,
2071 const PtEtaPhiMVector &nu2,
const double &mmc_mass,
2072 const double &vis_mass,
const double &eff_mass,
2073 const double &dphiTT) {
2084 const double MrecoMvis = mmc_mass / vis_mass;
2085 if (MrecoMvis > 2.6)
2087 const double MrecoMeff = mmc_mass / eff_mass;
2088 if (MrecoMeff > 1.9)
2090 const double e1p1 = nu1.E() / vis1.P();
2091 const double e2p2 = nu2.E() / vis2.P();
2092 if ((e1p1 + e2p2) > 4.5)
2112 const double MrecoMvis = mmc_mass / vis_mass;
2113 const double MrecoMeff = mmc_mass / eff_mass;
2114 const double x = dphiTT > 1.5 ? dphiTT : 1.5;
2115 if ((MrecoMeff + MrecoMvis) > 5.908 - 1.881 *
x + 0.2995 *
x *
x)
2128 double totalProbSumSol = 0.;
2129 double totalProbSumSolOld = 0.;
2130 bool firstPointWithSol =
false;
2132 for (
int isol = 0; isol <
m_nsol; ++isol) {
2137 bool notSureToKeep =
true;
2141 notSureToKeep =
false;
2148 firstPointWithSol =
true;
2160 if (notSureToKeep) {
2163 for (
int isol = 0; isol <
m_nsolOld; ++isol) {
2169 if (!firstPointWithSol && totalProbSumSolOld <= 0.) {
2170 Error(
"DiTauMassTools",
"%s",
2171 (
" ERROR null old probability !!! " +
std::to_string(totalProbSumSolOld) +
" nsolOld " +
2175 }
else if (totalProbSumSol > totalProbSumSolOld) {
2180 }
else if (totalProbSumSol < totalProbSumSolOld * 1
E-6) {
2184 }
else if (
m_nsol <= 0) {
2191 reject = (uMC > totalProbSumSol / totalProbSumSolOld);
2216 bool fillSolution =
true;
2217 bool oldToBeUsed =
false;
2225 fillSolution =
false;
2239 if (!firstPointWithSol) {
2240 fillSolution =
true;
2243 fillSolution =
false;
2250 if (!fillSolution) {
2251 if (firstPointWithSol) {
2254 for (
int isol = 0; isol <
m_nsol; ++isol) {
2266 double solSum2 = 0.;
2268 for (
int isol = 0; isol <
m_nsol; ++isol) {
2272 const PtEtaPhiMVector *pnuvec1_tmpj;
2273 const PtEtaPhiMVector *pnuvec2_tmpj;
2286 const PtEtaPhiMVector &nuvec1_tmpj = *pnuvec1_tmpj;
2287 const PtEtaPhiMVector &nuvec2_tmpj = *pnuvec2_tmpj;
2290 solSum2 += mtautau * mtautau;
2312 if (mtautau != 0. &&
weight != 0.)
2377 for (
int isol = 0; isol <
m_nsol; ++isol) {
2579 Info(
"DiTauMassTools",
" in m_meanbinToBeEvaluated && m_iterNsuc==500 ");
2595 int stopint = stopdouble;
2726 PtEtaPhiMVector Met4vec;
2799 const double &P_tau) {
2801 #ifndef WITHDTHETA3DLIM
2803 if (limit_code == 0)
2805 if (limit_code == 1)
2807 if (limit_code == 2)
2812 if (limit_code == 0)
2814 double par[3] = {0.0, 0.0, 0.0};
2816 if (tau_type == 8) {
2817 if (limit_code == 0)
2823 if (limit_code == 1)
2829 if (limit_code == 2)
2837 if (tau_type >= 0 && tau_type <= 2) {
2838 if (limit_code == 0)
2842 par[2] = -0.0004859;
2844 if (limit_code == 1)
2850 if (limit_code == 2)
2858 if (tau_type >= 3 && tau_type <= 5) {
2859 if (limit_code == 0)
2863 par[2] = -0.0009458;
2865 if (limit_code == 1)
2871 if (limit_code == 2)
2879 if (std::abs(P_tau +
par[1]) > 0.0)
2881 if (limit_code == 0) {
2884 }
else if (
limit > 0.03) {
2888 if (limit < 0.0 || limit > 0.5 * TMath::Pi()) {
2889 limit = 0.5 * TMath::Pi();
2890 }
else if (limit < 0.05 && limit > 0.0) {
2906 const double GEV = 1000.;
2920 if (LFVMode == -1) {
2922 }
else if (LFVMode != -2) {
2934 PtEtaPhiMVector fixedtau1;
2935 fixedtau1.SetCoordinates(tlvTau1.Pt() /
GEV, tlvTau1.Eta(), tlvTau1.Phi(), tlvTau1.M() /
GEV);
2936 PtEtaPhiMVector fixedtau2;
2937 fixedtau2.SetCoordinates(tlvTau2.Pt() /
GEV, tlvTau2.Eta(), tlvTau2.Phi(), tlvTau2.M() /
GEV);
2944 if (mmcType1 == 8 && mmcType2 == 8) {
2946 }
else if (mmcType1 >= 0 && mmcType1 <= 5 && mmcType2 >= 0 && mmcType2 <= 5) {
2962 Error(
"DiTauMassTools",
"MMCCalibrationSet has not been set !. Please use "
2963 "fMMC.SetCalibrationSet(MMCCalibrationSet::MMC2019)"
3005 Info(
"DiTauMassTools",
"correcting sumET");
3102 Info(
"DiTauMassTools",
"Substracting pt1 from sumEt");
3109 Info(
"DiTauMassTools",
"Substracting pt2 from sumEt");
3152 double HtOffset = 0.;
3157 HtOffset = 87.5 - 27.0 *
x;