CMS 3D CMS Logo

Public Member Functions | Private Member Functions | Private Attributes

TtFullHadSignalSelMVATrainer Class Reference

#include <TtFullHadSignalSelMVATrainer.h>

Inheritance diagram for TtFullHadSignalSelMVATrainer:
edm::EDAnalyzer

List of all members.

Public Member Functions

 TtFullHadSignalSelMVATrainer (const edm::ParameterSet &)
 ~TtFullHadSignalSelMVATrainer ()

Private Member Functions

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

Private Attributes

edm::InputTag jets_
int maxEv_
PhysicsTools::MVAComputerCache mvaComputer
int selEv
double weight_
int whatData_

Detailed Description

Definition at line 24 of file TtFullHadSignalSelMVATrainer.h.


Constructor & Destructor Documentation

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

Definition at line 16 of file TtFullHadSignalSelMVATrainer.cc.

                                                                                    :
  jets_      (cfg.getParameter<edm::InputTag>("jets")),
  whatData_  (cfg.getParameter<int>("whatData")),
  maxEv_     (cfg.getParameter<int>("maxEv")),
  weight_    (cfg.getParameter<double>("weight"))
{
}
TtFullHadSignalSelMVATrainer::~TtFullHadSignalSelMVATrainer ( )

Definition at line 24 of file TtFullHadSignalSelMVATrainer.cc.

{
}

Member Function Documentation

void TtFullHadSignalSelMVATrainer::analyze ( const edm::Event evt,
const edm::EventSetup setup 
) [private, virtual]

Implements edm::EDAnalyzer.

Definition at line 29 of file TtFullHadSignalSelMVATrainer.cc.

References gather_cfg::cout, evaluateTtFullHadSignalSel(), TtGenEvtProducer_cfi::genEvt, edm::Event::getByLabel(), analyzePatCleaning_cfg::jets, jets_, maxEv_, mvaComputer, corrVsCorr::selection, selEv, HcalObjRepresent::setup(), PhysicsTools::MVAComputerCache::update(), weight_, and whatData_.

{
  //communication with CMSSW CondDB
  mvaComputer.update<TtFullHadSignalSelMVARcd>("trainer", setup, "traintreeSaver");

  // can occur in the last iteration when the 
  // MVATrainer is about to save the result
  if(!mvaComputer) return;

  // get the jets out of the event
  edm::Handle< std::vector<pat::Jet> > jets;
  evt.getByLabel(jets_, jets);

  //count the number of selected events
  selEv++;
  //skip event if enough events are already selected
  if(selEv>maxEv_ && maxEv_!=-1) return;

  //calculation of InputVariables
  //see TopQuarkAnalysis/TopTools/interface/TtFullHadSignalSel.h
  //                             /src/TtFullHadSignalSel.cc
  //all objects, jets, which are needed for the calculation
  //of the input-variables have to be passed to this class

  TtFullHadSignalSel selection(*jets);

  if(whatData_==-1) {
    //your training-file contains both, signal and background events

    edm::Handle<TtGenEvent> genEvt;
    evt.getByLabel("genEvt", genEvt);
    
    bool isSignal = false;
    if(genEvt->isTtBar()){
      if(genEvt->isFullHadronic()) isSignal = true;
    }
    evaluateTtFullHadSignalSel(mvaComputer, selection, weight_, true, isSignal);
  }
  else {
   
    if(whatData_==1){
      //your tree contains only signal events

      evaluateTtFullHadSignalSel(mvaComputer, selection, weight_, true, true);
    }
    else if(whatData_==0){
      //your tree contains only background events

      evaluateTtFullHadSignalSel(mvaComputer, selection, weight_, true, false);
    }
    else std::cout<<"Config File Error!! Please check <whatData> in TtFullHadSignalSelMVATrainer_cfi";
  }
}
void TtFullHadSignalSelMVATrainer::beginJob ( void  ) [private, virtual]

Reimplemented from edm::EDAnalyzer.

Definition at line 83 of file TtFullHadSignalSelMVATrainer.cc.

References gather_cfg::cout, selEv, and whatData_.

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

Member Data Documentation

Definition at line 36 of file TtFullHadSignalSelMVATrainer.h.

Referenced by analyze().

Definition at line 39 of file TtFullHadSignalSelMVATrainer.h.

Referenced by analyze().

Definition at line 43 of file TtFullHadSignalSelMVATrainer.h.

Referenced by analyze().

Definition at line 40 of file TtFullHadSignalSelMVATrainer.h.

Referenced by analyze(), and beginJob().

Definition at line 41 of file TtFullHadSignalSelMVATrainer.h.

Referenced by analyze().

Definition at line 38 of file TtFullHadSignalSelMVATrainer.h.

Referenced by analyze(), and beginJob().