#include <TtSemiLepJetCombMVAComputer.h>
Public Member Functions | |
TtSemiLepJetCombMVAComputer (const edm::ParameterSet &) | |
~TtSemiLepJetCombMVAComputer () | |
Private Member Functions | |
virtual void | beginJob () |
virtual void | endJob () |
virtual void | produce (edm::Event &evt, const edm::EventSetup &setup) |
Private Attributes | |
edm::InputTag | jets_ |
edm::InputTag | leps_ |
int | maxNComb_ |
int | maxNJets_ |
edm::InputTag | mets_ |
PhysicsTools::MVAComputerCache | mvaComputer |
Definition at line 15 of file TtSemiLepJetCombMVAComputer.h.
TtSemiLepJetCombMVAComputer::TtSemiLepJetCombMVAComputer | ( | const edm::ParameterSet & | cfg | ) | [explicit] |
Definition at line 9 of file TtSemiLepJetCombMVAComputer.cc.
: leps_ (cfg.getParameter<edm::InputTag>("leps")), jets_ (cfg.getParameter<edm::InputTag>("jets")), mets_ (cfg.getParameter<edm::InputTag>("mets")), maxNJets_(cfg.getParameter<int>("maxNJets")), maxNComb_(cfg.getParameter<int>("maxNComb")) { produces<std::vector<std::vector<int> > >(); produces<std::vector<double> >("Discriminators"); produces<std::string >("Method"); produces<int >("NumberOfConsideredJets"); }
TtSemiLepJetCombMVAComputer::~TtSemiLepJetCombMVAComputer | ( | ) |
Definition at line 22 of file TtSemiLepJetCombMVAComputer.cc.
{ }
void TtSemiLepJetCombMVAComputer::beginJob | ( | void | ) | [private, virtual] |
Reimplemented from edm::EDProducer.
Definition at line 135 of file TtSemiLepJetCombMVAComputer.cc.
{ }
void TtSemiLepJetCombMVAComputer::endJob | ( | void | ) | [private, virtual] |
Reimplemented from edm::EDProducer.
Definition at line 140 of file TtSemiLepJetCombMVAComputer.cc.
{ }
void TtSemiLepJetCombMVAComputer::produce | ( | edm::Event & | evt, |
const edm::EventSetup & | setup | ||
) | [private, virtual] |
Implements edm::EDProducer.
Definition at line 27 of file TtSemiLepJetCombMVAComputer.cc.
References evaluateTtSemiLepJetComb(), edm::Event::getByLabel(), i, analyzePatCleaning_cfg::jets, jets_, leps_, EgammaValidation_Wenu_cff::leptons, TtSemiLepEvtPartons::LightQ, TtSemiLepEvtPartons::LightQBar, maxNComb_, maxNJets_, CaloMET_cfi::met, mets_, mvaComputer, stdcomb::next_combination(), nPartons, edm::Event::put(), HcalObjRepresent::setup(), PhysicsTools::MVAComputerCache::update(), and makeHLTPrescaleTable::values.
{ std::auto_ptr<std::vector<std::vector<int> > > pOut (new std::vector<std::vector<int> >); std::auto_ptr<std::vector<double> > pOutDisc(new std::vector<double>); std::auto_ptr<std::string > pOutMeth(new std::string); std::auto_ptr<int > pJetsConsidered(new int); mvaComputer.update<TtSemiLepJetCombMVARcd>(setup, "ttSemiLepJetCombMVA"); // read name of the processor that provides the MVA discriminator // (to be used as meta information) edm::ESHandle<PhysicsTools::Calibration::MVAComputerContainer> calibContainer; setup.get<TtSemiLepJetCombMVARcd>().get( calibContainer ); std::vector<PhysicsTools::Calibration::VarProcessor*> processors = (calibContainer->find("ttSemiLepJetCombMVA")).getProcessors(); *pOutMeth = ( processors[ processors.size()-3 ] )->getInstanceName(); evt.put(pOutMeth, "Method"); // get lepton, jets and mets edm::Handle< edm::View<reco::RecoCandidate> > leptons; evt.getByLabel(leps_, leptons); edm::Handle< std::vector<pat::Jet> > jets; evt.getByLabel(jets_, jets); edm::Handle< std::vector<pat::MET> > mets; evt.getByLabel(mets_, mets); const unsigned int nPartons = 4; // skip events with no appropriate lepton candidate, // empty METs vector or less jets than partons if( leptons->empty() || mets->empty() || jets->size() < nPartons ) { std::vector<int> invalidCombi; for(unsigned int i = 0; i < nPartons; ++i) invalidCombi.push_back( -1 ); pOut->push_back( invalidCombi ); evt.put(pOut); pOutDisc->push_back( 0. ); evt.put(pOutDisc, "Discriminators"); *pJetsConsidered = jets->size(); evt.put(pJetsConsidered, "NumberOfConsideredJets"); return; } const math::XYZTLorentzVector lepton = leptons->begin()->p4(); const pat::MET *met = &(*mets)[0]; // analyze jet combinations std::vector<int> jetIndices; for(unsigned int i=0; i<jets->size(); ++i){ if(maxNJets_ >= (int) nPartons && maxNJets_ == (int) i) { *pJetsConsidered = i; break; } jetIndices.push_back(i); } std::vector<int> combi; for(unsigned int i=0; i<nPartons; ++i) combi.push_back(i); typedef std::pair<double, std::vector<int> > discCombPair; std::list<discCombPair> discCombList; do{ for(int cnt = 0; cnt < TMath::Factorial( combi.size() ); ++cnt){ // take into account indistinguishability of the two jets from the hadr. W decay, // reduces combinatorics by a factor of 2 if(combi[TtSemiLepEvtPartons::LightQ] < combi[TtSemiLepEvtPartons::LightQBar]) { TtSemiLepJetComb jetComb(*jets, combi, lepton, *met); // feed MVA input variables into a ValueList PhysicsTools::Variable::ValueList values; evaluateTtSemiLepJetComb(values, jetComb); // get discriminator from the MVAComputer double discrim = mvaComputer->eval( values ); discCombList.push_back( std::make_pair(discrim, combi) ); } next_permutation( combi.begin() , combi.end() ); } } while(stdcomb::next_combination( jetIndices.begin(), jetIndices.end(), combi.begin(), combi.end() )); // sort results w.r.t. discriminator values discCombList.sort(); // write result into the event // (starting with the JetComb having the highest discriminator value -> reverse iterator) unsigned int iDiscComb = 0; typedef std::list<discCombPair>::reverse_iterator discCombIterator; for(discCombIterator discCombPair = discCombList.rbegin(); discCombPair != discCombList.rend(); ++discCombPair) { if(maxNComb_ >= 1 && iDiscComb == (unsigned int) maxNComb_) break; pOut ->push_back( discCombPair->second ); pOutDisc->push_back( discCombPair->first ); iDiscComb++; } evt.put(pOut); evt.put(pOutDisc, "Discriminators"); evt.put(pJetsConsidered, "NumberOfConsideredJets"); }
Definition at line 29 of file TtSemiLepJetCombMVAComputer.h.
Referenced by produce().
Definition at line 28 of file TtSemiLepJetCombMVAComputer.h.
Referenced by produce().
int TtSemiLepJetCombMVAComputer::maxNComb_ [private] |
Definition at line 33 of file TtSemiLepJetCombMVAComputer.h.
Referenced by produce().
int TtSemiLepJetCombMVAComputer::maxNJets_ [private] |
Definition at line 32 of file TtSemiLepJetCombMVAComputer.h.
Referenced by produce().
Definition at line 30 of file TtSemiLepJetCombMVAComputer.h.
Referenced by produce().
Definition at line 35 of file TtSemiLepJetCombMVAComputer.h.
Referenced by produce().