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 throw cms::Exception(
"ClassNotInitialized") <<
"Error: AntiElectronMVA not properly initialized.\n";
258 Float_t TauEmFraction =
TMath::Max(TauEmFract,
float(0.));
259 Float_t TauNumHitsVariable = (TauGSFNumHits - TauKFNumHits)/(TauGSFNumHits + TauKFNumHits);
260 Float_t ElecEtotOverPin = (ElecEe + ElecEgamma)/ElecPin;
261 Float_t ElecEgammaOverPdif = ElecEgamma/(ElecPin - ElecPout);
264 if (
deltaR(TauEtaAtEcalEntrance, TauPhi, ElecEta, ElecPhi) > 0.3 && TauSignalPFGammaCands == 0 && TauHasGsf < 0.5) {
265 if (
TMath::Abs(TauEtaAtEcalEntrance) < 1.479 ){
289 }
else if (
deltaR(TauEtaAtEcalEntrance, TauPhi, ElecEta, ElecPhi) > 0.3 && TauSignalPFGammaCands == 0 && TauHasGsf > 0.5) {
290 if (
TMath::Abs(TauEtaAtEcalEntrance) < 1.479 ){
326 }
else if (
deltaR(TauEtaAtEcalEntrance, TauPhi, ElecEta, ElecPhi) > 0.3 && TauSignalPFGammaCands > 0 && TauHasGsf < 0.5 ) {
327 if (
TMath::Abs(TauEtaAtEcalEntrance) < 1.479 ){
360 else if (
deltaR(TauEtaAtEcalEntrance, TauPhi, ElecEta, ElecPhi) > 0.3 && TauSignalPFGammaCands > 0 && TauHasGsf > 0.5 ) {
361 if (
TMath::Abs(TauEtaAtEcalEntrance) < 1.479 ) {
405 }
else if ( TauSignalPFGammaCands == 0 && TauHasGsf < 0.5 ) {
406 if (
TMath::Abs(TauEtaAtEcalEntrance) < 1.479 ) {
446 }
else if ( TauSignalPFGammaCands == 0 && TauHasGsf > 0.5 ) {
447 if (
TMath::Abs(TauEtaAtEcalEntrance) < 1.479 ) {
499 }
else if ( TauSignalPFGammaCands > 0 && TauHasGsf < 0.5 ) {
500 if (
TMath::Abs(TauEtaAtEcalEntrance) < 1.479 ) {
548 }
else if ( TauSignalPFGammaCands > 0 && TauHasGsf > 0.5 ) {
549 if (
TMath::Abs(TauEtaAtEcalEntrance) < 1.479 ) {
617 Float_t TauEtaAtEcalEntrance = -99.;
618 float sumEtaTimesEnergy = 0.;
619 float sumEnergy = 0.;
620 const std::vector<reco::PFCandidatePtr>& signalPFCands = thePFTau.
signalPFCands();
621 for ( std::vector<reco::PFCandidatePtr>::const_iterator pfCandidate = signalPFCands.begin();
622 pfCandidate != signalPFCands.end(); ++pfCandidate ) {
623 sumEtaTimesEnergy += (*pfCandidate)->positionAtECALEntrance().eta()*(*pfCandidate)->energy();
624 sumEnergy += (*pfCandidate)->energy();
626 if ( sumEnergy > 0. ) {
627 TauEtaAtEcalEntrance = sumEtaTimesEnergy/sumEnergy;
630 float TauLeadChargedPFCandEtaAtEcalEntrance = -99.;
631 float TauLeadChargedPFCandPt = -99.;
632 for ( std::vector<reco::PFCandidatePtr>::const_iterator pfCandidate = signalPFCands.begin();
633 pfCandidate != signalPFCands.end(); ++pfCandidate ) {
635 if ( (*pfCandidate)->trackRef().isNonnull() ) track = (*pfCandidate)->trackRef().get();
636 else if ( (*pfCandidate)->muonRef().isNonnull() && (*pfCandidate)->muonRef()->innerTrack().isNonnull() ) track = (*pfCandidate)->muonRef()->innerTrack().get();
637 else if ( (*pfCandidate)->muonRef().isNonnull() && (*pfCandidate)->muonRef()->globalTrack().isNonnull() ) track = (*pfCandidate)->muonRef()->globalTrack().get();
638 else if ( (*pfCandidate)->muonRef().isNonnull() && (*pfCandidate)->muonRef()->outerTrack().isNonnull() ) track = (*pfCandidate)->muonRef()->outerTrack().get();
639 else if ( (*pfCandidate)->gsfTrackRef().isNonnull() ) track = (*pfCandidate)->gsfTrackRef().get();
641 if ( track->
pt() > TauLeadChargedPFCandPt ) {
642 TauLeadChargedPFCandEtaAtEcalEntrance = (*pfCandidate)->positionAtECALEntrance().
eta();
643 TauLeadChargedPFCandPt = track->
pt();
648 Float_t TauPt = thePFTau.
pt();
651 Float_t TauLeadPFChargedHadrHoP = 0.;
652 Float_t TauLeadPFChargedHadrEoP = 0.;
657 Float_t TauVisMass = thePFTau.
mass();
659 std::vector<Float_t> GammasdEta;
660 std::vector<Float_t> GammasdPhi;
661 std::vector<Float_t> GammasPt;
668 GammasdEta.push_back(gamma->eta() - thePFTau.
eta());
669 GammasdPhi.push_back(gamma->phi() - thePFTau.
phi());
671 GammasPt.push_back(gamma->pt());
673 Float_t TauKFNumHits = -99.;
677 Float_t TauGSFNumHits = -99.;
678 Float_t TauGSFChi2 = -99.;
679 Float_t TauGSFTrackResol = -99.;
680 Float_t TauGSFTracklnPt = -99.;
681 Float_t TauGSFTrackEta = -99.;
691 Float_t TauPhi = thePFTau.
phi();
692 float sumPhiTimesEnergy = 0.;
693 float sumEnergyPhi = 0.;
694 for ( std::vector<reco::PFCandidatePtr>::const_iterator pfCandidate = signalPFCands.begin();
695 pfCandidate != signalPFCands.end(); ++pfCandidate ) {
696 sumPhiTimesEnergy += (*pfCandidate)->positionAtECALEntrance().phi()*(*pfCandidate)->energy();
697 sumEnergyPhi += (*pfCandidate)->energy();
699 if ( sumEnergyPhi > 0. ) {
700 TauPhi = sumPhiTimesEnergy/sumEnergyPhi;
702 Float_t TaudCrackPhi =
dCrackPhi(TauPhi, TauEtaAtEcalEntrance);
703 Float_t TaudCrackEta =
dCrackEta(TauEtaAtEcalEntrance);
707 Float_t ElecEta = theGsfEle.
eta();
708 Float_t ElecPhi = theGsfEle.
phi();
709 Float_t ElecPt = theGsfEle.
pt();
712 Float_t ElecEgamma = 0.;
716 pfCluster != pfSuperCluster->clustersEnd(); ++pfCluster ) {
717 double pfClusterEn = (*pfCluster)->energy();
718 if ( pfCluster == pfSuperCluster->clustersBegin() ) ElecEe += pfClusterEn;
719 else ElecEgamma += pfClusterEn;
724 Float_t ElecFbrem = theGsfEle.
fbrem();
726 Float_t ElecChi2GSF = -99.;
727 Float_t ElecGSFNumHits = -99.;
728 Float_t ElecGSFTrackResol = -99.;
729 Float_t ElecGSFTracklnPt = -99.;
730 Float_t ElecGSFTrackEta = -99.;
732 ElecChi2GSF = (theGsfEle).gsfTrack()->normalizedChi2();
733 ElecGSFNumHits = (theGsfEle).gsfTrack()->numberOfValidHits();
734 if ( theGsfEle.
gsfTrack()->pt() > 0. ) {
735 ElecGSFTrackResol = theGsfEle.
gsfTrack()->ptError()/theGsfEle.
gsfTrack()->pt();
736 ElecGSFTracklnPt =
log(theGsfEle.
gsfTrack()->pt())*TMath::Ln10();
738 ElecGSFTrackEta = theGsfEle.
gsfTrack()->eta();
741 return MVAValue(TauEtaAtEcalEntrance,
743 TauLeadChargedPFCandEtaAtEcalEntrance,
744 TauLeadChargedPFCandPt,
748 TauSignalPFGammaCands,
749 TauLeadPFChargedHadrHoP,
750 TauLeadPFChargedHadrEoP,
763 TauSignalPFChargedCands,
782 Float_t TauEtaAtEcalEntrance = -99.;
783 float sumEtaTimesEnergy = 0.;
784 float sumEnergy = 0.;
785 const std::vector<reco::PFCandidatePtr>& signalPFCands = thePFTau.
signalPFCands();
786 for ( std::vector<reco::PFCandidatePtr>::const_iterator pfCandidate = signalPFCands.begin();
787 pfCandidate != signalPFCands.end(); ++pfCandidate ) {
788 sumEtaTimesEnergy += (*pfCandidate)->positionAtECALEntrance().eta()*(*pfCandidate)->energy();
789 sumEnergy += (*pfCandidate)->energy();
791 if ( sumEnergy > 0. ) {
792 TauEtaAtEcalEntrance = sumEtaTimesEnergy/sumEnergy;
795 float TauLeadChargedPFCandEtaAtEcalEntrance = -99.;
796 float TauLeadChargedPFCandPt = -99.;
797 for ( std::vector<reco::PFCandidatePtr>::const_iterator pfCandidate = signalPFCands.begin();
798 pfCandidate != signalPFCands.end(); ++pfCandidate ) {
800 if ( (*pfCandidate)->trackRef().isNonnull() ) track = (*pfCandidate)->trackRef().get();
801 else if ( (*pfCandidate)->muonRef().isNonnull() && (*pfCandidate)->muonRef()->innerTrack().isNonnull() ) track = (*pfCandidate)->muonRef()->innerTrack().get();
802 else if ( (*pfCandidate)->muonRef().isNonnull() && (*pfCandidate)->muonRef()->globalTrack().isNonnull() ) track = (*pfCandidate)->muonRef()->globalTrack().get();
803 else if ( (*pfCandidate)->muonRef().isNonnull() && (*pfCandidate)->muonRef()->outerTrack().isNonnull() ) track = (*pfCandidate)->muonRef()->outerTrack().get();
804 else if ( (*pfCandidate)->gsfTrackRef().isNonnull() ) track = (*pfCandidate)->gsfTrackRef().get();
806 if ( track->
pt() > TauLeadChargedPFCandPt ) {
807 TauLeadChargedPFCandEtaAtEcalEntrance = (*pfCandidate)->positionAtECALEntrance().
eta();
808 TauLeadChargedPFCandPt = track->
pt();
813 Float_t TauPt = thePFTau.
pt();
816 Float_t TauLeadPFChargedHadrHoP = 0.;
817 Float_t TauLeadPFChargedHadrEoP = 0.;
822 Float_t TauVisMass = thePFTau.
mass();
824 std::vector<Float_t> GammasdEta;
825 std::vector<Float_t> GammasdPhi;
826 std::vector<Float_t> GammasPt;
833 GammasdEta.push_back(gamma->eta() - thePFTau.
eta());
834 GammasdPhi.push_back(gamma->phi() - thePFTau.
phi());
836 GammasPt.push_back(gamma->pt());
838 Float_t TauKFNumHits = -99.;
842 Float_t TauGSFNumHits = -99.;
843 Float_t TauGSFChi2 = -99.;
844 Float_t TauGSFTrackResol = -99.;
845 Float_t TauGSFTracklnPt = -99.;
846 Float_t TauGSFTrackEta = -99.;
856 Float_t TauPhi = thePFTau.
phi();
857 float sumPhiTimesEnergy = 0.;
858 float sumEnergyPhi = 0.;
859 for ( std::vector<reco::PFCandidatePtr>::const_iterator pfCandidate = signalPFCands.begin();
860 pfCandidate != signalPFCands.end(); ++pfCandidate ) {
861 sumPhiTimesEnergy += (*pfCandidate)->positionAtECALEntrance().phi()*(*pfCandidate)->energy();
862 sumEnergyPhi += (*pfCandidate)->energy();
864 if ( sumEnergyPhi > 0. ) {
865 TauPhi = sumPhiTimesEnergy/sumEnergyPhi;
867 Float_t TaudCrackPhi =
dCrackPhi(TauPhi,TauEtaAtEcalEntrance) ;
868 Float_t TaudCrackEta =
dCrackEta(TauEtaAtEcalEntrance) ;
872 Float_t dummyElecEta = 9.9;
874 return MVAValue(TauEtaAtEcalEntrance,
876 TauLeadChargedPFCandEtaAtEcalEntrance,
877 TauLeadChargedPFCandPt,
881 TauSignalPFGammaCands,
882 TauLeadPFChargedHadrHoP,
883 TauLeadPFChargedHadrEoP,
896 TauSignalPFChargedCands,
926 static std::vector<double> cPhi;
927 if ( cPhi.size() == 0 ) {
930 for (
unsigned iCrack = 1; iCrack <= 17; ++iCrack ) {
931 cPhi[iCrack] = cPhi[0] - 2.*iCrack*pi/18;
936 double delta_cPhi = 0.00638;
940 if ( eta >= -1.47464 && eta <= 1.47464 ) {
943 if ( eta < 0. ) phi += delta_cPhi;
946 if ( phi > pi ) phi -= 2.*
pi;
947 if ( phi < -pi ) phi += 2.*
pi;
949 if ( phi >= -pi && phi <= pi ) {
952 if ( phi < cPhi[17] || phi >= cPhi[0] ) {
953 if ( phi < 0. ) phi += 2.*
pi;
954 retVal =
minimum(phi - cPhi[0], phi - cPhi[17] - 2.*pi);
958 unsigned iCrack = 16;
960 if ( phi < cPhi[iCrack] ) {
961 retVal =
minimum(phi - cPhi[iCrack + 1], phi - cPhi[iCrack]);
983 double cracks[5] = { 0., 4.44747e-01, 7.92824e-01, 1.14090e+00, 1.47464e+00 };
987 for (
int iCrack = 0; iCrack < 5 ; ++iCrack ) {
988 double d =
minimum(eta - cracks[iCrack], eta + cracks[iCrack]);
GBRForest * gbr_NoEleMatch_wGwGSF_EC_
GBRForest * gbr_wGwGSF_EC_
SuperClusterRef parentSuperCluster() const
const PFCandidatePtr & leadPFChargedHadrCand() const
virtual float pt() const
transverse momentum
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_
virtual float phi() const
momentum azimuthal angle
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.
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_
virtual float eta() const
momentum pseudorapidity
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_
double deltaR(double eta1, double eta2, double phi1, double phi2)
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_
virtual float mass() const
mass
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_
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_