00001 /* class PFRecoTauDiscriminationAgainstElectronMVA 00002 * created : Nov 23 2011, 00003 * revised : , 00004 * Authorss : Lorenzo Bianchini (LLR Ecole-Polytechnique) 00005 */ 00006 00007 #include "RecoTauTag/RecoTau/interface/TauDiscriminationProducerBase.h" 00008 #include "FWCore/ParameterSet/interface/FileInPath.h" 00009 #include "RecoTauTag/RecoTau/interface/AntiElectronIDMVA.h" 00010 00011 using namespace reco; 00012 00013 class PFRecoTauDiscriminationAgainstElectronMVA : public PFTauDiscriminationProducerBase { 00014 public: 00015 explicit PFRecoTauDiscriminationAgainstElectronMVA(const edm::ParameterSet& iConfig):PFTauDiscriminationProducerBase(iConfig) { 00016 00017 method_ = iConfig.getParameter<std::string>("method"); 00018 inputFileName1prongBL_ = iConfig.getParameter<edm::FileInPath>("inputFileName1prongBL"); 00019 inputFileName1prongStripsWgsfBL_ = iConfig.getParameter<edm::FileInPath>("inputFileName1prongStripsWgsfBL"); 00020 inputFileName1prongStripsWOgsfBL_ = iConfig.getParameter<edm::FileInPath>("inputFileName1prongStripsWOgsfBL"); 00021 inputFileName1prongEC_ = iConfig.getParameter<edm::FileInPath>("inputFileName1prongEC"); 00022 inputFileName1prongStripsWgsfEC_ = iConfig.getParameter<edm::FileInPath>("inputFileName1prongStripsWgsfEC"); 00023 inputFileName1prongStripsWOgsfEC_ = iConfig.getParameter<edm::FileInPath>("inputFileName1prongStripsWOgsfEC"); 00024 00025 returnMVA_ = iConfig.getParameter<bool>("returnMVA"); 00026 minMVA1prongBL_ = iConfig.getParameter<double>("minMVA1prongBL"); 00027 minMVA1prongStripsWgsfBL_ = iConfig.getParameter<double>("minMVA1prongStripsWgsfBL"); 00028 minMVA1prongStripsWOgsfBL_ = iConfig.getParameter<double>("minMVA1prongStripsWOgsfBL"); 00029 minMVA1prongEC_ = iConfig.getParameter<double>("minMVA1prongEC"); 00030 minMVA1prongStripsWgsfEC_ = iConfig.getParameter<double>("minMVA1prongStripsWgsfEC"); 00031 minMVA1prongStripsWOgsfEC_ = iConfig.getParameter<double>("minMVA1prongStripsWOgsfEC"); 00032 00033 mva_ = new AntiElectronIDMVA(); 00034 mva_->Initialize(method_, 00035 inputFileName1prongBL_.fullPath().data(), 00036 inputFileName1prongStripsWgsfBL_.fullPath().data(), 00037 inputFileName1prongStripsWOgsfBL_.fullPath().data(), 00038 inputFileName1prongEC_.fullPath().data(), 00039 inputFileName1prongStripsWgsfEC_.fullPath().data(), 00040 inputFileName1prongStripsWOgsfEC_.fullPath().data() 00041 ); 00042 00043 00044 } 00045 00046 double discriminate(const PFTauRef& thePFTauRef); 00047 00048 ~PFRecoTauDiscriminationAgainstElectronMVA(){ delete mva_;} 00049 00050 private: 00051 00052 std::string method_ ; 00053 edm::FileInPath inputFileName1prongBL_; 00054 edm::FileInPath inputFileName1prongStripsWgsfBL_; 00055 edm::FileInPath inputFileName1prongStripsWOgsfBL_; 00056 edm::FileInPath inputFileName1prongEC_; 00057 edm::FileInPath inputFileName1prongStripsWgsfEC_; 00058 edm::FileInPath inputFileName1prongStripsWOgsfEC_; 00059 AntiElectronIDMVA* mva_; 00060 bool returnMVA_ ; 00061 double minMVA1prongBL_ ; 00062 double minMVA1prongStripsWgsfBL_ ; 00063 double minMVA1prongStripsWOgsfBL_ ; 00064 double minMVA1prongEC_ ; 00065 double minMVA1prongStripsWgsfEC_ ; 00066 double minMVA1prongStripsWOgsfEC_; 00067 00068 00069 }; 00070 00071 double PFRecoTauDiscriminationAgainstElectronMVA::discriminate(const PFTauRef& thePFTauRef) 00072 { 00073 00074 double mva = -1.0; 00075 double workingPoint = 0.0; 00076 00077 if( (*thePFTauRef).leadPFChargedHadrCand().isNonnull() ) { 00078 00079 mva = mva_->MVAValue( thePFTauRef ); 00080 00081 workingPoint = 00082 ((*thePFTauRef).signalPFChargedHadrCands().size()==3 || 00083 (fabs((*thePFTauRef).eta())<1.5 && ((*thePFTauRef).signalPFGammaCands().size())<=0 && mva > minMVA1prongBL_) || 00084 (fabs((*thePFTauRef).eta())<1.5 && ((*thePFTauRef).signalPFGammaCands().size())>0 && (((*thePFTauRef).leadPFChargedHadrCand())->gsfTrackRef()).isNonnull()>0.5 && mva > minMVA1prongStripsWgsfBL_) || 00085 (fabs((*thePFTauRef).eta())<1.5 && ((*thePFTauRef).signalPFGammaCands().size())>0 && (((*thePFTauRef).leadPFChargedHadrCand())->gsfTrackRef()).isNonnull()<0.5 && mva > minMVA1prongStripsWOgsfBL_) || 00086 (fabs((*thePFTauRef).eta())>1.5 && ((*thePFTauRef).signalPFGammaCands().size())<=0 && mva > minMVA1prongEC_) || 00087 (fabs((*thePFTauRef).eta())>1.5 && ((*thePFTauRef).signalPFGammaCands().size())>0 && (((*thePFTauRef).leadPFChargedHadrCand())->gsfTrackRef()).isNonnull()>0.5 && mva > minMVA1prongStripsWgsfEC_) || 00088 (fabs((*thePFTauRef).eta())>1.5 && ((*thePFTauRef).signalPFGammaCands().size())>0 && (((*thePFTauRef).leadPFChargedHadrCand())->gsfTrackRef()).isNonnull()<0.5 && mva > minMVA1prongStripsWOgsfEC_)) ? 1.0 : 0.0; 00089 00090 } 00091 00092 return ( returnMVA_ ? mva : workingPoint); 00093 00094 } 00095 00096 00097 DEFINE_FWK_MODULE(PFRecoTauDiscriminationAgainstElectronMVA);