File indexing completed on 2024-04-06 12:27:45
0001
0002
0003
0004
0005
0006
0007
0008
0009 #ifndef RECOTAUTAG_RECOTAU_AntiElectronIDCut2_H
0010 #define RECOTAUTAG_RECOTAU_AntiElectronIDCut2_H
0011
0012 #include "DataFormats/TauReco/interface/PFTau.h"
0013 #include "DataFormats/TrackReco/interface/Track.h"
0014 #include "DataFormats/TrackReco/interface/TrackFwd.h"
0015 #include "DataFormats/GsfTrackReco/interface/GsfTrack.h"
0016 #include "DataFormats/Math/interface/deltaR.h"
0017
0018 #include <vector>
0019
0020 typedef std::pair<double, double> pdouble;
0021
0022 class AntiElectronIDCut2 {
0023 public:
0024 AntiElectronIDCut2();
0025 ~AntiElectronIDCut2();
0026
0027 double Discriminator(float TauPt,
0028 float TauEta,
0029 float TauLeadChargedPFCandPt,
0030 float TauLeadChargedPFCandEtaAtEcalEntrance,
0031 float TauLeadPFChargedHadrEoP,
0032 float TauHcal3x3OverPLead,
0033 float TauGammaEtaMom,
0034 float TauGammaPhiMom,
0035 float TauGammaEnFrac);
0036
0037 double Discriminator(float TauPt,
0038 float TauEta,
0039 float TauLeadChargedPFCandPt,
0040 float TauLeadChargedPFCandEtaAtEcalEntrance,
0041 float TauLeadPFChargedHadrEoP,
0042 float TauHcal3x3OverPLead,
0043 const std::vector<float>& GammasdEta,
0044 const std::vector<float>& GammasdPhi,
0045 const std::vector<float>& GammasPt);
0046
0047 template <typename T>
0048 double Discriminator(const T& thePFTau) {
0049 float TauLeadChargedPFCandEtaAtEcalEntrance = -99.;
0050 float TauLeadChargedPFCandPt = -99.;
0051 const std::vector<reco::PFCandidatePtr>& signalPFCands = thePFTau.signalPFCands();
0052 for (std::vector<reco::PFCandidatePtr>::const_iterator pfCandidate = signalPFCands.begin();
0053 pfCandidate != signalPFCands.end();
0054 ++pfCandidate) {
0055 const reco::Track* track = nullptr;
0056 if ((*pfCandidate)->trackRef().isNonnull())
0057 track = (*pfCandidate)->trackRef().get();
0058 else if ((*pfCandidate)->muonRef().isNonnull() && (*pfCandidate)->muonRef()->innerTrack().isNonnull())
0059 track = (*pfCandidate)->muonRef()->innerTrack().get();
0060 else if ((*pfCandidate)->muonRef().isNonnull() && (*pfCandidate)->muonRef()->globalTrack().isNonnull())
0061 track = (*pfCandidate)->muonRef()->globalTrack().get();
0062 else if ((*pfCandidate)->muonRef().isNonnull() && (*pfCandidate)->muonRef()->outerTrack().isNonnull())
0063 track = (*pfCandidate)->muonRef()->outerTrack().get();
0064 else if ((*pfCandidate)->gsfTrackRef().isNonnull())
0065 track = (*pfCandidate)->gsfTrackRef().get();
0066 if (track) {
0067 if (track->pt() > TauLeadChargedPFCandPt) {
0068 TauLeadChargedPFCandEtaAtEcalEntrance = (*pfCandidate)->positionAtECALEntrance().eta();
0069 TauLeadChargedPFCandPt = track->pt();
0070 }
0071 }
0072 }
0073
0074 float TauPt = thePFTau.pt();
0075 float TauEta = thePFTau.eta();
0076
0077 float TauLeadPFChargedHadrEoP = 0.;
0078 if (thePFTau.leadPFChargedHadrCand()->p() > 0.) {
0079
0080 TauLeadPFChargedHadrEoP = thePFTau.leadPFChargedHadrCand()->ecalEnergy() / thePFTau.leadPFChargedHadrCand()->p();
0081 }
0082
0083 std::vector<float> GammasdEta;
0084 std::vector<float> GammasdPhi;
0085 std::vector<float> GammasPt;
0086 for (unsigned i = 0; i < thePFTau.signalGammaCands().size(); ++i) {
0087 reco::CandidatePtr gamma = thePFTau.signalGammaCands().at(i);
0088 if (thePFTau.leadChargedHadrCand().isNonnull()) {
0089 GammasdEta.push_back(gamma->eta() - thePFTau.leadChargedHadrCand()->eta());
0090 GammasdPhi.push_back(gamma->phi() - thePFTau.leadChargedHadrCand()->phi());
0091 } else {
0092 GammasdEta.push_back(gamma->eta() - thePFTau.eta());
0093 GammasdPhi.push_back(gamma->phi() - thePFTau.phi());
0094 }
0095 GammasPt.push_back(gamma->pt());
0096 }
0097
0098 float TauHcal3x3OverPLead = thePFTau.hcal3x3OverPLead();
0099
0100 return Discriminator(TauPt,
0101 TauEta,
0102 TauLeadChargedPFCandPt,
0103 TauLeadChargedPFCandEtaAtEcalEntrance,
0104 TauLeadPFChargedHadrEoP,
0105 TauHcal3x3OverPLead,
0106 GammasdEta,
0107 GammasdPhi,
0108 GammasPt);
0109 };
0110
0111 void SetBarrelCutValues(float TauLeadPFChargedHadrEoP_min,
0112 float TauLeadPFChargedHadrEoP_max,
0113 float TauHcal3x3OverPLead_max,
0114 float TauGammaEtaMom_max,
0115 float TauGammaPhiMom_max,
0116 float TauGammaEnFrac_max);
0117
0118 void SetEndcapCutValues(float TauLeadPFChargedHadrEoP_min_1,
0119 float TauLeadPFChargedHadrEoP_max_1,
0120 float TauLeadPFChargedHadrEoP_min_2,
0121 float TauLeadPFChargedHadrEoP_max_2,
0122 float TauHcal3x3OverPLead_max,
0123 float TauGammaEtaMom_max,
0124 float TauGammaPhiMom_max,
0125 float TauGammaEnFrac_max);
0126 void ApplyCut_EcalCrack(bool keepAll_, bool rejectAll_) {
0127 keepAllInEcalCrack_ = keepAll_;
0128 rejectAllInEcalCrack_ = rejectAll_;
0129 };
0130
0131 void ApplyCuts(bool applyCut_hcal3x3OverPLead,
0132 bool applyCut_leadPFChargedHadrEoP,
0133 bool applyCut_GammaEtaMom,
0134 bool applyCut_GammaPhiMom,
0135 bool applyCut_GammaEnFrac,
0136 bool applyCut_HLTSpecific);
0137
0138 void SetEcalCracks(const std::vector<pdouble>& etaCracks) {
0139 ecalCracks_.clear();
0140 for (size_t i = 0; i < etaCracks.size(); i++)
0141 ecalCracks_.push_back(etaCracks[i]);
0142 }
0143
0144 private:
0145 bool isInEcalCrack(double eta) const;
0146
0147 float TauLeadPFChargedHadrEoP_barrel_min_;
0148 float TauLeadPFChargedHadrEoP_barrel_max_;
0149 float TauHcal3x3OverPLead_barrel_max_;
0150 float TauGammaEtaMom_barrel_max_;
0151 float TauGammaPhiMom_barrel_max_;
0152 float TauGammaEnFrac_barrel_max_;
0153 float TauLeadPFChargedHadrEoP_endcap_min1_;
0154 float TauLeadPFChargedHadrEoP_endcap_max1_;
0155 float TauLeadPFChargedHadrEoP_endcap_min2_;
0156 float TauLeadPFChargedHadrEoP_endcap_max2_;
0157 float TauHcal3x3OverPLead_endcap_max_;
0158 float TauGammaEtaMom_endcap_max_;
0159 float TauGammaPhiMom_endcap_max_;
0160 float TauGammaEnFrac_endcap_max_;
0161
0162 bool keepAllInEcalCrack_;
0163 bool rejectAllInEcalCrack_;
0164
0165 bool Tau_applyCut_hcal3x3OverPLead_;
0166 bool Tau_applyCut_leadPFChargedHadrEoP_;
0167 bool Tau_applyCut_GammaEtaMom_;
0168 bool Tau_applyCut_GammaPhiMom_;
0169 bool Tau_applyCut_GammaEnFrac_;
0170 bool Tau_applyCut_HLTSpecific_;
0171
0172 std::vector<pdouble> ecalCracks_;
0173
0174 int verbosity_;
0175 };
0176
0177 #endif