274 const std::vector<int>& wIndices,
275 PtEtaPhiMVector& top_b_p4,
276 PtEtaPhiMVector& top_W_decay0_p4,
277 PtEtaPhiMVector& top_W_decay1_p4) {
279 if (topIndices.size() != 3 || wIndices.size() != 2) {
280 top_b_p4.SetCoordinates(0.0, 0.0, 0.0, 0.0);
281 top_W_decay0_p4.SetCoordinates(0.0, 0.0, 0.0, 0.0);
282 top_W_decay1_p4.SetCoordinates(0.0, 0.0, 0.0, 0.0);
287 if (std::find(topIndices.begin(), topIndices.end(), wIndices[0]) ==
289 std::find(topIndices.begin(), topIndices.end(), wIndices[1]) ==
291 top_b_p4.SetCoordinates(0.0, 0.0, 0.0, 0.0);
292 top_W_decay0_p4.SetCoordinates(0.0, 0.0, 0.0, 0.0);
293 top_W_decay1_p4.SetCoordinates(0.0, 0.0, 0.0, 0.0);
301 std::vector<int> goodWIndices;
302 for (
const auto idx : wIndices) {
304 goodWIndices.push_back(idx);
308 if (goodWIndices.size() == 1) {
309 int leadingWIndex = goodWIndices[0];
314 else if (goodWIndices.size() == 2) {
315 int leadingWIndex = goodWIndices[0];
316 int subleadingWIndex = goodWIndices[1];
319 if (jet1->
pt() >= jet2->
pt()) {
329 for (
const auto idx : topIndices) {
330 if (std::find(wIndices.begin(), wIndices.end(), idx) == wIndices.end()) {
336 (bJetIndex != -1) ?
m_hyperInputs.m_jets.at(bJetIndex) :
nullptr;
339 top_b_p4.SetCoordinates(0.0, 0.0, 0.0, 0.0);
340 top_W_decay0_p4.SetCoordinates(0.0, 0.0, 0.0, 0.0);
341 top_W_decay1_p4.SetCoordinates(0.0, 0.0, 0.0, 0.0);
344 ROOT::Math::PtEtaPhiEVector bJetP4 =
345 buildRecoP4(bJet->
pt(), bJet->
eta(), bJet->
phi(), bJet->
e());
346 top_b_p4 = toPtEtaPhiM(bJetP4);
349 ROOT::Math::PtEtaPhiEVector leadWJetP4 = buildRecoP4(
350 leadWJet->
pt(), leadWJet->
eta(), leadWJet->
phi(), leadWJet->
e());
351 top_W_decay0_p4 = toPtEtaPhiM(leadWJetP4);
354 ROOT::Math::PtEtaPhiEVector subleadWJetP4 =
355 buildRecoP4(subleadWJet->
pt(), subleadWJet->
eta(), subleadWJet->
phi(),
357 top_W_decay1_p4 = toPtEtaPhiM(subleadWJetP4);
362 const std::vector<int>& topHadIndices,
const std::vector<int>& wHadIndices,
363 const std::vector<int>& topLepIndices,
const std::vector<int>& topLepIDs,
364 PtEtaPhiMVector& tophad_b_p4, PtEtaPhiMVector& tophad_w_decay0_p4,
365 PtEtaPhiMVector& tophad_w_decay1_p4, PtEtaPhiMVector& toplep_b_p4,
366 PtEtaPhiMVector& toplep_lep_p4) {
367 tophad_b_p4.SetCoordinates(0.0, 0.0, 0.0, 0.0);
368 tophad_w_decay0_p4.SetCoordinates(0.0, 0.0, 0.0, 0.0);
369 tophad_w_decay1_p4.SetCoordinates(0.0, 0.0, 0.0, 0.0);
370 toplep_b_p4.SetCoordinates(0.0, 0.0, 0.0, 0.0);
371 toplep_lep_p4.SetCoordinates(0.0, 0.0, 0.0, 0.0);
375 tophad_w_decay0_p4, tophad_w_decay1_p4);
378 if (topLepIndices.size() == 3 && topLepIDs.size() == 3) {
383 for (std::size_t i = 0; i < 3; ++i) {
384 int idx = topLepIndices[i];
385 int id = topLepIDs[i];
392 toplep_b_p4 = toPtEtaPhiM(
393 buildRecoP4(
jet->pt(),
jet->eta(),
jet->phi(),
jet->e()));
395 }
else if (
id == electronID) {
396 if (idx <
static_cast<int>(
m_hyperInputs.m_electrons.size())) {
399 toPtEtaPhiM(buildRecoP4(el->pt(), el->eta(), el->phi(), el->e()));
401 }
else if (
id == muonID) {
405 toPtEtaPhiM(buildRecoP4(
mu->pt(),
mu->eta(),
mu->phi(),
mu->e()));
413 auto invalidRecoParton = []() {
415 vec.SetCoordinates(0.0, 0.0, 0.0, 0.0);
429 this->
msg().setLevel(MSG::VERBOSE);
432 this->
msg().setLevel(MSG::INFO);
442 auto lockAllDecorations = [&]() {
498 *evtInfo, std::vector<int>{-1, -1, -1}, sys);
501 *evtInfo, std::vector<int>{-1, -1, -1}, sys);
504 *evtInfo, std::vector<int>{-1, -1, -1}, sys);
507 *evtInfo, std::vector<int>{-1, -1, -1}, sys);
510 m_top_b_p4.set(*evtInfo, invalidRecoParton(), sys);
525 std::vector<int>{-1, -1, -1}, sys);
527 std::vector<int>{-1, -1, -1}, sys);
565 m_top_b_p4.set(*evtInfo, invalidRecoParton(), sys);
575 lockAllDecorations();
594 std::vector<int> selected_jets_btag;
625 if (this->
msg().level() == MSG::VERBOSE) {
637 unsigned int modelToUse;
640 modelToUse = evtInfo->
eventNumber() % 2 == 0 ? 1 : 0;
646 if (this->
msg().level() == MSG::VERBOSE) {
673 std::vector<std::string> recoLabels =
m_hyperParser->getLabels();
674 std::vector<std::vector<int>> recoIndices =
m_hyperParser->getIndices();
678 std::vector<int> top1Indices(recoIndices[
index]);
683 std::vector<int> top2Indices(recoIndices[
index]);
688 std::vector<int> w1Indices(recoIndices[
index]);
693 std::vector<int> w2Indices(recoIndices[
index]);
698 PtEtaPhiMVector top_b_p4 = invalidRecoParton();
699 PtEtaPhiMVector top_Wplus_decay0_p4 = invalidRecoParton();
700 PtEtaPhiMVector top_Wplus_decay1_p4 = invalidRecoParton();
704 top_Wplus_decay0_p4, top_Wplus_decay1_p4);
710 PtEtaPhiMVector topbar_bbar_p4 = invalidRecoParton();
711 PtEtaPhiMVector topbar_Wminus_decay0_p4 = invalidRecoParton();
712 PtEtaPhiMVector topbar_Wminus_decay1_p4 = invalidRecoParton();
716 topbar_Wminus_decay0_p4,
717 topbar_Wminus_decay1_p4);
724 std::vector<std::string> recoLabels =
m_hyperParser->getLabels();
725 std::vector<std::vector<int>> recoIndices =
m_hyperParser->getIndices();
727 std::vector<std::vector<int>> recoIDs =
m_hyperParser->getIds();
732 std::size_t indexTopHad =
734 ANA_MSG_DEBUG(
"Index of HyPER_Reco_TopHad: " << indexTopHad);
735 std::vector<int> topHadIndices = recoIndices[indexTopHad];
741 std::size_t indexTopLep =
743 ANA_MSG_DEBUG(
"Index of HyPER_Reco_TopLep: " << indexTopLep);
744 std::vector<int> topLepIndices = recoIndices[indexTopLep];
745 std::vector<int> topLepIDs = recoIDs[indexTopLep];
753 std::vector<int> wHadIndices = recoIndices[indexWHad];
764 PtEtaPhiMVector tophad_b_p4 = invalidRecoParton();
765 PtEtaPhiMVector tophad_w_decay0_p4 = invalidRecoParton();
766 PtEtaPhiMVector tophad_w_decay1_p4 = invalidRecoParton();
767 PtEtaPhiMVector toplep_b_p4 = invalidRecoParton();
768 PtEtaPhiMVector toplep_lep_p4 = invalidRecoParton();
771 tophad_b_p4, tophad_w_decay0_p4, tophad_w_decay1_p4,
772 toplep_b_p4, toplep_lep_p4);
786 std::vector<std::string> recoLabels =
m_hyperParser->getLabels();
787 std::vector<std::vector<int>> recoIndices =
m_hyperParser->getIndices();
789 std::vector<std::vector<int>> recoIDs =
m_hyperParser->getIds();
791 PtEtaPhiMVector topBP4 = invalidRecoParton();
792 PtEtaPhiMVector topbarBbarP4 = invalidRecoParton();
793 PtEtaPhiMVector topLepP4 = invalidRecoParton();
794 PtEtaPhiMVector topbarLepbarP4 = invalidRecoParton();
804 PtEtaPhiMVector candidateBJetP4 = invalidRecoParton();
805 PtEtaPhiMVector candidateLeptonP4 = invalidRecoParton();
806 float analyserCharge = 0.;
808 candidateBJetP4, candidateLeptonP4,
810 if (analyserCharge > 0.) {
811 topBP4 = candidateBJetP4;
812 topLepP4 = candidateLeptonP4;
813 }
else if (analyserCharge < 0.) {
814 topbarBbarP4 = candidateBJetP4;
815 topbarLepbarP4 = candidateLeptonP4;
825 candidateBJetP4 = invalidRecoParton();
826 candidateLeptonP4 = invalidRecoParton();
829 candidateBJetP4, candidateLeptonP4,
831 if (analyserCharge > 0.) {
832 topBP4 = candidateBJetP4;
833 topLepP4 = candidateLeptonP4;
834 }
else if (analyserCharge < 0.) {
835 topbarBbarP4 = candidateBJetP4;
836 topbarLepbarP4 = candidateLeptonP4;
863 lockAllDecorations();
865 return StatusCode::SUCCESS;
901 std::vector<Features> particles;
916 <<
" aux variable!");
917 return StatusCode::FAILURE;
919 int bTagQuantile = (*m_bTagDecoAcc)(*jet);
920 if (bTagQuantile >= 2)
922 if (bTagQuantile >= 3)
924 if (bTagQuantile >= 4)
926 if (bTagQuantile >= 5)
928 if (bTagQuantile >= 6)
930 feats = {float(
jet->e() / 1000),
933 float(
jet->pt() / 1000),
940 feats = {float(
jet->e() / 1000),
943 float(
jet->pt() / 1000),
949 particles.push_back(std::move(feats));
954 feats = {float(el->e() / 1000),
957 float(el->pt() / 1000),
963 feats = {float(el->e() / 1000),
966 float(el->pt() / 1000),
972 particles.push_back(std::move(feats));
977 feats = {float(
mu->e() / 1000),
980 float(
mu->pt() / 1000),
986 feats = {float(
mu->e() / 1000),
989 float(
mu->pt() / 1000),
995 particles.push_back(std::move(feats));
999 metFeats = {float((*
m_hyperInputs.m_met)[
"Final"]->met() / 1000),
1008 metFeats = {float((*
m_hyperInputs.m_met)[
"Final"]->met() / 1000),
1016 particles.push_back(std::move(metFeats));
1019 for (std::size_t i = 0; i < particles.size(); i++) {
1026 globalFeats = {nJets / 6.0f, nBJets90 / 2.0f, nBJets85 / 2.0f,
1027 nBJets77 / 2.0f, nBJets70 / 2.0f, nBJets65 / 2.0f};
1029 globalFeats = {nJets / 6.0f};
1038 for (
const auto& edge :
m_hyperGraph->getEdgeIndicesVector()) {
1040 int64_t source = edge.first;
1041 int64_t target = edge.second;
1047 float dEta = secondNodeFeats[1] - firstNodeFeats[1];
1048 float dPhi =
deltaPhi(secondNodeFeats[2], firstNodeFeats[2]);
1049 float dR = sqrt(dEta * dEta + dPhi * dPhi);
1050 ROOT::Math::PtEtaPhiEVector particle1;
1051 ROOT::Math::PtEtaPhiEVector particle2;
1052 particle1.SetCoordinates(firstNodeFeats[3], firstNodeFeats[1],
1053 firstNodeFeats[2], firstNodeFeats[0]);
1054 particle2.SetCoordinates(secondNodeFeats[3], secondNodeFeats[1],
1055 secondNodeFeats[2], secondNodeFeats[0]);
1056 float m = (particle1 + particle2).M();
1058 Features edgeFeats = {dEta, dPhi, dR, log(m)};
1063 for (std::size_t i{0}; i < static_cast<std::size_t>(
m_hyperGraph->nNodes());
1066 nodeFeats.at(0) = log(nodeFeats.at(0));
1067 nodeFeats.at(3) = log(nodeFeats.at(3));
1069 return StatusCode::SUCCESS;
1081 std::vector<Features> particles;
1094 <<
" aux variable!");
1095 return StatusCode::FAILURE;
1098 int bTagQuantile = (*m_bTagDecoAcc)(*jet);
1099 if (bTagQuantile >= 2)
1101 if (bTagQuantile >= 3)
1103 if (bTagQuantile >= 4)
1105 if (bTagQuantile >= 5)
1107 if (bTagQuantile >= 6)
1110 float(
jet->phi()), float(
jet->pt() / 1000),
1112 particles.push_back(std::move(feats));
1116 for (std::size_t i = 0; i < particles.size(); i++) {
1121 Features globalFeats = {nJets / 6.0f, nBJets90 / 2.0f, nBJets85 / 2.0f,
1122 nBJets77 / 2.0f, nBJets70 / 2.0f, nBJets65 / 2.0f};
1131 for (
const auto& edge :
m_hyperGraph->getEdgeIndicesVector()) {
1133 int64_t source = edge.first;
1134 int64_t target = edge.second;
1140 float dEta = secondNodeFeats[1] - firstNodeFeats[1];
1141 float dPhi =
deltaPhi(secondNodeFeats[2], firstNodeFeats[2]);
1142 float dR = sqrt(dEta * dEta + dPhi * dPhi);
1143 ROOT::Math::PtEtaPhiEVector particle1;
1144 ROOT::Math::PtEtaPhiEVector particle2;
1145 particle1.SetCoordinates(firstNodeFeats[3], firstNodeFeats[1],
1146 firstNodeFeats[2], firstNodeFeats[0]);
1147 particle2.SetCoordinates(secondNodeFeats[3], secondNodeFeats[1],
1148 secondNodeFeats[2], secondNodeFeats[0]);
1149 float m = (particle1 + particle2).M();
1151 Features edgeFeats = {dEta, dPhi, dR, log(m)};
1156 for (std::size_t i{0}; i < static_cast<std::size_t>(
m_hyperGraph->nNodes());
1159 nodeFeats.at(0) = log(nodeFeats.at(0));
1160 nodeFeats.at(3) = log(nodeFeats.at(3));
1162 return StatusCode::SUCCESS;
1175 std::vector<Features> particles;
1189 <<
" aux variable!");
1190 return StatusCode::FAILURE;
1192 int bTagQuantile = (*m_bTagDecoAcc)(*jet);
1193 if (bTagQuantile >= 2)
1195 if (bTagQuantile >= 3)
1197 if (bTagQuantile >= 4)
1199 if (bTagQuantile >= 5)
1201 if (bTagQuantile >= 6)
1206 float(
jet->pt() / 1000),
1207 float(bTagQuantile),
1212 particles.push_back(std::move(feats));
1217 Features feats = {float(el->e() / 1000),
1220 float(el->pt() / 1000),
1222 float(el->charge()),
1225 particles.push_back(std::move(feats));
1233 float(
mu->pt() / 1000),
1235 float(
mu->charge()),
1240 particles.push_back(std::move(feats));
1251 particles.push_back(std::move(metFeats));
1254 for (std::size_t i = 0; i < particles.size(); i++) {
1261 globalFeats = {nJets / 6.0f, log(met_pt), met_phi,
1262 nBJets90 / 2.0f, nBJets85 / 2.0f, nBJets77 / 2.0f,
1263 nBJets70 / 2.0f, nBJets65 / 2.0f};
1272 for (
const auto& edge :
m_hyperGraph->getEdgeIndicesVector()) {
1274 int64_t source = edge.first;
1275 int64_t target = edge.second;
1281 float dEta = secondNodeFeats[1] - firstNodeFeats[1];
1282 float dPhi =
deltaPhi(secondNodeFeats[2], firstNodeFeats[2]);
1283 float dR = sqrt(dEta * dEta + dPhi * dPhi);
1284 ROOT::Math::PtEtaPhiEVector particle1;
1285 ROOT::Math::PtEtaPhiEVector particle2;
1286 particle1.SetCoordinates(firstNodeFeats[3], firstNodeFeats[1],
1287 firstNodeFeats[2], firstNodeFeats[0]);
1288 particle2.SetCoordinates(secondNodeFeats[3], secondNodeFeats[1],
1289 secondNodeFeats[2], secondNodeFeats[0]);
1290 float m = (particle1 + particle2).M();
1292 Features edgeFeats = {dEta, dPhi, dR, log(m)};
1297 for (std::size_t i{0}; i < static_cast<std::size_t>(
m_hyperGraph->nNodes());
1300 nodeFeats.at(0) = log(nodeFeats.at(0));
1301 nodeFeats.at(3) = log(nodeFeats.at(3));
1302 nodeFeats.at(4) = nodeFeats.at(4) / 6.0f;
1303 nodeFeats.at(6) = nodeFeats.at(6) / 2.0f;
1305 return StatusCode::SUCCESS;