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;
127 float hEmax = 3000.0;
137 m_fMfit_all = std::make_shared<TH1F>(
"MMC_h1",
"M", hNbins, 0.0,
144 std::make_shared<TH1F>(
"MMC_h1NoW",
"M no weight", hNbins, 0.0, hEmax);
146 m_fPXfit1 = std::make_shared<TH1F>(
"MMC_h2",
"Px1", 4 * hNbins, -hEmax,
148 m_fPYfit1 = std::make_shared<TH1F>(
"MMC_h3",
"Py1", 4 * hNbins, -hEmax,
150 m_fPZfit1 = std::make_shared<TH1F>(
"MMC_h4",
"Pz1", 4 * hNbins, -hEmax,
152 m_fPXfit2 = std::make_shared<TH1F>(
"MMC_h5",
"Px2", 4 * hNbins, -hEmax,
154 m_fPYfit2 = std::make_shared<TH1F>(
"MMC_h6",
"Py2", 4 * hNbins, -hEmax,
156 m_fPZfit2 = std::make_shared<TH1F>(
"MMC_h7",
"Pz2", 4 * hNbins, -hEmax,
173 m_fFitting->SetParNames(
"Max",
"Mean",
"InvWidth2");
198 Info(
"DiTauMassTools",
"------------- Raw Input for MissingMassCalculator --------------");
203 Info(
"DiTauMassTools",
"------------- Prepared Input for MissingMassCalculator--------------");
222 double dummy_METres =
243 Info(
"DiTauMassTools",
"Calling DitauMassCalculatorV9lfv");
249 TFile *
outFile = TFile::Open(
"MMC_likelihoods.root",
"UPDATE");
264 TH1D *nosol =
new TH1D(
"nosol",
"nosol", 7, 0, 7);
272 nosol->Write(nosol->GetName(), TObject::kOverwrite);
287 fStuff.
nutau1 = PtEtaPhiMVector(0., 0., 0., 0.);
288 fStuff.
nutau2 = PtEtaPhiMVector(0., 0., 0., 0.);
289 fStuff.
vistau1 = PtEtaPhiMVector(0., 0., 0., 0.);
290 fStuff.
vistau2 = PtEtaPhiMVector(0., 0., 0., 0.);
302 Info(
"DiTauMassTools",
"Retrieving output from fDitauStuffFit");
307 double q1 = (1. - 0.68) / 2.;
334 PtEtaPhiMVector tlvdummy(0., 0., 0., 0.);
335 XYVector metdummy(0., 0.);
376 PtEtaPhiMVector dummy_vec1(0.0, 0.0, 0.0, 0.0);
377 PtEtaPhiMVector dummy_vec2(0.0, 0.0, 0.0, 0.0);
378 for (
int i = 0;
i < 3;
i++) {
400 Info(
"DiTauMassTools",
401 ".........................Other input.....................................");
402 Info(
"DiTauMassTools",
"%s",
406 Info(
"DiTauMassTools",
"%s",
409 Info(
"DiTauMassTools",
"%s",
417 Info(
"DiTauMassTools",
418 "tau1 and tau2 were internally swapped (visible on prepared input printout)");
420 Info(
"DiTauMassTools",
"tau1 and tau2 were NOT internally swapped");
423 Info(
"DiTauMassTools",
"%s",
425 Info(
"DiTauMassTools",
"%s",
427 Info(
"DiTauMassTools",
"%s",
429 Info(
"DiTauMassTools",
"%s",
431 Info(
"DiTauMassTools",
"%s",
433 Info(
"DiTauMassTools",
"%s",
443 const PtEtaPhiMVector *origVisTau1 = 0;
444 const PtEtaPhiMVector *origVisTau2 = 0;
457 Info(
"DiTauMassTools",
458 "------------- Printing Final Results for MissingMassCalculator --------------");
459 Info(
"DiTauMassTools",
460 ".............................................................................");
464 Info(
"DiTauMassTools",
"%s",
467 Info(
"DiTauMassTools",
"%s",
473 Info(
"DiTauMassTools",
" no 4-momentum or MET from this method ");
478 Info(
"DiTauMassTools",
" fit failed ");
487 Info(
"DiTauMassTools",
"%s",
493 Info(
"DiTauMassTools",
"%s",
499 Info(
"DiTauMassTools",
"%s",
505 Info(
"DiTauMassTools",
"%s",
512 Info(
"DiTauMassTools",
"%s",
514 Info(
"DiTauMassTools",
"%s",
517 Info(
"DiTauMassTools",
"%s",
544 const double &phi1,
const double &phi2,
545 int &nsol1,
int &nsol2) {
566 int solution_code = 0;
584 if (pTmiss2 * dPhiSign < 0) {
586 return solution_code;
592 if (pTmiss1 * (-dPhiSign) < 0) {
594 return solution_code;
603 double m4noma1 = m2noma1 * m2noma1;
605 double p2v1proj =
std::pow(pv1proj, 2);
607 double pTmiss2CscDPhi = pTmiss2 / sinDPhi2;
608 double &pTn1 = pTmiss2CscDPhi;
609 double pT2miss2CscDPhi = pTmiss2CscDPhi * pTmiss2CscDPhi;
612 const double discri1 = m4noma1 + 4 * m2noma1 * pTmiss2CscDPhi * pv1proj -
613 4 * (
m_ET2v1 * (
m_m2Nu1 + pT2miss2CscDPhi) - (pT2miss2CscDPhi * p2v1proj));
618 return solution_code;
626 double m4noma2 = m2noma2 * m2noma2;
628 double p2v2proj =
std::pow(pv2proj, 2);
629 double sinDPhi1 = -sinDPhi2;
630 double pTmiss1CscDPhi = pTmiss1 / sinDPhi1;
631 double &pTn2 = pTmiss1CscDPhi;
632 double pT2miss1CscDPhi = pTmiss1CscDPhi * pTmiss1CscDPhi;
634 const double discri2 = m4noma2 + 4 * m2noma2 * pTmiss1CscDPhi * pv2proj -
635 4 * (
m_ET2v2 * (
m_m2Nu2 + pT2miss1CscDPhi) - (pT2miss1CscDPhi * p2v2proj));
640 return solution_code;
646 double sqdiscri1 = sqrt(discri1);
652 double pn1Z = first1 + second1;
654 if (m2noma1 + 2 * pTmiss2CscDPhi * pv1proj + 2 * pn1Z *
m_tauVec1Pz >
663 pn1Z = first1 - second1;
665 if (m2noma1 + 2 * pTmiss2CscDPhi * pv1proj + 2 * pn1Z *
m_tauVec1Pz >
677 return solution_code;
682 double sqdiscri2 = sqrt(discri2);
688 double pn2Z = first2 + second2;
690 if (m2noma2 + 2 * pTmiss1CscDPhi * pv2proj + 2 * pn2Z *
m_tauVec2Pz >
699 pn2Z = first2 - second2;
702 if (m2noma2 + 2 * pTmiss1CscDPhi * pv2proj + 2 * pn2Z *
m_tauVec2Pz >
713 return solution_code;
729 if (std::abs(pnux - pTmissx) > 0.001 || std::abs(pnuy - pTmissy) > 0.001) {
730 Info(
"DiTauMassTools",
"%s", (
"NuPsolutionV3 ERROR Pnux-Met.X or Pnuy-Met.Y > 0.001 : " +
735 if (std::abs(mtau1plus -
m_mTau) > 0.001 || std::abs(mtau1moins -
m_mTau) > 0.001 ||
736 std::abs(mtau2plus -
m_mTau) > 0.001 || std::abs(mtau2moins -
m_mTau) > 0.001) {
737 Info(
"DiTauMassTools",
"%s", (
"NuPsolutionV3 ERROR tau mass not recovered : " +
744 return solution_code;
749 const PtEtaPhiMVector &tau,
const double &l_nu,
750 std::vector<PtEtaPhiMVector> &nu_vec) {
751 int solution_code = 0;
754 PxPyPzMVector nu(met_vec.X(), met_vec.Y(), 0.0, l_nu);
755 PxPyPzMVector nu2(met_vec.X(), met_vec.Y(), 0.0, l_nu);
757 const double Mtau = 1.777;
759 double msq = (Mtau * Mtau - tau.M() * tau.M() - l_nu * l_nu) /
761 double gamma = nu.Px() * nu.Px() + nu.Py() * nu.Py();
762 double beta = tau.Px() * nu.Px() + tau.Py() * nu.Py() + msq;
763 double a = tau.E() * tau.E() - tau.Pz() * tau.Pz();
764 double b = -2 * tau.Pz() *
beta;
766 if ((
b *
b - 4 *
a *
c) < 0)
767 return solution_code;
770 double pvz1 = (-
b + sqrt(
b *
b - 4 *
a *
c)) / (2 *
a);
771 double pvz2 = (-
b - sqrt(
b *
b - 4 *
a *
c)) / (2 *
a);
773 nu.SetCoordinates(met_vec.X(), met_vec.Y(), pvz1, l_nu);
774 nu2.SetCoordinates(met_vec.X(), met_vec.Y(), pvz2, l_nu);
776 PtEtaPhiMVector return_nu(nu.Pt(), nu.Eta(), nu.Phi(), nu.M());
777 PtEtaPhiMVector return_nu2(nu2.Pt(), nu2.Eta(), nu2.Phi(), nu2.M());
778 nu_vec.push_back(return_nu);
779 nu_vec.push_back(return_nu2);
780 return solution_code;
838 XYVector deltamet_vec;
845 bool paramInsideRange =
false;
864 if (paramInsideRange)
888 if (nsuccesses > 0) {
894 double Px1, Py1, Pz1;
895 double Px2, Py2, Pz2;
896 if (nsuccesses > 0) {
917 if (prob_hist != 0.0)
941 PxPyPzMVector fulltau1, fulltau2;
942 fulltau1.SetCoordinates(Px1, Py1, Pz1, 1.777);
943 fulltau2.SetCoordinates(Px2, Py2, Pz2, 1.777);
963 Info(
"DiTauMassTools",
"Scanning ");
964 Info(
"DiTauMassTools",
" Markov ");
965 Info(
"DiTauMassTools",
"%s",
971 Info(
"DiTauMassTools",
"%s",
978 Info(
"DiTauMassTools",
"%s", (
"!!!----> Warning-3 in "
979 "MissingMassCalculator::DitauMassCalculatorV9Walk() : fit status=" +
982 Info(
"DiTauMassTools",
"%s",
"....... No solution is found. Printing input info .......");
1000 Info(
"DiTauMassTools",
" ---------------------------------------------------------- ");
1022 const double Mtau = 1.777;
1042 double METresX_binSize = 2 * N_METsigma * METresX / NiterMET;
1043 double METresY_binSize = 2 * N_METsigma * METresY / NiterMET;
1047 std::vector<PtEtaPhiMVector> nu_vec;
1052 double metprob = 1.0;
1053 double sign_tmp = 0.0;
1054 double tauprob = 1.0;
1055 double totalProb = 0.0;
1059 double met_smear_x = 0.0;
1060 double met_smear_y = 0.0;
1061 double met_smearL = 0.0;
1062 double met_smearP = 0.0;
1064 double angle1 = 0.0;
1104 Info(
"DiTauMassTools",
"Running in dilepton mode");
1109 PtEtaPhiMVector tau_tmp(0.0, 0.0, 0.0, 0.0);
1110 PtEtaPhiMVector lep_tmp(0.0, 0.0, 0.0, 0.0);
1150 double Mlep = tau_tmp.M();
1157 double MnuProb = 1.0;
1159 for (
int i3 = 0; i3 < NiterMnu; i3++)
1161 M_nu = Mnu_binSize * i3;
1162 if (M_nu >= (Mtau - Mlep))
1168 for (
int i4 = 0; i4 < NiterMET + 1; i4++)
1170 met_smearL = METresX_binSize * i4 - N_METsigma * METresX;
1171 for (
int i5 = 0; i5 < NiterMET + 1; i5++)
1173 met_smearP = METresY_binSize * i5 - N_METsigma * METresY;
1174 if (
pow(met_smearL / METresX, 2) +
pow(met_smearP / METresY, 2) >
pow(N_METsigma, 2))
1176 met_smear_x = met_smearL * met_coscovphi - met_smearP * met_sincovphi;
1177 met_smear_y = met_smearL * met_sincovphi + met_smearP * met_coscovphi;
1178 metvec_tmp.SetXY(input_metX + met_smear_x, input_metY + met_smear_y);
1196 for (
unsigned int j1 = 0;
j1 < nu_vec.size();
j1++) {
1199 const double tau1_tmpp = (tau_tmp + nu_vec[
j1]).
P();
1200 angle1 =
Angle(nu_vec[
j1], tau_tmp);
1210 double tauvecprob1j =
1212 if (tauvecprob1j == 0.)
1215 totalProb = tauvecprob1j * metprob * MnuProb * tauprob;
1232 m_fPXfit1->Fill((tau_tmp + nu_vec[
j1]).Px(), totalProb);
1233 m_fPYfit1->Fill((tau_tmp + nu_vec[
j1]).Py(), totalProb);
1234 m_fPZfit1->Fill((tau_tmp + nu_vec[
j1]).Pz(), totalProb);
1238 sign_tmp = -log10(totalProb);
1262 Info(
"DiTauMassTools",
"Running in lepton+tau mode");
1288 PtEtaPhiMVector tau_tmp(0.0, 0.0, 0.0, 0.0);
1289 PtEtaPhiMVector lep_tmp(0.0, 0.0, 0.0, 0.0);
1303 for (
int i4 = 0; i4 < NiterMET + 1; i4++)
1305 met_smearL = METresX_binSize * i4 - N_METsigma * METresX;
1306 for (
int i5 = 0; i5 < NiterMET + 1; i5++)
1308 met_smearP = METresY_binSize * i5 - N_METsigma * METresY;
1309 if (
pow(met_smearL / METresX, 2) +
pow(met_smearP / METresY, 2) >
pow(N_METsigma, 2))
1313 metvec_tmp.SetXY(input_metX + met_smear_x, input_metY + met_smear_y);
1331 for (
unsigned int j1 = 0;
j1 < nu_vec.size();
j1++) {
1334 const double tau1_tmpp = (tau_tmp + nu_vec[
j1]).
P();
1335 angle1 =
Angle(nu_vec[
j1], tau_tmp);
1345 double tauvecprob1j =
1347 if (tauvecprob1j == 0.)
1350 totalProb = tauvecprob1j * metprob * tauprob;
1373 sign_tmp = -log10(totalProb);
1399 Info(
"DiTauMassTools",
"Running in an unknown mode?!?!");
1406 Info(
"DiTauMassTools",
"%s",
1428 if (prob_hist != 0.0)
1446 PxPyPzMVector nu1_tmp(0.0, 0.0, 0.0, 0.0);
1447 PxPyPzMVector nu2_tmp(0.0, 0.0, 0.0, 0.0);
1450 nu2_tmp.SetCoordinates(Px1, Py1, Pz1, 1.777);
1454 nu1_tmp.SetCoordinates(Px1, Py1, Pz1, 1.777);
1467 if (fit_code == 0) {
1469 "DiTauMassTools",
"%s",
1470 (
"!!!----> Warning-3 in MissingMassCalculator::DitauMassCalculatorV9lfv() : fit status=" +
1473 Info(
"DiTauMassTools",
"....... No solution is found. Printing input info .......");
1485 Info(
"DiTauMassTools",
" ---------------------------------------------------------- ");
1496 const double mM =
x[0];
1497 const double mMax =
par[0];
1498 const double mMean =
par[1];
1499 const double mInvWidth2 =
par[2];
1501 const double fitval = mMax * (1 - 4 * mInvWidth2 *
std::pow(mM - mMean, 2));
1514 const int winHalfWidth,
bool debug) {
1531 winHalfWidth == 0)) {
1535 int max_bin = theHist->GetMaximumBin();
1536 maxPos = theHist->GetBinCenter(max_bin);
1539 prob = theHist->GetBinContent(max_bin) /
double(theHist->GetEntries());
1546 int hNbins = theHist->GetNbinsX();
1551 int max_bin = theHist->GetMaximumBin();
1552 int iBinMin = max_bin - winHalfWidth;
1555 int iBinMax = max_bin + winHalfWidth;
1556 if (iBinMax > hNbins)
1557 iBinMax = hNbins - 1;
1560 for (
int iBin = iBinMin; iBin <= iBinMax; ++iBin) {
1561 const double weight = theHist->GetBinContent(iBin);
1563 sumx +=
weight * theHist->GetBinCenter(iBin);
1565 maxPos = sumx /
sumw;
1568 prob =
sumw / theHist->GetEntries();
1578 Error(
"DiTauMassTools",
"%s",
1579 (
"ERROR undefined maxHistStrategy:" +
std::to_string(maxHistStrategy)).c_str());
1585 int lastNonZeroBin = -1;
1586 int firstNonZeroBin = -1;
1587 double totalSumw = 0.;
1588 bool firstNullPart =
true;
1589 for (
int iBin = 0; iBin < hNbins; ++iBin) {
1590 const double weight = theHist->GetBinContent(iBin);
1593 lastNonZeroBin = iBin;
1594 if (firstNullPart) {
1595 firstNullPart =
false;
1596 firstNonZeroBin = iBin;
1603 firstNonZeroBin =
std::max(0, firstNonZeroBin - winHalfWidth - 1);
1604 lastNonZeroBin =
std::min(hNbins - 1, lastNonZeroBin + winHalfWidth + 1);
1613 const int nwidth = 2 * winHalfWidth + 1;
1616 for (
int ibin = 0; ibin < nwidth; ++ibin) {
1617 winsum += theHist->GetBinContent(ibin);
1619 double winmax = winsum;
1622 int iBinL = firstNonZeroBin;
1623 int iBinR = iBinL + 2 * winHalfWidth;
1624 bool goingUp =
true;
1629 const double deltawin = theHist->GetBinContent(iBinR) - theHist->GetBinContent(iBinL - 1);
1635 if (winsum > winmax) {
1638 max_bin = (iBinR + iBinL) / 2 - 1;
1649 }
while (iBinR < lastNonZeroBin);
1652 int iBinMin = max_bin - winHalfWidth;
1655 int iBinMax = max_bin + winHalfWidth;
1656 if (iBinMax >= hNbins)
1657 iBinMax = hNbins - 1;
1660 for (
int iBin = iBinMin; iBin <= iBinMax; ++iBin) {
1661 const double weight = theHist->GetBinContent(iBin);
1663 sumx +=
weight * theHist->GetBinCenter(iBin);
1666 double maxPosWin = -1.;
1669 maxPosWin = sumx /
sumw;
1676 const double h_rms = theHist->GetRMS(1);
1680 double numerator = 0;
1682 bool nullBin =
false;
1684 for (
int i = iBinMin;
i < iBinMax; ++
i) {
1685 double binError = theHist->GetBinError(
i);
1686 if (binError < 1
e-10) {
1689 double binErrorSquare =
std::pow(binError, 2);
1690 num = theHist->GetBinContent(
i) / (binErrorSquare);
1691 numerator = numerator +
num;
1694 if (numerator < 1
e-10 ||
denominator < 1
e-10 || nullBin ==
true) {
1710 const double binWidth = theHist->GetBinCenter(2) - theHist->GetBinCenter(1);
1711 double fitWidth = (winHalfWidth + 0.5) *
binWidth;
1724 TString fitOption =
debug ?
"QS" :
"QNS";
1730 TFitResultPtr fitRes =
1731 theHist->Fit(
m_fFitting, fitOption,
"", maxPos - fitWidth, maxPos + fitWidth);
1733 double maxPosFit = -1.;
1735 if (
int(fitRes) == 0) {
1738 const double mMax = fitRes->Parameter(0);
1739 const double mMean = fitRes->Parameter(1);
1740 const double mInvWidth2 = fitRes->Parameter(2);
1741 double mMaxError = fitRes->ParError(0);
1743 double mMeanError = fitRes->ParError(1);
1745 double mInvWidth2Error = fitRes->ParError(2);
1748 mInvWidth2Error = 0.;
1749 const double c = mMax * (1 - 4 * mMean * mMean * mInvWidth2);
1750 const double b = 8 * mMax * mMean * mInvWidth2;
1751 const double a = -4 * mMax * mInvWidth2;
1757 const double h_discri =
b *
b - 4 *
a *
c;
1759 const double sqrth_discri = sqrt(h_discri);
1760 const double h_fitLength = sqrth_discri /
a;
1767 maxPosFit = -
b / (2 *
a);
1771 if (maxPosFit >= 0. and std::abs(maxPosFit - maxPosWin) < 0.8 * fitWidth) {
1789 const double &M_nu1,
1790 const double &M_nu2) {
1796 const int solution =
NuPsolutionV3(M_nu1, M_nu2, phi1, phi2, nsol1, nsol2);
1815 const int nsol1,
const int nsol2,
1816 const double &Mvis,
const double &Meff)
1822 Error(
"DiTauMassTools",
"%s",
1826 Error(
"DiTauMassTools",
"%s",
1830 Error(
"DiTauMassTools",
"%s",
1834 Error(
"DiTauMassTools",
"%s",
1838 Error(
"DiTauMassTools",
"%s", (
"refineSolutions ERROR nsol1 " +
std::to_string(nsol1) +
1842 Error(
"DiTauMassTools",
"%s", (
"refineSolutions ERROR nsol1 " +
std::to_string(nsol2) +
1849 Prob->
apply(
preparedInput, -99, -99, PtEtaPhiMVector(0, 0, 0, 0), PtEtaPhiMVector(0, 0, 0, 0),
1850 PtEtaPhiMVector(0, 0, 0, 0), PtEtaPhiMVector(0, 0, 0, 0),
true,
false,
false);
1852 for (
int j1 = 0;
j1 < nsol1; ++
j1) {
1862 const int pickInt = std::abs(10000 *
m_Phi1);
1863 const int pickDigit = pickInt - 10 * (pickInt / 10);
1871 nuvec1_tmpj.SetCoordinates(nuvec1_tmpj.Pt(), nuvec1_tmpj.Eta(), nuvec1_tmpj.Phi(), M_nu1);
1872 tauvecsol1j.SetPxPyPzE(0., 0., 0., 0.);
1873 tauvecsol1j += nuvec1_tmpj;
1878 PtEtaPhiMVector(0, 0, 0, 0), nuvec1_tmpj,
1879 PtEtaPhiMVector(0, 0, 0, 0),
false,
true,
false);
1883 for (
int j2 = 0;
j2 < nsol2; ++
j2) {
1894 const int pickInt = std::abs(10000 *
m_Phi2);
1895 const int pickDigit = pickInt - 10 *
int(pickInt / 10);
1903 nuvec2_tmpj.SetCoordinates(nuvec2_tmpj.Pt(), nuvec2_tmpj.Eta(), nuvec2_tmpj.Phi(), M_nu2);
1904 tauvecsol2j.SetPxPyPzE(0., 0., 0., 0.);
1905 tauvecsol2j += nuvec2_tmpj;
1911 PtEtaPhiMVector(0, 0, 0, 0), nuvec2_tmpj,
false,
true,
false);
1915 if (tauvecprob1j == 0.)
1917 if (tauvecprob2j == 0.)
1920 double totalProb = 1.;
1933 (constProb * tauvecprob1j * tauvecprob2j *
1937 if (totalProb <= 0) {
1939 Warning(
"DiTauMassTools",
"%s",
1940 (
"null proba solution, rejected "+
std::to_string(totalProb)).c_str());
1947 Error(
"DiTauMassTools",
"%s",
1948 (
"refineSolutions ERROR nsol getting larger than nsolfinalmax!!! " +
1951 Error(
"DiTauMassTools",
"%s",
1967 nu1Final.SetPxPyPzE(nuvec1_tmpj.Px(), nuvec1_tmpj.Py(), nuvec1_tmpj.Pz(), nuvec1_tmpj.E());
1968 nu2Final.SetPxPyPzE(nuvec2_tmpj.Px(), nuvec2_tmpj.Py(), nuvec2_tmpj.Pz(), nuvec2_tmpj.E());
1976 if (ngoodsol1 == 0) {
1979 if (ngoodsol2 == 0) {
1986 const PtEtaPhiMVector &nu1,
1987 const PtEtaPhiMVector &vis2,
1988 const PtEtaPhiMVector &nu2,
const double &mmc_mass,
1989 const double &vis_mass,
const double &eff_mass,
1990 const double &dphiTT) {
2001 const double MrecoMvis = mmc_mass / vis_mass;
2002 if (MrecoMvis > 2.6)
2004 const double MrecoMeff = mmc_mass / eff_mass;
2005 if (MrecoMeff > 1.9)
2007 const double e1p1 = nu1.E() / vis1.P();
2008 const double e2p2 = nu2.E() / vis2.P();
2009 if ((e1p1 + e2p2) > 4.5)
2030 const double MrecoMvis = mmc_mass / vis_mass;
2031 const double MrecoMeff = mmc_mass / eff_mass;
2032 const double x = dphiTT > 1.5 ? dphiTT : 1.5;
2033 if ((MrecoMeff + MrecoMvis) > 5.908 - 1.881 *
x + 0.2995 *
x *
x)
2046 double totalProbSumSol = 0.;
2047 double totalProbSumSolOld = 0.;
2048 bool firstPointWithSol =
false;
2050 for (
int isol = 0; isol <
m_nsol; ++isol) {
2055 bool notSureToKeep =
true;
2059 notSureToKeep =
false;
2066 firstPointWithSol =
true;
2078 if (notSureToKeep) {
2081 for (
int isol = 0; isol <
m_nsolOld; ++isol) {
2087 if (!firstPointWithSol && totalProbSumSolOld <= 0.) {
2088 Error(
"DiTauMassTools",
"%s",
2089 (
" ERROR null old probability !!! " +
std::to_string(totalProbSumSolOld) +
" nsolOld " +
2093 }
else if (totalProbSumSol > totalProbSumSolOld) {
2098 }
else if (totalProbSumSol < totalProbSumSolOld * 1
E-6) {
2102 }
else if (
m_nsol <= 0) {
2109 reject = (uMC > totalProbSumSol / totalProbSumSolOld);
2134 bool fillSolution =
true;
2135 bool oldToBeUsed =
false;
2143 fillSolution =
false;
2157 if (!firstPointWithSol) {
2158 fillSolution =
true;
2161 fillSolution =
false;
2168 if (!fillSolution) {
2169 if (firstPointWithSol) {
2172 for (
int isol = 0; isol <
m_nsol; ++isol) {
2184 double solSum2 = 0.;
2186 for (
int isol = 0; isol <
m_nsol; ++isol) {
2190 const PtEtaPhiMVector *pnuvec1_tmpj;
2191 const PtEtaPhiMVector *pnuvec2_tmpj;
2204 const PtEtaPhiMVector &nuvec1_tmpj = *pnuvec1_tmpj;
2205 const PtEtaPhiMVector &nuvec2_tmpj = *pnuvec2_tmpj;
2208 solSum2 += mtautau * mtautau;
2230 if (mtautau != 0. &&
weight != 0.)
2295 for (
int isol = 0; isol <
m_nsol; ++isol) {
2497 Info(
"DiTauMassTools",
" in m_meanbinToBeEvaluated && m_iterNsuc==500 ");
2513 int stopint = stopdouble;
2644 PtEtaPhiMVector Met4vec;
2717 const double &P_tau) {
2719 #ifndef WITHDTHETA3DLIM
2721 if (limit_code == 0)
2723 if (limit_code == 1)
2725 if (limit_code == 2)
2730 if (limit_code == 0)
2732 double par[3] = {0.0, 0.0, 0.0};
2734 if (tau_type == 8) {
2735 if (limit_code == 0)
2741 if (limit_code == 1)
2747 if (limit_code == 2)
2755 if (tau_type >= 0 && tau_type <= 2) {
2756 if (limit_code == 0)
2760 par[2] = -0.0004859;
2762 if (limit_code == 1)
2768 if (limit_code == 2)
2776 if (tau_type >= 3 && tau_type <= 5) {
2777 if (limit_code == 0)
2781 par[2] = -0.0009458;
2783 if (limit_code == 1)
2789 if (limit_code == 2)
2797 if (std::abs(P_tau +
par[1]) > 0.0)
2799 if (limit_code == 0) {
2802 }
else if (
limit > 0.03) {
2806 if (limit < 0.0 || limit > 0.5 * TMath::Pi()) {
2807 limit = 0.5 * TMath::Pi();
2808 }
else if (limit < 0.05 && limit > 0.0) {
2824 const double GEV = 1000.;
2838 if (LFVMode == -1) {
2840 }
else if (LFVMode != -2) {
2852 PtEtaPhiMVector fixedtau1;
2853 fixedtau1.SetCoordinates(tlvTau1.Pt() /
GEV, tlvTau1.Eta(), tlvTau1.Phi(), tlvTau1.M() /
GEV);
2854 PtEtaPhiMVector fixedtau2;
2855 fixedtau2.SetCoordinates(tlvTau2.Pt() /
GEV, tlvTau2.Eta(), tlvTau2.Phi(), tlvTau2.M() /
GEV);
2862 if (mmcType1 == 8 && mmcType2 == 8) {
2864 }
else if (mmcType1 >= 0 && mmcType1 <= 5 && mmcType2 >= 0 && mmcType2 <= 5) {
2880 Error(
"DiTauMassTools",
"MMCCalibrationSet has not been set !. Please use "
2881 "fMMC.SetCalibrationSet(MMCCalibrationSet::MMC2019) or fMMC.SetCalibrationSet(MMCCalibrationSet::MMC2024)"
2923 Info(
"DiTauMassTools",
"correcting sumET");
3021 Info(
"DiTauMassTools",
"Substracting pt1 from sumEt");
3028 Info(
"DiTauMassTools",
"Substracting pt2 from sumEt");
3071 double HtOffset = 0.;
3076 HtOffset = 87.5 - 27.0 *
x;
3095 float hEmax = 3000.0;
3097 m_fMEtP_all = std::make_shared<TH1F>(
"MEtP_h1",
"M", hNbins, -100.0,
3099 m_fMEtL_all = std::make_shared<TH1F>(
"MEtL_h1",
"M", hNbins, -100.0,
3101 m_fMnu1_all = std::make_shared<TH1F>(
"Mnu1_h1",
"M", hNbins, 0.0,
3103 m_fMnu2_all = std::make_shared<TH1F>(
"Mnu2_h1",
"M", hNbins, 0.0,
3105 m_fPhi1_all = std::make_shared<TH1F>(
"Phi1_h1",
"M", hNbins, -10.0,
3107 m_fPhi2_all = std::make_shared<TH1F>(
"Phi2_h1",
"M", hNbins, -10.0,
3130 float hEmax = 3000.0;
3132 m_fMmass_split1 = std::make_shared<TH1F>(
"mass_h1_1",
"M", hNbins, 0.0, hEmax);
3133 m_fMEtP_split1 = std::make_shared<TH1F>(
"MEtP_h1_1",
"M", hNbins, -100.0, 100.0);
3134 m_fMEtL_split1 = std::make_shared<TH1F>(
"MEtL_h1_1",
"M", hNbins, -100.0, 100.0);
3135 m_fMnu1_split1 = std::make_shared<TH1F>(
"Mnu1_h1_1",
"M", hNbins, 0.0, hEmax);
3136 m_fMnu2_split1 = std::make_shared<TH1F>(
"Mnu2_h1_1",
"M", hNbins, 0.0, hEmax);
3137 m_fPhi1_split1 = std::make_shared<TH1F>(
"Phi1_h1_1",
"M", hNbins, -10.0, 10.0);
3138 m_fPhi2_split1 = std::make_shared<TH1F>(
"Phi2_h1_1",
"M", hNbins, -10.0, 10.0);
3139 m_fMmass_split2 = std::make_shared<TH1F>(
"mass_h1_2",
"M", hNbins, 0.0, hEmax);
3140 m_fMEtP_split2 = std::make_shared<TH1F>(
"MEtP_h1_2",
"M", hNbins, -100.0, 100.0);
3141 m_fMEtL_split2 = std::make_shared<TH1F>(
"MEtL_h1_2",
"M", hNbins, -100.0, 100.0);
3142 m_fMnu1_split2 = std::make_shared<TH1F>(
"Mnu1_h1_2",
"M", hNbins, 0.0, hEmax);
3143 m_fMnu2_split2 = std::make_shared<TH1F>(
"Mnu2_h1_2",
"M", hNbins, 0.0, hEmax);
3144 m_fPhi1_split2 = std::make_shared<TH1F>(
"Phi1_h1_2",
"M", hNbins, -10.0, 10.0);
3145 m_fPhi2_split2 = std::make_shared<TH1F>(
"Phi2_h1_2",
"M", hNbins, -10.0, 10.0);