8 #include "AthLinks/ElementLink.h"
28 #include "fastjet/PseudoJet.hh"
29 #include "fastjet/JetDefinition.hh"
30 #include "fastjet/AreaDefinition.hh"
31 #include "fastjet/ClusterSequenceArea.hh"
32 #include "fastjet/tools/Filter.hh"
33 #include "fastjet/tools/MassDropTagger.hh"
43 DiTauIDVarCalculator::DiTauIDVarCalculator(
const std::string&
name )
46 declareProperty(
"DefaultValue", m_dDefault = -1234);
50 DiTauIDVarCalculator::~DiTauIDVarCalculator( )
58 return StatusCode::SUCCESS;
115 ditau_ptDec(xDiTau) =
ditau_pt(xDiTau);
116 f_core_leadDec(xDiTau) =
f_core(xDiTau, 0);
117 f_core_sublDec(xDiTau) =
f_core(xDiTau, 1);
118 f_subjet_leadDec(xDiTau) =
f_subjet(xDiTau, 0);
119 f_subjet_sublDec(xDiTau) =
f_subjet(xDiTau, 1);
120 f_subjetsDec(xDiTau) =
f_subjets(xDiTau);
121 f_track_leadDec(xDiTau) =
f_track(xDiTau, 0);
122 f_track_sublDec(xDiTau) =
f_track(xDiTau, 1);
123 R_max_leadDec(xDiTau) =
R_max(xDiTau, 0);
124 R_max_sublDec(xDiTau) =
R_max(xDiTau, 1);
125 n_trackDec(xDiTau) =
n_track(xDiTau);
126 n_tracks_leadDec(xDiTau) =
n_tracks(xDiTau, 0);
127 n_tracks_sublDec(xDiTau) =
n_tracks(xDiTau, 1);
129 R_trackDec(xDiTau) =
R_track(xDiTau);
133 R_core_leadDec(xDiTau) =
R_core(xDiTau, 0);
134 R_core_sublDec(xDiTau) =
R_core(xDiTau, 1);
135 R_tracks_leadDec(xDiTau) =
R_tracks(xDiTau, 0);
136 R_tracks_sublDec(xDiTau) =
R_tracks(xDiTau, 1);
139 M_core_leadDec(xDiTau) =
mass_core(xDiTau, 0);
140 M_core_sublDec(xDiTau) =
mass_core(xDiTau, 1);
144 E_frac_sublDec(xDiTau) =
E_frac(xDiTau,1);
145 E_frac_subsublDec(xDiTau) =
E_frac(xDiTau, 2);
146 R_subjets_sublDec(xDiTau) =
R_subjets(xDiTau, 1);
147 R_subjets_subsublDec(xDiTau) =
R_subjets(xDiTau, 2);
152 return StatusCode::SUCCESS;
161 while (xDiTau.
subjetPt(nSubjet) > 0. )
173 if (n_subjetsAcc(xDiTau) < 2 ) {
185 if (iSubjet < 0 || iSubjet >= n_subjetsAcc(xDiTau)) {
189 return xDiTau.
fCore(iSubjet);
197 if (iSubjet < 0 || iSubjet >= n_subjetsAcc(xDiTau)) {
201 return xDiTau.
subjetPt(iSubjet) / xDiTau.
pt();
209 if (n_subjetsAcc(xDiTau) < 2 ) {
221 if (iSubjet < 0 || iSubjet >= n_subjetsAcc(xDiTau)) {
233 TLorentzVector tlvSubjet;
234 tlvSubjet.SetPtEtaPhiE( xDiTau.
subjetPt(iSubjet),
239 TLorentzVector tlvTrack;
240 TLorentzVector tlvLeadTrack;
241 tlvLeadTrack.SetPtEtaPhiE( 0,0,0, 0);
243 for (
const auto &xTrack: xTracks)
250 tlvTrack.SetPtEtaPhiE( (*xTrack)->pt(),
255 if ( tlvSubjet.DeltaR(tlvTrack) < 0.2 )
257 if (tlvLeadTrack.Pt() < tlvTrack.Pt())
259 tlvLeadTrack = tlvTrack;
264 return tlvLeadTrack.Pt() / tlvSubjet.Pt();
272 if (iSubjet < 0 || iSubjet >= n_subjetsAcc(xDiTau)) {
278 TLorentzVector tlvSubjet;
279 tlvSubjet.SetPtEtaPhiE( xDiTau.
subjetPt(iSubjet),
284 TLorentzVector tlvTrack;
285 TLorentzVector tlvRmaxTrack;
288 for (
const auto &xTrack: xTracks)
290 tlvTrack.SetPtEtaPhiE( (*xTrack)->pt(),
295 if ( tlvSubjet.DeltaR(tlvTrack) < R_subjetAcc(xDiTau) )
297 if (tlvTrack.DeltaR(tlvSubjet) > Rmax)
299 Rmax = tlvTrack.DeltaR(tlvSubjet);
318 if (iSubjet < 0 || iSubjet >= n_subjetsAcc(xDiTau)) {
325 ATH_MSG_DEBUG(
"n_tracks decoration not available. Try with track links.");
336 TLorentzVector tlvSubjet;
337 tlvSubjet.SetPtEtaPhiE( xDiTau.
subjetPt(iSubjet),
342 TLorentzVector tlvTrack;
344 for (
const auto &xTrack: xTracks)
346 tlvTrack.SetPtEtaPhiE( (*xTrack)->pt(),
350 if ( tlvSubjet.DeltaR(tlvTrack) < 0.2 ) nTracks++;
356 return n_tracksAcc(xDiTau).at(iSubjet);
379 if (iSubjet < 0 || iSubjet >= n_subjetsAcc(xDiTau)) {
385 TLorentzVector tlvSubjet;
386 tlvSubjet.SetPtEtaPhiE( xDiTau.
subjetPt(iSubjet),
391 TLorentzVector tlvTrack;
393 for (
const auto& xTrack: xTracks)
395 tlvTrack.SetPtEtaPhiE( (*xTrack)->pt(),
400 if ( tlvSubjet.DeltaR(tlvTrack) < 0.2 )
403 R_sum += tlvSubjet.DeltaR(tlvTrack)*tlvTrack.Pt();
428 if (iSubjet < 0 || iSubjet >= n_subjetsAcc(xDiTau)) {
434 TLorentzVector tlvSubjet;
435 tlvSubjet.SetPtEtaPhiE( xDiTau.
subjetPt(iSubjet),
440 TLorentzVector tlvTrack;
443 for (
const auto& xTrack: xTracks)
445 tlvTrack.SetPtEtaPhiE( (*xTrack)->pt(),
450 if ( tlvSubjet.DeltaR(tlvTrack) < R_coreAcc(xDiTau) )
452 R_sum += tlvSubjet.DeltaR(tlvTrack)*tlvTrack.Pt();
477 if (n_subjetsAcc(xDiTau) < 2) {
482 for (
int i = 0;
i<=1;
i++)
487 TLorentzVector tlvSubjet;
488 tlvSubjet.SetPtEtaPhiE( xDiTau.
subjetPt(
i),
493 TLorentzVector tlvTrack;
496 for (
const auto& xTrack: xTracks)
498 tlvTrack.SetPtEtaPhiE( (*xTrack)->pt(),
502 if ( tlvSubjet.DeltaR(tlvTrack) < R_coreAcc(xDiTau) )
505 R_sum += tlvSubjet.DeltaR(tlvTrack)*tlvTrack.Pt();
530 if (n_subjetsAcc(xDiTau) < 2) {
534 for (
int i = 0;
i<=1;
i++)
539 TLorentzVector tlvSubjet;
540 tlvSubjet.SetPtEtaPhiE( xDiTau.
subjetPt(
i),
545 TLorentzVector tlvTrack;
547 for (
const auto& xTrack: xTracks)
549 tlvTrack.SetPtEtaPhiE( (*xTrack)->pt(),
554 if (tlvSubjet.DeltaR(tlvTrack) < 0.2)
556 R_sum += tlvSubjet.DeltaR(tlvTrack)*tlvTrack.Pt();
581 for (
int i = 0;
i<n_subjetsAcc(xDiTau);
i++)
586 TLorentzVector tlvSubjet;
587 tlvSubjet.SetPtEtaPhiE( xDiTau.
subjetPt(
i),
592 TLorentzVector tlvTrack;
594 for (
const auto& xTrack: xTracks)
596 tlvTrack.SetPtEtaPhiE( (*xTrack)->pt(),
601 if (tlvSubjet.DeltaR(tlvTrack) <= 0.2)
603 R_sum += tlvSubjet.DeltaR(tlvTrack)*tlvTrack.Pt();
630 if (n_subjetsAcc(xDiTau) < 2) {
634 for (
int i = 0;
i<=1;
i++)
639 TLorentzVector tlvSubjet;
640 tlvSubjet.SetPtEtaPhiE( xDiTau.
subjetPt(
i),
645 TLorentzVector tlvIsoTrack;
647 for (
const auto& xIsoTrack: xIsoTracks)
649 tlvIsoTrack.SetPtEtaPhiE( (*xIsoTrack)->pt(),
654 if (tlvSubjet.DeltaR(tlvIsoTrack) < 0.4)
656 R_sum += tlvSubjet.DeltaR(tlvIsoTrack)*tlvIsoTrack.Pt();
657 pt += tlvIsoTrack.Pt();
681 if (n_subjetsAcc(xDiTau) < 2) {
685 TLorentzVector tlvallTracks;
688 for (
int i = 0;
i<=1;
i++)
693 TLorentzVector tlvSubjet;
694 tlvSubjet.SetPtEtaPhiE( xDiTau.
subjetPt(
i),
699 TLorentzVector tlvTrack;
701 for (
const auto& xTrack: xTracks)
703 tlvTrack.SetPtEtaPhiE( (*xTrack)->pt(),
707 if ( tlvSubjet.DeltaR(tlvTrack) < R_coreAcc(xDiTau) )
710 tlvallTracks += tlvTrack;
714 if (tlvallTracks.M() < 0)
719 return tlvallTracks.M();
733 if ( iSubjet < 0 || iSubjet >= n_subjetsAcc(xDiTau)) {
737 TLorentzVector tlvallTracks;
742 TLorentzVector tlvSubjet;
743 tlvSubjet.SetPtEtaPhiE( xDiTau.
subjetPt(iSubjet),
748 TLorentzVector tlvTrack;
751 for (
const auto& xTrack: xTracks)
753 tlvTrack.SetPtEtaPhiE( (*xTrack)->pt(),
757 if ( tlvSubjet.DeltaR(tlvTrack) < R_coreAcc(xDiTau) )
760 tlvallTracks += tlvTrack;
764 if (tlvallTracks.M() < 0)
769 return tlvallTracks.M();
783 if ( iSubjet < 0 || iSubjet >= n_subjetsAcc(xDiTau)) {
787 TLorentzVector tlvallTracks;
791 TLorentzVector tlvSubjet;
792 tlvSubjet.SetPtEtaPhiE( xDiTau.
subjetPt(iSubjet),
797 TLorentzVector tlvTrack;
799 for (
const auto& xTrack: xTracks)
801 tlvTrack.SetPtEtaPhiE( (*xTrack)->pt(),
805 if ( tlvSubjet.DeltaR(tlvTrack) < 0.2 )
807 tlvallTracks += tlvTrack;
811 if (tlvallTracks.M() < 0)
816 return tlvallTracks.M();
828 TLorentzVector tlvallTracks;
832 TLorentzVector tlvTrack;
834 for (
const auto& xTrack: xTracks)
836 tlvTrack.SetPtEtaPhiE( (*xTrack)->pt(),
841 tlvallTracks += tlvTrack;
844 if (tlvallTracks.M() < 0)
848 return tlvallTracks.M();
860 TLorentzVector tlvallTracks;
864 TLorentzVector tlvTrack;
866 for (
const auto& xTrack: xTracks)
868 tlvTrack.SetPtEtaPhiE( (*xTrack)->pt(),
873 tlvallTracks += tlvTrack;
879 TLorentzVector tlvIsoTrack;
881 for (
const auto& xIsoTrack: xIsoTracks)
883 tlvIsoTrack.SetPtEtaPhiE( (*xIsoTrack)->pt(),
888 tlvallTracks += tlvIsoTrack;
891 if (tlvallTracks.M() < 0)
896 return tlvallTracks.M();
903 if ( iSubjet < 0 || iSubjet >= n_subjetsAcc(xDiTau)) {
915 if ( iSubjet < 0 || iSubjet >= n_subjetsAcc(xDiTau)) {
925 TLorentzVector tlvLeadSubjet;
926 tlvLeadSubjet.SetPtEtaPhiE( xDiTau.
subjetPt(0),
931 TLorentzVector tlvSubjet;
932 tlvSubjet.SetPtEtaPhiE( xDiTau.
subjetPt(iSubjet),
936 return tlvLeadSubjet.DeltaR(tlvSubjet);
942 double pt_leadtrk = 0;
951 if ( iSubjet < 0 || iSubjet >= n_subjetsAcc(xDiTau)) {
955 TLorentzVector tlvSubjet;
956 tlvSubjet.SetPtEtaPhiE( xDiTau.
subjetPt(iSubjet),
963 TLorentzVector tlvTrack;
966 for (
auto &xTrack: xTracks)
968 tlvTrack.SetPtEtaPhiE( (*xTrack)->pt(),
973 if (tlvTrack.DeltaR(tlvSubjet) < R_coreAcc(xDiTau))
975 if (tlvTrack.Pt() > pt_leadtrk)
977 pt_leadtrk = tlvTrack.Pt();
978 d0 = (*xTrack)->d0();
997 TLorentzVector tlvIsoTrack;
999 for (
const auto& xIsoTrack: xIsoTracks)
1001 tlvIsoTrack.SetPtEtaPhiE( (*xIsoTrack)->pt(),
1002 (*xIsoTrack)->eta(),
1003 (*xIsoTrack)->phi(),
1004 (*xIsoTrack)->e() );
1006 iso_pt += tlvIsoTrack.Pt();
1009 return iso_pt / xDiTau.
pt();
1018 Warning(
"decorNtracks()",
"Track links not available.");
1019 return StatusCode::FAILURE;
1023 int nSubjets = n_subjetsAcc(xDiTau);
1026 float Rsubjet = R_subjetAcc(xDiTau);
1027 std::vector<int> nTracks(nSubjets, 0);
1030 for (
const auto &xTrack: xTracks)
1032 double dRmin = 1111;
1035 for (
int i=0;
i<nSubjets; ++
i)
1037 TLorentzVector tlvSubjet = TLorentzVector();
1038 tlvSubjet.SetPtEtaPhiE(xDiTau.
subjetPt(
i),
1042 double dR = tlvSubjet.DeltaR((*xTrack)->p4());
1045 if ((dR < Rsubjet) && (dR < dRmin))
1051 if (itrmin > -1) nTracks[itrmin]++;
1055 n_tracksDec(xDiTau) = nTracks;
1057 return StatusCode::SUCCESS;