15 : isInitialized_(kFALSE),
82 fin_ =
new TFile(gbrFile.data(),
"READ");
83 if (
fin_->IsZombie() )
85 <<
" Failed to open File = " << gbrFile <<
" !!\n";
108 Float_t TauLeadChargedPFCandEtaAtEcalEntrance,
109 Float_t TauLeadChargedPFCandPt,
110 Float_t TaudCrackEta,
111 Float_t TaudCrackPhi,
112 Float_t TauEmFraction,
113 Float_t TauSignalPFGammaCands,
114 Float_t TauLeadPFChargedHadrHoP,
115 Float_t TauLeadPFChargedHadrEoP,
118 const std::vector<Float_t>& GammasdEta,
119 const std::vector<Float_t>& GammasdPhi,
120 const std::vector<Float_t>& GammasPt,
121 Float_t TauKFNumHits,
122 Float_t TauGSFNumHits,
124 Float_t TauGSFTrackResol,
125 Float_t TauGSFTracklnPt,
126 Float_t TauGSFTrackEta,
128 Float_t TauSignalPFChargedCands,
139 Float_t ElecGSFNumHits,
140 Float_t ElecGSFTrackResol,
141 Float_t ElecGSFTracklnPt,
142 Float_t ElecGSFTrackEta)
150 for (
unsigned int i = 0 ;
i < GammasPt.size() ; ++
i ) {
151 double pt_i = GammasPt[
i];
152 double phi_i = GammasdPhi[
i];
155 double eta_i = GammasdEta[
i];
157 sumPt2 += (pt_i*pt_i);
158 dEta += (pt_i*eta_i);
159 dEta2 += (pt_i*eta_i*eta_i);
160 dPhi += (pt_i*phi_i);
161 dPhi2 += (pt_i*phi_i*phi_i);
164 Float_t TauGammaEnFrac = sumPt/TauPt;
173 Float_t TauGammaEtaMom = TMath::Sqrt(dEta2)*TMath::Sqrt(TauGammaEnFrac)*TauPt;
174 Float_t TauGammaPhiMom = TMath::Sqrt(dPhi2)*TMath::Sqrt(TauGammaEnFrac)*TauPt;
176 return MVAValue(TauEtaAtEcalEntrance,
178 TauLeadChargedPFCandEtaAtEcalEntrance,
179 TauLeadChargedPFCandPt,
183 TauSignalPFGammaCands,
184 TauLeadPFChargedHadrHoP,
185 TauLeadPFChargedHadrEoP,
198 TauSignalPFChargedCands,
217 Float_t TauLeadChargedPFCandEtaAtEcalEntrance,
218 Float_t TauLeadChargedPFCandPt,
219 Float_t TaudCrackEta,
220 Float_t TaudCrackPhi,
222 Float_t TauSignalPFGammaCands,
223 Float_t TauLeadPFChargedHadrHoP,
224 Float_t TauLeadPFChargedHadrEoP,
227 Float_t TauGammaEtaMom,
228 Float_t TauGammaPhiMom,
229 Float_t TauGammaEnFrac,
230 Float_t TauKFNumHits,
231 Float_t TauGSFNumHits,
233 Float_t TauGSFTrackResol,
234 Float_t TauGSFTracklnPt,
235 Float_t TauGSFTrackEta,
237 Float_t TauSignalPFChargedCands,
248 Float_t ElecGSFNumHits,
249 Float_t ElecGSFTrackResol,
250 Float_t ElecGSFTracklnPt,
251 Float_t ElecGSFTrackEta)
255 std::cout <<
"Error: AntiElectronMVA not properly initialized.\n";
259 Float_t TauEmFraction =
TMath::Max(TauEmFract,
float(0.));
260 Float_t TauNumHitsVariable = (TauGSFNumHits - TauKFNumHits)/(TauGSFNumHits + TauKFNumHits);
261 Float_t ElecEtotOverPin = (ElecEe + ElecEgamma)/ElecPin;
262 Float_t ElecEgammaOverPdif = ElecEgamma/(ElecPin - ElecPout);
265 if (
deltaR(TauEtaAtEcalEntrance, TauPhi, ElecEta, ElecPhi) > 0.3 && TauSignalPFGammaCands == 0 && TauHasGsf < 0.5) {
266 if ( TMath::Abs(TauEtaAtEcalEntrance) < 1.479 ){
290 }
else if (
deltaR(TauEtaAtEcalEntrance, TauPhi, ElecEta, ElecPhi) > 0.3 && TauSignalPFGammaCands == 0 && TauHasGsf > 0.5) {
291 if ( TMath::Abs(TauEtaAtEcalEntrance) < 1.479 ){
327 }
else if (
deltaR(TauEtaAtEcalEntrance, TauPhi, ElecEta, ElecPhi) > 0.3 && TauSignalPFGammaCands > 0 && TauHasGsf < 0.5 ) {
328 if ( TMath::Abs(TauEtaAtEcalEntrance) < 1.479 ){
361 else if (
deltaR(TauEtaAtEcalEntrance, TauPhi, ElecEta, ElecPhi) > 0.3 && TauSignalPFGammaCands > 0 && TauHasGsf > 0.5 ) {
362 if ( TMath::Abs(TauEtaAtEcalEntrance) < 1.479 ) {
406 }
else if ( TauSignalPFGammaCands == 0 && TauHasGsf < 0.5 ) {
407 if ( TMath::Abs(TauEtaAtEcalEntrance) < 1.479 ) {
447 }
else if ( TauSignalPFGammaCands == 0 && TauHasGsf > 0.5 ) {
448 if ( TMath::Abs(TauEtaAtEcalEntrance) < 1.479 ) {
500 }
else if ( TauSignalPFGammaCands > 0 && TauHasGsf < 0.5 ) {
501 if ( TMath::Abs(TauEtaAtEcalEntrance) < 1.479 ) {
549 }
else if ( TauSignalPFGammaCands > 0 && TauHasGsf > 0.5 ) {
550 if ( TMath::Abs(TauEtaAtEcalEntrance) < 1.479 ) {
618 Float_t TauEtaAtEcalEntrance = -99.;
619 float sumEtaTimesEnergy = 0.;
620 float sumEnergy = 0.;
621 const std::vector<reco::PFCandidatePtr>& signalPFCands = thePFTau.
signalPFCands();
622 for ( std::vector<reco::PFCandidatePtr>::const_iterator pfCandidate = signalPFCands.begin();
623 pfCandidate != signalPFCands.end(); ++pfCandidate ) {
624 sumEtaTimesEnergy += (*pfCandidate)->positionAtECALEntrance().eta()*(*pfCandidate)->energy();
625 sumEnergy += (*pfCandidate)->energy();
627 if ( sumEnergy > 0. ) {
628 TauEtaAtEcalEntrance = sumEtaTimesEnergy/sumEnergy;
631 float TauLeadChargedPFCandEtaAtEcalEntrance = -99.;
632 float TauLeadChargedPFCandPt = -99.;
633 for ( std::vector<reco::PFCandidatePtr>::const_iterator pfCandidate = signalPFCands.begin();
634 pfCandidate != signalPFCands.end(); ++pfCandidate ) {
636 if ( (*pfCandidate)->trackRef().isNonnull() ) track = (*pfCandidate)->trackRef().get();
637 else if ( (*pfCandidate)->muonRef().isNonnull() && (*pfCandidate)->muonRef()->innerTrack().isNonnull() ) track = (*pfCandidate)->muonRef()->innerTrack().get();
638 else if ( (*pfCandidate)->muonRef().isNonnull() && (*pfCandidate)->muonRef()->globalTrack().isNonnull() ) track = (*pfCandidate)->muonRef()->globalTrack().get();
639 else if ( (*pfCandidate)->muonRef().isNonnull() && (*pfCandidate)->muonRef()->outerTrack().isNonnull() ) track = (*pfCandidate)->muonRef()->outerTrack().get();
640 else if ( (*pfCandidate)->gsfTrackRef().isNonnull() ) track = (*pfCandidate)->gsfTrackRef().get();
642 if ( track->
pt() > TauLeadChargedPFCandPt ) {
643 TauLeadChargedPFCandEtaAtEcalEntrance = (*pfCandidate)->positionAtECALEntrance().
eta();
644 TauLeadChargedPFCandPt = track->
pt();
649 Float_t TauPt = thePFTau.
pt();
652 Float_t TauLeadPFChargedHadrHoP = 0.;
653 Float_t TauLeadPFChargedHadrEoP = 0.;
658 Float_t TauVisMass = thePFTau.
mass();
660 std::vector<Float_t> GammasdEta;
661 std::vector<Float_t> GammasdPhi;
662 std::vector<Float_t> GammasPt;
669 GammasdEta.push_back(gamma->eta() - thePFTau.
eta());
670 GammasdPhi.push_back(gamma->phi() - thePFTau.
phi());
672 GammasPt.push_back(gamma->pt());
674 Float_t TauKFNumHits = -99.;
678 Float_t TauGSFNumHits = -99.;
679 Float_t TauGSFChi2 = -99.;
680 Float_t TauGSFTrackResol = -99.;
681 Float_t TauGSFTracklnPt = -99.;
682 Float_t TauGSFTrackEta = -99.;
692 Float_t TauPhi = thePFTau.
phi();
693 float sumPhiTimesEnergy = 0.;
694 float sumEnergyPhi = 0.;
695 for ( std::vector<reco::PFCandidatePtr>::const_iterator pfCandidate = signalPFCands.begin();
696 pfCandidate != signalPFCands.end(); ++pfCandidate ) {
697 sumPhiTimesEnergy += (*pfCandidate)->positionAtECALEntrance().phi()*(*pfCandidate)->energy();
698 sumEnergyPhi += (*pfCandidate)->energy();
700 if ( sumEnergyPhi > 0. ) {
701 TauPhi = sumPhiTimesEnergy/sumEnergyPhi;
703 Float_t TaudCrackPhi =
dCrackPhi(TauPhi, TauEtaAtEcalEntrance);
704 Float_t TaudCrackEta =
dCrackEta(TauEtaAtEcalEntrance);
708 Float_t ElecEta = theGsfEle.
eta();
709 Float_t ElecPhi = theGsfEle.
phi();
710 Float_t ElecPt = theGsfEle.
pt();
713 Float_t ElecEgamma = 0.;
717 pfCluster != pfSuperCluster->clustersEnd(); ++pfCluster ) {
718 double pfClusterEn = (*pfCluster)->energy();
719 if ( pfCluster == pfSuperCluster->clustersBegin() ) ElecEe += pfClusterEn;
720 else ElecEgamma += pfClusterEn;
725 Float_t ElecFbrem = theGsfEle.
fbrem();
727 Float_t ElecChi2GSF = -99.;
728 Float_t ElecGSFNumHits = -99.;
729 Float_t ElecGSFTrackResol = -99.;
730 Float_t ElecGSFTracklnPt = -99.;
731 Float_t ElecGSFTrackEta = -99.;
733 ElecChi2GSF = (theGsfEle).gsfTrack()->normalizedChi2();
734 ElecGSFNumHits = (theGsfEle).gsfTrack()->numberOfValidHits();
735 if ( theGsfEle.
gsfTrack()->pt() > 0. ) {
736 ElecGSFTrackResol = theGsfEle.
gsfTrack()->ptError()/theGsfEle.
gsfTrack()->pt();
737 ElecGSFTracklnPt =
log(theGsfEle.
gsfTrack()->pt())*TMath::Ln10();
739 ElecGSFTrackEta = theGsfEle.
gsfTrack()->eta();
742 return MVAValue(TauEtaAtEcalEntrance,
744 TauLeadChargedPFCandEtaAtEcalEntrance,
745 TauLeadChargedPFCandPt,
749 TauSignalPFGammaCands,
750 TauLeadPFChargedHadrHoP,
751 TauLeadPFChargedHadrEoP,
764 TauSignalPFChargedCands,
783 Float_t TauEtaAtEcalEntrance = -99.;
784 float sumEtaTimesEnergy = 0.;
785 float sumEnergy = 0.;
786 const std::vector<reco::PFCandidatePtr>& signalPFCands = thePFTau.
signalPFCands();
787 for ( std::vector<reco::PFCandidatePtr>::const_iterator pfCandidate = signalPFCands.begin();
788 pfCandidate != signalPFCands.end(); ++pfCandidate ) {
789 sumEtaTimesEnergy += (*pfCandidate)->positionAtECALEntrance().eta()*(*pfCandidate)->energy();
790 sumEnergy += (*pfCandidate)->energy();
792 if ( sumEnergy > 0. ) {
793 TauEtaAtEcalEntrance = sumEtaTimesEnergy/sumEnergy;
796 float TauLeadChargedPFCandEtaAtEcalEntrance = -99.;
797 float TauLeadChargedPFCandPt = -99.;
798 for ( std::vector<reco::PFCandidatePtr>::const_iterator pfCandidate = signalPFCands.begin();
799 pfCandidate != signalPFCands.end(); ++pfCandidate ) {
801 if ( (*pfCandidate)->trackRef().isNonnull() ) track = (*pfCandidate)->trackRef().get();
802 else if ( (*pfCandidate)->muonRef().isNonnull() && (*pfCandidate)->muonRef()->innerTrack().isNonnull() ) track = (*pfCandidate)->muonRef()->innerTrack().get();
803 else if ( (*pfCandidate)->muonRef().isNonnull() && (*pfCandidate)->muonRef()->globalTrack().isNonnull() ) track = (*pfCandidate)->muonRef()->globalTrack().get();
804 else if ( (*pfCandidate)->muonRef().isNonnull() && (*pfCandidate)->muonRef()->outerTrack().isNonnull() ) track = (*pfCandidate)->muonRef()->outerTrack().get();
805 else if ( (*pfCandidate)->gsfTrackRef().isNonnull() ) track = (*pfCandidate)->gsfTrackRef().get();
807 if ( track->
pt() > TauLeadChargedPFCandPt ) {
808 TauLeadChargedPFCandEtaAtEcalEntrance = (*pfCandidate)->positionAtECALEntrance().
eta();
809 TauLeadChargedPFCandPt = track->
pt();
814 Float_t TauPt = thePFTau.
pt();
817 Float_t TauLeadPFChargedHadrHoP = 0.;
818 Float_t TauLeadPFChargedHadrEoP = 0.;
823 Float_t TauVisMass = thePFTau.
mass();
825 std::vector<Float_t> GammasdEta;
826 std::vector<Float_t> GammasdPhi;
827 std::vector<Float_t> GammasPt;
834 GammasdEta.push_back(gamma->eta() - thePFTau.
eta());
835 GammasdPhi.push_back(gamma->phi() - thePFTau.
phi());
837 GammasPt.push_back(gamma->pt());
839 Float_t TauKFNumHits = -99.;
843 Float_t TauGSFNumHits = -99.;
844 Float_t TauGSFChi2 = -99.;
845 Float_t TauGSFTrackResol = -99.;
846 Float_t TauGSFTracklnPt = -99.;
847 Float_t TauGSFTrackEta = -99.;
857 Float_t TauPhi = thePFTau.
phi();
858 float sumPhiTimesEnergy = 0.;
859 float sumEnergyPhi = 0.;
860 for ( std::vector<reco::PFCandidatePtr>::const_iterator pfCandidate = signalPFCands.begin();
861 pfCandidate != signalPFCands.end(); ++pfCandidate ) {
862 sumPhiTimesEnergy += (*pfCandidate)->positionAtECALEntrance().phi()*(*pfCandidate)->energy();
863 sumEnergyPhi += (*pfCandidate)->energy();
865 if ( sumEnergyPhi > 0. ) {
866 TauPhi = sumPhiTimesEnergy/sumEnergyPhi;
868 Float_t TaudCrackPhi =
dCrackPhi(TauPhi,TauEtaAtEcalEntrance) ;
869 Float_t TaudCrackEta =
dCrackEta(TauEtaAtEcalEntrance) ;
873 Float_t dummyElecEta = 9.9;
875 return MVAValue(TauEtaAtEcalEntrance,
877 TauLeadChargedPFCandEtaAtEcalEntrance,
878 TauLeadChargedPFCandPt,
882 TauSignalPFGammaCands,
883 TauLeadPFChargedHadrHoP,
884 TauLeadPFChargedHadrEoP,
897 TauSignalPFChargedCands,
916 if ( TMath::Abs(b) < TMath::Abs(a) )
return b;
927 static std::vector<double> cPhi;
928 if ( cPhi.size() == 0 ) {
931 for (
unsigned iCrack = 1; iCrack <= 17; ++iCrack ) {
932 cPhi[iCrack] = cPhi[0] - 2.*iCrack*pi/18;
937 double delta_cPhi = 0.00638;
941 if ( eta >= -1.47464 && eta <= 1.47464 ) {
944 if ( eta < 0. ) phi += delta_cPhi;
947 if ( phi > pi ) phi -= 2.*
pi;
948 if ( phi < -pi ) phi += 2.*
pi;
950 if ( phi >= -pi && phi <= pi ) {
953 if ( phi < cPhi[17] || phi >= cPhi[0] ) {
954 if ( phi < 0. ) phi += 2.*
pi;
955 retVal =
minimum(phi - cPhi[0], phi - cPhi[17] - 2.*pi);
959 unsigned iCrack = 16;
961 if ( phi < cPhi[iCrack] ) {
962 retVal =
minimum(phi - cPhi[iCrack + 1], phi - cPhi[iCrack]);
976 return TMath::Abs(retVal);
984 double cracks[5] = { 0., 4.44747e-01, 7.92824e-01, 1.14090e+00, 1.47464e+00 };
988 for (
int iCrack = 0; iCrack < 5 ; ++iCrack ) {
989 double d =
minimum(eta - cracks[iCrack], eta + cracks[iCrack]);
990 if ( TMath::Abs(d) < TMath::Abs(retVal) ) {
995 return TMath::Abs(retVal);
GBRForest * gbr_NoEleMatch_wGwGSF_EC_
GBRForest * gbr_wGwGSF_EC_
SuperClusterRef parentSuperCluster() const
const PFCandidatePtr & leadPFChargedHadrCand() const
void Initialize_from_file(const std::string &methodName, const std::string &gbrFile)
pair< int, edm::FunctionWithDict > OK
Float_t * Var_NoEleMatch_woGwGSF_Endcap_
Float_t * Var_NoEleMatch_woGwGSF_Barrel_
math::XYZVectorF trackMomentumAtVtx() const
const std::vector< reco::PFCandidatePtr > & signalPFGammaCands() const
Gamma candidates in signal region.
GBRForest * gbr_woGwGSF_EC_
GBRForest * gbr_woGwoGSF_BL_
GBRForest * gbr_wGwGSF_BL_
Float_t * Var_wGwoGSF_Endcap_
Float_t * Var_woGwGSF_Barrel_
GBRForest * gbr_wGwoGSF_BL_
const std::vector< reco::PFCandidatePtr > & signalPFCands() const
PFCandidates in signal region.
double minimum(double a, double b)
GBRForest * gbr_NoEleMatch_wGwGSF_BL_
GBRForest * gbr_NoEleMatch_wGwoGSF_BL_
bool isNonnull() const
Checks for non-null.
virtual float phi() const GCC11_FINAL
momentum azimuthal angle
bool isNonnull() const
Checks for non-null.
double eta() const
pseudorapidity of momentum vector
GBRForest * gbr_NoEleMatch_woGwoGSF_EC_
double dPhi(double phi1, double phi2)
Float_t * Var_NoEleMatch_wGwGSF_Barrel_
math::XYZVectorF trackMomentumOut() const
double pt() const
track transverse momentum
GBRForest * gbr_NoEleMatch_woGwoGSF_BL_
Float_t * Var_NoEleMatch_wGwGSF_Endcap_
Float_t * Var_NoEleMatch_woGwoGSF_Endcap_
GBRForest * gbr_NoEleMatch_woGwGSF_EC_
virtual float eta() const GCC11_FINAL
momentum pseudorapidity
double deltaR(double eta1, double eta2, double phi1, double phi2)
virtual float mass() const GCC11_FINAL
mass
GBRForest * gbr_NoEleMatch_woGwGSF_BL_
GBRForest * gbr_wGwoGSF_EC_
Float_t * Var_NoEleMatch_woGwoGSF_Barrel_
Float_t * Var_NoEleMatch_wGwoGSF_Endcap_
Float_t * Var_NoEleMatch_wGwoGSF_Barrel_
GBRForest * gbr_woGwoGSF_EC_
double dCrackPhi(double phi, double eta)
Float_t * Var_woGwGSF_Endcap_
Float_t * Var_wGwGSF_Barrel_
double MVAValue(Float_t TauEtaAtEcalEntrance, Float_t TauPt, Float_t TauLeadChargedPFCandEtaAtEcalEntrance, Float_t TauLeadChargedPFCandPt, Float_t TaudCrackEta, Float_t TaudCrackPhi, Float_t TauEmFraction, Float_t TauSignalPFGammaCands, Float_t TauLeadPFChargedHadrHoP, Float_t TauLeadPFChargedHadrEoP, Float_t TauVisMass, Float_t TauHadrMva, const std::vector< Float_t > &GammasdEta, const std::vector< Float_t > &GammasdPhi, const std::vector< Float_t > &GammasPt, Float_t TauKFNumHits, Float_t TauGSFNumHits, Float_t TauGSFChi2, Float_t TauGSFTrackResol, Float_t TauGSFTracklnPt, Float_t TauGSFTrackEta, Float_t TauPhi, Float_t TauSignalPFChargedCands, Float_t TauHasGsf, Float_t ElecEta, Float_t ElecPhi, Float_t ElecPt, Float_t ElecEe, Float_t ElecEgamma, Float_t ElecPin, Float_t ElecPout, Float_t ElecFbrem, Float_t ElecChi2GSF, Float_t ElecGSFNumHits, Float_t ElecGSFTrackResol, Float_t ElecGSFTracklnPt, Float_t ElecGSFTrackEta)
Float_t * Var_woGwoGSF_Endcap_
GBRForest * gbr_woGwGSF_BL_
virtual float pt() const GCC11_FINAL
transverse momentum
double GetClassifier(const float *vector) const
float electronPreIDOutput() const
GBRForest * gbr_NoEleMatch_wGwoGSF_EC_
Float_t * Var_wGwoGSF_Barrel_
double dCrackEta(double eta)
Float_t * Var_wGwGSF_Endcap_
const std::vector< reco::PFCandidatePtr > & signalPFChargedHadrCands() const
Charged hadrons in signal region.
virtual GsfTrackRef gsfTrack() const
reference to a GsfTrack
Float_t * Var_woGwoGSF_Barrel_