Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:03:47

0001 #include "DataFormats/BTauReco/interface/IsolatedTauTagInfo.h"
0002 #include "DataFormats/TrackReco/interface/Track.h"
0003 #include "DataFormats/TrackReco/interface/TrackFwd.h"
0004 #include <Math/GenVector/VectorUtil.h>
0005 
0006 using namespace edm;
0007 using namespace reco;
0008 
0009 const RefVector<TrackCollection> IsolatedTauTagInfo::tracksInCone(const math::XYZVector& myVector,
0010                                                                   const float size,
0011                                                                   const float pt_min) const {
0012   RefVector<TrackCollection> tmp;
0013 
0014   RefVector<TrackCollection>::const_iterator myTrack = selectedTracks_.begin();
0015   for (; myTrack != selectedTracks_.end(); myTrack++) {
0016     const math::XYZVector trackMomentum = (*myTrack)->momentum();
0017     float pt_tk = (*myTrack)->pt();
0018     float deltaR = ROOT::Math::VectorUtil::DeltaR(myVector, trackMomentum);
0019     if (deltaR < size && pt_tk > pt_min)
0020       tmp.push_back(*myTrack);
0021   }
0022 
0023   //  sort(tmp.begin(), tmp.end(), SortByDescendingTrackPt());
0024   return tmp;
0025 }
0026 
0027 const RefVector<TrackCollection> IsolatedTauTagInfo::tracksInCone(
0028     const math::XYZVector& myVector, const float size, const float pt_min, const float z_pv, const float dz_lt) const {
0029   RefVector<TrackCollection> tmp;
0030 
0031   RefVector<TrackCollection>::const_iterator myTrack = selectedTracks_.begin();
0032   for (; myTrack != selectedTracks_.end(); myTrack++) {
0033     const math::XYZVector trackMomentum = (*myTrack)->momentum();
0034     float pt_tk = (*myTrack)->pt();
0035     float deltaR = ROOT::Math::VectorUtil::DeltaR(myVector, trackMomentum);
0036     if (deltaR < size && pt_tk > pt_min && fabs((*myTrack)->dz() - z_pv) < dz_lt)
0037       tmp.push_back(*myTrack);
0038   }
0039 
0040   //  sort(tmp.begin(), tmp.end(), SortByDescendingTrackPt());
0041   return tmp;
0042 }
0043 
0044 void IsolatedTauTagInfo::setLeadingTrack(const TrackRef leadTk) { leadTrack_ = leadTk; }
0045 
0046 const TrackRef IsolatedTauTagInfo::leadingSignalTrack() const { return leadTrack_; }
0047 
0048 const TrackRef IsolatedTauTagInfo::leadingSignalTrack(const float rm_cone, const float pt_min) const {
0049   const Jet& myjet = *jet();
0050   math::XYZVector jet3Vec(myjet.px(), myjet.py(), myjet.pz());
0051 
0052   const RefVector<TrackCollection> sTracks = tracksInCone(jet3Vec, rm_cone, pt_min);
0053   TrackRef leadTk;
0054   float pt_cut = pt_min;
0055   if (!sTracks.empty()) {
0056     RefVector<TrackCollection>::const_iterator myTrack = sTracks.begin();
0057     for (; myTrack != sTracks.end(); myTrack++) {
0058       if ((*myTrack)->pt() > pt_cut) {
0059         leadTk = *myTrack;
0060         pt_cut = (*myTrack)->pt();
0061       }
0062     }
0063   }
0064   return leadTk;
0065 }
0066 
0067 const TrackRef IsolatedTauTagInfo::leadingSignalTrack(const math::XYZVector& myVector,
0068                                                       const float rm_cone,
0069                                                       const float pt_min) const {
0070   const RefVector<TrackCollection> sTracks = tracksInCone(myVector, rm_cone, pt_min);
0071   TrackRef leadTk;
0072   float pt_cut = pt_min;
0073   if (!sTracks.empty()) {
0074     RefVector<TrackCollection>::const_iterator myTrack = sTracks.begin();
0075     for (; myTrack != sTracks.end(); myTrack++) {
0076       if ((*myTrack)->pt() > pt_cut) {
0077         leadTk = *myTrack;
0078         pt_cut = (*myTrack)->pt();
0079       }
0080     }
0081   }
0082   return leadTk;
0083 }
0084 
0085 float IsolatedTauTagInfo::discriminator(
0086     float m_cone, float sig_cone, float iso_cone, float pt_min_lt, float pt_min_tk, int nTracksIsoRing) const {
0087   double myDiscriminator = 0.;
0088   const TrackRef leadTk = leadingSignalTrack(m_cone, pt_min_lt);
0089 
0090   if (!leadTk) {
0091     return myDiscriminator;
0092   }
0093   //if signal cone is greater then the isolation cone and the leadTk exists, the jet is isolated.
0094   if (sig_cone > iso_cone)
0095     return 1.;
0096 
0097   math::XYZVector trackMomentum = leadTk->momentum();
0098   const RefVector<TrackCollection> signalTracks = tracksInCone(trackMomentum, sig_cone, pt_min_tk);
0099   const RefVector<TrackCollection> isolationTracks = tracksInCone(trackMomentum, iso_cone, pt_min_tk);
0100 
0101   if (!signalTracks.empty() && (int)(isolationTracks.size() - signalTracks.size()) <= nTracksIsoRing)
0102     myDiscriminator = 1;
0103 
0104   return myDiscriminator;
0105 }
0106 
0107 float IsolatedTauTagInfo::discriminator(const math::XYZVector& myVector,
0108                                         float m_cone,
0109                                         float sig_cone,
0110                                         float iso_cone,
0111                                         float pt_min_lt,
0112                                         float pt_min_tk,
0113                                         int nTracksIsoRing) const {
0114   double myDiscriminator = 0;
0115   //if signal cone is greater then the isolation cone and the leadTk exists, the jet is isolated.
0116   if (sig_cone > iso_cone)
0117     return 1.;
0118 
0119   const TrackRef leadTk = leadingSignalTrack(myVector, m_cone, pt_min_lt);
0120   if (!leadTk)
0121     return myDiscriminator;
0122 
0123   //if signal cone is greater then the isolation cone and the leadTk exists, the jet is isolated.
0124   if (sig_cone > iso_cone)
0125     return 1.;
0126 
0127   math::XYZVector trackMomentum = leadTk->momentum();
0128   const RefVector<TrackCollection> signalTracks = tracksInCone(trackMomentum, sig_cone, pt_min_tk);
0129   const RefVector<TrackCollection> isolationTracks = tracksInCone(trackMomentum, iso_cone, pt_min_tk);
0130 
0131   if (!signalTracks.empty() && (int)(isolationTracks.size() - signalTracks.size()) <= nTracksIsoRing)
0132     myDiscriminator = 1;
0133 
0134   return myDiscriminator;
0135 }
0136 
0137 float IsolatedTauTagInfo::discriminator(float m_cone,
0138                                         float sig_cone,
0139                                         float iso_cone,
0140                                         float pt_min_lt,
0141                                         float pt_min_tk,
0142                                         int nTracksIsoRing,
0143                                         float dz_lt) const {
0144   double myDiscriminator = 0;
0145 
0146   const TrackRef leadTk = leadingSignalTrack(m_cone, pt_min_lt);
0147 
0148   if (!leadTk) {
0149     return myDiscriminator;
0150   }
0151   //if signal cone is greater then the isolation cone and the leadTk exists, the jet is isolated.
0152   if (sig_cone > iso_cone)
0153     return 1.;
0154 
0155   math::XYZVector trackMomentum = leadTk->momentum();
0156   float z_pv = leadTk->dz();
0157   const RefVector<TrackCollection> signalTracks = tracksInCone(trackMomentum, sig_cone, pt_min_tk, z_pv, dz_lt);
0158   const RefVector<TrackCollection> isolationTracks = tracksInCone(trackMomentum, iso_cone, pt_min_tk, z_pv, dz_lt);
0159 
0160   if (!signalTracks.empty() && (int)(isolationTracks.size() - signalTracks.size()) <= nTracksIsoRing)
0161     myDiscriminator = 1;
0162 
0163   return myDiscriminator;
0164 }
0165 
0166 float IsolatedTauTagInfo::discriminator(const math::XYZVector& myVector,
0167                                         float m_cone,
0168                                         float sig_cone,
0169                                         float iso_cone,
0170                                         float pt_min_lt,
0171                                         float pt_min_tk,
0172                                         int nTracksIsoRing,
0173                                         float dz_lt) const {
0174   double myDiscriminator = 0;
0175 
0176   const TrackRef leadTk = leadingSignalTrack(myVector, m_cone, pt_min_lt);
0177   if (!leadTk)
0178     return myDiscriminator;
0179   //if signal cone is greater then the isolation cone and the leadTk exists, the jet is isolated.
0180   if (sig_cone > iso_cone)
0181     return 1.;
0182 
0183   math::XYZVector trackMomentum = leadTk->momentum();
0184   float z_pv = leadTk->dz();
0185   const RefVector<TrackCollection> signalTracks = tracksInCone(trackMomentum, sig_cone, pt_min_tk, z_pv, dz_lt);
0186   const RefVector<TrackCollection> isolationTracks = tracksInCone(trackMomentum, iso_cone, pt_min_tk, z_pv, dz_lt);
0187 
0188   if (!signalTracks.empty() && (int)(isolationTracks.size() - signalTracks.size()) <= nTracksIsoRing)
0189     myDiscriminator = 1;
0190 
0191   return myDiscriminator;
0192 }