From 5097255ea70d2beae8ca857da41f40d99a713076 Mon Sep 17 00:00:00 2001 From: maria Date: Fri, 10 Mar 2017 20:27:43 +0100 Subject: [PATCH 1/4] first modification for FullHad --- dat/branches.txt | 2 + dat/configTopBot_FullHad.dat | 47 ++++ interface/AnalysisChargedHiggsTBfullHad.hpp | 77 ++++++ interface/Event.hpp | 5 + interface/FatJet.hpp | 107 ++++++++ interface/LinkDef.hpp | 1 + interface/Loader.hpp | 1 + src/AnalysisChargedHiggsTBfullHad.cpp | 272 ++++++++++++++++++++ src/Event.cpp | 26 +- src/Loader.cpp | 59 +++++ src/classes.h | 2 + src/classes_def.xml | 1 + 12 files changed, 597 insertions(+), 3 deletions(-) create mode 100644 dat/configTopBot_FullHad.dat create mode 100644 interface/AnalysisChargedHiggsTBfullHad.hpp create mode 100644 interface/FatJet.hpp create mode 100644 src/AnalysisChargedHiggsTBfullHad.cpp diff --git a/dat/branches.txt b/dat/branches.txt index 3c353846fdeba..2da4ffbb9ed4c 100644 --- a/dat/branches.txt +++ b/dat/branches.txt @@ -4,6 +4,8 @@ jetUnc jetBdiscr jetSelBits jetQGL +### FatJet +fatjetAK8CHSP4 ### Leptons lepP4 lepIso diff --git a/dat/configTopBot_FullHad.dat b/dat/configTopBot_FullHad.dat new file mode 100644 index 0000000000000..9f774b8d81aa5 --- /dev/null +++ b/dat/configTopBot_FullHad.dat @@ -0,0 +1,47 @@ +##configure Looper +##### This file store the configuratino to run all the analysis +##### if you want to make a config file that overwrite some changes just create a new one with the line +##### Loader=LoadNero +##### include=dat/config.txt +##### Files=....,....,... + +include=dat/config.2017.moriond.dat + +Files= +include=dat/catalog/2017.moriond/tt.dat +## signal +include=dat/catalog/2017.moriond/topbottom.dat + + +include=dat/topBot_FullHad.2017.dat +pileup=aux/pileup.2017.BCDEFGH.root + +#____________________ SPECIAL SETTINGS _____________________________ + +#__________________________________________________________________ +#____________________ COMMON SETTINGS _____________________________ +# + +# Smearer + +Smear=NONE + +################################# ANALYSIS CONFIGURATION ############################ + +Correct=NONE +#Correct=MetPhiCorrector +Final=no +#Final=yes +# final remember: no tree, no data, w/ syst + +#________________________________________________________________ +#____________________ CONFIGURATION _____________________________ +# +########## ANALYSIS ################ +Analysis=JsonAnalysis,MetFiltersAnalysis,ChargedHiggsTopBottomFullHad + +Output=ChHiggs_FullHad.root + + + + diff --git a/interface/AnalysisChargedHiggsTBfullHad.hpp b/interface/AnalysisChargedHiggsTBfullHad.hpp new file mode 100644 index 0000000000000..5e9b445dabf1e --- /dev/null +++ b/interface/AnalysisChargedHiggsTBfullHad.hpp @@ -0,0 +1,77 @@ +#ifndef CHARGEDHIGGSTOPBOTTOMFULLHAD_H +#define CHARGEDHIGGSTOPBOTTOMFULLHAD_H +#include "interface/AnalysisBase.hpp" +#include "interface/CutSelector.hpp" + + +#include "interface/Output.hpp" // DataStore +#include "TMVA/Reader.h" +#include "TMVA/Tools.h" + +class ChargedHiggsTopBottomFullHad: virtual public AnalysisBase +{ +public: + + ChargedHiggsTopBottomFullHad() : AnalysisBase () {} + virtual ~ChargedHiggsTopBottomFullHad () {} + + void Init() override; + + void SetLeptonCuts(Lepton *l) override ; + void SetJetCuts(Jet*j) override; + void SetTauCuts(Tau*t) override; + + void BookCutFlow(string l, string category); + void BookHisto(string l, string category, string phasespace); + void BookFlavor(string l, string category, string phasespace, string flavor, string SR); + void Preselection(); + + // function with various plots + void jetPlot(Event*e, string label, string category, string systname, string jetname); + void leptonPlot(Event*e, string label, string category, string systname, string phasespace); + void eventShapePlot(Event*e, string label, string category, string systname, string phasespace); + void classifyHF(Event*e, string label, string category, string systname, string jetname, string SR); + void leptonicHiggs(Event*e, string label, string systname, TLorentzVector b1, TLorentzVector b2, TLorentzVector p4W, string combination); + + void computeVar(Event*e); + + void printSynch(Event*e); + + int analyze(Event*,string systname) override; + const string name() const override {return "ChargedHiggsTopBottomFullHad";} + + vector weights; + + +private: + + CutSelector cut; + + enum CutFlow{ Total=0, + NoLep, + NoTau, + MaxCut + }; + + double evt_HT=-1; + + ///// + ///// + + DataStore varValues_; + + // + //TMVA::Reader *reader_ ; + vector readers_; + + +}; + +#endif +// Local Variables: +// mode:c++ +// indent-tabs-mode:nil +// tab-width:4 +// c-basic-offset:4 +// End: +// vim: tabstop=4 expandtab shiftwidth=4 softtabstop=4 diff --git a/interface/Event.hpp b/interface/Event.hpp index b4704dfaacb05..30372334b770c 100644 --- a/interface/Event.hpp +++ b/interface/Event.hpp @@ -9,6 +9,7 @@ using namespace std; // ----- #include "interface/Object.hpp" #include "interface/Jet.hpp" +#include "interface/FatJet.hpp" #include "interface/Lepton.hpp" #include "interface/Tau.hpp" #include "interface/Met.hpp" @@ -37,6 +38,7 @@ class Event{ protected: vector leps_; vector jets_; + vector fat_; vector taus_; vector phos_; vector genparticles_; // gen particles @@ -71,6 +73,7 @@ class Event{ // Bare version -- don't use these functions, unless for debug or sync inline Jet * GetBareJet(unsigned iJet) const { if (jets_.size() <= iJet) return (Jet*) NULL; return jets_[iJet]; } + inline FatJet * GetBareFatJet(unsigned iJet) const { if (fat_.size() <= iJet) return (FatJet*) NULL; return fat_[iJet]; } inline Tau * GetBareTau(unsigned iTau) const { if (taus_.size() <= iTau) return (Tau*) NULL; return taus_[iTau]; } inline Lepton * GetBareLepton(unsigned iLepton) const { if (leps_.size() <= iLepton) return (Lepton*) NULL; return leps_[iLepton]; } inline Photon * GetBarePhoton(unsigned iPhoton) const { if (phos_.size() <= iPhoton) return (Photon*) NULL; return phos_[iPhoton]; } @@ -90,6 +93,7 @@ class Event{ Jet * GetBjet( int iJet ); Jet * GetBjetInvIso( int iJet ); Jet * GetLjet( int iJet ); + FatJet * GetFatJet( int iJet ); Tau * GetTau( int iTau ); Tau * GetTauInvIso( int iTau ); Lepton * GetLepton( int iLep ); @@ -119,6 +123,7 @@ class Event{ inline int Bjets()const {int n=0; for(auto j : jets_) if(j->IsBJet()) n++; return n;} inline int Ljets()const {int n=0; for(auto j : jets_) if(not j->IsBJet()) n++; return n;} inline int BjetsInvIso()const {int n=0; for(auto j : jets_) if(j->IsBJetInvIso()) n++; return n;} + inline int NFatJets()const {int n=0; for(auto j : fat_) if(j->IsJet()) n++; return n;} inline int Ntaus(){int n=0; for(auto t : taus_) if(t->IsTau()) n++; return n;} inline int Nleps(){int n=0; for(auto t : leps_) if(t->IsLep()) n++; return n;} inline int NGenPar(){return genparticles_.size();} diff --git a/interface/FatJet.hpp b/interface/FatJet.hpp new file mode 100644 index 0000000000000..80847a72f579a --- /dev/null +++ b/interface/FatJet.hpp @@ -0,0 +1,107 @@ +#ifndef FATJET_H +#define FATJET_H + +#include "interface/Object.hpp" +#include "interface/Smearable.hpp" +#include +#include +#include + +//#include +//using namespace std; + +// --- +class FatJet : virtual public Object, virtual public SmearableComplex +{ + // This class take care of the jet definition in the analysis + // + float ptcut_; // ** pt cut on the accepted jets + float etacut_ ; // ** eta cut on the accepted jets + float tau1cut_ ; // To Set + float tau2cut_ ; // To Set + float tau3cut_ ; // To Set + + float corrprunedMasscut_ ; + float prunedMasscut_ ; + float softdropMasscut_ ; + float nSubjetscut_ ; + float hbbcut_; + + // FIXME: add puppi + + TLorentzVector pp4; + + public: + + void SetPtCut(float x){ptcut_= x;} + void SetEtaCut(float x){etacut_ = x;} + + void SetTau1Cut(float x){tau1cut_ = x;} + void SetTau2Cut(float x){tau2cut_ = x;} + void SetTau3Cut(float x){tau3cut_ = x;} + + void SetCorrPrunedMassCut(float x){corrprunedMasscut_ = x;} + void SetPrunedMassCut(float x){prunedMasscut_ = x;} + void SetSDMassCut(float x){softdropMasscut_ = x;} + void SetSubjetsCut(float x){nSubjetscut_ = x;} + + void SetDoubleBBCut(float x){hbbcut_ = x;} + + + FatJet() ; + + + float bdiscr; // + + //Gen-level info + + // --- + inline float Pt() const override { + // --- cout<<"[Jet]::[Pt]::[DEBUG]"<<"Requested Pt for jet"<0) cout<<"[Jet]::[Pt]::[DEBUG]"<0 ) return ptUpSyst[type]; + else return ptDownSyst[type]; + } + inline float E() const override { + if (syst == 0) return p4.E(); + else return Pt()/p4.Pt() *p4.E(); + } + + inline TLorentzVector & GetP4() override { + if (syst == 0) return p4; + if (syst!=0 ) { + pp4=p4; + if (p4.Pt()>0) { + return pp4 *= (Pt()/p4.Pt()); + } else { + return pp4; + } + } + } + + inline float GetUnc() const { return Pt()/p4.Pt(); } + + inline int IsJet() const { + return 1; + // if (not isValid) return 0; + // return IsJetExceptValidity(); + } + + +}; + +#endif +// Local Variables: +// mode:c++ +// indent-tabs-mode:nil +// tab-width:4 +// c-basic-offset:4 +// End: +// vim: tabstop=4 expandtab shiftwidth=4 softtabstop=4 diff --git a/interface/LinkDef.hpp b/interface/LinkDef.hpp index a38e6c8388313..7e4dc9852aa03 100644 --- a/interface/LinkDef.hpp +++ b/interface/LinkDef.hpp @@ -2,6 +2,7 @@ #pragma link C++ class Object+ ; #pragma link C++ class Jet+ ; +#pragma link C++ class FatJet+ ; #pragma link C++ class GenParticle+ ; #pragma link C++ class Lepton+ ; #pragma link C++ class Met+ ; diff --git a/interface/Loader.hpp b/interface/Loader.hpp index 6d332d1b01266..c7994869eaccd 100644 --- a/interface/Loader.hpp +++ b/interface/Loader.hpp @@ -51,6 +51,7 @@ class LoadNero : public Loader{ void Clear() override { for (auto c : bare_) c->clear() ;} void FillJets(); + void FillFatJets(); void FillLeptons(); void FillPhotons(); void FillTaus(); diff --git a/src/AnalysisChargedHiggsTBfullHad.cpp b/src/AnalysisChargedHiggsTBfullHad.cpp new file mode 100644 index 0000000000000..baa06e0b46605 --- /dev/null +++ b/src/AnalysisChargedHiggsTBfullHad.cpp @@ -0,0 +1,272 @@ +#include "interface/AnalysisChargedHiggsTBfullHad.hpp" + +void ChargedHiggsTopBottomFullHad::SetLeptonCuts(Lepton *l){ + // these are used for the Veto + l->SetPtCut(10); + l->SetIsoCut(-1.); // absolute isolation + //https://indico.cern.ch/event/594396/contributions/2402538/attachments/1389409/2116003/20161215_MuonPOG_GeneralPPD.pdf + l->SetIsoRelCut(0.25); // relative isolation // for muon 0.25 is loose, 0.15 is tight + l->SetMiniIsoRelCut(-1); // relative mini-isolation + l->SetEtaCut(2.4); + l->SetVetoCut(); // loosest selection of them all + l->SetTightCut(false); // use the loose selection for now +} + +void ChargedHiggsTopBottomFullHad::SetJetCuts(Jet *j){ + // https://twiki.cern.ch/twiki/bin/view/CMS/BtagRecommendation80XReReco + // doSynch + j->SetBCut(0.8484); //0.8484 medium // 0.5426 loose + j->SetEtaCut(4.7); + j->SetEtaCutCentral(2.4); + j->SetPtCut(40); + // j->SetPtCut(30); // for MIAO + j->SetPuIdCut(-100); +} + +void ChargedHiggsTopBottomFullHad::SetTauCuts(Tau *t){ + // these are used for the Veto + t->SetPtCut(20); + /// MARIA FIXME 2.4 --> 2.3 + t->SetEtaCut(2.4); + t->SetMuRej(false); + t->SetEleRej(false); + t->SetTrackPtCut(-1.); // no requirement on the leading Track + t->SetIsoRelCut(-1); // LooseCombinedIsolationDeltaBetaCorr3Hits + t->SetIsoCut(2.5); + t->SetProngsCut(-1); // all Prong + t->SetDecayMode(1); // 0=TauDecayModeFindingNewDMs 1=TauDecayModeFinding +} + + +void ChargedHiggsTopBottomFullHad::Init() +{ + + Preselection(); + +} + +void ChargedHiggsTopBottomFullHad::BookCutFlow(string l, string category) +{ + + cout <<"[ChargedHiggsTopBottom]::[Init]::[INFO] Boking Histo CutFlow/Baseline" <GetXaxis()->SetBinLabel(Total+1,"Total"); + GetHisto("ChargedHiggsTopBottom/CutFlow"+category+"/CutFlow_"+l,"")->GetXaxis()->SetBinLabel(NoLep+1,"N_{lep} == 0"); + GetHisto("ChargedHiggsTopBottom/CutFlow"+category+"/CutFlow_"+l,"")->GetXaxis()->SetBinLabel(NoTau+1,"N_{taus} = 0"); + +} + +void ChargedHiggsTopBottomFullHad::BookFlavor(string l, string category, string phasespace, string flavor, string SR) +{ + + AddFinalHisto("ChargedHiggsTopBottom/"+phasespace+category+"/ST_"+SR+flavor+l); + AddFinalHisto("ChargedHiggsTopBottom/"+phasespace+category+"/HT_"+SR+flavor+l); + AddFinalHisto("ChargedHiggsTopBottom/"+phasespace+category+"/ST_zoom_"+SR+flavor+l); + AddFinalHisto("ChargedHiggsTopBottom/"+phasespace+category+"/HT_zoom_"+SR+flavor+l); + + Book("ChargedHiggsTopBottom/"+phasespace+category+"/HT_"+SR+flavor+l,"HT "+l+"; HT (P_{T}^{jet}>40 [GeV])",800,0,8000); + Book("ChargedHiggsTopBottom/"+phasespace+category+"/ST_"+SR+flavor+l,"ST "+l+"; ST ( HT+met+lepsPt )",800,0,8000); + Book("ChargedHiggsTopBottom/"+phasespace+category+"/HT_zoom_"+SR+flavor+l,"HT "+l+"; HT (P_{T}^{jet}>40 [GeV])",40,0,2000); + Book("ChargedHiggsTopBottom/"+phasespace+category+"/ST_zoom_"+SR+flavor+l,"ST "+l+"; ST ( HT+met+lepsPt )",50,0,2500); + +} + + +void ChargedHiggsTopBottomFullHad::BookHisto(string l, string category, string phasespace) +{ + + cout <<"[ChargedHiggsTopBottom]::[Init]::[INFO] Boking Final Histo" <40 [GeV])",40,0,2000); + Book("ChargedHiggsTopBottom/"+phasespace+category+"/HT_"+l,"HT "+l+"; HT (P_{T}^{jet}>40 [GeV])",800,0,8000); + + ///// + Book("ChargedHiggsTopBottom/"+phasespace+category+"/ST_zoom_"+l,"ST "+l+"; ST ( HT+met+lepsPt )",50,0,2500); + Book("ChargedHiggsTopBottom/"+phasespace+category+"/ST_"+l,"ST "+l+"; ST ( HT+MET+lepsPt )",800,0,8000); + + /// Vertices + Book("ChargedHiggsTopBottom/"+phasespace+category+"/Met_"+l,"Met "+l+";MET [GeV]",50,0.,1000.); + Book("ChargedHiggsTopBottom/"+phasespace+category+"/Vertices_"+l,"Vertices "+l + ";Number of vertices",50,0.,50.); + + ///// + Book("ChargedHiggsTopBottom/"+phasespace+category+"/NBjets_"+l,"NBjets "+l + ";Number of b jets P_{T}>40 ",10,0,10); + Book("ChargedHiggsTopBottom/"+phasespace+category+"/Njets_"+l,"Njets "+l + ";Number of jets P_{T}>40 |#eta|>2.4",10,0,10); + Book("ChargedHiggsTopBottom/"+phasespace+category+"/Ncentraljets_"+l,"Ncentraljets "+l + ";Number of jets P_{T}>40 |#eta|<=2.4",10,0,10); + Book("ChargedHiggsTopBottom/"+phasespace+category+"/Nforwardjets_"+l,"Nforwardjets "+l + ";Number of jets P_{T}>40 |#eta|>2.4",10,0,10); + +} + +void ChargedHiggsTopBottomFullHad::Preselection() +{ + + for ( string l : AllLabel() ) { + + BookCutFlow(l, ""); + BookHisto(l, "","Baseline"); // this is when there is nothing + + } + +} + +void ChargedHiggsTopBottomFullHad::eventShapePlot(Event*e, string label, string category, string systname, string phasespace) { + + + // Fill("ChargedHiggsTopBottom/"+phasespace+category+"/Centrality_"+label,systname,evt_C,e->weight()); + // Fill("ChargedHiggsTopBottom/"+phasespace+category+"/HemiOut_"+label,systname,evt_HemiMetOut,e->weight()); + + + +} + +void ChargedHiggsTopBottomFullHad::computeVar(Event*e) { + + + double minDRbb=99999; + double maxDRbb=0; + double minDRbb_invMass=-1; + double maxDRbb_invMass=-1; + double indexI=-1; + double indexJ=-1; + + double indexMaxJ=-1; + + for(int i=0;i!=e->Bjets();++i) { + Jet* bjet = e->GetBjet(i); + for(int j=0;j!=e->Bjets();++j) { + if (j==i) continue; + double dr = bjet->DeltaR(e->GetBjet(j)); + double mass = (bjet->GetP4() + e->GetBjet(j)->GetP4()).M(); + if(drmaxDRbb and i==0) { maxDRbb=dr; maxDRbb_invMass=mass; indexMaxJ=j;} + } + } + + + ////$$$$$$ + ////$$$$$$ + ////$$$$$$ + ////$$$$$$ + + + evt_HT=0; + + // check the impact of the HT(w/ central jet only) + for(int i=0;i!=e->NcentralJets();++i) { + evt_HT += e->GetCentralJet(i)->Pt(); + } + + ////$$$$$$ + ////$$$$$$ + ////$$$$$$ + ////$$$$$$ + +} + +void ChargedHiggsTopBottomFullHad::jetPlot(Event*e, string label, string category, string systname, string phasespace) { + + Fill("ChargedHiggsTopBottom/"+phasespace+category+"/Vertices_"+label,systname,e->Npv(),e->weight()); + + /////////// + //// STUDY various jets properties + //// forward vs central + + Fill("ChargedHiggsTopBottom/"+phasespace+category+"/HT_"+label,systname, evt_HT ,e->weight()); + Fill("ChargedHiggsTopBottom/"+phasespace+category+"/HT_zoom_"+label,systname, evt_HT ,e->weight()); + + Fill("ChargedHiggsTopBottom/"+phasespace+category+"/Ncentraljets_"+label,systname, e->NcentralJets() ,e->weight()); + Fill("ChargedHiggsTopBottom/"+phasespace+category+"/Nforwardjets_"+label,systname, e->NforwardJets() ,e->weight()); + + Fill("ChargedHiggsTopBottom/"+phasespace+category+"/NBjets_"+label,systname, e->Bjets() ,e->weight()); + Fill("ChargedHiggsTopBottom/"+phasespace+category+"/Njets_"+label,systname, e->Njets() ,e->weight()); + +} + + +void ChargedHiggsTopBottomFullHad::classifyHF(Event*e, string label, string category, string systname, string phasespace, string Sregion) { + + + // if((label.find("TTTo2L2Nu")!=string::npos) || (label.find("TTToSemilepton")!=string::npos)) { + if((label.find("TTTo2L2Nu")!=string::npos) || (label.find("TTToSemilepton")!=string::npos) || (label.find("TT_TuneCUETP8M2T4")!=string::npos) ) { + + //https://github.com/cms-sw/cmssw/blob/CMSSW_8_0_X/TopQuarkAnalysis/TopTools/plugins/GenTtbarCategorizer.cc#L35 + string LabelHF="other_"; + if((e->GetGenTtbarId()%100)==55 || (e->GetGenTtbarId()%100)==54) LabelHF="tt2bMerged_"; + if((e->GetGenTtbarId()%100)==53) LabelHF="tt2b_"; + if((e->GetGenTtbarId()%100)==52 || (e->GetGenTtbarId()%100)==51) LabelHF="tt1b_"; + if((e->GetGenTtbarId()%100)==45 || (e->GetGenTtbarId()%100)==44 || (e->GetGenTtbarId()%100)==43 || (e->GetGenTtbarId()%100)==42 || (e->GetGenTtbarId()%100)==41) LabelHF="ttc_"; + if((e->GetGenTtbarId()%100)==00) LabelHF="ttlight_"; + + vector > valid; // csv, idx + for(int i = 0 ; iNcentralJets() ;++i) + { + valid.push_back(pair(e->GetCentralJet(i)->bdiscr,i)); + } + + std::sort(valid.begin(), valid.end(),[](pair &a,pair &b) { if (a.first> b.first) return true; if (a.firstBjets() ,e->weight()); + if(e->NcentralJets()>=3 && valid.size() != 0) Fill("ChargedHiggsTopBottom/"+phasespace+category+"/thirdBDiscr_"+Sregion+LabelHF+label,systname, valid[2].first ,e->weight()); + + } + + Fill("ChargedHiggsTopBottom/"+phasespace+category+"/HT_"+Sregion+LabelHF+label,systname, evt_HT ,e->weight()); + Fill("ChargedHiggsTopBottom/"+phasespace+category+"/HT_zoom_"+Sregion+LabelHF+label,systname, evt_HT ,e->weight()); + + } + +} + + +int ChargedHiggsTopBottomFullHad::analyze(Event*e,string systname) +{ +#ifdef VERBOSE + if(VERBOSE>0)cout<<"[ChargedHiggsTopBottom]::[analyze]::[DEBUG] analyze event with syst: "<weight() == 0. ) cout <<"[ChargedHiggsTopBottom]::[analyze]::[INFO] Even Weight is NULL !!"<< e->weight() <weight()); + + if ( e->Nleps() == 0 ) cut.SetCutBit(NoLep); // only two lep <--- kill multiboson/ttV + if ( cut.passAllUpTo(NoLep) ) Fill("ChargedHiggsTopBottom/CutFlow/CutFlow_"+label,systname,NoLep,e->weight()); + + if(!cut.passAllUpTo(NoLep) ) return EVENT_NOT_USED; + + std::cout << " e->NFatJets() = " << e->NFatJets() << std::endl; + + //////// + //// UP TO NOW: LEPTONS selection only + //// + + bool Baseline=(e->Bjets() > 0); + + computeVar(e); + + string category=""; + jetPlot(e, label, category, systname,"Baseline"); + + return EVENT_NOT_USED; + +} +// Local Variables: +// mode:c++ +// indent-tabs-mode:nil +// tab-width:4 +// c-basic-offset:4 +// End: +// vim: tabstop=4 expandtab shiftwidth=4 softtabstop=4 diff --git a/src/Event.cpp b/src/Event.cpp index 9870fb6a995e5..7ae32c3324c90 100644 --- a/src/Event.cpp +++ b/src/Event.cpp @@ -19,11 +19,13 @@ Event::~Event(){ void Event::ClearEvent(){ for (auto o : jets_ ) ChargedHiggs::Delete(o); + for (auto o : fat_ ) ChargedHiggs::Delete(o); for (auto o : leps_ ) ChargedHiggs::Delete(o); for (auto o : taus_ ) ChargedHiggs::Delete(o); for (auto o : genparticles_ ) ChargedHiggs::Delete(o); jets_ . clear(); + fat_ . clear(); leps_ . clear(); taus_ . clear(); phos_ . clear(); @@ -35,6 +37,7 @@ void Event::ClearEvent(){ void Event::clearSyst(){ for ( auto o: jets_) o->clearSyst(); + for ( auto o: fat_) o->clearSyst(); for ( auto o: taus_) o->clearSyst(); for ( auto o: leps_) o->clearSyst(); for ( auto o: genparticles_) o->clearSyst(); @@ -226,12 +229,12 @@ void Event::validate(){ } // Get Object functions -Jet * Event::GetJet( int iJet ) -{ +Jet * Event::GetJet( int iJet ) +{ vector > valid; // pt, idx for(int i = 0 ; iIsJet()) valid.push_back(pair(jets_[i]->Pt(),i)); + if ( jets_[i]->IsJet()) valid.push_back(pair(jets_[i]->Pt(),i)); } if (valid.size() == 0 ) return NULL; @@ -323,6 +326,23 @@ Jet * Event::GetLjet( int iJet ) return jets_[ valid[iJet].second]; } +FatJet * Event::GetFatJet( int iJet ) +{ + vector > valid; // pt, idx + for(int i = 0 ; iIsJet()) valid.push_back(pair(fat_[i]->Pt(),i)); + } + + if (valid.size() == 0 ) return NULL; + if (valid.size() <= iJet ) return NULL; + + sort(valid.begin(),valid.end(),[](pair &a,pair &b) { if (a.first> b.first) return true; if (a.first > valid; // pt, idx diff --git a/src/Loader.cpp b/src/Loader.cpp index 1f18aae20e610..a2445d7908ac3 100644 --- a/src/Loader.cpp +++ b/src/Loader.cpp @@ -36,6 +36,7 @@ int LoadNero::InitTree(){ "BareVertex", "BareMonteCarlo", "BareJets", + "BareFatJets", "BareTaus", "BareLeptons", "BareMet", @@ -68,6 +69,7 @@ int LoadNero::FillEvent(){ //FillEventInfo(); // new file uses isRealData, but not the weights, called directly FillJets(); + FillFatJets(); FillLeptons(); FillPhotons(); FillTaus(); @@ -190,6 +192,63 @@ void LoadNero::FillJets(){ }// end fill jets +void LoadNero::FillFatJets(){ + //fill Jets +#ifdef VERBOSE + if(VERBOSE>1) Log(__FUNCTION__,"DEBUG","Filling Fat Jets"); +#endif + + BareFatJets *bj = dynamic_cast ( bare_ [ names_[ "BareFatJets" ] ] ); assert (bj !=NULL); + + if ( tree_ ->GetBranchStatus("fatjetAK8CHSP4") == 0 ){ + LogN(__FUNCTION__,"WARNING","Jets Not FILLED",10); + return; + } + + for (int iJet=0;iJet< bj -> p4 ->GetEntries() ; ++iJet) + { + +#ifdef VERBOSE + if (VERBOSE >1 ) + { + cout <<"[LoadNero]::[FillJets]::[DEBUG2] considering jet: "< p4 ->GetEntries() <selBits ->size()< unc ->size() < bDiscr ->size() < matchedPartonPdgId -> size()<motherPdgId ->size()< grMotherPdgId -> size()< puId -> size() < p4 -> At(iJet)) ->Pt() < p4 -> At(iJet)) ->Eta() < p4 -> At(iJet)) ->Phi() <selBits -> at( iJet) ) & BareJets::Selection::JetLoose; +// if (not id) continue; + + FatJet *j =new FatJet(); + j->SetP4( *(TLorentzVector*) ((*bj->p4)[iJet]) ); + // JES + //Log(__FUNCTION__,"DEBUG",Form("Going to Fill Jes for jet: %d",iJet)); + + //Log(__FUNCTION__,"DEBUG",Form(" JesUp=%f", (1. + bj -> unc -> at(iJet) ) * ((TLorentzVector*)(*bj->p4)[iJet])->Pt())); + //Log(__FUNCTION__,"DEBUG",Form(" JesDown=%f", (1. - bj -> unc -> at(iJet) ) * ((TLorentzVector*)(*bj->p4)[iJet])->Pt())); + + //Log(__FUNCTION__,"DEBUG","-> Done"); + // --- + + // add it + event_ -> fat_ . push_back(j); + } + return; + +}// end fill jets + + void LoadNero::FillLeptons(){ // Fill Leptons #ifdef VERBOSE diff --git a/src/classes.h b/src/classes.h index 6fff03fd28c06..5540653f79ce9 100644 --- a/src/classes.h +++ b/src/classes.h @@ -8,6 +8,7 @@ #include "interface/AnalysisChargedHiggsTmva.hpp" #include "interface/AnalysisChargedHiggsTopBottom.hpp" #include "interface/AnalysisChargedHiggsZW.hpp" +#include "interface/AnalysisChargedHiggsTBfullHad.hpp" #include "interface/AnalysisDY.hpp" #include "interface/AnalysisGG.hpp" #include "interface/AnalysisHmumu.hpp" @@ -27,6 +28,7 @@ #include "interface/GenParticle.hpp" #include "interface/Handlers.hpp" #include "interface/Jet.hpp" +#include "interface/FatJet.hpp" #include "interface/JSON.hpp" #include "interface/KalmanMuonCalibrator.hpp" #include "interface/KaMuCa.hpp" diff --git a/src/classes_def.xml b/src/classes_def.xml index 412f7f8cd7c15..c349169ec0b63 100644 --- a/src/classes_def.xml +++ b/src/classes_def.xml @@ -2,6 +2,7 @@ + From 6544f094007f1452df14471c3ff4691817d8c3a6 Mon Sep 17 00:00:00 2001 From: maria Date: Mon, 13 Mar 2017 11:25:10 +0100 Subject: [PATCH 2/4] add missing file --- dat/topBot_FullHad.2017.dat | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 dat/topBot_FullHad.2017.dat diff --git a/dat/topBot_FullHad.2017.dat b/dat/topBot_FullHad.2017.dat new file mode 100644 index 0000000000000..256a94f5d4a40 --- /dev/null +++ b/dat/topBot_FullHad.2017.dat @@ -0,0 +1,21 @@ +############# +### TopBottom FullHad ### +############# + +config=ChargedHiggsTopBottom|AddLabel('ChargedHiggs_HplusTB_HplusToTB_M-3000_13TeV_amcatnlo_pythia8') +###addConfig=ChargedHiggsTopBottom|AddLabel('HplusToTB_M-2000') +###addConfig=ChargedHiggsTopBottom|AddLabel('HplusToTB_M-1000') +addConfig=ChargedHiggsTopBottom|AddLabel('ChargedHiggs_HplusTB_HplusToTB_M-800_13TeV_amcatnlo_pythia8') +###addConfig=ChargedHiggsTopBottom|AddLabel('HplusToTB_M-750') +addConfig=ChargedHiggsTopBottom|AddLabel('ChargedHiggs_HplusTB_HplusToTB_M-500_13TeV_amcatnlo_pythia8') +###addConfig=ChargedHiggsTopBottom|AddLabel('HplusToTB_M-450') +addConfig=ChargedHiggsTopBottom|AddLabel('ChargedHiggs_HplusTB_HplusToTB_M-400_13TeV_amcatnlo_pythia8') +addConfig=ChargedHiggsTopBottom|AddLabel('ChargedHiggs_HplusTB_HplusToTB_M-350_13TeV_amcatnlo_pythia8') +addConfig=ChargedHiggsTopBottom|AddLabel('ChargedHiggs_HplusTB_HplusToTB_M-300_13TeV_amcatnlo_pythia8') +addConfig=ChargedHiggsTopBottom|AddLabel('ChargedHiggs_HplusTB_HplusToTB_M-250_13TeV_amcatnlo_pythia8') +addConfig=ChargedHiggsTopBottom|AddLabel('ChargedHiggs_HplusTB_HplusToTB_M-220_13TeV_amcatnlo_pythia8') +addConfig=ChargedHiggsTopBottom|AddLabel('ChargedHiggs_HplusTB_HplusToTB_M-200_13TeV_amcatnlo_pythia8') +addConfig=ChargedHiggsTopBottom|AddLabel('ChargedHiggs_HplusTB_HplusToTB_M-180_13TeV_amcatnlo_pythia8') + +addConfig=ChargedHiggsTopBottom|AddLabel('TT_TuneCUETP8M2T4') + From bc83a7185f94a3ec2a4fe4bfa07c3bef401b5838 Mon Sep 17 00:00:00 2001 From: Andrea Carlo Marini Date: Mon, 13 Mar 2017 12:04:01 +0100 Subject: [PATCH 3/4] fixing fatjets --- interface/FatJet.hpp | 41 +++-------------------------------------- src/FatJet.cpp | 5 +++++ src/Loader.cpp | 36 +++++++++++++++++------------------- 3 files changed, 25 insertions(+), 57 deletions(-) create mode 100644 src/FatJet.cpp diff --git a/interface/FatJet.hpp b/interface/FatJet.hpp index 80847a72f579a..fede1d10e5f1a 100644 --- a/interface/FatJet.hpp +++ b/interface/FatJet.hpp @@ -11,7 +11,7 @@ //using namespace std; // --- -class FatJet : virtual public Object, virtual public SmearableComplex +class FatJet : virtual public Object, virtual public SmearableBase { // This class take care of the jet definition in the analysis // @@ -56,43 +56,8 @@ class FatJet : virtual public Object, virtual public SmearableComplex //Gen-level info // --- - inline float Pt() const override { - // --- cout<<"[Jet]::[Pt]::[DEBUG]"<<"Requested Pt for jet"<0) cout<<"[Jet]::[Pt]::[DEBUG]"<0 ) return ptUpSyst[type]; - else return ptDownSyst[type]; - } - inline float E() const override { - if (syst == 0) return p4.E(); - else return Pt()/p4.Pt() *p4.E(); - } - - inline TLorentzVector & GetP4() override { - if (syst == 0) return p4; - if (syst!=0 ) { - pp4=p4; - if (p4.Pt()>0) { - return pp4 *= (Pt()/p4.Pt()); - } else { - return pp4; - } - } - } - - inline float GetUnc() const { return Pt()/p4.Pt(); } - - inline int IsJet() const { - return 1; - // if (not isValid) return 0; - // return IsJetExceptValidity(); - } + + inline int IsJet() const { return 1;} }; diff --git a/src/FatJet.cpp b/src/FatJet.cpp new file mode 100644 index 0000000000000..d16cbb579bc1b --- /dev/null +++ b/src/FatJet.cpp @@ -0,0 +1,5 @@ +#include "interface/FatJet.hpp" + +FatJet::FatJet() :Object(){ + syst=0; +} diff --git a/src/Loader.cpp b/src/Loader.cpp index a2445d7908ac3..b5d8c6ed52e52 100644 --- a/src/Loader.cpp +++ b/src/Loader.cpp @@ -54,9 +54,15 @@ int LoadNero::InitTree(){ bare_[ names_ ["BareTaus"] ] -> SetExtend(); bare_[ names_ ["BarePhotons"] ] -> SetExtend(); dynamic_cast (bare_[ names_ ["BareTaus"] ]) -> SetMatch(); + //dynamic_cast (bare_[ names_ ["BareFatJets"] ]) -> cachedPrefix="AK8CHS"; for (auto b : bare_ ) - b->setBranchAddresses(tree_); + { + if (dynamic_cast(b) !=NULL) + dynamic_cast(b)->setBranchAddresses(tree_,"AK8CHS"); + else + b->setBranchAddresses(tree_); + } // branches are activate from configuration file tree_ -> SetBranchStatus("*",0); @@ -201,25 +207,21 @@ void LoadNero::FillFatJets(){ BareFatJets *bj = dynamic_cast ( bare_ [ names_[ "BareFatJets" ] ] ); assert (bj !=NULL); if ( tree_ ->GetBranchStatus("fatjetAK8CHSP4") == 0 ){ - LogN(__FUNCTION__,"WARNING","Jets Not FILLED",10); + LogN(__FUNCTION__,"WARNING","FatJets Not FILLED",10); return; } +#ifdef VERBOSE + if(VERBOSE>1) Log(__FUNCTION__,"DEBUG",Form("FatJets Branch has %u entries",bj -> p4 ->GetEntries())); +#endif + for (int iJet=0;iJet< bj -> p4 ->GetEntries() ; ++iJet) { #ifdef VERBOSE if (VERBOSE >1 ) { - cout <<"[LoadNero]::[FillJets]::[DEBUG2] considering jet: "< p4 ->GetEntries() <selBits ->size()< unc ->size() < bDiscr ->size() < matchedPartonPdgId -> size()<motherPdgId ->size()< grMotherPdgId -> size()< puId -> size() < p4 ->GetEntries() < p4 -> At(iJet)) ->Pt() < p4 -> At(iJet)) ->Eta() <SetP4( *(TLorentzVector*) ((*bj->p4)[iJet]) ); - // JES - //Log(__FUNCTION__,"DEBUG",Form("Going to Fill Jes for jet: %d",iJet)); - - //Log(__FUNCTION__,"DEBUG",Form(" JesUp=%f", (1. + bj -> unc -> at(iJet) ) * ((TLorentzVector*)(*bj->p4)[iJet])->Pt())); - //Log(__FUNCTION__,"DEBUG",Form(" JesDown=%f", (1. - bj -> unc -> at(iJet) ) * ((TLorentzVector*)(*bj->p4)[iJet])->Pt())); - - //Log(__FUNCTION__,"DEBUG","-> Done"); - // --- // add it event_ -> fat_ . push_back(j); + +#ifdef VERBOSE + if(VERBOSE>1) Log(__FUNCTION__,"DEBUG","Done"); +#endif } return; From 855f00fba4255cbb16a1da384a046896d3564b70 Mon Sep 17 00:00:00 2001 From: maria Date: Tue, 14 Mar 2017 16:07:10 +0100 Subject: [PATCH 4/4] add more basic variable/function --- interface/AnalysisChargedHiggsTBfullHad.hpp | 17 ++ src/AnalysisChargedHiggsTBfullHad.cpp | 320 +++++++++++++++++++- 2 files changed, 331 insertions(+), 6 deletions(-) diff --git a/interface/AnalysisChargedHiggsTBfullHad.hpp b/interface/AnalysisChargedHiggsTBfullHad.hpp index 5e9b445dabf1e..5585df2c56110 100644 --- a/interface/AnalysisChargedHiggsTBfullHad.hpp +++ b/interface/AnalysisChargedHiggsTBfullHad.hpp @@ -40,6 +40,17 @@ class ChargedHiggsTopBottomFullHad: virtual public AnalysisBase int analyze(Event*,string systname) override; const string name() const override {return "ChargedHiggsTopBottomFullHad";} + // Tree + bool writeTree = false; + void setTree(Event*e, string label, string category); + + // Variables for MVA + + template + void SetVariable( string name, T value){ varValues_.Set(name, value); } + void AddVariable( string name, char type, int r); + void AddSpectator( string name, char type, int r); + vector weights; @@ -54,6 +65,12 @@ class ChargedHiggsTopBottomFullHad: virtual public AnalysisBase }; double evt_HT=-1; + double evt_minDRbb=-1; + double evt_minDRbb_invMass=-1; + double evt_DEtaMaxBB=-1; + + double evt_C=0; + ///// ///// diff --git a/src/AnalysisChargedHiggsTBfullHad.cpp b/src/AnalysisChargedHiggsTBfullHad.cpp index baa06e0b46605..0dd4a32ba620d 100644 --- a/src/AnalysisChargedHiggsTBfullHad.cpp +++ b/src/AnalysisChargedHiggsTBfullHad.cpp @@ -26,10 +26,9 @@ void ChargedHiggsTopBottomFullHad::SetJetCuts(Jet *j){ void ChargedHiggsTopBottomFullHad::SetTauCuts(Tau *t){ // these are used for the Veto t->SetPtCut(20); - /// MARIA FIXME 2.4 --> 2.3 - t->SetEtaCut(2.4); - t->SetMuRej(false); - t->SetEleRej(false); + t->SetEtaCut(2.3); + t->SetMuRej(true); + t->SetEleRej(true); t->SetTrackPtCut(-1.); // no requirement on the leading Track t->SetIsoRelCut(-1); // LooseCombinedIsolationDeltaBetaCorr3Hits t->SetIsoCut(2.5); @@ -37,12 +36,269 @@ void ChargedHiggsTopBottomFullHad::SetTauCuts(Tau *t){ t->SetDecayMode(1); // 0=TauDecayModeFindingNewDMs 1=TauDecayModeFinding } +void ChargedHiggsTopBottomFullHad::setTree(Event*e, string label, string category ) +{ + + SetTreeVar("run",e->runNum()); + SetTreeVar("lumi",e->lumiNum()); + SetTreeVar("evt",e->eventNum()); + SetTreeVar("isRealData",e->IsRealData()); + + SetTreeVar("weight",e->weight()); + SetTreeVar("npv",e->Npv()); + SetTreeVar("weight_pu",e->GetWeight()->GetBarePUWeight()); + SetTreeVar("weight_bTag",e->GetWeight()->GetSF("btag")->get()); + SetTreeVar("weight_topPt",e->GetWeight()->GetSF("topreweight")->get()); + SetTreeVar("weight_nEv",e->GetWeight()->GetBareNevents()); + SetTreeVar("xsec",e->GetWeight()->GetBareMCXsec()); + + SetTreeVar("NJets",e->Njets()); + SetTreeVar("NcentralJets",e->NcentralJets()); + SetTreeVar("NBJets",e->Bjets()); + + for(int i=0;i!=min(e->Njets(),10);++i) { + // for(int i=0;i!=10;++i) { // fill only the first 10 jets + SetTreeVar("jet_pt",i,e->GetJet(i)->Pt()); + SetTreeVar("jet_eta",i,e->GetJet(i)->Eta()); + SetTreeVar("jet_phi",i,e->GetJet(i)->Phi()); + SetTreeVar("jet_e",i,e->GetJet(i)->E()); + SetTreeVar("jet_discr",i,e->GetJet(i)->bdiscr); + } + + for(int i=0;i!=min(e->Bjets(),10);++i) { + // for(int i=0;i!=10;++i) { // fill only the first 10 jets + SetTreeVar("bjet_pt",i,e->GetBjet(i)->Pt()); + SetTreeVar("bjet_eta",i,e->GetBjet(i)->Eta()); + SetTreeVar("bjet_phi",i,e->GetBjet(i)->Phi()); + SetTreeVar("bjet_e",i,e->GetBjet(i)->E()); + SetTreeVar("bjet_discr",i,e->GetBjet(i)->bdiscr); + } + + SetTreeVar("met_pt",e->GetMet().Pt()); + SetTreeVar("met_phi",e->GetMet().Phi()); + + SetTreeVar("ht",evt_HT); + SetTreeVar("DRbbmin",evt_minDRbb); + SetTreeVar("MassDRbbmin",evt_minDRbb_invMass); + + SetTreeVar("DEtaMaxBB",evt_DEtaMaxBB); + + SetTreeVar("Cen",evt_C); + + if (label.find("Hplus") !=string::npos) // SIG + { + SetTreeVar("sig",1); + } + else{ // BKG + SetTreeVar("sig",0); + } + + int mc=0; + if (label.find("HplusToTB") !=string::npos) //sig + { + // mc = 0; + // low mass + if (label.find("M-180") !=string::npos) mc = 1; + if (label.find("M-200") !=string::npos) mc = 2; + if (label.find("M-220") !=string::npos) mc = 3; + if (label.find("M-250") !=string::npos) mc = 4; + if (label.find("M-300") !=string::npos) mc = 5; + if (label.find("M-350") !=string::npos) mc = 6; + if (label.find("M-400") !=string::npos) mc = 7; + if (label.find("M-450") !=string::npos) mc = 8; + if (label.find("M-500") !=string::npos) mc = 9; + // high mass + if (label.find("M-750") !=string::npos) mc = 10; + if (label.find("M-800") !=string::npos) mc = 11; + if (label.find("M-1000")!=string::npos) mc = 12; + if (label.find("M-2000")!=string::npos) mc = 13; + if (label.find("M-3000")!=string::npos) mc = 14; + + + } else if (label.find("HplusToTauNu") !=string::npos) //sig TauNu + { + // mc = 50; + if (label.find("M-180") !=string::npos) mc = 51; + if (label.find("M-200") !=string::npos) mc = 52; + if (label.find("M-220") !=string::npos) mc = 53; + if (label.find("M-250") !=string::npos) mc = 54; + if (label.find("M-300") !=string::npos) mc = 55; + if (label.find("M-400") !=string::npos) mc = 57; + if (label.find("M-500") !=string::npos) mc = 59; + if (label.find("M-800") !=string::npos) mc = 61; + if (label.find("M-1000")!=string::npos) mc = 62; + if (label.find("M-2000")!=string::npos) mc = 63; + if (label.find("M-3000")!=string::npos) mc = 64; + + } else // bkg + { + // ttbar + single top + ttV + // mc = 100; + if(label.find("TTTo2L2Nu") !=string::npos) mc =101 ; + if(label.find("TTToSemilepton") !=string::npos) mc =102 ; + if(label.find("TT_TuneCUETP8M2T4") !=string::npos) mc =103 ; + + if(label.find("ST") !=string::npos) mc =111 ; + // if(label.find("ST_tW_top") !=string::npos) mc =111 ; + // if(label.find("ST_tW_antitop") !=string::npos) mc =112 ; + // if(label.find("ST_t-channel_top") !=string::npos) mc =113 ; + // if(label.find("ST_t-channel_antitop") !=string::npos) mc =114 ; + // if(label.find("ST_s-channel_4f") !=string::npos) mc =115 ; + if(label.find("tZq") !=string::npos) mc =116 ; + // if(label.find("tZq_ll_4f") !=string::npos) mc =116 ; + // if(label.find("tZq_nunu_4f") !=string::npos) mc =117 ; + + // tt+X with X=Z,W,H,TT + if(label.find("TTZ") !=string::npos) mc = 121; + // if(label.find("TTZToQQ") !=string::npos) mc = 121; + // if(label.find("TTZToLLNuNu") !=string::npos) mc =122 ; + if(label.find("TTW") !=string::npos) mc =123 ; + // if(label.find("TTWJetsToQQ") !=string::npos) mc =123 ; + // if(label.find("TTWJetsToLNu") !=string::npos) mc =124 ; + if(label.find("ttH") !=string::npos) mc =125 ; + // if(label.find("ttHJetTobb") !=string::npos) mc =125 ; + // if(label.find("ttHJetToNonbb") !=string::npos) mc =126 ; + if(label.find("TTTT") !=string::npos) mc =127 ; + if(label.find("TTG") !=string::npos) mc =128 ; + + // V+jets + // mc = 200; + if(label.find("DYJetsToLL_M") !=string::npos) mc =221 ; + if(label.find("WJetsToLNu")!=string::npos) mc =222; + + // EWK + // missing tribosons + // mc = 300; + if(label.find("WWTo") !=string::npos) mc =331 ; + // if(label.find("WWTo2L2Nu") !=string::npos) mc =331 ; + // if(label.find("WWToLNuQQ") !=string::npos) mc =332 ; + if(label.find("WZTo") !=string::npos) mc =333 ; + // if(label.find("WZTo1L1Nu2Q") !=string::npos) mc =333 ; + // if(label.find("WZTo1L3Nu") !=string::npos) mc =334 ; + // if(label.find("WZTo2L2Q") !=string::npos) mc =335 ; + // if(label.find("WZTo3LNu") !=string::npos) mc =336 ; + if(label.find("ZZTo") !=string::npos) mc =337 ; + // if(label.find("ZZTo2L2Nu") !=string::npos) mc =337 ; + // if(label.find("ZZTo2L2Q") !=string::npos) mc =338 ; + // if(label.find("ZZTo4L") !=string::npos) mc =339 ; + if(label.find("VHToNonbb_M125") !=string::npos) mc =340 ; + if(label.find("WH_HToBB_WToLNu_M125") !=string::npos) mc =341 ; + + } + + SetTreeVar("mc",mc); + + SetTreeVar("genTTid",e->GetGenTtbarId()); + +} + + +void ChargedHiggsTopBottomFullHad::AddSpectator( string name, char type, int r){ + + cout<<"[TmvaAnalysis]::[AddSpectator]::[INFO] Adding variable: '"< AddSpectator(name.c_str(), (int*)varValues_.GetPointer(name)); + else if ( type == 'F') readers_[r] -> AddSpectator(name.c_str(), (float*)varValues_.GetPointer(name)); + //else if ( type == 'D') for(auto &r : readers_) r -> AddVariable(name.c_str(), (double*)varValues_.GetPointer(name)); + else { + cout <<"[TmvaAnalysis]::[AddSpectator]::[ERROR] type '"< AddVariable(name.c_str(), (int*)varValues_.GetPointer(name)); + // else if ( type == 'F') for(auto&r : readers_) r -> AddVariable(name.c_str(), (float*)varValues_.GetPointer(name)); + if ( type == 'I') readers_[r] -> AddVariable(name.c_str(), (int*)varValues_.GetPointer(name)); + else if ( type == 'F') readers_[r] -> AddVariable(name.c_str(), (float*)varValues_.GetPointer(name)); + //else if ( type == 'D') for(auto &r : readers_) r -> AddVariable(name.c_str(), (double*)varValues_.GetPointer(name)); + else { + cout <<"[TmvaAnalysis]::[AddVariable]::[ERROR] type '"<BookMVA("BDTG",weights[i].c_str()); + } + cout <<"[TmvaAnalysis]::[Init]::[INFO] Done"<Bjets()>1) { + + double DEtaMaxBB=0.; + + for(int i=0;i!=e->Bjets();++i) { + Jet* bj = e->GetBjet(i); + for(int j=0;j!=e->Bjets();++j) { + if (j==i) continue; + Jet* bjet = e->GetBjet(j); + if(bj->DeltaEta(*bjet)>DEtaMaxBB) DEtaMaxBB=bj->DeltaEta(*bjet); + + // double dr = bjet->DeltaR(e->GetBjet(j)); + // double mass = (bjet->GetP4() + e->GetBjet(j)->GetP4()).M(); + // if(drmaxDRbb and i==0) { maxDRbb=dr; maxDRbb_invMass=mass; indexMaxJ=j;} + } + } + + evt_DEtaMaxBB=DEtaMaxBB; + + } + + + double DEtaMaxJJ=0.; + + for(int i=0;i!=e->Njets();++i) { + Jet* lj = e->GetJet(i); + for(int j=0;j!=e->Njets();++j) { + if (j==i) continue; + Jet* jet = e->GetJet(j); + if(lj->DeltaEta(*jet)>DEtaMaxJJ) DEtaMaxJJ=lj->DeltaEta(*jet); + + // double dr = bjet->DeltaR(e->GetBjet(j)); + // double mass = (bjet->GetP4() + e->GetBjet(j)->GetP4()).M(); + // if(drmaxDRbb and i==0) { maxDRbb=dr; maxDRbb_invMass=mass; indexMaxJ=j;} + } + } + + + } void ChargedHiggsTopBottomFullHad::jetPlot(Event*e, string label, string category, string systname, string phasespace) { @@ -242,12 +539,12 @@ int ChargedHiggsTopBottomFullHad::analyze(Event*e,string systname) Fill("ChargedHiggsTopBottom/CutFlow/CutFlow_"+label,systname,0,e->weight()); - if ( e->Nleps() == 0 ) cut.SetCutBit(NoLep); // only two lep <--- kill multiboson/ttV + if ( e->Nleps() == 0 ) cut.SetCutBit(NoLep); // kill Top/W/Z if ( cut.passAllUpTo(NoLep) ) Fill("ChargedHiggsTopBottom/CutFlow/CutFlow_"+label,systname,NoLep,e->weight()); if(!cut.passAllUpTo(NoLep) ) return EVENT_NOT_USED; - std::cout << " e->NFatJets() = " << e->NFatJets() << std::endl; + // std::cout << " e->NFatJets() = " << e->NFatJets() << std::endl; //////// //// UP TO NOW: LEPTONS selection only @@ -260,6 +557,17 @@ int ChargedHiggsTopBottomFullHad::analyze(Event*e,string systname) string category=""; jetPlot(e, label, category, systname,"Baseline"); + + // //////// + // //// + // //// Fill tree + // //// + + if (systname.find("NONE") !=string::npos) { + if(writeTree) setTree(e,label,category); + if(writeTree) FillTree("tree_tb"); + } + return EVENT_NOT_USED; }