63 std::set<int> bHadronIdxs;
64 for (
size_t i = 0,
n = genParticleHandle->size();
i <
n; ++
i) {
72 bHadronIdxs.insert(-
i - 1);
77 std::vector<size_t> leptonIdxs;
78 for (
size_t i = 0,
n = finalStateHandle->size();
i <
n; ++
i) {
80 const int absPdgId =
abs(
p.pdgId());
85 if (
p.numberOfMothers() == 0)
87 if (
p.mother()->status() == 4)
95 leptonIdxs.push_back(
i);
110 std::vector<fastjet::PseudoJet> fjLepInputs;
111 fjLepInputs.reserve(leptonIdxs.size());
112 for (
auto index : leptonIdxs) {
117 fjLepInputs.push_back(fastjet::PseudoJet(
p.px(),
p.py(),
p.pz(),
p.energy()));
118 fjLepInputs.back().set_user_index(
index);
122 fastjet::ClusterSequence fjLepClusterSeq(fjLepInputs, *
fjLepDef_);
123 std::vector<fastjet::PseudoJet> fjLepJets = fastjet::sorted_by_pt(fjLepClusterSeq.inclusive_jets(
minLeptonPt_));
126 leptons->reserve(fjLepJets.size());
127 std::set<size_t> lepDauIdxs;
128 for (
auto& fjJet : fjLepJets) {
133 const std::vector<fastjet::PseudoJet> fjConstituents = fastjet::sorted_by_pt(fjJet.constituents());
135 std::vector<reco::CandidatePtr> constituents;
137 for (
auto& fjConstituent : fjConstituents) {
138 const size_t index = fjConstituent.user_index();
140 const int absPdgId =
abs(
cand->pdgId());
141 if (absPdgId == 11
or absPdgId == 13) {
146 constituents.push_back(
cand);
151 const LorentzVector jetP4(fjJet.px(), fjJet.py(), fjJet.pz(), fjJet.E());
155 lepJet.setPdgId(lepCand->
pdgId());
156 lepJet.setCharge(lepCand->
charge());
158 const double jetArea = fjJet.has_area() ? fjJet.area() : 0;
159 lepJet.setJetArea(jetArea);
164 for (
auto& fjConstituent : fjConstituents) {
165 lepDauIdxs.insert(fjConstituent.user_index());
172 std::vector<fastjet::PseudoJet> fjJetInputs;
173 fjJetInputs.reserve(nStables);
174 for (
size_t i = 0,
n = finalStateHandle->size();
i <
n; ++
i) {
182 if (absId == 12
or absId == 14
or absId == 16)
184 if (lepDauIdxs.find(
i) != lepDauIdxs.end())
187 fjJetInputs.push_back(fastjet::PseudoJet(
p.px(),
p.py(),
p.pz(),
p.energy()));
188 fjJetInputs.back().set_user_index(
i);
191 for (
auto index : bHadronIdxs) {
196 const double scale = 1
e-20 /
p.p();
198 fjJetInputs.back().set_user_index(
index);
202 fastjet::ClusterSequence fjJetClusterSeq(fjJetInputs, *
fjJetDef_);
203 std::vector<fastjet::PseudoJet> fjJets = fastjet::sorted_by_pt(fjJetClusterSeq.inclusive_jets(
minJetPt_));
206 jets->reserve(fjJets.size());
207 std::vector<size_t> bjetIdxs, ljetIdxs;
208 for (
auto& fjJet : fjJets) {
213 const std::vector<fastjet::PseudoJet> fjConstituents = fastjet::sorted_by_pt(fjJet.constituents());
215 std::vector<reco::CandidatePtr> constituents;
216 bool hasBHadron =
false;
217 for (
size_t j = 0,
m = fjConstituents.size();
j <
m; ++
j) {
218 const int index = fjConstituents[
j].user_index();
219 if (bHadronIdxs.find(
index) != bHadronIdxs.end()) {
224 constituents.push_back(
cand);
227 const LorentzVector jetP4(fjJet.px(), fjJet.py(), fjJet.pz(), fjJet.E());
231 const double jetArea = fjJet.has_area() ? fjJet.area() : 0;
232 genJet.setJetArea(jetArea);
235 bjetIdxs.push_back(
jets->size());
237 ljetIdxs.push_back(
jets->size());
240 jets->push_back(genJet);
246 if (bjetIdxs.size() < 2)
268 int selNu1 = -1, selNu2 = -1;
269 for (
int i = 0;
i < 2; ++
i) {
271 for (
int j = 0;
j < 2; ++
j) {
275 const double newDm = dm1 + dm2;
289 const auto w1LVec = lepton1.p4() + nu1.p4();
290 const auto w2LVec = lepton2.p4() + nu2.p4();
294 int selB1 = -1, selB2 = -1;
295 for (
auto i : bjetIdxs) {
297 for (
auto j : bjetIdxs) {
301 const double newDm = dm1 + dm2;
315 const auto t1LVec = w1LVec +
bJet1.p4();
316 const auto t2LVec = w2LVec +
bJet2.p4();
319 const int lepQ1 = lepton1.charge();
320 const int lepQ2 = lepton2.charge();
347 }
else if (!
leptons->empty() and !
neutrinos->empty() and ljetIdxs.size() >= 2) {
349 const auto& lepton =
leptons->at(0);
354 bool hasVetoLepton =
false;
355 for (
auto vetoLeptonItr =
next(
leptons->begin()); vetoLeptonItr !=
leptons->end(); ++vetoLeptonItr) {
358 hasVetoLepton =
true;
365 double metX = 0, metY = 0;
366 for (
const auto& neutrino : *
neutrinos) {
367 metX += neutrino.px();
368 metY += neutrino.py();
370 const double metPt = std::hypot(metX, metY);
374 const double mtW =
std::sqrt(2 * lepton.pt() * metPt *
cos(lepton.phi() - atan2(metX, metY)));
384 const double lpz = lepton.pz(), le = lepton.energy(), lpt = lepton.pt();
385 const double cf = (
wMass_ *
wMass_) / 2 + lepton.px() * metX + lepton.py() * metY;
386 const double det = cf * cf * lpz * lpz - lpt * lpt * (le * le * metPt * metPt - cf * cf);
387 const double pz = (cf * lpz + (cf < 0 ? -
sqrt(det) :
sqrt(det))) / lpt / lpt;
389 const auto w1LVec = lepton.p4() + nu1P4;
394 for (
auto b1Itr = bjetIdxs.begin(); b1Itr != bjetIdxs.end(); ++b1Itr) {
395 const double dR =
deltaR(
jets->at(*b1Itr).p4(), w1LVec);
404 const auto t1LVec = w1LVec +
bJet1.p4();
407 const auto& wJet1 =
jets->at(ljetIdxs[0]);
408 const auto& wJet2 =
jets->at(ljetIdxs[1]);
409 const auto w2LVec = wJet1.p4() + wJet2.p4();
414 for (
auto i : bjetIdxs) {
427 const auto t2LVec = w2LVec +
bJet2.p4();
429 const int q = lepton.charge();