41 m_onnxUtil = std::make_shared<FlavorTagDiscriminants::OnnxUtil>(fullPathToOnnxFile);
44 m_onnxUtil_endcap = std::make_shared<FlavorTagDiscriminants::OnnxUtil>(fullPathToOnnxFile_endcap);
50 std::map<std::string, FlavorTagDiscriminants::Inputs> gnn_input;
52 std::vector<int64_t> elec_feat_dim = {1,
static_cast<int64_t
>(elec_feat.size())};
54 gnn_input.insert({
"jet_features", elec_info});
58 gnn_input.insert({
"track_features", track_info});
59 auto [out_f, out_vc, out_vf] =
m_onnxUtil->runInference(gnn_input);
61 std::vector<std::string> output_names;
62 for (
auto& singlefloat : out_f){
70 m_onnxUtil = std::make_shared<FlavorTagDiscriminants::OnnxUtil>(fullPathToOnnxFile);
76 std::map<std::string, FlavorTagDiscriminants::Inputs> gnn_input;
78 std::vector<int64_t> muon_feat_dim = {1,
static_cast<int64_t
>(muon_feat.size())};
80 gnn_input.insert({
"jet_features", muon_info});
84 gnn_input.insert({
"track_features", track_info});
85 auto [out_f, out_vc, out_vf] =
m_onnxUtil->runInference(gnn_input);
87 std::vector<std::string> output_names;
88 for (
auto& singlefloat : out_f){
96 return StatusCode::FAILURE;
101 return StatusCode::SUCCESS;
112 std::vector<SG::WriteDecorHandle<xAOD::ElectronContainer, float>> dec_el_plit_output;
114 dec_el_plit_output.emplace_back(wdhk, ctx);
118 if (!
predictElec(*elec, *trackjets, *tracks, *caloclusters, dec_el_plit_output, ctx)) {
119 ATH_MSG_ERROR(
"DecoratePLIT::execute - failed to predict electron");
120 return StatusCode::FAILURE;
126 std::vector<SG::WriteDecorHandle<xAOD::MuonContainer, float>> dec_mu_plit_output;
128 dec_mu_plit_output.emplace_back(wdhk, ctx);
132 if (!
predictMuon(*
muon, *trackjets, *tracks, dec_mu_plit_output, ctx)) {
133 ATH_MSG_ERROR(
"DecoratePLIT::execute - failed to predict muon");
134 return StatusCode::FAILURE;
139 return StatusCode::SUCCESS;
160 return StatusCode::SUCCESS;
168 const EventContext& ctx)
const {
183 std::map<std::string, FlavorTagDiscriminants::Inputs> gnn_input;
186 float muon_pt =
muon.pt();
187 float muon_eta =
muon.eta();
188 float muon_phi =
muon.phi();
190 float muon_ptvarcone30TTVARel = acc_ptvarcone30TTVA(
muon) / muon_pt;
191 float muon_topoetcone30Rel = acc_topoetcone30(
muon) / muon_pt;
193 float muon_caloClusterERel = -99;
196 float energyloss = 0;
197 if (!
muon.parameter(energyloss,xAOD::Muon::MeasEnergyLoss)) {
198 ATH_MSG_WARNING(
"DecoratePLIT::execute - failed to retrieve energy loss");
199 return StatusCode::FAILURE;
201 float calE = cluster->
calE();
202 if (std::abs(energyloss) > 0)
203 muon_caloClusterERel = calE / energyloss;
208 float muon_ptfrac_lepton{-99.f}, muon_ptrel_lepton{-99.f}, muon_dRtrackjet_lepton{-99.f}, muon_nTracksTrackjet{-99.f};
213 muon_ptfrac_lepton = muon_pt / trackjet->
pt();
215 float angle =
muon.p4().Vect().Angle(trackjet->
p4().Vect());
218 muon_dRtrackjet_lepton =
muon.p4().DeltaR(trackjet->
p4());
222 std::vector<float> muon_feat = {
223 muon_pt, muon_eta, muon_phi, muon_ptvarcone30TTVARel, muon_topoetcone30Rel,
224 muon_caloClusterERel, muon_ptfrac_lepton, muon_ptrel_lepton,
225 muon_dRtrackjet_lepton, muon_nTracksTrackjet
227 std::vector<int64_t> muon_feat_dim = {1,
static_cast<int64_t
>(muon_feat.size())};
231 gnn_input.insert({
"jet_features", muon_info});
235 std::vector<const xAOD::IParticle *>
parts;
238 ATH_MSG_ERROR(
"DecoratePLIT::execute - failed to fill particles");
239 return StatusCode::FAILURE;
243 std::vector<float> track_feat;
244 track_feat.reserve(
parts.size() *
static_cast<int64_t
>(muon_feat.size()));
249 float ptfrac = acc_ptfrac(*
track);
250 track_feat.push_back(ptfrac);
252 float dr_trackjet = acc_dr_trackjet(*
track);
253 track_feat.push_back(dr_trackjet);
255 float qoverp =
track->qOverP();
256 track_feat.push_back(qoverp);
259 track_feat.push_back(
d0);
270 float d0_significance = -99;
272 track_feat.push_back(d0_significance);
274 float z0SinTheta_significance = -99;
276 track_feat.push_back(z0SinTheta_significance);
280 ATH_MSG_ERROR(
"DecoratePLIT::execute - failed to retrieve xAOD::numberOfPixelHits");
281 return StatusCode::FAILURE;
283 track_feat.push_back(pix_hits);
287 ATH_MSG_ERROR(
"DecoratePLIT::execute - failed to retrieve xAOD::numberOfInnermostPixelLayerHits");
288 return StatusCode::FAILURE;
290 track_feat.push_back(pix_innermosthits);
292 uint8_t pix_nextinnermosthits = 0;
294 ATH_MSG_ERROR(
"DecoratePLIT::execute - failed to retrieve xAOD::numberOfNextToInnermostPixelLayerHits");
295 return StatusCode::FAILURE;
297 track_feat.push_back(pix_nextinnermosthits);
299 uint8_t pix_innermostsharedhits = 0;
301 ATH_MSG_ERROR(
"DecoratePLIT::execute - failed to retrieve xAOD::numberOfInnermostPixelLayerSharedHits");
302 return StatusCode::FAILURE;
304 track_feat.push_back(pix_innermostsharedhits);
306 uint8_t pix_innermostsplithits = 0;
308 ATH_MSG_ERROR(
"DecoratePLIT::execute - failed to retrieve xAOD::numberOfInnermostPixelLayerSplitHits");
309 return StatusCode::FAILURE;
311 track_feat.push_back(pix_innermostsplithits);
315 ATH_MSG_ERROR(
"DecoratePLIT::execute - failed to retrieve xAOD::numberOfPixelSharedHits");
316 return StatusCode::FAILURE;
318 track_feat.push_back(pix_shared);
322 ATH_MSG_ERROR(
"DecoratePLIT::execute - failed to retrieve xAOD::numberOfPixelSplitHits");
323 return StatusCode::FAILURE;
325 track_feat.push_back(pix_split);
329 ATH_MSG_ERROR(
"DecoratePLIT::execute - failed to retrieve xAOD::numberOfSCTHits");
330 return StatusCode::FAILURE;
332 track_feat.push_back(sct_hits);
336 ATH_MSG_ERROR(
"DecoratePLIT::execute - failed to retrieve xAOD::numberOfSCTSharedHits");
337 return StatusCode::FAILURE;
339 track_feat.push_back(sct_shared);
343 int num_cnsts =
parts.size();
347 gnn_input.insert({
"track_features", track_info});
350 for (
auto& inp : gnn_input){
352 for (
auto &
dim: inp.second.second) {
356 for (
auto & con: inp.second.first) {
364 auto [out_f, out_vc, out_vf] =
m_onnxUtil->runInference(gnn_input);
369 for (
auto& singlefloat : out_f){
373 for (
auto& vecchar : out_vc){
375 for (
auto&
cc : vecchar.second){
380 for (
auto& vecfloat : out_vf){
382 for (
auto&
ff : vecfloat.second){
388 auto it_dec_mu_plit_output = dec_mu_plit_output.begin();
389 for (
auto& singlefloat : out_f){
390 (*it_dec_mu_plit_output)(
muon) = singlefloat.second;
391 ++it_dec_mu_plit_output;
394 return StatusCode::SUCCESS;
403 const EventContext& ctx)
const {
406 std::map<std::string, FlavorTagDiscriminants::Inputs> gnn_input;
426 float elec_ntracks =
static_cast<float>(
electron.nTrackParticles());
427 float elec_ptvarcone30Rel = acc_ptvarcone30(
electron) / elec_pt;
428 float elec_topoetcone30Rel = acc_topoetcone30(
electron) / elec_pt;
431 float elec_caloClusterSumEtRel = 0.0;
432 float sumCoreEt_large = 0.0;
434 float elec_calEta =
electron.caloCluster()->eta();
435 float elec_calPhi =
electron.caloCluster()->phi();
438 float deta = elec_calEta - cluster->eta();
440 float dr = std::sqrt(deta*deta + dphi*dphi);
443 sumCoreEt_large += cluster->pt();
447 elec_caloClusterSumEtRel = sumCoreEt_large / elec_pt;
451 float elec_ptfrac_lepton = -99;
452 float elec_ptrel_lepton = -99;
453 float elec_dRtrackjet_lepton = -99;
454 float elec_nTracksTrackjet = -99;
459 elec_ptfrac_lepton = elec_pt / trackjet->
pt();
464 elec_dRtrackjet_lepton =
electron.p4().DeltaR(trackjet->
p4());
470 if (bestmatchedGSFElTrack) {
473 float elec_d0sig = -99;
474 float elec_qd0 = -99;
475 float elec_z0sinTheta = -99;
477 float d0 = electronTrack->
d0();
480 float d0sigma = std::sqrt(vard0);
481 if (std::abs(d0sigma) > 0)
482 elec_d0sig = std::abs(
d0 / d0sigma);
485 elec_z0sinTheta = electronTrack->
z0() *
std::sin(electronTrack->
theta());
489 float elec_SCTWeightedCharge{0.f},
charge{0.f};
491 for (
unsigned TPit = 0; TPit <
electron.nTrackParticles(); TPit++) {
495 SCT += temp_NSCTHits;
505 std::vector<float> electron_feat = {elec_pt, elec_eta, elec_phi, elec_ptvarcone30Rel, elec_topoetcone30Rel, elec_caloClusterSumEtRel, elec_ptfrac_lepton, elec_ptrel_lepton, elec_dRtrackjet_lepton, elec_d0sig, elec_z0sinTheta, elec_SCTWeightedCharge, elec_qd0, elec_ntracks, elec_nTracksTrackjet};
506 std::vector<int64_t> electron_feat_dim = {1,
static_cast<int64_t
>(electron_feat.size())};
510 gnn_input.insert({
"jet_features", electron_info});
513 std::vector<const xAOD::IParticle *>
parts;
515 ATH_MSG_ERROR(
"DecoratePLIT::execute - failed to fill particles");
516 return StatusCode::FAILURE;
520 std::vector<float> track_feat;
521 track_feat.reserve(
parts.size() *
static_cast<int64_t
>(electron_feat.size()));
529 float ptfrac = acc_ptfrac(*
track);
530 track_feat.push_back(ptfrac);
532 float dr_trackjet = acc_dr_trackjet(*
track);
533 track_feat.push_back(dr_trackjet);
535 float dr_lepton = acc_dr_lepton(*
track);
536 track_feat.push_back(dr_lepton);
538 float qoverp =
track->qOverP();
539 track_feat.push_back(qoverp);
542 track_feat.push_back(
d0);
550 float d0_significance = -99;
552 track_feat.push_back(d0_significance);
554 float z0SinTheta_significance = -99;
556 track_feat.push_back(z0SinTheta_significance);
560 ATH_MSG_ERROR(
"DecoratePLIT::execute - failed to retrieve xAOD::numberOfInnermostPixelLayerHits");
561 return StatusCode::FAILURE;
563 track_feat.push_back(pix_innermosthits);
565 uint8_t pix_nextinnermosthits = 0;
567 ATH_MSG_ERROR(
"DecoratePLIT::execute - failed to retrieve xAOD::numberOfNextToInnermostPixelLayerHits");
568 return StatusCode::FAILURE;
570 track_feat.push_back(pix_nextinnermosthits);
572 uint8_t pix_innermostsharedhits = 0;
574 ATH_MSG_ERROR(
"DecoratePLIT::execute - failed to retrieve xAOD::numberOfInnermostPixelLayerSharedHits");
575 return StatusCode::FAILURE;
577 track_feat.push_back(pix_innermostsharedhits);
579 uint8_t pix_innermostsplithits = 0;
581 ATH_MSG_ERROR(
"DecoratePLIT::execute - failed to retrieve xAOD::numberOfInnermostPixelLayerSplitHits");
582 return StatusCode::FAILURE;
584 track_feat.push_back(pix_innermostsplithits);
588 ATH_MSG_ERROR(
"DecoratePLIT::execute - failed to retrieve xAOD::numberOfPixelHits");
589 return StatusCode::FAILURE;
591 track_feat.push_back(pix_hits);
595 ATH_MSG_ERROR(
"DecoratePLIT::execute - failed to retrieve xAOD::numberOfPixelSharedHits");
596 return StatusCode::FAILURE;
598 track_feat.push_back(pix_shared);
602 ATH_MSG_ERROR(
"DecoratePLIT::execute - failed to retrieve xAOD::numberOfPixelSplitHits");
603 return StatusCode::FAILURE;
605 track_feat.push_back(pix_split);
609 ATH_MSG_ERROR(
"DecoratePLIT::execute - failed to retrieve xAOD::numberOfSCTHits");
610 return StatusCode::FAILURE;
612 track_feat.push_back(sct_hits);
616 ATH_MSG_ERROR(
"DecoratePLIT::execute - failed to retrieve xAOD::numberOfSCTSharedHits");
617 return StatusCode::FAILURE;
619 track_feat.push_back(sct_shared);
623 ATH_MSG_ERROR(
"DecoratePLIT::execute - failed to retrieve xAOD::numberOfTRTHits");
624 return StatusCode::FAILURE;
626 track_feat.push_back(trt_hits);
628 char electron_track = acc_electron_track(*
track);
629 track_feat.push_back(electron_track);
633 int num_cnsts =
parts.size();
637 gnn_input.insert({
"track_features", track_info});
641 for (
auto& inp : gnn_input){
643 for (
auto &
dim: inp.second.second) {
647 for (
auto & con: inp.second.first) {
656 auto [out_f, out_vc, out_vf] = (std::abs(elec_eta) < 1.37) ?
m_onnxUtil->runInference(gnn_input) :
m_onnxUtil_endcap->runInference(gnn_input);
661 for (
auto& singlefloat : out_f){
665 for (
auto& vecchar : out_vc){
667 for (
auto&
cc : vecchar.second){
672 for (
auto& vecfloat : out_vf){
674 for (
auto&
ff : vecfloat.second){
680 auto it_dec_el_plit_output = dec_el_plit_output.begin();
681 for (
auto& singlefloat : out_f){
682 (*it_dec_el_plit_output)(
electron) = singlefloat.second;
683 ++it_dec_el_plit_output;
686 return StatusCode::SUCCESS;
707 constexpr
float pt_minimum = 500;
708 constexpr
float abs_eta_maximum = 2.5;
709 constexpr
float d0_maximum = 3.5;
710 constexpr
float z0_maximum= 5.0;
711 constexpr
unsigned char si_hits_minimum = 8;
712 constexpr
unsigned char si_shared_maximum = 1;
713 constexpr
unsigned char si_holes_maximum = 2;
714 constexpr
unsigned char pix_holes_maximum = 1;
723 ATH_MSG_ERROR(
"DecoratePLIT::passed_r22tracking_cuts - failed to retrieve xAOD::numberOfPixelSharedHits");
728 ATH_MSG_ERROR(
"DecoratePLIT::passed_r22tracking_cuts - failed to retrieve xAOD::numberOfSCTSharedHits");
733 ATH_MSG_ERROR(
"DecoratePLIT::passed_r22tracking_cuts - failed to retrieve xAOD::numberOfPixelHits");
738 ATH_MSG_ERROR(
"DecoratePLIT::passed_r22tracking_cuts - failed to retrieve xAOD::numberOfSCTHits");
743 ATH_MSG_ERROR(
"DecoratePLIT::passed_r22tracking_cuts - failed to retrieve xAOD::numberOfPixelDeadSensors");
748 ATH_MSG_ERROR(
"DecoratePLIT::passed_r22tracking_cuts - failed to retrieve xAOD::numberOfSCTDeadSensors");
753 ATH_MSG_ERROR(
"DecoratePLIT::passed_r22tracking_cuts - failed to retrieve xAOD::numberOfPixelHoles");
758 ATH_MSG_ERROR(
"DecoratePLIT::passed_r22tracking_cuts - failed to retrieve xAOD::numberOfSCTHoles");
762 if (std::abs(
tp.eta()) > abs_eta_maximum)
764 double n_module_shared = (pix_shared + sct_shared / 2);
765 if (n_module_shared > si_shared_maximum)
767 if (
tp.pt() <= pt_minimum)
769 if (std::isfinite(d0_maximum) &&
770 std::abs(acc_d0(
tp)) >= d0_maximum)
772 if (std::isfinite(z0_maximum) &&
773 std::abs(acc_z0SinTheta(
tp)) >= z0_maximum)
775 if (pix_hits + pix_dead + sct_hits + sct_dead < si_hits_minimum)
777 if ((pix_holes + sct_holes) > si_holes_maximum)
779 if (pix_holes > pix_holes_maximum)
785 std::vector<const xAOD::IParticle *> &
parts,
790 const EventContext& ctx)
const
796 std::set<const xAOD::TrackParticle*> tracksUsedForElectron;
797 std::set<const xAOD::TrackParticle*> tracksUsedForMuon;
798 if (
const auto* elec =
dynamic_cast<const xAOD::Electron*
>(&lepton)) {
800 }
else if (
const auto*
muon =
dynamic_cast<const xAOD::Muon*
>(&lepton)) {
802 tracksUsedForMuon.insert(
muon->primaryTrackParticle());
809 ATH_MSG_ERROR(
"DecoratePLIT::fillParticles - null track pointer");
816 float dr_lepton = (lepton.
p4().Pt() > 0.) ?
track->p4().DeltaR(lepton.
p4()) : -99;
817 bool isUsedForElectron = tracksUsedForElectron.count(
track);
818 bool isUsedForMuon = tracksUsedForMuon.count(
track);
820 if (!
decorateTrack(*
track, dr_lepton, isUsedForElectron, isUsedForMuon, trackJet, trackLep)) {
821 ATH_MSG_ERROR(
"DecoratePLIT::fillParticles - failed to decorate track");
822 return StatusCode::FAILURE;
832 return a->p4().DeltaR(lepton_p4) <
b->p4().DeltaR(lepton_p4);
834 std::sort(
parts.begin(),
parts.end(), SORT_TRACKLEP);
836 return StatusCode::SUCCESS;
842 bool isUsedForElectron,
856 dec_trk_dr_lepton(
track) = dr_lepton;
857 dec_trk_electron_track(
track) =
static_cast<char>(isUsedForElectron);
858 dec_trk_muon_track(
track) =
static_cast<char>(isUsedForMuon);
862 float dr_trackjet = -99;
863 float dr_leptontrack = -99;
867 if (trackJet->
pt() > 0.) {
868 ptfrac =
track.pt() / trackJet->
pt();
869 dr_trackjet =
track.p4().DeltaR(trackJet->
p4());
875 if (trackLep->
pt() > 0.) {
876 dr_leptontrack =
track.p4().DeltaR(trackLep->
p4());
881 dec_trk_ptfrac(
track) = ptfrac;
882 dec_trk_dr_trackjet(
track) = dr_trackjet;
883 dec_trk_dr_leptontrack(
track) = dr_leptontrack;
885 return StatusCode::SUCCESS;