17 : isInitialized_(
false),
18 mva_NoEleMatch_woGwoGSF_BL_(0),
19 mva_NoEleMatch_woGwGSF_BL_(0),
20 mva_NoEleMatch_wGwoGSF_BL_(0),
21 mva_NoEleMatch_wGwGSF_BL_(0),
26 mva_NoEleMatch_woGwoGSF_EC_(0),
27 mva_NoEleMatch_woGwGSF_EC_(0),
28 mva_NoEleMatch_wGwoGSF_EC_(0),
29 mva_NoEleMatch_wGwGSF_EC_(0),
126 throw cms::Exception(
"PFRecoTauDiscriminationAgainstMuonMVA::loadMVA")
127 <<
" Failed to load MVA = " << mvaName.data() <<
" from file " <<
" !!\n";
189 Float_t TauLeadChargedPFCandEtaAtEcalEntrance,
190 Float_t TauLeadChargedPFCandPt,
191 Float_t TaudCrackEta,
192 Float_t TaudCrackPhi,
193 Float_t TauEmFraction,
194 Float_t TauSignalPFGammaCands,
195 Float_t TauLeadPFChargedHadrHoP,
196 Float_t TauLeadPFChargedHadrEoP,
199 const std::vector<Float_t>& GammasdEta,
200 const std::vector<Float_t>& GammasdPhi,
201 const std::vector<Float_t>& GammasPt,
202 Float_t TauKFNumHits,
203 Float_t TauGSFNumHits,
205 Float_t TauGSFTrackResol,
206 Float_t TauGSFTracklnPt,
207 Float_t TauGSFTrackEta,
209 Float_t TauSignalPFChargedCands,
220 Float_t ElecGSFNumHits,
221 Float_t ElecGSFTrackResol,
222 Float_t ElecGSFTracklnPt,
223 Float_t ElecGSFTrackEta)
231 for (
unsigned int i = 0 ;
i < GammasPt.size() ; ++
i ) {
232 double pt_i = GammasPt[
i];
233 double phi_i = GammasdPhi[
i];
234 if ( GammasdPhi[
i] >
M_PI ) phi_i = GammasdPhi[
i] - 2*
M_PI;
235 else if ( GammasdPhi[
i] < -M_PI ) phi_i = GammasdPhi[
i] + 2*
M_PI;
236 double eta_i = GammasdEta[
i];
238 sumPt2 += (pt_i*pt_i);
239 dEta += (pt_i*eta_i);
240 dEta2 += (pt_i*eta_i*eta_i);
241 dPhi += (pt_i*phi_i);
242 dPhi2 += (pt_i*phi_i*phi_i);
245 Float_t TauGammaEnFrac = sumPt/TauPt;
257 return MVAValue(TauEtaAtEcalEntrance,
259 TauLeadChargedPFCandEtaAtEcalEntrance,
260 TauLeadChargedPFCandPt,
264 TauSignalPFGammaCands,
265 TauLeadPFChargedHadrHoP,
266 TauLeadPFChargedHadrEoP,
279 TauSignalPFChargedCands,
298 Float_t TauLeadChargedPFCandEtaAtEcalEntrance,
299 Float_t TauLeadChargedPFCandPt,
300 Float_t TaudCrackEta,
301 Float_t TaudCrackPhi,
303 Float_t TauSignalPFGammaCands,
304 Float_t TauLeadPFChargedHadrHoP,
305 Float_t TauLeadPFChargedHadrEoP,
308 Float_t TauGammaEtaMom,
309 Float_t TauGammaPhiMom,
310 Float_t TauGammaEnFrac,
311 Float_t TauKFNumHits,
312 Float_t TauGSFNumHits,
314 Float_t TauGSFTrackResol,
315 Float_t TauGSFTracklnPt,
316 Float_t TauGSFTrackEta,
318 Float_t TauSignalPFChargedCands,
329 Float_t ElecGSFNumHits,
330 Float_t ElecGSFTrackResol,
331 Float_t ElecGSFTracklnPt,
332 Float_t ElecGSFTrackEta)
336 <<
" AntiElectronMVA not properly initialized !!\n";
339 Float_t TauEmFraction =
std::max(TauEmFract,
float(0.));
340 Float_t TauNumHitsVariable = (TauGSFNumHits - TauKFNumHits)/(TauGSFNumHits + TauKFNumHits);
341 Float_t ElecEtotOverPin = (ElecEe + ElecEgamma)/ElecPin;
342 Float_t ElecEgammaOverPdif = ElecEgamma/(ElecPin - ElecPout);
344 double mvaValue = -99.;
345 if (
deltaR(TauEtaAtEcalEntrance, TauPhi, ElecEta, ElecPhi) > 0.3 && TauSignalPFGammaCands == 0 && TauHasGsf < 0.5) {
346 if (
std::abs(TauEtaAtEcalEntrance) < 1.479 ){
370 }
else if (
deltaR(TauEtaAtEcalEntrance, TauPhi, ElecEta, ElecPhi) > 0.3 && TauSignalPFGammaCands == 0 && TauHasGsf > 0.5) {
371 if (
std::abs(TauEtaAtEcalEntrance) < 1.479 ){
407 }
else if (
deltaR(TauEtaAtEcalEntrance, TauPhi, ElecEta, ElecPhi) > 0.3 && TauSignalPFGammaCands > 0 && TauHasGsf < 0.5 ) {
408 if (
std::abs(TauEtaAtEcalEntrance) < 1.479 ){
441 else if (
deltaR(TauEtaAtEcalEntrance, TauPhi, ElecEta, ElecPhi) > 0.3 && TauSignalPFGammaCands > 0 && TauHasGsf > 0.5 ) {
442 if (
std::abs(TauEtaAtEcalEntrance) < 1.479 ) {
486 }
else if ( TauSignalPFGammaCands == 0 && TauHasGsf < 0.5 ) {
487 if (
std::abs(TauEtaAtEcalEntrance) < 1.479 ) {
527 }
else if ( TauSignalPFGammaCands == 0 && TauHasGsf > 0.5 ) {
528 if (
std::abs(TauEtaAtEcalEntrance) < 1.479 ) {
580 }
else if ( TauSignalPFGammaCands > 0 && TauHasGsf < 0.5 ) {
581 if (
std::abs(TauEtaAtEcalEntrance) < 1.479 ) {
629 }
else if ( TauSignalPFGammaCands > 0 && TauHasGsf > 0.5 ) {
630 if (
std::abs(TauEtaAtEcalEntrance) < 1.479 ) {
698 Float_t TauEtaAtEcalEntrance = -99.;
699 float sumEtaTimesEnergy = 0.;
700 float sumEnergy = 0.;
701 const std::vector<reco::PFCandidatePtr>& signalPFCands = thePFTau.
signalPFCands();
702 for ( std::vector<reco::PFCandidatePtr>::const_iterator pfCandidate = signalPFCands.begin();
703 pfCandidate != signalPFCands.end(); ++pfCandidate ) {
704 sumEtaTimesEnergy += (*pfCandidate)->positionAtECALEntrance().eta()*(*pfCandidate)->energy();
705 sumEnergy += (*pfCandidate)->energy();
707 if ( sumEnergy > 0. ) {
708 TauEtaAtEcalEntrance = sumEtaTimesEnergy/sumEnergy;
711 float TauLeadChargedPFCandEtaAtEcalEntrance = -99.;
712 float TauLeadChargedPFCandPt = -99.;
713 for ( std::vector<reco::PFCandidatePtr>::const_iterator pfCandidate = signalPFCands.begin();
714 pfCandidate != signalPFCands.end(); ++pfCandidate ) {
716 if ( (*pfCandidate)->trackRef().isNonnull() ) track = (*pfCandidate)->trackRef().get();
717 else if ( (*pfCandidate)->muonRef().isNonnull() && (*pfCandidate)->muonRef()->innerTrack().isNonnull() ) track = (*pfCandidate)->muonRef()->innerTrack().get();
718 else if ( (*pfCandidate)->muonRef().isNonnull() && (*pfCandidate)->muonRef()->globalTrack().isNonnull() ) track = (*pfCandidate)->muonRef()->globalTrack().get();
719 else if ( (*pfCandidate)->muonRef().isNonnull() && (*pfCandidate)->muonRef()->outerTrack().isNonnull() ) track = (*pfCandidate)->muonRef()->outerTrack().get();
720 else if ( (*pfCandidate)->gsfTrackRef().isNonnull() ) track = (*pfCandidate)->gsfTrackRef().get();
722 if ( track->
pt() > TauLeadChargedPFCandPt ) {
723 TauLeadChargedPFCandEtaAtEcalEntrance = (*pfCandidate)->positionAtECALEntrance().
eta();
724 TauLeadChargedPFCandPt = track->
pt();
729 Float_t TauPt = thePFTau.
pt();
732 Float_t TauLeadPFChargedHadrHoP = 0.;
733 Float_t TauLeadPFChargedHadrEoP = 0.;
738 Float_t TauVisMass = thePFTau.
mass();
740 std::vector<Float_t> GammasdEta;
741 std::vector<Float_t> GammasdPhi;
742 std::vector<Float_t> GammasPt;
749 GammasdEta.push_back(gamma->eta() - thePFTau.
eta());
750 GammasdPhi.push_back(gamma->phi() - thePFTau.
phi());
752 GammasPt.push_back(gamma->pt());
754 Float_t TauKFNumHits = -99.;
758 Float_t TauGSFNumHits = -99.;
759 Float_t TauGSFChi2 = -99.;
760 Float_t TauGSFTrackResol = -99.;
761 Float_t TauGSFTracklnPt = -99.;
762 Float_t TauGSFTrackEta = -99.;
772 Float_t TauPhi = thePFTau.
phi();
773 float sumPhiTimesEnergy = 0.;
774 float sumEnergyPhi = 0.;
775 for ( std::vector<reco::PFCandidatePtr>::const_iterator pfCandidate = signalPFCands.begin();
776 pfCandidate != signalPFCands.end(); ++pfCandidate ) {
777 sumPhiTimesEnergy += (*pfCandidate)->positionAtECALEntrance().phi()*(*pfCandidate)->energy();
778 sumEnergyPhi += (*pfCandidate)->energy();
780 if ( sumEnergyPhi > 0. ) {
781 TauPhi = sumPhiTimesEnergy/sumEnergyPhi;
783 Float_t TaudCrackPhi =
dCrackPhi(TauPhi, TauEtaAtEcalEntrance);
784 Float_t TaudCrackEta =
dCrackEta(TauEtaAtEcalEntrance);
788 Float_t ElecEta = theGsfEle.
eta();
789 Float_t ElecPhi = theGsfEle.
phi();
790 Float_t ElecPt = theGsfEle.
pt();
793 Float_t ElecEgamma = 0.;
797 pfCluster != pfSuperCluster->clustersEnd(); ++pfCluster ) {
798 double pfClusterEn = (*pfCluster)->energy();
799 if ( pfCluster == pfSuperCluster->clustersBegin() ) ElecEe += pfClusterEn;
800 else ElecEgamma += pfClusterEn;
805 Float_t ElecFbrem = theGsfEle.
fbrem();
807 Float_t ElecChi2GSF = -99.;
808 Float_t ElecGSFNumHits = -99.;
809 Float_t ElecGSFTrackResol = -99.;
810 Float_t ElecGSFTracklnPt = -99.;
811 Float_t ElecGSFTrackEta = -99.;
813 ElecChi2GSF = (theGsfEle).gsfTrack()->normalizedChi2();
814 ElecGSFNumHits = (theGsfEle).gsfTrack()->numberOfValidHits();
815 if ( theGsfEle.
gsfTrack()->pt() > 0. ) {
816 ElecGSFTrackResol = theGsfEle.
gsfTrack()->ptError()/theGsfEle.
gsfTrack()->pt();
817 ElecGSFTracklnPt =
log(theGsfEle.
gsfTrack()->pt())*M_LN10;
819 ElecGSFTrackEta = theGsfEle.
gsfTrack()->eta();
822 return MVAValue(TauEtaAtEcalEntrance,
824 TauLeadChargedPFCandEtaAtEcalEntrance,
825 TauLeadChargedPFCandPt,
829 TauSignalPFGammaCands,
830 TauLeadPFChargedHadrHoP,
831 TauLeadPFChargedHadrEoP,
844 TauSignalPFChargedCands,
863 Float_t TauEtaAtEcalEntrance = -99.;
864 float sumEtaTimesEnergy = 0.;
865 float sumEnergy = 0.;
866 const std::vector<reco::PFCandidatePtr>& signalPFCands = thePFTau.
signalPFCands();
867 for ( std::vector<reco::PFCandidatePtr>::const_iterator pfCandidate = signalPFCands.begin();
868 pfCandidate != signalPFCands.end(); ++pfCandidate ) {
869 sumEtaTimesEnergy += (*pfCandidate)->positionAtECALEntrance().eta()*(*pfCandidate)->energy();
870 sumEnergy += (*pfCandidate)->energy();
872 if ( sumEnergy > 0. ) {
873 TauEtaAtEcalEntrance = sumEtaTimesEnergy/sumEnergy;
876 float TauLeadChargedPFCandEtaAtEcalEntrance = -99.;
877 float TauLeadChargedPFCandPt = -99.;
878 for ( std::vector<reco::PFCandidatePtr>::const_iterator pfCandidate = signalPFCands.begin();
879 pfCandidate != signalPFCands.end(); ++pfCandidate ) {
881 if ( (*pfCandidate)->trackRef().isNonnull() ) track = (*pfCandidate)->trackRef().get();
882 else if ( (*pfCandidate)->muonRef().isNonnull() && (*pfCandidate)->muonRef()->innerTrack().isNonnull() ) track = (*pfCandidate)->muonRef()->innerTrack().get();
883 else if ( (*pfCandidate)->muonRef().isNonnull() && (*pfCandidate)->muonRef()->globalTrack().isNonnull() ) track = (*pfCandidate)->muonRef()->globalTrack().get();
884 else if ( (*pfCandidate)->muonRef().isNonnull() && (*pfCandidate)->muonRef()->outerTrack().isNonnull() ) track = (*pfCandidate)->muonRef()->outerTrack().get();
885 else if ( (*pfCandidate)->gsfTrackRef().isNonnull() ) track = (*pfCandidate)->gsfTrackRef().get();
887 if ( track->
pt() > TauLeadChargedPFCandPt ) {
888 TauLeadChargedPFCandEtaAtEcalEntrance = (*pfCandidate)->positionAtECALEntrance().
eta();
889 TauLeadChargedPFCandPt = track->
pt();
894 Float_t TauPt = thePFTau.
pt();
897 Float_t TauLeadPFChargedHadrHoP = 0.;
898 Float_t TauLeadPFChargedHadrEoP = 0.;
903 Float_t TauVisMass = thePFTau.
mass();
905 std::vector<Float_t> GammasdEta;
906 std::vector<Float_t> GammasdPhi;
907 std::vector<Float_t> GammasPt;
914 GammasdEta.push_back(gamma->eta() - thePFTau.
eta());
915 GammasdPhi.push_back(gamma->phi() - thePFTau.
phi());
917 GammasPt.push_back(gamma->pt());
919 Float_t TauKFNumHits = -99.;
923 Float_t TauGSFNumHits = -99.;
924 Float_t TauGSFChi2 = -99.;
925 Float_t TauGSFTrackResol = -99.;
926 Float_t TauGSFTracklnPt = -99.;
927 Float_t TauGSFTrackEta = -99.;
937 Float_t TauPhi = thePFTau.
phi();
938 float sumPhiTimesEnergy = 0.;
939 float sumEnergyPhi = 0.;
940 for ( std::vector<reco::PFCandidatePtr>::const_iterator pfCandidate = signalPFCands.begin();
941 pfCandidate != signalPFCands.end(); ++pfCandidate ) {
942 sumPhiTimesEnergy += (*pfCandidate)->positionAtECALEntrance().phi()*(*pfCandidate)->energy();
943 sumEnergyPhi += (*pfCandidate)->energy();
945 if ( sumEnergyPhi > 0. ) {
946 TauPhi = sumPhiTimesEnergy/sumEnergyPhi;
948 Float_t TaudCrackPhi =
dCrackPhi(TauPhi,TauEtaAtEcalEntrance) ;
949 Float_t TaudCrackEta =
dCrackEta(TauEtaAtEcalEntrance) ;
953 Float_t dummyElecEta = 9.9;
955 return MVAValue(TauEtaAtEcalEntrance,
957 TauLeadChargedPFCandEtaAtEcalEntrance,
958 TauLeadChargedPFCandPt,
962 TauSignalPFGammaCands,
963 TauLeadPFChargedHadrHoP,
964 TauLeadPFChargedHadrEoP,
977 TauSignalPFChargedCands,
1005 std::array<double,18> fill_cPhi() {
1007 std::array<double,18> cPhi;
1010 for (
unsigned iCrack = 1; iCrack <= 17; ++iCrack )
1011 cPhi[iCrack] = cPhi[0] - 2.*iCrack*pi/18;
1015 static const std::array<double,18> cPhi = fill_cPhi();
1030 double retVal = 99.;
1032 if ( eta >= -1.47464 && eta <= 1.47464 ) {
1035 if ( eta < 0. ) phi += delta_cPhi;
1038 if ( phi > pi ) phi -= 2.*
pi;
1039 if ( phi < -pi ) phi += 2.*
pi;
1041 if ( phi >= -pi && phi <= pi ) {
1044 if ( phi < cPhi[17] || phi >= cPhi[0] ) {
1045 if ( phi < 0. ) phi += 2.*
pi;
1046 retVal =
minimum(phi - cPhi[0], phi - cPhi[17] - 2.*pi);
1050 unsigned iCrack = 16;
1052 if ( phi < cPhi[iCrack] ) {
1053 retVal =
minimum(phi - cPhi[iCrack + 1], phi - cPhi[iCrack]);
1075 double cracks[5] = { 0., 4.44747e-01, 7.92824e-01, 1.14090e+00, 1.47464e+00 };
1077 double retVal = 99.;
1079 for (
int iCrack = 0; iCrack < 5 ; ++iCrack ) {
1080 double d =
minimum(eta - cracks[iCrack], eta + cracks[iCrack]);
const GBRForest * mva_woGwGSF_BL_
T getParameter(std::string const &) const
Float_t * Var_NoEleMatch_woGwoGSF_Endcap_
Float_t * Var_woGwGSF_Endcap_
Float_t * Var_NoEleMatch_wGwoGSF_Barrel_
bool isNonnull() const
Checks for non-null.
SuperClusterRef parentSuperCluster() const
const PFCandidatePtr & leadPFChargedHadrCand() const
virtual float pt() const
transverse momentum
pair< int, edm::FunctionWithDict > OK
const GBRForest * mva_woGwoGSF_BL_
Float_t * Var_wGwGSF_Barrel_
double minimum(double a, double b)
virtual float phi() const
momentum azimuthal angle
edm::FileInPath inputFileName_
const GBRForest * mva_wGwoGSF_EC_
std::string mvaName_woGwoGSF_BL_
math::XYZVectorF trackMomentumAtVtx() const
const std::vector< reco::PFCandidatePtr > & signalPFGammaCands() const
Gamma candidates in signal region.
const GBRForest * mva_NoEleMatch_woGwGSF_EC_
std::string mvaName_NoEleMatch_woGwoGSF_EC_
bool exists(std::string const ¶meterName) const
checks if a parameter exists
Float_t * Var_NoEleMatch_woGwoGSF_Barrel_
std::string mvaName_NoEleMatch_woGwGSF_BL_
const GBRForest * mva_NoEleMatch_wGwGSF_EC_
const std::vector< reco::PFCandidatePtr > & signalPFCands() const
PFCandidates in signal region.
std::string mvaName_woGwoGSF_EC_
std::string mvaName_NoEleMatch_woGwGSF_EC_
std::string mvaName_wGwoGSF_EC_
const GBRForest * mva_NoEleMatch_woGwoGSF_EC_
void beginEvent(const edm::Event &, const edm::EventSetup &)
double eta() const
pseudorapidity of momentum vector
const GBRForest * mva_woGwoGSF_EC_
const GBRForest * mva_NoEleMatch_wGwGSF_BL_
double dPhi(double phi1, double phi2)
const GBRForest * mva_NoEleMatch_woGwoGSF_BL_
virtual float eta() const
momentum pseudorapidity
std::string mvaName_wGwoGSF_BL_
math::XYZVectorF trackMomentumOut() const
Float_t * Var_wGwoGSF_Barrel_
double pt() const
track transverse momentum
std::string mvaName_woGwGSF_EC_
std::string mvaName_woGwGSF_BL_
const GBRForest * mva_woGwGSF_EC_
Abs< T >::type abs(const T &t)
std::string mvaName_wGwGSF_EC_
std::string mvaName_NoEleMatch_wGwoGSF_BL_
Float_t * Var_NoEleMatch_woGwGSF_Endcap_
Float_t * Var_woGwGSF_Barrel_
std::vector< TFile * > inputFilesToDelete_
Float_t * Var_wGwGSF_Endcap_
std::string mvaName_NoEleMatch_woGwoGSF_BL_
double dCrackEta(double eta)
bool isNonnull() const
Checks for non-null.
double deltaR(double eta1, double eta2, double phi1, double phi2)
const GBRForest * mva_wGwoGSF_BL_
std::string mvaName_wGwGSF_BL_
LocationCode location() const
Where was the file found?
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)
const GBRForest * mva_NoEleMatch_woGwGSF_BL_
const GBRForest * mva_NoEleMatch_wGwoGSF_BL_
std::string mvaName_NoEleMatch_wGwGSF_BL_
T const * product() const
Float_t * Var_NoEleMatch_woGwGSF_Barrel_
const GBRForest * mva_wGwGSF_BL_
Float_t * Var_NoEleMatch_wGwGSF_Endcap_
Float_t * Var_wGwoGSF_Endcap_
const GBRForest * mva_NoEleMatch_wGwoGSF_EC_
const GBRForest * mva_wGwGSF_EC_
double dCrackPhi(double phi, double eta)
std::string mvaName_NoEleMatch_wGwoGSF_EC_
Float_t * Var_woGwoGSF_Endcap_
virtual float mass() const
mass
Float_t * Var_woGwoGSF_Barrel_
std::string mvaName_NoEleMatch_wGwGSF_EC_
Float_t * Var_NoEleMatch_wGwGSF_Barrel_
volatile std::atomic< bool > shutdown_flag false
std::string fullPath() const
AntiElectronIDMVA5(const edm::ParameterSet &)
double GetClassifier(const float *vector) const
float electronPreIDOutput() const
Float_t * Var_NoEleMatch_wGwoGSF_Endcap_
const std::vector< reco::PFCandidatePtr > & signalPFChargedHadrCands() const
Charged hadrons in signal region.
virtual GsfTrackRef gsfTrack() const
reference to a GsfTrack