CMS 3D CMS Logo

List of all members | Public Member Functions | Private Member Functions | Private Attributes
TtFullHadSignalSelMVATrainer Class Reference

#include <TtFullHadSignalSelMVATrainer.h>

Inheritance diagram for TtFullHadSignalSelMVATrainer:
edm::EDAnalyzer edm::EDConsumerBase

Public Member Functions

 TtFullHadSignalSelMVATrainer (const edm::ParameterSet &)
 
 ~TtFullHadSignalSelMVATrainer () override
 
- Public Member Functions inherited from edm::EDAnalyzer
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
 EDAnalyzer ()
 
SerialTaskQueueglobalLuminosityBlocksQueue ()
 
SerialTaskQueueglobalRunsQueue ()
 
ModuleDescription const & moduleDescription () const
 
std::string workerType () const
 
 ~EDAnalyzer () override
 
- Public Member Functions inherited from edm::EDConsumerBase
std::vector< ConsumesInfoconsumesInfo () const
 
void convertCurrentProcessAlias (std::string const &processName)
 Convert "@currentProcess" in InputTag process names to the actual current process name. More...
 
 EDConsumerBase ()
 
 EDConsumerBase (EDConsumerBase const &)=delete
 
 EDConsumerBase (EDConsumerBase &&)=default
 
ProductResolverIndexAndSkipBit indexFrom (EDGetToken, BranchType, TypeID const &) const
 
void itemsMayGet (BranchType, std::vector< ProductResolverIndexAndSkipBit > &) const
 
void itemsToGet (BranchType, std::vector< ProductResolverIndexAndSkipBit > &) const
 
std::vector< ProductResolverIndexAndSkipBit > const & itemsToGetFrom (BranchType iType) const
 
void labelsForToken (EDGetToken iToken, Labels &oLabels) const
 
void modulesWhoseProductsAreConsumed (std::vector< ModuleDescription const * > &modules, ProductRegistry const &preg, std::map< std::string, ModuleDescription const * > const &labelsToDesc, std::string const &processName) const
 
EDConsumerBase const & operator= (EDConsumerBase const &)=delete
 
EDConsumerBaseoperator= (EDConsumerBase &&)=default
 
bool registeredToConsume (ProductResolverIndex, bool, BranchType) const
 
bool registeredToConsumeMany (TypeID const &, BranchType) const
 
ProductResolverIndexAndSkipBit uncheckedIndexFrom (EDGetToken) const
 
void updateLookup (BranchType iBranchType, ProductResolverIndexHelper const &, bool iPrefetchMayGet)
 
virtual ~EDConsumerBase () noexcept(false)
 

Private Member Functions

void analyze (const edm::Event &evt, const edm::EventSetup &setup) override
 
void beginJob () override
 

Private Attributes

edm::EDGetTokenT< TtGenEventgenEvtToken_
 
edm::EDGetTokenT< std::vector< pat::Jet > > jetsToken_
 
int maxEv_
 
PhysicsTools::MVAComputerCache mvaComputer
 
int selEv
 
double weight_
 
int whatData_
 

Additional Inherited Members

- Public Types inherited from edm::EDAnalyzer
typedef EDAnalyzer ModuleType
 
- Public Types inherited from edm::EDConsumerBase
typedef ProductLabels Labels
 
- Static Public Member Functions inherited from edm::EDAnalyzer
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &)
 
static bool wantsGlobalLuminosityBlocks ()
 
static bool wantsGlobalRuns ()
 
static bool wantsStreamLuminosityBlocks ()
 
static bool wantsStreamRuns ()
 
- 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 25 of file TtFullHadSignalSelMVATrainer.h.

Constructor & Destructor Documentation

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

Definition at line 13 of file TtFullHadSignalSelMVATrainer.cc.

13  :
14  jetsToken_ (consumes< std::vector<pat::Jet> >(cfg.getParameter<edm::InputTag>("jets"))),
15  genEvtToken_ (consumes<TtGenEvent>(edm::InputTag("genEvt"))),
16  whatData_ (cfg.getParameter<int>("whatData")),
17  maxEv_ (cfg.getParameter<int>("maxEv")),
18  weight_ (cfg.getParameter<double>("weight"))
19 {
20 }
T getParameter(std::string const &) const
EDGetTokenT< ProductType > consumes(edm::InputTag const &tag)
edm::EDGetTokenT< std::vector< pat::Jet > > jetsToken_
edm::EDGetTokenT< TtGenEvent > genEvtToken_
TtFullHadSignalSelMVATrainer::~TtFullHadSignalSelMVATrainer ( )
override

Definition at line 22 of file TtFullHadSignalSelMVATrainer.cc.

23 {
24 }

Member Function Documentation

void TtFullHadSignalSelMVATrainer::analyze ( const edm::Event evt,
const edm::EventSetup setup 
)
overrideprivate

Definition at line 27 of file TtFullHadSignalSelMVATrainer.cc.

References gather_cfg::cout, evaluateTtFullHadSignalSel(), TtGenEvtProducer_cfi::genEvt, genEvtToken_, edm::Event::getByToken(), TtGenEvent::isFullHadronic(), TtGenEvent::isTtBar(), fwrapper::jets, jetsToken_, maxEv_, mvaComputer, corrVsCorr::selection, selEv, GeneralSetup::setup(), PhysicsTools::MVAComputerCache::update(), weight_, and whatData_.

28 {
29  //communication with CMSSW CondDB
30  mvaComputer.update<TtFullHadSignalSelMVARcd>("trainer", setup, "traintreeSaver");
31 
32  // can occur in the last iteration when the
33  // MVATrainer is about to save the result
34  if(!mvaComputer) return;
35 
36  // get the jets out of the event
38  evt.getByToken(jetsToken_, jets);
39 
40  //count the number of selected events
41  selEv++;
42  //skip event if enough events are already selected
43  if(selEv>maxEv_ && maxEv_!=-1) return;
44 
45  //calculation of InputVariables
46  //see TopQuarkAnalysis/TopTools/interface/TtFullHadSignalSel.h
47  // /src/TtFullHadSignalSel.cc
48  //all objects, jets, which are needed for the calculation
49  //of the input-variables have to be passed to this class
50 
52 
53  if(whatData_==-1) {
54  //your training-file contains both, signal and background events
55 
57  evt.getByToken(genEvtToken_, genEvt);
58 
59  bool isSignal = false;
60  if(genEvt->isTtBar()){
61  if(genEvt->isFullHadronic()) isSignal = true;
62  }
64  }
65  else {
66 
67  if(whatData_==1){
68  //your tree contains only signal events
69 
71  }
72  else if(whatData_==0){
73  //your tree contains only background events
74 
76  }
77  else std::cout<<"Config File Error!! Please check <whatData> in TtFullHadSignalSelMVATrainer_cfi";
78  }
79 }
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:579
selection
main part
Definition: corrVsCorr.py:99
def setup(process, global_tag, zero_tesla=False)
Definition: GeneralSetup.py:2
bool isFullHadronic(bool excludeTauLeptons=false) const
check if the event can be classified as full hadronic
Definition: TtGenEvent.h:36
vector< PseudoJet > jets
double evaluateTtFullHadSignalSel(PhysicsTools::MVAComputerCache &mvaComputer, const TtFullHadSignalSel &sigsel, double weight=1.0, const bool training=false, const bool isSignal=false)
edm::EDGetTokenT< std::vector< pat::Jet > > jetsToken_
edm::EDGetTokenT< TtGenEvent > genEvtToken_
bool update(const Calibration::MVAComputer *computer)
PhysicsTools::MVAComputerCache mvaComputer
bool isTtBar() const
check if the event can be classified as ttbar
Definition: TtGenEvent.h:30
void TtFullHadSignalSelMVATrainer::beginJob ( void  )
overrideprivatevirtual

Reimplemented from edm::EDAnalyzer.

Definition at line 81 of file TtFullHadSignalSelMVATrainer.cc.

References gather_cfg::cout, selEv, and whatData_.

81  {
82  selEv = 0;
83  if(whatData_!=-1 && whatData_!=0 && whatData_!=1){
84  std::cout<<"Config File Error!! Please check <whatData> in TtFullHadSignalSelMVATrainer_cfi"<<std::endl;;
85  return;
86  }
87 }

Member Data Documentation

edm::EDGetTokenT<TtGenEvent> TtFullHadSignalSelMVATrainer::genEvtToken_
private

Definition at line 38 of file TtFullHadSignalSelMVATrainer.h.

Referenced by analyze().

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

Definition at line 37 of file TtFullHadSignalSelMVATrainer.h.

Referenced by analyze().

int TtFullHadSignalSelMVATrainer::maxEv_
private

Definition at line 41 of file TtFullHadSignalSelMVATrainer.h.

Referenced by analyze().

PhysicsTools::MVAComputerCache TtFullHadSignalSelMVATrainer::mvaComputer
private

Definition at line 45 of file TtFullHadSignalSelMVATrainer.h.

Referenced by analyze().

int TtFullHadSignalSelMVATrainer::selEv
private

Definition at line 42 of file TtFullHadSignalSelMVATrainer.h.

Referenced by analyze(), and beginJob().

double TtFullHadSignalSelMVATrainer::weight_
private

Definition at line 43 of file TtFullHadSignalSelMVATrainer.h.

Referenced by analyze().

int TtFullHadSignalSelMVATrainer::whatData_
private

Definition at line 40 of file TtFullHadSignalSelMVATrainer.h.

Referenced by analyze(), and beginJob().