Definition at line 23 of file PFRecoTauDiscriminationAgainstElectronMVA2.cc.
PFRecoTauDiscriminationAgainstElectronMVA2::PFRecoTauDiscriminationAgainstElectronMVA2 | ( | const edm::ParameterSet & | iConfig | ) | [inline, explicit] |
Definition at line 26 of file PFRecoTauDiscriminationAgainstElectronMVA2.cc.
References edm::FileInPath::fullPath(), and edm::ParameterSet::getParameter().
: PFTauDiscriminationProducerBase(iConfig), moduleLabel_(iConfig.getParameter<std::string>("@module_label")), mva_(0), category_output_(0) { //std::cout << "<PFRecoTauDiscriminationAgainstElectronMVA2::PFRecoTauDiscriminationAgainstElectronMVA2>:" << std::endl; //std::cout << " moduleLabel = " << moduleLabel_ << std::endl; method_ = iConfig.getParameter<std::string>("method"); inputFileName1prongNoEleMatchBL_ = iConfig.getParameter<edm::FileInPath>("inputFileName1prongNoEleMatchBL"); inputFileName1prongBL_ = iConfig.getParameter<edm::FileInPath>("inputFileName1prongBL"); inputFileName1prongStripsWOgsfBL_ = iConfig.getParameter<edm::FileInPath>("inputFileName1prongStripsWOgsfBL"); inputFileName1prongStripsWgsfWOpfEleMvaBL_ = iConfig.getParameter<edm::FileInPath>("inputFileName1prongStripsWgsfWOpfEleMvaBL"); inputFileName1prongStripsWgsfWpfEleMvaBL_ = iConfig.getParameter<edm::FileInPath>("inputFileName1prongStripsWgsfWpfEleMvaBL"); inputFileName1prongNoEleMatchEC_ = iConfig.getParameter<edm::FileInPath>("inputFileName1prongNoEleMatchEC"); inputFileName1prongEC_ = iConfig.getParameter<edm::FileInPath>("inputFileName1prongEC"); inputFileName1prongStripsWOgsfEC_ = iConfig.getParameter<edm::FileInPath>("inputFileName1prongStripsWOgsfEC"); inputFileName1prongStripsWgsfWOpfEleMvaEC_ = iConfig.getParameter<edm::FileInPath>("inputFileName1prongStripsWgsfWOpfEleMvaEC"); inputFileName1prongStripsWgsfWpfEleMvaEC_ = iConfig.getParameter<edm::FileInPath>("inputFileName1prongStripsWgsfWpfEleMvaEC"); returnMVA_ = iConfig.getParameter<bool>("returnMVA"); minMVA1prongNoEleMatchBL_ = iConfig.getParameter<double>("minMVA1prongNoEleMatchBL"); minMVA1prongBL_ = iConfig.getParameter<double>("minMVA1prongBL"); minMVA1prongStripsWOgsfBL_ = iConfig.getParameter<double>("minMVA1prongStripsWOgsfBL"); minMVA1prongStripsWgsfWOpfEleMvaBL_ = iConfig.getParameter<double>("minMVA1prongStripsWgsfWOpfEleMvaBL"); minMVA1prongStripsWgsfWpfEleMvaBL_ = iConfig.getParameter<double>("minMVA1prongStripsWgsfWpfEleMvaBL"); minMVA1prongNoEleMatchEC_ = iConfig.getParameter<double>("minMVA1prongNoEleMatchEC"); minMVA1prongEC_ = iConfig.getParameter<double>("minMVA1prongEC"); minMVA1prongStripsWOgsfEC_ = iConfig.getParameter<double>("minMVA1prongStripsWOgsfEC"); minMVA1prongStripsWgsfWOpfEleMvaEC_ = iConfig.getParameter<double>("minMVA1prongStripsWgsfWOpfEleMvaEC"); minMVA1prongStripsWgsfWpfEleMvaEC_ = iConfig.getParameter<double>("minMVA1prongStripsWgsfWpfEleMvaEC"); srcGsfElectrons_ = iConfig.getParameter<edm::InputTag>("srcGsfElectrons"); mva_ = new AntiElectronIDMVA2(); // CV: working version of file compression not implemented yet //mva_->Initialize_from_string(method_, // readZippedFile(inputFileName1prongNoEleMatchBL_.fullPath()), // readZippedFile(inputFileName1prongBL_.fullPath()), // readZippedFile(inputFileName1prongStripsWOgsfBL_.fullPath()), // readZippedFile(inputFileName1prongStripsWgsfWOpfEleMvaBL_.fullPath()), // readZippedFile(inputFileName1prongStripsWgsfWpfEleMvaBL_.fullPath()), // readZippedFile(inputFileName1prongNoEleMatchEC_.fullPath()), // readZippedFile(inputFileName1prongEC_.fullPath()), // readZippedFile(inputFileName1prongStripsWOgsfEC_.fullPath()), // readZippedFile(inputFileName1prongStripsWgsfWOpfEleMvaEC_.fullPath()), // readZippedFile(inputFileName1prongStripsWgsfWpfEleMvaEC_.fullPath())); mva_->Initialize_from_file(method_, inputFileName1prongNoEleMatchBL_.fullPath(), inputFileName1prongBL_.fullPath(), inputFileName1prongStripsWOgsfBL_.fullPath(), inputFileName1prongStripsWgsfWOpfEleMvaBL_.fullPath(), inputFileName1prongStripsWgsfWpfEleMvaBL_.fullPath(), inputFileName1prongNoEleMatchEC_.fullPath(), inputFileName1prongEC_.fullPath(), inputFileName1prongStripsWOgsfEC_.fullPath(), inputFileName1prongStripsWgsfWOpfEleMvaEC_.fullPath(), inputFileName1prongStripsWgsfWpfEleMvaEC_.fullPath()); // add category index if ( returnMVA_ ) { produces<PFTauDiscriminator>("category"); } }
PFRecoTauDiscriminationAgainstElectronMVA2::~PFRecoTauDiscriminationAgainstElectronMVA2 | ( | ) | [inline] |
Definition at line 98 of file PFRecoTauDiscriminationAgainstElectronMVA2.cc.
{ delete mva_; }
void PFRecoTauDiscriminationAgainstElectronMVA2::beginEvent | ( | const edm::Event & | evt, |
const edm::EventSetup & | es | ||
) | [virtual] |
Reimplemented from TauDiscriminationProducerBase< TauType, TauDiscriminator >.
Definition at line 158 of file PFRecoTauDiscriminationAgainstElectronMVA2.cc.
References edm::Event::getByLabel().
{ if ( returnMVA_ ) { evt.getByLabel(TauProducer_, taus_); category_output_.reset(new PFTauDiscriminator(TauRefProd(taus_))); tauIndex_ = 0; } evt.getByLabel(srcGsfElectrons_, gsfElectrons_); }
double PFRecoTauDiscriminationAgainstElectronMVA2::discriminate | ( | const PFTauRef & | thePFTauRef | ) |
Definition at line 168 of file PFRecoTauDiscriminationAgainstElectronMVA2.cc.
References python::rootplot::argparse::category, reco::deltaR(), edm::Ref< C, T, F >::isNonnull(), and siStripFEDMonitor_P5_cff::Min.
{ double mva = 1.; double workingPoint = 1.; double category = -1.; bool isGsfElectronMatched = false; if( (*thePFTauRef).leadPFChargedHadrCand().isNonnull()) { for ( reco::GsfElectronCollection::const_iterator theGsfElectron = gsfElectrons_->begin(); theGsfElectron != gsfElectrons_->end(); ++theGsfElectron ) { if ( theGsfElectron->pt() > 10. ) { // CV: only take electrons above some minimal energy/Pt into account... double deltaREleTau = deltaR(theGsfElectron->p4(), thePFTauRef->p4()); if ( deltaREleTau < 0.3 ) { double mva_match = mva_->MVAValue(*thePFTauRef, *theGsfElectron); double workingPoint_match = 0.; size_t numSignalPFGammaCands = thePFTauRef->signalPFGammaCands().size(); bool hasGsfTrack = thePFTauRef->leadPFChargedHadrCand()->gsfTrackRef().isNonnull(); bool isPFElectron = (theGsfElectron->mvaOutput().mva > -0.1); if ( thePFTauRef->signalPFChargedHadrCands().size() == 1 ) { double mvaCut = 999.; if ( TMath::Abs(thePFTauRef->eta()) < 1.5 ) { // Barrel if ( numSignalPFGammaCands == 0 ) { category = 1.; mvaCut = minMVA1prongBL_; } else if ( numSignalPFGammaCands >= 1 && !hasGsfTrack ) { category = 2.; mvaCut = minMVA1prongStripsWOgsfBL_; } else if ( numSignalPFGammaCands >= 1 && hasGsfTrack && !isPFElectron ) { category = 3.; mvaCut = minMVA1prongStripsWgsfWOpfEleMvaBL_; } else if ( numSignalPFGammaCands >= 1 && hasGsfTrack && isPFElectron ) { category = 4.; mvaCut = minMVA1prongStripsWgsfWpfEleMvaBL_; } } else { // Endcap if ( numSignalPFGammaCands == 0 ) { category = 6.; mvaCut = minMVA1prongEC_; } else if ( numSignalPFGammaCands >= 1 && !hasGsfTrack ) { category = 7.; mvaCut = minMVA1prongStripsWOgsfEC_; } else if ( numSignalPFGammaCands >= 1 && hasGsfTrack && !isPFElectron ) { category = 8.; mvaCut = minMVA1prongStripsWgsfWOpfEleMvaEC_; } else if ( numSignalPFGammaCands >= 1 && hasGsfTrack && isPFElectron ) { category = 9.; mvaCut = minMVA1prongStripsWgsfWpfEleMvaEC_; } } workingPoint_match = (mva_match > mvaCut); } else { workingPoint_match = 1.; } mva = TMath::Min(mva, mva_match); workingPoint = TMath::Min(workingPoint, workingPoint_match); isGsfElectronMatched = true; } } } } if ( !isGsfElectronMatched ) { mva = mva_->MVAValue(*thePFTauRef); double mvaCut = 999.; if ( TMath::Abs(thePFTauRef->eta()) < 1.5 ) { // Barrel category = 0.; mvaCut = minMVA1prongNoEleMatchBL_; } else { // Endcap category = 5.; mvaCut = minMVA1prongNoEleMatchEC_; } workingPoint = (mva > mvaCut); } //std::cout << "<PFRecoTauDiscriminationAgainstElectronMVA2::discriminate>:" << std::endl; //std::cout << " tau: Pt = " << thePFTauRef->pt() << ", eta = " << thePFTauRef->eta() << ", phi = " << thePFTauRef->phi() << std::endl; //std::cout << " mva = " << mva << ": workingPoint = " << workingPoint << std::endl; if ( returnMVA_ ) { // add category index category_output_->setValue(tauIndex_, category); ++tauIndex_; // return MVA output value return mva; } else { return workingPoint; } }
void PFRecoTauDiscriminationAgainstElectronMVA2::endEvent | ( | edm::Event & | evt | ) | [virtual] |
Reimplemented from TauDiscriminationProducerBase< TauType, TauDiscriminator >.
Definition at line 259 of file PFRecoTauDiscriminationAgainstElectronMVA2.cc.
References edm::Event::put().
{ // add all category indices to event if ( returnMVA_ ) { evt.put(category_output_, "category"); } }
std::string PFRecoTauDiscriminationAgainstElectronMVA2::readZippedFile | ( | const std::string & | fileName | ) | [inline, private] |
Definition at line 105 of file PFRecoTauDiscriminationAgainstElectronMVA2.cc.
References mergeVDriftHistosByStation::file, and ext::basic_izstreambase< Item_t, Traits_t, Allocator_t >::rdbuf().
{ //std::cout << "<PFRecoTauDiscriminationAgainstElectronMVA2::readZippedFile>:" << std::endl; //std::cout << " fileName = " << fileName << std::endl; // CV: code adapted from PhysicsTools/MVAComputer/src/MVAComputer.cc std::ifstream file; file.open(fileName.c_str()); if ( !file.good() ) throw cms::Exception("InvalidFileState") << "Failed to open MVA file = " << fileName << " !!\n"; std::ostringstream buffer_zipped; while ( file.good() ) { buffer_zipped << (char)file.get(); } file.close(); //std::cout << " buffer (zipped) = " << buffer_zipped.str() << std::endl; ext::izstream gunzip(&file); std::ostringstream buffer_unzipped; buffer_unzipped << gunzip.rdbuf(); //std::cout << " buffer (unzipped) = " << buffer_unzipped.str() << std::endl; return buffer_unzipped.str(); }
std::auto_ptr<PFTauDiscriminator> PFRecoTauDiscriminationAgainstElectronMVA2::category_output_ [private] |
Definition at line 154 of file PFRecoTauDiscriminationAgainstElectronMVA2.cc.
edm::Handle<reco::GsfElectronCollection> PFRecoTauDiscriminationAgainstElectronMVA2::gsfElectrons_ [private] |
Definition at line 152 of file PFRecoTauDiscriminationAgainstElectronMVA2.cc.
Definition at line 130 of file PFRecoTauDiscriminationAgainstElectronMVA2.cc.
Definition at line 135 of file PFRecoTauDiscriminationAgainstElectronMVA2.cc.
edm::FileInPath PFRecoTauDiscriminationAgainstElectronMVA2::inputFileName1prongNoEleMatchBL_ [private] |
Definition at line 129 of file PFRecoTauDiscriminationAgainstElectronMVA2.cc.
edm::FileInPath PFRecoTauDiscriminationAgainstElectronMVA2::inputFileName1prongNoEleMatchEC_ [private] |
Definition at line 134 of file PFRecoTauDiscriminationAgainstElectronMVA2.cc.
edm::FileInPath PFRecoTauDiscriminationAgainstElectronMVA2::inputFileName1prongStripsWgsfWOpfEleMvaBL_ [private] |
Definition at line 132 of file PFRecoTauDiscriminationAgainstElectronMVA2.cc.
edm::FileInPath PFRecoTauDiscriminationAgainstElectronMVA2::inputFileName1prongStripsWgsfWOpfEleMvaEC_ [private] |
Definition at line 137 of file PFRecoTauDiscriminationAgainstElectronMVA2.cc.
edm::FileInPath PFRecoTauDiscriminationAgainstElectronMVA2::inputFileName1prongStripsWgsfWpfEleMvaBL_ [private] |
Definition at line 133 of file PFRecoTauDiscriminationAgainstElectronMVA2.cc.
edm::FileInPath PFRecoTauDiscriminationAgainstElectronMVA2::inputFileName1prongStripsWgsfWpfEleMvaEC_ [private] |
Definition at line 138 of file PFRecoTauDiscriminationAgainstElectronMVA2.cc.
edm::FileInPath PFRecoTauDiscriminationAgainstElectronMVA2::inputFileName1prongStripsWOgsfBL_ [private] |
Definition at line 131 of file PFRecoTauDiscriminationAgainstElectronMVA2.cc.
edm::FileInPath PFRecoTauDiscriminationAgainstElectronMVA2::inputFileName1prongStripsWOgsfEC_ [private] |
Definition at line 136 of file PFRecoTauDiscriminationAgainstElectronMVA2.cc.
std::string PFRecoTauDiscriminationAgainstElectronMVA2::method_ [private] |
Definition at line 128 of file PFRecoTauDiscriminationAgainstElectronMVA2.cc.
double PFRecoTauDiscriminationAgainstElectronMVA2::minMVA1prongBL_ [private] |
Definition at line 142 of file PFRecoTauDiscriminationAgainstElectronMVA2.cc.
double PFRecoTauDiscriminationAgainstElectronMVA2::minMVA1prongEC_ [private] |
Definition at line 147 of file PFRecoTauDiscriminationAgainstElectronMVA2.cc.
Definition at line 141 of file PFRecoTauDiscriminationAgainstElectronMVA2.cc.
Definition at line 146 of file PFRecoTauDiscriminationAgainstElectronMVA2.cc.
Definition at line 144 of file PFRecoTauDiscriminationAgainstElectronMVA2.cc.
Definition at line 149 of file PFRecoTauDiscriminationAgainstElectronMVA2.cc.
Definition at line 145 of file PFRecoTauDiscriminationAgainstElectronMVA2.cc.
Definition at line 150 of file PFRecoTauDiscriminationAgainstElectronMVA2.cc.
Definition at line 143 of file PFRecoTauDiscriminationAgainstElectronMVA2.cc.
Definition at line 148 of file PFRecoTauDiscriminationAgainstElectronMVA2.cc.
std::string PFRecoTauDiscriminationAgainstElectronMVA2::moduleLabel_ [private] |
Definition at line 127 of file PFRecoTauDiscriminationAgainstElectronMVA2.cc.
Definition at line 139 of file PFRecoTauDiscriminationAgainstElectronMVA2.cc.
bool PFRecoTauDiscriminationAgainstElectronMVA2::returnMVA_ [private] |
Definition at line 140 of file PFRecoTauDiscriminationAgainstElectronMVA2.cc.
Definition at line 151 of file PFRecoTauDiscriminationAgainstElectronMVA2.cc.
size_t PFRecoTauDiscriminationAgainstElectronMVA2::tauIndex_ [private] |
Definition at line 155 of file PFRecoTauDiscriminationAgainstElectronMVA2.cc.
Definition at line 153 of file PFRecoTauDiscriminationAgainstElectronMVA2.cc.