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),
37 if(cfg.
exists(
"inputFileName")){
39 }
else throw cms::Exception(
"MVA input not defined") <<
"Requested to load tau MVA input from ROOT file but no file provided in cfg file";
129 throw cms::Exception(
"PFRecoTauDiscriminationAgainstMuonMVA::loadMVA")
130 <<
" Failed to load MVA = " << mvaName.data() <<
" from file " <<
" !!\n";
192 Float_t TauLeadChargedPFCandEtaAtEcalEntrance,
193 Float_t TauLeadChargedPFCandPt,
194 Float_t TaudCrackEta,
195 Float_t TaudCrackPhi,
196 Float_t TauEmFraction,
197 Float_t TauSignalPFGammaCands,
198 Float_t TauLeadPFChargedHadrHoP,
199 Float_t TauLeadPFChargedHadrEoP,
202 const std::vector<Float_t>& GammasdEta,
203 const std::vector<Float_t>& GammasdPhi,
204 const std::vector<Float_t>& GammasPt,
205 Float_t TauKFNumHits,
206 Float_t TauGSFNumHits,
208 Float_t TauGSFTrackResol,
209 Float_t TauGSFTracklnPt,
210 Float_t TauGSFTrackEta,
212 Float_t TauSignalPFChargedCands,
223 Float_t ElecGSFNumHits,
224 Float_t ElecGSFTrackResol,
225 Float_t ElecGSFTracklnPt,
226 Float_t ElecGSFTrackEta)
234 for (
unsigned int i = 0 ;
i < GammasPt.size() ; ++
i ) {
235 double pt_i = GammasPt[
i];
236 double phi_i = GammasdPhi[
i];
237 if ( GammasdPhi[
i] >
M_PI ) phi_i = GammasdPhi[
i] - 2*
M_PI;
238 else if ( GammasdPhi[
i] < -M_PI ) phi_i = GammasdPhi[
i] + 2*
M_PI;
239 double eta_i = GammasdEta[
i];
241 sumPt2 += (pt_i*pt_i);
242 dEta += (pt_i*eta_i);
243 dEta2 += (pt_i*eta_i*eta_i);
244 dPhi += (pt_i*phi_i);
245 dPhi2 += (pt_i*phi_i*phi_i);
248 Float_t TauGammaEnFrac = sumPt/TauPt;
260 return MVAValue(TauEtaAtEcalEntrance,
262 TauLeadChargedPFCandEtaAtEcalEntrance,
263 TauLeadChargedPFCandPt,
267 TauSignalPFGammaCands,
268 TauLeadPFChargedHadrHoP,
269 TauLeadPFChargedHadrEoP,
282 TauSignalPFChargedCands,
301 Float_t TauLeadChargedPFCandEtaAtEcalEntrance,
302 Float_t TauLeadChargedPFCandPt,
303 Float_t TaudCrackEta,
304 Float_t TaudCrackPhi,
306 Float_t TauSignalPFGammaCands,
307 Float_t TauLeadPFChargedHadrHoP,
308 Float_t TauLeadPFChargedHadrEoP,
311 Float_t TauGammaEtaMom,
312 Float_t TauGammaPhiMom,
313 Float_t TauGammaEnFrac,
314 Float_t TauKFNumHits,
315 Float_t TauGSFNumHits,
317 Float_t TauGSFTrackResol,
318 Float_t TauGSFTracklnPt,
319 Float_t TauGSFTrackEta,
321 Float_t TauSignalPFChargedCands,
332 Float_t ElecGSFNumHits,
333 Float_t ElecGSFTrackResol,
334 Float_t ElecGSFTracklnPt,
335 Float_t ElecGSFTrackEta)
339 <<
" AntiElectronMVA not properly initialized !!\n";
342 Float_t TauEmFraction =
std::max(TauEmFract,
float(0.));
343 Float_t TauNumHitsVariable = (TauGSFNumHits - TauKFNumHits)/(TauGSFNumHits + TauKFNumHits);
344 Float_t ElecEtotOverPin = (ElecEe + ElecEgamma)/ElecPin;
345 Float_t ElecEgammaOverPdif = ElecEgamma/(ElecPin - ElecPout);
347 double mvaValue = -99.;
348 if (
deltaR(TauEtaAtEcalEntrance, TauPhi, ElecEta, ElecPhi) > 0.3 && TauSignalPFGammaCands == 0 && TauHasGsf < 0.5) {
349 if (
std::abs(TauEtaAtEcalEntrance) < 1.479 ){
373 }
else if (
deltaR(TauEtaAtEcalEntrance, TauPhi, ElecEta, ElecPhi) > 0.3 && TauSignalPFGammaCands == 0 && TauHasGsf > 0.5) {
374 if (
std::abs(TauEtaAtEcalEntrance) < 1.479 ){
410 }
else if (
deltaR(TauEtaAtEcalEntrance, TauPhi, ElecEta, ElecPhi) > 0.3 && TauSignalPFGammaCands > 0 && TauHasGsf < 0.5 ) {
411 if (
std::abs(TauEtaAtEcalEntrance) < 1.479 ){
444 else if (
deltaR(TauEtaAtEcalEntrance, TauPhi, ElecEta, ElecPhi) > 0.3 && TauSignalPFGammaCands > 0 && TauHasGsf > 0.5 ) {
445 if (
std::abs(TauEtaAtEcalEntrance) < 1.479 ) {
489 }
else if ( TauSignalPFGammaCands == 0 && TauHasGsf < 0.5 ) {
490 if (
std::abs(TauEtaAtEcalEntrance) < 1.479 ) {
530 }
else if ( TauSignalPFGammaCands == 0 && TauHasGsf > 0.5 ) {
531 if (
std::abs(TauEtaAtEcalEntrance) < 1.479 ) {
583 }
else if ( TauSignalPFGammaCands > 0 && TauHasGsf < 0.5 ) {
584 if (
std::abs(TauEtaAtEcalEntrance) < 1.479 ) {
632 }
else if ( TauSignalPFGammaCands > 0 && TauHasGsf > 0.5 ) {
633 if (
std::abs(TauEtaAtEcalEntrance) < 1.479 ) {
701 Float_t TauEtaAtEcalEntrance = -99.;
702 float sumEtaTimesEnergy = 0.;
703 float sumEnergy = 0.;
704 const std::vector<reco::PFCandidatePtr>& signalPFCands = thePFTau.
signalPFCands();
705 for ( std::vector<reco::PFCandidatePtr>::const_iterator pfCandidate = signalPFCands.begin();
706 pfCandidate != signalPFCands.end(); ++pfCandidate ) {
707 sumEtaTimesEnergy += (*pfCandidate)->positionAtECALEntrance().eta()*(*pfCandidate)->energy();
708 sumEnergy += (*pfCandidate)->energy();
710 if ( sumEnergy > 0. ) {
711 TauEtaAtEcalEntrance = sumEtaTimesEnergy/sumEnergy;
714 float TauLeadChargedPFCandEtaAtEcalEntrance = -99.;
715 float TauLeadChargedPFCandPt = -99.;
716 for ( std::vector<reco::PFCandidatePtr>::const_iterator pfCandidate = signalPFCands.begin();
717 pfCandidate != signalPFCands.end(); ++pfCandidate ) {
719 if ( (*pfCandidate)->trackRef().isNonnull() ) track = (*pfCandidate)->trackRef().get();
720 else if ( (*pfCandidate)->muonRef().isNonnull() && (*pfCandidate)->muonRef()->innerTrack().isNonnull() ) track = (*pfCandidate)->muonRef()->innerTrack().get();
721 else if ( (*pfCandidate)->muonRef().isNonnull() && (*pfCandidate)->muonRef()->globalTrack().isNonnull() ) track = (*pfCandidate)->muonRef()->globalTrack().get();
722 else if ( (*pfCandidate)->muonRef().isNonnull() && (*pfCandidate)->muonRef()->outerTrack().isNonnull() ) track = (*pfCandidate)->muonRef()->outerTrack().get();
723 else if ( (*pfCandidate)->gsfTrackRef().isNonnull() ) track = (*pfCandidate)->gsfTrackRef().get();
725 if ( track->
pt() > TauLeadChargedPFCandPt ) {
726 TauLeadChargedPFCandEtaAtEcalEntrance = (*pfCandidate)->positionAtECALEntrance().
eta();
727 TauLeadChargedPFCandPt = track->
pt();
732 Float_t TauPt = thePFTau.
pt();
735 Float_t TauLeadPFChargedHadrHoP = 0.;
736 Float_t TauLeadPFChargedHadrEoP = 0.;
741 Float_t TauVisMass = thePFTau.
mass();
743 std::vector<Float_t> GammasdEta;
744 std::vector<Float_t> GammasdPhi;
745 std::vector<Float_t> GammasPt;
752 GammasdEta.push_back(gamma->eta() - thePFTau.
eta());
753 GammasdPhi.push_back(gamma->phi() - thePFTau.
phi());
755 GammasPt.push_back(gamma->pt());
757 Float_t TauKFNumHits = -99.;
761 Float_t TauGSFNumHits = -99.;
762 Float_t TauGSFChi2 = -99.;
763 Float_t TauGSFTrackResol = -99.;
764 Float_t TauGSFTracklnPt = -99.;
765 Float_t TauGSFTrackEta = -99.;
775 Float_t TauPhi = thePFTau.
phi();
776 float sumPhiTimesEnergy = 0.;
777 float sumEnergyPhi = 0.;
778 for ( std::vector<reco::PFCandidatePtr>::const_iterator pfCandidate = signalPFCands.begin();
779 pfCandidate != signalPFCands.end(); ++pfCandidate ) {
780 sumPhiTimesEnergy += (*pfCandidate)->positionAtECALEntrance().phi()*(*pfCandidate)->energy();
781 sumEnergyPhi += (*pfCandidate)->energy();
783 if ( sumEnergyPhi > 0. ) {
784 TauPhi = sumPhiTimesEnergy/sumEnergyPhi;
786 Float_t TaudCrackPhi =
dCrackPhi(TauPhi, TauEtaAtEcalEntrance);
787 Float_t TaudCrackEta =
dCrackEta(TauEtaAtEcalEntrance);
791 Float_t ElecEta = theGsfEle.
eta();
792 Float_t ElecPhi = theGsfEle.
phi();
793 Float_t ElecPt = theGsfEle.
pt();
796 Float_t ElecEgamma = 0.;
800 pfCluster != pfSuperCluster->clustersEnd(); ++pfCluster ) {
801 double pfClusterEn = (*pfCluster)->energy();
802 if ( pfCluster == pfSuperCluster->clustersBegin() ) ElecEe += pfClusterEn;
803 else ElecEgamma += pfClusterEn;
808 Float_t ElecFbrem = theGsfEle.
fbrem();
810 Float_t ElecChi2GSF = -99.;
811 Float_t ElecGSFNumHits = -99.;
812 Float_t ElecGSFTrackResol = -99.;
813 Float_t ElecGSFTracklnPt = -99.;
814 Float_t ElecGSFTrackEta = -99.;
816 ElecChi2GSF = (theGsfEle).gsfTrack()->normalizedChi2();
817 ElecGSFNumHits = (theGsfEle).gsfTrack()->numberOfValidHits();
818 if ( theGsfEle.
gsfTrack()->pt() > 0. ) {
819 ElecGSFTrackResol = theGsfEle.
gsfTrack()->ptError()/theGsfEle.
gsfTrack()->pt();
820 ElecGSFTracklnPt =
log(theGsfEle.
gsfTrack()->pt())*M_LN10;
822 ElecGSFTrackEta = theGsfEle.
gsfTrack()->eta();
825 return MVAValue(TauEtaAtEcalEntrance,
827 TauLeadChargedPFCandEtaAtEcalEntrance,
828 TauLeadChargedPFCandPt,
832 TauSignalPFGammaCands,
833 TauLeadPFChargedHadrHoP,
834 TauLeadPFChargedHadrEoP,
847 TauSignalPFChargedCands,
866 Float_t TauEtaAtEcalEntrance = -99.;
867 float sumEtaTimesEnergy = 0.;
868 float sumEnergy = 0.;
869 const std::vector<reco::PFCandidatePtr>& signalPFCands = thePFTau.
signalPFCands();
870 for ( std::vector<reco::PFCandidatePtr>::const_iterator pfCandidate = signalPFCands.begin();
871 pfCandidate != signalPFCands.end(); ++pfCandidate ) {
872 sumEtaTimesEnergy += (*pfCandidate)->positionAtECALEntrance().eta()*(*pfCandidate)->energy();
873 sumEnergy += (*pfCandidate)->energy();
875 if ( sumEnergy > 0. ) {
876 TauEtaAtEcalEntrance = sumEtaTimesEnergy/sumEnergy;
879 float TauLeadChargedPFCandEtaAtEcalEntrance = -99.;
880 float TauLeadChargedPFCandPt = -99.;
881 for ( std::vector<reco::PFCandidatePtr>::const_iterator pfCandidate = signalPFCands.begin();
882 pfCandidate != signalPFCands.end(); ++pfCandidate ) {
884 if ( (*pfCandidate)->trackRef().isNonnull() ) track = (*pfCandidate)->trackRef().get();
885 else if ( (*pfCandidate)->muonRef().isNonnull() && (*pfCandidate)->muonRef()->innerTrack().isNonnull() ) track = (*pfCandidate)->muonRef()->innerTrack().get();
886 else if ( (*pfCandidate)->muonRef().isNonnull() && (*pfCandidate)->muonRef()->globalTrack().isNonnull() ) track = (*pfCandidate)->muonRef()->globalTrack().get();
887 else if ( (*pfCandidate)->muonRef().isNonnull() && (*pfCandidate)->muonRef()->outerTrack().isNonnull() ) track = (*pfCandidate)->muonRef()->outerTrack().get();
888 else if ( (*pfCandidate)->gsfTrackRef().isNonnull() ) track = (*pfCandidate)->gsfTrackRef().get();
890 if ( track->
pt() > TauLeadChargedPFCandPt ) {
891 TauLeadChargedPFCandEtaAtEcalEntrance = (*pfCandidate)->positionAtECALEntrance().
eta();
892 TauLeadChargedPFCandPt = track->
pt();
897 Float_t TauPt = thePFTau.
pt();
900 Float_t TauLeadPFChargedHadrHoP = 0.;
901 Float_t TauLeadPFChargedHadrEoP = 0.;
906 Float_t TauVisMass = thePFTau.
mass();
908 std::vector<Float_t> GammasdEta;
909 std::vector<Float_t> GammasdPhi;
910 std::vector<Float_t> GammasPt;
917 GammasdEta.push_back(gamma->eta() - thePFTau.
eta());
918 GammasdPhi.push_back(gamma->phi() - thePFTau.
phi());
920 GammasPt.push_back(gamma->pt());
922 Float_t TauKFNumHits = -99.;
926 Float_t TauGSFNumHits = -99.;
927 Float_t TauGSFChi2 = -99.;
928 Float_t TauGSFTrackResol = -99.;
929 Float_t TauGSFTracklnPt = -99.;
930 Float_t TauGSFTrackEta = -99.;
940 Float_t TauPhi = thePFTau.
phi();
941 float sumPhiTimesEnergy = 0.;
942 float sumEnergyPhi = 0.;
943 for ( std::vector<reco::PFCandidatePtr>::const_iterator pfCandidate = signalPFCands.begin();
944 pfCandidate != signalPFCands.end(); ++pfCandidate ) {
945 sumPhiTimesEnergy += (*pfCandidate)->positionAtECALEntrance().phi()*(*pfCandidate)->energy();
946 sumEnergyPhi += (*pfCandidate)->energy();
948 if ( sumEnergyPhi > 0. ) {
949 TauPhi = sumPhiTimesEnergy/sumEnergyPhi;
951 Float_t TaudCrackPhi =
dCrackPhi(TauPhi,TauEtaAtEcalEntrance) ;
952 Float_t TaudCrackEta =
dCrackEta(TauEtaAtEcalEntrance) ;
956 Float_t dummyElecEta = 9.9;
958 return MVAValue(TauEtaAtEcalEntrance,
960 TauLeadChargedPFCandEtaAtEcalEntrance,
961 TauLeadChargedPFCandPt,
965 TauSignalPFGammaCands,
966 TauLeadPFChargedHadrHoP,
967 TauLeadPFChargedHadrEoP,
980 TauSignalPFChargedCands,
1008 std::array<double,18> fill_cPhi() {
1010 std::array<double,18> cPhi;
1013 for (
unsigned iCrack = 1; iCrack <= 17; ++iCrack )
1014 cPhi[iCrack] = cPhi[0] - 2.*iCrack*pi/18;
1018 static const std::array<double,18> cPhi = fill_cPhi();
1033 double retVal = 99.;
1035 if ( eta >= -1.47464 && eta <= 1.47464 ) {
1038 if ( eta < 0. ) phi += delta_cPhi;
1041 if ( phi > pi ) phi -= 2.*
pi;
1042 if ( phi < -pi ) phi += 2.*
pi;
1044 if ( phi >= -pi && phi <= pi ) {
1047 if ( phi < cPhi[17] || phi >= cPhi[0] ) {
1048 if ( phi < 0. ) phi += 2.*
pi;
1049 retVal =
minimum(phi - cPhi[0], phi - cPhi[17] - 2.*pi);
1053 unsigned iCrack = 16;
1055 if ( phi < cPhi[iCrack] ) {
1056 retVal =
minimum(phi - cPhi[iCrack + 1], phi - cPhi[iCrack]);
1078 double cracks[5] = { 0., 4.44747e-01, 7.92824e-01, 1.14090e+00, 1.47464e+00 };
1080 double retVal = 99.;
1082 for (
int iCrack = 0; iCrack < 5 ; ++iCrack ) {
1083 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
const GBRForest * mva_woGwoGSF_BL_
Float_t * Var_wGwGSF_Barrel_
double minimum(double a, double b)
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
virtual double phi() const final
momentum azimuthal angle
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_
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_
virtual double mass() const final
mass
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_
std::pair< int, edm::FunctionWithDict > OK
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_
Geom::Phi< T > phi() const
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_
Float_t * Var_woGwoGSF_Barrel_
std::string mvaName_NoEleMatch_wGwGSF_EC_
Float_t * Var_NoEleMatch_wGwGSF_Barrel_
virtual double eta() const final
momentum pseudorapidity
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
virtual double pt() const final
transverse momentum