CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Member Functions | Private Member Functions | Private Attributes
TtSemiLepJetCombMVAComputer Class Reference

#include <TtSemiLepJetCombMVAComputer.h>

Inheritance diagram for TtSemiLepJetCombMVAComputer:
edm::EDProducer edm::ProducerBase edm::EDConsumerBase edm::ProductRegistryHelper

Public Member Functions

 TtSemiLepJetCombMVAComputer (const edm::ParameterSet &)
 
 ~TtSemiLepJetCombMVAComputer ()
 
- Public Member Functions inherited from edm::EDProducer
 EDProducer ()
 
ModuleDescription const & moduleDescription () const
 
virtual ~EDProducer ()
 
- Public Member Functions inherited from edm::ProducerBase
 ProducerBase ()
 
void registerProducts (ProducerBase *, ProductRegistry *, ModuleDescription const &)
 
std::function< void(BranchDescription
const &)> 
registrationCallback () const
 used by the fwk to register list of products More...
 
virtual ~ProducerBase ()
 
- Public Member Functions inherited from edm::EDConsumerBase
 EDConsumerBase ()
 
ProductHolderIndexAndSkipBit indexFrom (EDGetToken, BranchType, TypeID const &) const
 
void itemsMayGet (BranchType, std::vector< ProductHolderIndexAndSkipBit > &) const
 
void itemsToGet (BranchType, std::vector< ProductHolderIndexAndSkipBit > &) const
 
std::vector
< ProductHolderIndexAndSkipBit >
const & 
itemsToGetFromEvent () const
 
void labelsForToken (EDGetToken iToken, Labels &oLabels) const
 
void modulesDependentUpon (const std::string &iProcessName, std::vector< const char * > &oModuleLabels) const
 
bool registeredToConsume (ProductHolderIndex, bool, BranchType) const
 
bool registeredToConsumeMany (TypeID const &, BranchType) const
 
void updateLookup (BranchType iBranchType, ProductHolderIndexHelper const &)
 
virtual ~EDConsumerBase ()
 

Private Member Functions

virtual void beginJob ()
 
virtual void endJob ()
 
virtual void produce (edm::Event &evt, const edm::EventSetup &setup)
 

Private Attributes

edm::EDGetTokenT< std::vector
< pat::Jet > > 
jetsToken_
 
edm::EDGetTokenT< edm::View
< reco::RecoCandidate > > 
lepsToken_
 
int maxNComb_
 
int maxNJets_
 
edm::EDGetTokenT< std::vector
< pat::MET > > 
metsToken_
 
PhysicsTools::MVAComputerCache mvaComputer
 

Additional Inherited Members

- Public Types inherited from edm::EDProducer
typedef EDProducer ModuleType
 
- Public Types inherited from edm::ProducerBase
typedef
ProductRegistryHelper::TypeLabelList 
TypeLabelList
 
- Static Public Member Functions inherited from edm::EDProducer
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &descriptions)
 
- Protected Member Functions inherited from edm::ProducerBase
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
- Protected Member Functions inherited from edm::EDConsumerBase
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > consumes (edm::InputTag const &tag)
 
EDGetToken consumes (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken consumes (TypeToGet const &id, edm::InputTag const &tag)
 
ConsumesCollector consumesCollector ()
 Use a ConsumesCollector to gather consumes information from helper functions. More...
 
template<typename ProductType , BranchType B = InEvent>
void consumesMany ()
 
void consumesMany (const TypeToGet &id)
 
template<BranchType B>
void consumesMany (const TypeToGet &id)
 
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > mayConsume (edm::InputTag const &tag)
 
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 

Detailed Description

Definition at line 21 of file TtSemiLepJetCombMVAComputer.h.

Constructor & Destructor Documentation

TtSemiLepJetCombMVAComputer::TtSemiLepJetCombMVAComputer ( const edm::ParameterSet cfg)
explicit

Definition at line 5 of file TtSemiLepJetCombMVAComputer.cc.

5  :
7  jetsToken_ (consumes< std::vector<pat::Jet> >(cfg.getParameter<edm::InputTag>("jets"))),
8  metsToken_ (consumes< std::vector<pat::MET> >(cfg.getParameter<edm::InputTag>("mets"))),
9  maxNJets_(cfg.getParameter<int>("maxNJets")),
10  maxNComb_(cfg.getParameter<int>("maxNComb"))
11 {
12  produces<std::vector<std::vector<int> > >();
13  produces<std::vector<double> >("Discriminators");
14  produces<std::string >("Method");
15  produces<int >("NumberOfConsideredJets");
16 }
T getParameter(std::string const &) const
edm::EDGetTokenT< edm::View< reco::RecoCandidate > > lepsToken_
EDGetTokenT< ProductType > consumes(edm::InputTag const &tag)
edm::EDGetTokenT< std::vector< pat::MET > > metsToken_
edm::EDGetTokenT< std::vector< pat::Jet > > jetsToken_
TtSemiLepJetCombMVAComputer::~TtSemiLepJetCombMVAComputer ( )

Definition at line 18 of file TtSemiLepJetCombMVAComputer.cc.

19 {
20 }

Member Function Documentation

void TtSemiLepJetCombMVAComputer::beginJob ( void  )
privatevirtual

Reimplemented from edm::EDProducer.

Definition at line 131 of file TtSemiLepJetCombMVAComputer.cc.

132 {
133 }
void TtSemiLepJetCombMVAComputer::endJob ( void  )
privatevirtual

Reimplemented from edm::EDProducer.

Definition at line 136 of file TtSemiLepJetCombMVAComputer.cc.

137 {
138 }
void TtSemiLepJetCombMVAComputer::produce ( edm::Event evt,
const edm::EventSetup setup 
)
privatevirtual

Implements edm::EDProducer.

Definition at line 23 of file TtSemiLepJetCombMVAComputer.cc.

References PhysicsTools::MVAComputer::eval(), evaluateTtSemiLepJetComb(), edm::eventsetup::EventSetupRecord::get(), edm::Event::getByToken(), i, fwrapper::jets, jetsToken_, lepsToken_, EgammaValidation_Wenu_cff::leptons, TtSemiLepEvtPartons::LightQ, TtSemiLepEvtPartons::LightQBar, maxNComb_, maxNJets_, CaloMET_cfi::met, metsToken_, mvaComputer, stdcomb::next_combination(), nPartons, edm::Event::put(), HcalObjRepresent::setup(), AlCaHLTBitMon_QueryRunRegistry::string, PhysicsTools::MVAComputerCache::update(), and makeHLTPrescaleTable::values.

24 {
25  std::auto_ptr<std::vector<std::vector<int> > > pOut (new std::vector<std::vector<int> >);
26  std::auto_ptr<std::vector<double> > pOutDisc(new std::vector<double>);
27  std::auto_ptr<std::string > pOutMeth(new std::string);
28  std::auto_ptr<int > pJetsConsidered(new int);
29 
30  mvaComputer.update<TtSemiLepJetCombMVARcd>(setup, "ttSemiLepJetCombMVA");
31 
32  // read name of the processor that provides the MVA discriminator
33  // (to be used as meta information)
35  setup.get<TtSemiLepJetCombMVARcd>().get( calibContainer );
36  std::vector<PhysicsTools::Calibration::VarProcessor*> processors
37  = (calibContainer->find("ttSemiLepJetCombMVA")).getProcessors();
38  *pOutMeth = ( processors[ processors.size()-3 ] )->getInstanceName();
39  evt.put(pOutMeth, "Method");
40 
41  // get lepton, jets and mets
43  evt.getByToken(lepsToken_, leptons);
44 
46  evt.getByToken(jetsToken_, jets);
47 
49  evt.getByToken(metsToken_, mets);
50 
51  const unsigned int nPartons = 4;
52 
53  // skip events with no appropriate lepton candidate,
54  // empty METs vector or less jets than partons
55  if( leptons->empty() || mets->empty() || jets->size() < nPartons ) {
56  std::vector<int> invalidCombi;
57  for(unsigned int i = 0; i < nPartons; ++i)
58  invalidCombi.push_back( -1 );
59  pOut->push_back( invalidCombi );
60  evt.put(pOut);
61  pOutDisc->push_back( 0. );
62  evt.put(pOutDisc, "Discriminators");
63  *pJetsConsidered = jets->size();
64  evt.put(pJetsConsidered, "NumberOfConsideredJets");
65  return;
66  }
67 
68  const math::XYZTLorentzVector lepton = leptons->begin()->p4();
69 
70  const pat::MET *met = &(*mets)[0];
71 
72  // analyze jet combinations
73  std::vector<int> jetIndices;
74  for(unsigned int i=0; i<jets->size(); ++i){
75  if(maxNJets_ >= (int) nPartons && maxNJets_ == (int) i) {
76  *pJetsConsidered = i;
77  break;
78  }
79  jetIndices.push_back(i);
80  }
81 
82  std::vector<int> combi;
83  for(unsigned int i=0; i<nPartons; ++i)
84  combi.push_back(i);
85 
86  typedef std::pair<double, std::vector<int> > discCombPair;
87  std::list<discCombPair> discCombList;
88 
89  do{
90  for(int cnt = 0; cnt < TMath::Factorial( combi.size() ); ++cnt){
91  // take into account indistinguishability of the two jets from the hadr. W decay,
92  // reduces combinatorics by a factor of 2
94 
95  TtSemiLepJetComb jetComb(*jets, combi, lepton, *met);
96 
97  // feed MVA input variables into a ValueList
99  evaluateTtSemiLepJetComb(values, jetComb);
100 
101  // get discriminator from the MVAComputer
102  double discrim = mvaComputer->eval( values );
103 
104  discCombList.push_back( std::make_pair(discrim, combi) );
105 
106  }
107  next_permutation( combi.begin() , combi.end() );
108  }
109  }
110  while(stdcomb::next_combination( jetIndices.begin(), jetIndices.end(), combi.begin(), combi.end() ));
111 
112  // sort results w.r.t. discriminator values
113  discCombList.sort();
114 
115  // write result into the event
116  // (starting with the JetComb having the highest discriminator value -> reverse iterator)
117  unsigned int iDiscComb = 0;
118  typedef std::list<discCombPair>::reverse_iterator discCombIterator;
119  for(discCombIterator discCombPair = discCombList.rbegin(); discCombPair != discCombList.rend(); ++discCombPair) {
120  if(maxNComb_ >= 1 && iDiscComb == (unsigned int) maxNComb_) break;
121  pOut ->push_back( discCombPair->second );
122  pOutDisc->push_back( discCombPair->first );
123  iDiscComb++;
124  }
125  evt.put(pOut);
126  evt.put(pOutDisc, "Discriminators");
127  evt.put(pJetsConsidered, "NumberOfConsideredJets");
128 }
Analysis-level MET class.
Definition: MET.h:42
int i
Definition: DBlmapReader.cc:9
static const unsigned int nPartons
edm::EDGetTokenT< edm::View< reco::RecoCandidate > > lepsToken_
tuple met
____________________________________________________________________________||
Definition: CaloMET_cfi.py:4
double eval(Iterator_t first, Iterator_t last) const
evaluate variables given by a range of iterators given by first and last
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:434
XYZTLorentzVectorD XYZTLorentzVector
Lorentz vector with cylindrical internal representation using pseudorapidity.
Definition: LorentzVector.h:29
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:116
vector< PseudoJet > jets
void get(HolderT &iHolder) const
PhysicsTools::MVAComputerCache mvaComputer
Helper class that can contain an list of identifier-value pairs.
Definition: Variable.h:81
bool update(const Calibration::MVAComputer *computer)
edm::EDGetTokenT< std::vector< pat::MET > > metsToken_
void evaluateTtSemiLepJetComb(PhysicsTools::Variable::ValueList &values, const TtSemiLepJetComb &jetComb)
edm::EDGetTokenT< std::vector< pat::Jet > > jetsToken_
Common calculator class to keep multivariate analysis variables for jet combinations in semi-leptonic...
bool next_combination(BidIt n_begin, BidIt n_end, BidIt r_begin, BidIt r_end)
Definition: combination.h:22
void setup(std::vector< TH2F > &depth, std::string name, std::string units="")

Member Data Documentation

edm::EDGetTokenT< std::vector<pat::Jet> > TtSemiLepJetCombMVAComputer::jetsToken_
private

Definition at line 35 of file TtSemiLepJetCombMVAComputer.h.

Referenced by produce().

edm::EDGetTokenT< edm::View<reco::RecoCandidate> > TtSemiLepJetCombMVAComputer::lepsToken_
private

Definition at line 34 of file TtSemiLepJetCombMVAComputer.h.

Referenced by produce().

int TtSemiLepJetCombMVAComputer::maxNComb_
private

Definition at line 39 of file TtSemiLepJetCombMVAComputer.h.

Referenced by produce().

int TtSemiLepJetCombMVAComputer::maxNJets_
private

Definition at line 38 of file TtSemiLepJetCombMVAComputer.h.

Referenced by produce().

edm::EDGetTokenT< std::vector<pat::MET> > TtSemiLepJetCombMVAComputer::metsToken_
private

Definition at line 36 of file TtSemiLepJetCombMVAComputer.h.

Referenced by produce().

PhysicsTools::MVAComputerCache TtSemiLepJetCombMVAComputer::mvaComputer
private

Definition at line 41 of file TtSemiLepJetCombMVAComputer.h.

Referenced by produce().