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()));
528 float ptfrac = acc_ptfrac(*
track);
529 track_feat.push_back(ptfrac);
531 float dr_trackjet = acc_dr_trackjet(*
track);
532 track_feat.push_back(dr_trackjet);
534 float dr_lepton = acc_dr_lepton(*
track);
535 track_feat.push_back(dr_lepton);
537 float qoverp =
track->qOverP();
538 track_feat.push_back(qoverp);
541 track_feat.push_back(
d0);
549 float d0_significance = -99;
551 track_feat.push_back(d0_significance);
553 float z0SinTheta_significance = -99;
555 track_feat.push_back(z0SinTheta_significance);
559 ATH_MSG_ERROR(
"DecoratePLIT::execute - failed to retrieve xAOD::numberOfInnermostPixelLayerHits");
560 return StatusCode::FAILURE;
562 track_feat.push_back(pix_innermosthits);
564 uint8_t pix_nextinnermosthits = 0;
566 ATH_MSG_ERROR(
"DecoratePLIT::execute - failed to retrieve xAOD::numberOfNextToInnermostPixelLayerHits");
567 return StatusCode::FAILURE;
569 track_feat.push_back(pix_nextinnermosthits);
571 uint8_t pix_innermostsharedhits = 0;
573 ATH_MSG_ERROR(
"DecoratePLIT::execute - failed to retrieve xAOD::numberOfInnermostPixelLayerSharedHits");
574 return StatusCode::FAILURE;
576 track_feat.push_back(pix_innermostsharedhits);
578 uint8_t pix_innermostsplithits = 0;
580 ATH_MSG_ERROR(
"DecoratePLIT::execute - failed to retrieve xAOD::numberOfInnermostPixelLayerSplitHits");
581 return StatusCode::FAILURE;
583 track_feat.push_back(pix_innermostsplithits);
587 ATH_MSG_ERROR(
"DecoratePLIT::execute - failed to retrieve xAOD::numberOfPixelHits");
588 return StatusCode::FAILURE;
590 track_feat.push_back(pix_hits);
594 ATH_MSG_ERROR(
"DecoratePLIT::execute - failed to retrieve xAOD::numberOfPixelSharedHits");
595 return StatusCode::FAILURE;
597 track_feat.push_back(pix_shared);
601 ATH_MSG_ERROR(
"DecoratePLIT::execute - failed to retrieve xAOD::numberOfPixelSplitHits");
602 return StatusCode::FAILURE;
604 track_feat.push_back(pix_split);
608 ATH_MSG_ERROR(
"DecoratePLIT::execute - failed to retrieve xAOD::numberOfSCTHits");
609 return StatusCode::FAILURE;
611 track_feat.push_back(sct_hits);
615 ATH_MSG_ERROR(
"DecoratePLIT::execute - failed to retrieve xAOD::numberOfSCTSharedHits");
616 return StatusCode::FAILURE;
618 track_feat.push_back(sct_shared);
622 ATH_MSG_ERROR(
"DecoratePLIT::execute - failed to retrieve xAOD::numberOfTRTHits");
623 return StatusCode::FAILURE;
625 track_feat.push_back(trt_hits);
627 char electron_track = acc_electron_track(*
track);
628 track_feat.push_back(electron_track);
632 int num_cnsts =
parts.size();
636 gnn_input.insert({
"track_features", track_info});
640 for (
auto& inp : gnn_input){
642 for (
auto &
dim: inp.second.second) {
646 for (
auto & con: inp.second.first) {
655 auto [out_f, out_vc, out_vf] = (std::abs(elec_eta) < 1.37) ?
m_onnxUtil->runInference(gnn_input) :
m_onnxUtil_endcap->runInference(gnn_input);
660 for (
auto& singlefloat : out_f){
664 for (
auto& vecchar : out_vc){
666 for (
auto&
cc : vecchar.second){
671 for (
auto& vecfloat : out_vf){
673 for (
auto&
ff : vecfloat.second){
679 auto it_dec_el_plit_output = dec_el_plit_output.begin();
680 for (
auto& singlefloat : out_f){
681 (*it_dec_el_plit_output)(
electron) = singlefloat.second;
682 ++it_dec_el_plit_output;
685 return StatusCode::SUCCESS;
706 constexpr
float pt_minimum = 500;
707 constexpr
float abs_eta_maximum = 2.5;
708 constexpr
float d0_maximum = 3.5;
709 constexpr
float z0_maximum= 5.0;
710 constexpr
unsigned char si_hits_minimum = 8;
711 constexpr
unsigned char si_shared_maximum = 1;
712 constexpr
unsigned char si_holes_maximum = 2;
713 constexpr
unsigned char pix_holes_maximum = 1;
722 ATH_MSG_ERROR(
"DecoratePLIT::passed_r22tracking_cuts - failed to retrieve xAOD::numberOfPixelSharedHits");
727 ATH_MSG_ERROR(
"DecoratePLIT::passed_r22tracking_cuts - failed to retrieve xAOD::numberOfSCTSharedHits");
732 ATH_MSG_ERROR(
"DecoratePLIT::passed_r22tracking_cuts - failed to retrieve xAOD::numberOfPixelHits");
737 ATH_MSG_ERROR(
"DecoratePLIT::passed_r22tracking_cuts - failed to retrieve xAOD::numberOfSCTHits");
742 ATH_MSG_ERROR(
"DecoratePLIT::passed_r22tracking_cuts - failed to retrieve xAOD::numberOfPixelDeadSensors");
747 ATH_MSG_ERROR(
"DecoratePLIT::passed_r22tracking_cuts - failed to retrieve xAOD::numberOfSCTDeadSensors");
752 ATH_MSG_ERROR(
"DecoratePLIT::passed_r22tracking_cuts - failed to retrieve xAOD::numberOfPixelHoles");
757 ATH_MSG_ERROR(
"DecoratePLIT::passed_r22tracking_cuts - failed to retrieve xAOD::numberOfSCTHoles");
761 if (std::abs(
tp.eta()) > abs_eta_maximum)
763 double n_module_shared = (pix_shared + sct_shared / 2);
764 if (n_module_shared > si_shared_maximum)
766 if (
tp.pt() <= pt_minimum)
768 if (std::isfinite(d0_maximum) &&
769 std::abs(acc_d0(
tp)) >= d0_maximum)
771 if (std::isfinite(z0_maximum) &&
772 std::abs(acc_z0SinTheta(
tp)) >= z0_maximum)
774 if (pix_hits + pix_dead + sct_hits + sct_dead < si_hits_minimum)
776 if ((pix_holes + sct_holes) > si_holes_maximum)
778 if (pix_holes > pix_holes_maximum)
784 std::vector<const xAOD::IParticle *> &
parts,
789 const EventContext& ctx)
const
795 std::set<const xAOD::TrackParticle*> tracksUsedForElectron;
796 std::set<const xAOD::TrackParticle*> tracksUsedForMuon;
797 if (
const auto* elec =
dynamic_cast<const xAOD::Electron*
>(&lepton)) {
799 }
else if (
const auto*
muon =
dynamic_cast<const xAOD::Muon*
>(&lepton)) {
801 tracksUsedForMuon.insert(
muon->primaryTrackParticle());
808 ATH_MSG_ERROR(
"DecoratePLIT::fillParticles - null track pointer");
814 float dr_lepton = (lepton.
p4().Pt() > 0.) ?
track->p4().DeltaR(lepton.
p4()) : -99;
815 bool isUsedForElectron = tracksUsedForElectron.count(
track);
816 bool isUsedForMuon = tracksUsedForMuon.count(
track);
818 if (!
decorateTrack(*
track, dr_lepton, isUsedForElectron, isUsedForMuon, trackJet, trackLep)) {
819 ATH_MSG_ERROR(
"DecoratePLIT::fillParticles - failed to decorate track");
820 return StatusCode::FAILURE;
830 return a->p4().DeltaR(lepton_p4) <
b->p4().DeltaR(lepton_p4);
832 std::sort(
parts.begin(),
parts.end(), SORT_TRACKLEP);
834 return StatusCode::SUCCESS;
840 bool isUsedForElectron,
854 dec_trk_dr_lepton(
track) = dr_lepton;
855 dec_trk_electron_track(
track) =
static_cast<char>(isUsedForElectron);
856 dec_trk_muon_track(
track) =
static_cast<char>(isUsedForMuon);
860 float dr_trackjet = -99;
861 float dr_leptontrack = -99;
865 if (trackJet->
pt() > 0.) {
866 ptfrac =
track.pt() / trackJet->
pt();
867 dr_trackjet =
track.p4().DeltaR(trackJet->
p4());
873 if (trackLep->
pt() > 0.) {
874 dr_leptontrack =
track.p4().DeltaR(trackLep->
p4());
879 dec_trk_ptfrac(
track) = ptfrac;
880 dec_trk_dr_trackjet(
track) = dr_trackjet;
881 dec_trk_dr_leptontrack(
track) = dr_leptontrack;
883 return StatusCode::SUCCESS;