bool MassChi2RecoTPlugin::ProcessEvent() { auto const &jets = (*reader)->GetJets(); // Make sure the event contains a sufficient number of jets if (jets.size() < 2) throw logic_error("MassChi2RecoTPlugin::ProcessEvent: Cannot reconstruct an event because " "it contains less than two jets."); // Reconstruct W boson Candidate const wBoson((*reader)->GetLeptons().front().P4() + (*reader)->GetNeutrino().P4()); // Loop over all the possible ways to choose a central jet. Only a central jet can be assigned //to the top iBTop = -1; double minChi2 = numeric_limits<double>::infinity(); for (unsigned i = 0; i < jets.size(); ++i) { // Skip non-central jets if (fabs(jets.at(i).Eta()) > BTagSFInterface::GetMaxPseudorapidity()) continue; double const chi2 = pow(((wBoson.P4() + jets.at(i).P4()).M() - 176.5) / 37.1, 2); //^ Mass mean and resoulution is cited according to //~aapopov/workspace/tHq/2012Bravo/2013.11.28_Mass-chi2-reconstruction/info.txt if (chi2 < minChi2) { iBTop = i; minChi2 = chi2; } } // A sanity check if (iBTop == unsigned(-1)) //^ This could have happened if only there were no central jets in the event throw logic_error("MassChi2RecoTPlugin::ProcessEvent: Cannot reconstruct an event because " "it does not contain central jets."); // Find the recoil jet. It is chosen as the most forward jet excluding the jet already used to //reconstruct the top quark iRecoilJet = -1; double maxEta = -numeric_limits<double>::infinity(); for (unsigned i = 0; i < jets.size(); ++i) { if (i == iBTop) continue; auto const &jet = jets.at(i); if (fabs(jet.Eta()) > maxEta) { iRecoilJet = i; maxEta = fabs(jet.Eta()); } } // Because an event is required to contain at least two jets, a recoil jet is always found return true; }
void GlobalRecoTTbarPlugin::CalculateVariables(Jet const &bTopLep, Jet const &bTopHad, Jet const &q1TopHad, Jet const &q2TopHad) { // Calculate variables related to the top quark decaying semileptonically auto const &lepton = (*reader)->GetLeptons().front(); Candidate const wLep(lepton.P4() + (*reader)->GetNeutrino().P4()); Candidate const topLep(wLep.P4() + bTopLep.P4()); //bfMass_TopLep = topLep.M(); LogPt_TopLep = log(topLep.Pt()); //bfEta_TopLep = topLep.Eta(); //bfPt_BTopLep = bTopLep.Pt(); //bfEta_BTopLep = bTopLep.Eta(); //PassBTag_BTopLep = 0 + bTagger->IsTagged(bTopLep); //bfCharge_BTopLep = bTopLep.Charge() * lepton.Charge(); LogMass_BTopLepLep = log((bTopLep.P4() + lepton.P4()).M()); DeltaR_BTopLepWLep = bTopLep.P4().DeltaR(wLep.P4()); //bfDEta_TopLepLep = fabs(topLep.Eta() - lepton.Eta()); // Calculate the cosine // TVector3 b((wLep.P4()).BoostVector()); // TLorentzVector boostedLepton(lepton.P4()); // boostedLepton.Boost(-b); // TVector3 p3Lepton(boostedLepton.Vect()); // TLorentzVector boostedBJet(bTopLep.P4()); // boostedBJet.Boost(-b); // TVector3 const p3BJet(boostedBJet.Vect()); // bfCos_LepBTopLep_WLep = p3Lepton.Dot(p3BJet) / (p3Lepton.Mag() * p3BJet.Mag()); // Calculate variables related to the top quark decaying semileptonically Candidate const wHad(q1TopHad.P4() + q2TopHad.P4()); Candidate const topHad(wHad.P4() + bTopHad.P4()); //bfMass_TopHad = topHad.M(); LogPt_TopHad = log(topHad.Pt()); AbsEta_TopHad = fabs(topHad.Eta()); LogMass_WHad = log(wHad.M()); //bfPt_WHad = wHad.Pt(); //bfEta_WHad= wHad.Eta(); DeltaR_BTopHadWHad = bTopHad.P4().DeltaR(wHad.P4()); //bfPt_BTopHad = bTopHad.Pt(); //bfEta_BTopHad = bTopHad.Eta(); //PassBTag_BTopHad = 0 + bTagger->IsTagged(bTopHad); //bfCharge_BTopHad = bTopHad.Charge() * lepton.Charge(); //bfMinPt_Light = min(fabs(q1TopHad.Pt()), fabs(q2TopHad.Pt())); //bfMaxEta_Light = max(fabs(q1TopHad.Eta()), fabs(q2TopHad.Eta())); SumCharge_Light = (q1TopHad.Charge() + q2TopHad.Charge()) * lepton.Charge(); NumBTag_Light = 0 + bTagger->IsTagged(q1TopHad) + bTagger->IsTagged(q2TopHad); DeltaR_Light = q1TopHad.P4().DeltaR(q2TopHad.P4()); // bfMaxMass_BTopHadLight = // max((bTopHad.P4() + q1TopHad.P4()).M(), (bTopHad.P4() + q2TopHad.P4()).M()); LogDMass_TopHadWHad = log(topHad.M() - wHad.M()); // Calcualate variables with correlations between different objects double Ht = lepton.Pt() + (*reader)->GetMET().Pt(); for (auto const &j: (*reader)->GetJets()) Ht += j.Pt(); RelHt = (topLep.Pt() + topHad.Pt()) / Ht; //bfMass_TopLepTopHad = (topLep.P4() + topHad.P4()).M(); //bfPt_TopLepTopHad = (topLep.P4() + topHad.P4()).Pt(); //bfEta_TopLepTopHad = (topLep.P4() + topHad.P4()).Eta(); //bfDeltaR_TopLepTopHad = topLep.P4().DeltaR(topHad.P4()); DCharge_BTopHadBTopLep = (bTopHad.Charge() - bTopLep.Charge()) * lepton.Charge(); }