Go to the documentation of this file.00001 #include "TMath.h"
00002 #include <algorithm>
00003
00004 #include "PhysicsTools/JetMCUtils/interface/combination.h"
00005 #include "PhysicsTools/MVATrainer/interface/HelperMacros.h"
00006
00007 #include "AnalysisDataFormats/TopObjects/interface/TtEvent.h"
00008 #include "TopQuarkAnalysis/TopEventSelection/plugins/TtFullHadSignalSelMVATrainer.h"
00009 #include "TopQuarkAnalysis/TopEventSelection/interface/TtFullHadSignalSelEval.h"
00010
00011 #include "DataFormats/PatCandidates/interface/Jet.h"
00012 #include "DataFormats/PatCandidates/interface/Flags.h"
00013 #include "DataFormats/RecoCandidate/interface/RecoCandidate.h"
00014
00015
00016 TtFullHadSignalSelMVATrainer::TtFullHadSignalSelMVATrainer(const edm::ParameterSet& cfg):
00017 jets_ (cfg.getParameter<edm::InputTag>("jets")),
00018 whatData_ (cfg.getParameter<int>("whatData")),
00019 maxEv_ (cfg.getParameter<int>("maxEv")),
00020 weight_ (cfg.getParameter<double>("weight"))
00021 {
00022 }
00023
00024 TtFullHadSignalSelMVATrainer::~TtFullHadSignalSelMVATrainer()
00025 {
00026 }
00027
00028 void
00029 TtFullHadSignalSelMVATrainer::analyze(const edm::Event& evt, const edm::EventSetup& setup)
00030 {
00031
00032 mvaComputer.update<TtFullHadSignalSelMVARcd>("trainer", setup, "traintreeSaver");
00033
00034
00035
00036 if(!mvaComputer) return;
00037
00038
00039 edm::Handle< std::vector<pat::Jet> > jets;
00040 evt.getByLabel(jets_, jets);
00041
00042
00043 selEv++;
00044
00045 if(selEv>maxEv_ && maxEv_!=-1) return;
00046
00047
00048
00049
00050
00051
00052
00053 TtFullHadSignalSel selection(*jets);
00054
00055 if(whatData_==-1) {
00056
00057
00058 edm::Handle<TtGenEvent> genEvt;
00059 evt.getByLabel("genEvt", genEvt);
00060
00061 bool isSignal = false;
00062 if(genEvt->isTtBar()){
00063 if(genEvt->isFullHadronic()) isSignal = true;
00064 }
00065 evaluateTtFullHadSignalSel(mvaComputer, selection, weight_, true, isSignal);
00066 }
00067 else {
00068
00069 if(whatData_==1){
00070
00071
00072 evaluateTtFullHadSignalSel(mvaComputer, selection, weight_, true, true);
00073 }
00074 else if(whatData_==0){
00075
00076
00077 evaluateTtFullHadSignalSel(mvaComputer, selection, weight_, true, false);
00078 }
00079 else std::cout<<"Config File Error!! Please check <whatData> in TtFullHadSignalSelMVATrainer_cfi";
00080 }
00081 }
00082
00083 void TtFullHadSignalSelMVATrainer::beginJob(){
00084 selEv = 0;
00085 if(whatData_!=-1 && whatData_!=0 && whatData_!=1){
00086 std::cout<<"Config File Error!! Please check <whatData> in TtFullHadSignalSelMVATrainer_cfi"<<std::endl;;
00087 return;
00088 }
00089 }
00090
00091
00092
00093
00094
00095 MVA_TRAINER_IMPLEMENT(TtFullHadSignalSelMVA);