diff --git a/dat/configDY.dat b/dat/configDY.dat index 5941e8ef3574d..9ad58536a9aae 100644 --- a/dat/configDY.dat +++ b/dat/configDY.dat @@ -8,41 +8,15 @@ sub=tag|v1.4 sub=amarini|/store/user/amarini/Nero sub=klute|/store/user/klute/Nero +include=dat/config.dat + ################ ### DATASETS ### ################ -#### BKG ### -Files=%(klute)s/%(tag)s/SingleMuon -#/store/user/amarini/Nero/%(tag)s/DYJetsToLL_M-50_TuneCUETP8M1_13TeV-amcatnloFXFX-pythia8 -#addfiles=/store/user/amarini/Nero/%(tag)s/WJetsToLNu_TuneCUETP8M1_13TeV-amcatnloFXFX-pythia8 -#addfiles=/store/user/amarini/Nero/v1.2/TTJets_TuneCUETP8M1_13TeV-madgraphMLM-pythia8 -##addfiles=/store/user/amarini/Nero/%(tag)s/TT_TuneCUETP8M1_13TeV-powheg-pythia8 -#### WW/WZ/ZZ### -#addfiles=/store/user/amarini/Nero/%(tag)s/WW_TuneCUETP8M1_13TeV-pythia8 -#addfiles=/store/user/amarini/Nero/%(tag)s/WZ_TuneCUETP8M1_13TeV-pythia8 -#addfiles=/store/user/amarini/Nero/%(tag)s/ZZ_TuneCUETP8M1_13TeV-pythia8 -#### SIGNAL ### -#### QCD -#addfiles=/store/user/amarini/Nero/%(tag)s/QCD_Pt_15to30_TuneCUETP8M1_13TeV_pythia8 -#addfiles=/store/user/amarini/Nero/%(tag)s/QCD_Pt_30to50_TuneCUETP8M1_13TeV_pythia8 -#addfiles=/store/user/amarini/Nero/%(tag)s/QCD_Pt_50to80_TuneCUETP8M1_13TeV_pythia8 -#addfiles=/store/user/amarini/Nero/%(tag)s/QCD_Pt_80to120_TuneCUETP8M1_13TeV_pythia8 -#addfiles=/store/user/amarini/Nero/%(tag)s/QCD_Pt_120to170_TuneCUETP8M1_13TeV_pythia8 -#addfiles=/store/user/amarini/Nero/%(tag)s/QCD_Pt_170to300_TuneCUETP8M1_13TeV_pythia8 -#addfiles=/store/user/amarini/Nero/%(tag)s/QCD_Pt_300to470_TuneCUETP8M1_13TeV_pythia8 -#addfiles=/store/user/amarini/Nero/%(tag)s/QCD_Pt_470to600_TuneCUETP8M1_13TeV_pythia8 -#addfiles=/store/user/amarini/Nero/%(tag)s/QCD_Pt_600to800_TuneCUETP8M1_13TeV_pythia8 -#addfiles=/store/user/amarini/Nero/%(tag)s/QCD_Pt_800to1000_TuneCUETP8M1_13TeV_pythia8 -#addfiles=/store/user/amarini/Nero/%(tag)s/QCD_Pt_1000to1400_TuneCUETP8M1_13TeV_pythia8 -#addfiles=/store/user/amarini/Nero/%(tag)s/QCD_Pt_1400to1800_TuneCUETP8M1_13TeV_pythia8 -#addfiles=/store/user/amarini/Nero/%(tag)s/QCD_Pt_1800to2400_TuneCUETP8M1_13TeV_pythia8 -#addfiles=/store/user/amarini/Nero/%(tag)s/QCD_Pt_2400to3200_TuneCUETP8M1_13TeV_pythia8 -#addfiles=/store/user/amarini/Nero/%(tag)s/QCD_Pt_3200toInf_TuneCUETP8M1_13TeV_pythia8 -##### -##### DATA -#addfiles=/store/user/amarini/Nero/%(tag)s/SingleMuon -#addfiles=/store/user/amarini/Nero/%(tag)s/SingleElectron +Files= +include=dat/catalog/2015/dy.dat +#addfiles=%(amarini)s/%(tag)s/SingleMuon #__________________________________________________________________ #____________________ COMMON SETTINGS _____________________________ @@ -52,16 +26,6 @@ Output=DY.root ## Preselection:1,Preselection:2 Analysis=JsonAnalysis,DYAnalysis -MCDB=dat/mc_database.txt -SFDB=aux/sf_database.txt -Branches=dat/branches.txt -### -pileup=aux/pileup.root -pileupRun= -pileupLumi= -#Lumi=2110 ## doing nothing -Lumi=1 -### # additional JSON FILE for Data selection # Smearer @@ -74,7 +38,6 @@ Correct=NONE #________________________________________________________________ #____________________ CONFIGURATION _____________________________ # -config=MitPhiCorrector|fileName="aux/MetPhi.root" ########## ANALYSIS ################ ############# @@ -91,8 +54,3 @@ addConfig=DYAnalysis|AddLabel('WW'),AddLabel('WZ'),AddLabel('ZZ'),AddLabel('TT') include=dat/json.dat -#configure Analysis -#config=AnalysisBase|Init() -#config=Preselection| -#config=MetPhiCorrector|fileName="" - diff --git a/dat/configTauNuTheory.dat b/dat/configTauNuTheory.dat index 0c1b14a28585f..14d8f52e45c17 100644 --- a/dat/configTauNuTheory.dat +++ b/dat/configTauNuTheory.dat @@ -1,13 +1,12 @@ include=dat/configTauNu.dat sub=tag|v1.4.lhe -Files=%(amarini)s/%(tag)s/ChargedHiggs_HplusTB_HplusToTauNu_M-200_13TeV_amcatnlo_pythia8 -#addfiles=%(amarini)s/%(tag)s/ChargedHiggs_HplusTB_HplusToTauNu_M-250_13TeV_amcatnlo_pythia8 -addfiles=%(amarini)s/%(tag)s/ChargedHiggs_HplusTB_HplusToTauNu_M-300_13TeV_amcatnlo_pythia8 -addfiles=%(amarini)s/%(tag)s/ChargedHiggs_HplusTB_HplusToTauNu_M-350_13TeV_amcatnlo_pythia8 -addfiles=%(amarini)s/%(tag)s/ChargedHiggs_HplusTB_HplusToTauNu_M-400_13TeV_amcatnlo_pythia8 -addfiles=%(amarini)s/%(tag)s/ChargedHiggs_HplusTB_HplusToTauNu_M-500_13TeV_amcatnlo_pythia8 -MCDB=dat/mc_db_scales.dat +Files= +include=dat/catalog/2015/taunu.dat +#MCDB=dat/mc_db_scales.dat #Smear=NONE ## the %% is because the is a substitution before with the dictionaries Smear=NONE,@SmearScales("ScaleR"!1!0),@SmearScales("ScaleF"!0!1),@SmearScales("ScaleRF"!1!1),*[0!50]SmearPdfs(%%d) Output=ChHiggsTheory.root +Final=true +## be less peaky, given the n. of systs +EntryPerSecond=10 diff --git a/dat/configTmvaTrainer.dat b/dat/configTmvaTrainer.dat index 75392ee8c5ece..837848f1b41ca 100644 --- a/dat/configTmvaTrainer.dat +++ b/dat/configTmvaTrainer.dat @@ -2,11 +2,15 @@ include=dat/config.dat ########################################### # --small set for test -addfiles=/store/user/amarini/Nero/%(tag)s/Tau +#addfiles=/store/user/amarini/Nero/%(tag)s/Tau +Files= +include=dat/catalog/2015/taunu.dat +include=dat/catalog/2015/tt.dat +include=dat/catalog/2015/wnjets.dat Output=TmvaOutput.root Analysis=TmvaTrainer config=TmvaTrainer|AddLabel('HplusToTauNu_M-180_13TeV_amcatnlo'),AddLabel('HplusToTauNu_M-200_13TeV_amcatnlo'),AddLabel('HplusToTauNu_M-220_13TeV_amcatnlo'),AddLabel('HplusToTauNu_M-250_13TeV_amcatnlo'),AddLabel('HplusToTauNu_M-300_13TeV_amcatnlo'),AddLabel('HplusToTauNu_M-400_13TeV_amcatnlo'),AddLabel('HplusToTauNu_M-500_13TeV_amcatnlo') addConfig=TmvaTrainer|AddLabel("DY"),AddLabel("QCD"),AddLabel("TTJets"),AddLabel("WJets"),AddLabel("WW"),AddLabel("WZ"),AddLabel("ZZ") ## just save the tree for training -addConfig=TmvaTrainer|train=0 +#addConfig=TmvaTrainer|train=0 diff --git a/interface/Event.hpp b/interface/Event.hpp index 30630f22828e4..9908848f2a870 100644 --- a/interface/Event.hpp +++ b/interface/Event.hpp @@ -99,17 +99,19 @@ class Event{ // inline Met GetMet( ) const { return met_;} // should be const, -- FIXED? but noCorrPt is not set correctly without & - inline float Rho() { return rho_; } - inline int Npv() { return npv_ ;} - inline float Ht() { float ht=0 ; for(auto j : jets_ ) if( j->IsJet() ) ht+= j->Pt() ; return ht;} - - inline int Njets(){int n=0; for(auto j : jets_) if(j->IsJet()) n++; return n;} - inline int NjetsInvIso(){int n=0; for(auto j : jets_) if(j->IsJetInvIso()) n++; return n;} - inline int NcentralJets(){int n=0; for(auto j : jets_) if(j->IsCentralJet()) n++; return n;} - inline int NforwardJets(){int n=0; for(auto j : jets_) if(j->IsForwardJet()) n++; return n;} - inline int Bjets(){int n=0; for(auto j : jets_) if(j->IsBJet()) n++; return n;} - inline int Ljets(){int n=0; for(auto j : jets_) if(not j->IsBJet()) n++; return n;} - inline int BjetsInvIso(){int n=0; for(auto j : jets_) if(j->IsBJetInvIso()) n++; return n;} + inline float Rho() const { return rho_; } + inline int Npv() const { return npv_ ;} + inline float Ht() const { float ht=0 ; for(auto j : jets_ ) if( j->IsJet() ) ht+= j->Pt() ; return ht;} + inline float HtInvIso() const { float ht=0 ; for(auto j : jets_ ) if( j->IsJetInvIso() ) ht+= j->Pt() ; return ht;} + + inline int Njets()const {int n=0; for(auto j : jets_) if(j->IsJet()) n++; return n;} + inline int NjetsInvIso()const {int n=0; for(auto j : jets_) if(j->IsJetInvIso()) n++; return n;} + inline int NcentralJets() const {int n=0; for(auto j : jets_) if(j->IsCentralJet()) n++; return n;} + inline int NcentralJetsInvIso() const {int n=0; for(auto j : jets_) if(j->IsCentralJetInvIso()) n++; return n;} + inline int NforwardJets()const {int n=0; for(auto j : jets_) if(j->IsForwardJet()) n++; return n;} + 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 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/GenParticle.hpp b/interface/GenParticle.hpp index e4b01fc6f2532..47b5333dd6ddd 100644 --- a/interface/GenParticle.hpp +++ b/interface/GenParticle.hpp @@ -19,6 +19,7 @@ class GenParticle : virtual public Object unsigned GetFlag() const { return flags_;} void SetFlags(unsigned x) { flags_ = x;} bool IsPromptFinalState() const { return flags_ & BareMonteCarlo::PromptFinalState ;} + bool IsDressed() const { return flags_ & BareMonteCarlo::Dressed;} int GetParentPdgId() const { return mopdgid_;} int GetParentIdx() const {return moidx_;} diff --git a/interface/Jet.hpp b/interface/Jet.hpp index c5ebdf61e9700..5389bec0a2267 100644 --- a/interface/Jet.hpp +++ b/interface/Jet.hpp @@ -108,6 +108,12 @@ class Jet : virtual public Object, virtual public SmearableComplex return 1; } + inline int IsCentralJetInvIso() const { + if ( not IsJetInvIso() ) return 0; + if ( fabs(Eta()) >= etacutcentral_ ) return 0; + return 1; + } + inline int IsForwardJet() const { if ( not IsJet() ) return 0; if ( fabs(Eta()) < etacutcentral_ ) return 0; diff --git a/interface/TmvaTrainer.hpp b/interface/TmvaTrainer.hpp index 022c1b1718570..cff28c505efb4 100644 --- a/interface/TmvaTrainer.hpp +++ b/interface/TmvaTrainer.hpp @@ -1,8 +1,6 @@ #ifndef TMVA_TRAINER_H #define TMVA_TRAINER_H -#include "TMVA/Factory.h" -#include "TMVA/Tools.h" #include "TTree.h" #include "interface/AnalysisBase.hpp" @@ -12,22 +10,17 @@ class TmvaTrainer : virtual public AnalysisBase { private: - TMVA::Factory *factory_; - TFile *fout_; vector variables_; DataStore varsValues_; public: - TmvaTrainer(); - ~TmvaTrainer(); + TmvaTrainer():AnalysisBase(){} + ~TmvaTrainer(){} virtual int analyze(Event*,string systname); int analyzeInvIso(Event*e,string systname); virtual void Init(); - virtual void End(); virtual const string name(){return "TmvaTrainer";} virtual void AddVariable( string, char, double=0.,double=0.); - - bool train; }; #endif diff --git a/interface/Weight.hpp b/interface/Weight.hpp index 9181929a2df4b..b237cde4bab3b 100644 --- a/interface/Weight.hpp +++ b/interface/Weight.hpp @@ -121,13 +121,13 @@ class Weight : virtual public SmearableBase { if (syst == MC::none and systPdf <0) return mcWeight_* mcXsec_ * lumi_ * sf_ * pu_.GetPUWeight(mcName_,puInt_,runNum_)/ nEvents_; else if (systPdf<0) - { + { // SCALES if (not scales_) {Log(__FUNCTION__,"ERROR","Scales reweighting uncorrect!!!");PrintInfo();} return scalesWeights_[syst] * scalesNeventReweight_[syst] * mcXsec_ * lumi_ * sf_ * pu_.GetPUWeight(mcName_,puInt_,runNum_)/ nEvents_; } else { // pdfs if (not pdfs_) {Log(__FUNCTION__,"ERROR","Pdfs reweighting uncorrect!!!"); PrintInfo();} - return pdfsWeights_[syst] * pdfsNeventReweight_[syst] * mcXsec_ * lumi_ * sf_ * pu_.GetPUWeight(mcName_,puInt_,runNum_)/ nEvents_; + return pdfsWeights_[systPdf] * pdfsNeventReweight_[systPdf] * mcXsec_ * lumi_ * sf_ * pu_.GetPUWeight(mcName_,puInt_,runNum_)/ nEvents_; } } double weight(){ diff --git a/python/Loop.py b/python/Loop.py index 929503047b49b..d4f4c3619aebe 100755 --- a/python/Loop.py +++ b/python/Loop.py @@ -81,6 +81,9 @@ def applyJson(obj,fname): if opts.verbose: PrintDat(cfg) +if 'EntryPerSecond' in cfg: + loop.SetEntryPerSecond( cfg['EntryPerSecond']) + ################ Loader #### if opts.verbose: print "-> Init Loader:",cfg['Loader'] loop.InitLoader(cfg['Loader']); diff --git a/python/ParseDat.py b/python/ParseDat.py index 77c1523c2704f..3c8d55aba267a 100644 --- a/python/ParseDat.py +++ b/python/ParseDat.py @@ -115,6 +115,9 @@ def ParseDat(name): ####### FLOAT ########## if key == 'Lumi': config[key]=FloatKey(value) + ####### INT ########## + if key == 'EntryPerSecond': + config[key]=IntKey(value) ####### V FLOAT ########## if key == 'pileupLumi': config[key]=vFloatKey(value) diff --git a/python/mcDatabase.py b/python/mcDatabase.py index 0fbca19ecf7ba..6efde6d8bab6f 100755 --- a/python/mcDatabase.py +++ b/python/mcDatabase.py @@ -24,6 +24,7 @@ #if '/eos/user' in opts.eos: cmd += " --childcount " cmd+=opts.eos + cmd += " || true" ##FIXME list = check_output(cmd,shell=True); for line in list.split('\n'): if line =='': continue diff --git a/script/buildworkspace.py b/script/buildworkspace.py index 6c63931a9a3c0..e8307c20fea29 100644 --- a/script/buildworkspace.py +++ b/script/buildworkspace.py @@ -493,7 +493,7 @@ def ImportPdfStatUncFromTH1(tfile, name,syst="TTSTAT", target="", add=[]): ## w ## print " FIX MH POINTS " ## print "#########################" for syst in systSig: - for sigMH in [ 200,250,300,350,400,500,750,1000,2000,3000]: + for sigMH in [ 200,250,300,350,400,500,750,1000,3000]: #for sigMH in [ 200,350,400,500]: for cat in range(0,opts.ncat): sigStr="HplusToTauNu_M-"+str(sigMH)+"_13TeV_amcatnlo" @@ -690,7 +690,7 @@ def writeNormSystList(name="lumi",valueL=["1.027","1.026"], regexpL=["TT","ST"]) regexp=regexp[1:] if (match and not invert) or (not match and invert): idx=i - break + continue if (idx>=0): datacard.write("\t"+valueL[idx]) @@ -716,7 +716,8 @@ def writeSyst(syst="JES"): systOrig=syst[:] syst=WorkspaceSubstitution(syst) datacard.write(syst+" shape") - for proc in mcAll: + for cat in range(0,opts.ncat): + for proc in mcAll: if 'STAT' in systOrig: if proc in re.sub('STAT','',systOrig): datacard.write("\t1") diff --git a/src/AnalysisChargedHiggsQCDPurity.cpp b/src/AnalysisChargedHiggsQCDPurity.cpp index 047d2d9f1dfbf..7b8536dde2c9c 100644 --- a/src/AnalysisChargedHiggsQCDPurity.cpp +++ b/src/AnalysisChargedHiggsQCDPurity.cpp @@ -91,16 +91,22 @@ void ChargedHiggsQCDPurity::Init() } // I don't need to split it by pt - Book( dir + "Mt"+"_"+ l , ("Mt "+ l).c_str(),8000,0.,8000); // same binning in TauNu - Book( dir + "MtIsoInv"+"_"+ l , ("MtIsoInv "+ l).c_str(),8000,0.,8000.); - Book( none + "EtMissIsoInv"+"_"+ l , ("EtMissIsoInv "+ l).c_str(),1000,0.,1000.); - Book( none + "EtMiss"+"_"+ l , ("EtMiss "+ l).c_str(),1000,0.,1000.); // copy of the Tau Nu ? + Book( dir + "Mt"+"_"+ l , ("Mt "+ l).c_str(),8000,0.,8000); // same binning in TauNu + Book( dir + "MtIsoInv"+"_"+ l , ("MtIsoInv "+ l).c_str(),8000,0.,8000.); + Book( none + "EtMissIsoInv"+"_"+ l , ("EtMissIsoInv "+ l).c_str(),1000,0.,1000.); + Book( none + "EtMiss"+"_"+ l , ("EtMiss "+ l).c_str(),1000,0.,1000.); // copy of the Tau Nu ? Book( none+"RbbMin_"+l,"RbbMin "+l+";R_{bb}^{min}",100,0,2*TMath::Pi()); Book( none+"RCollMin_"+l,"RCollMin "+l+";R_{coll}^{min}",100,0,2*TMath::Pi()); Book( none+"RbbMinIsoInv_"+l,"RbbMin IsoInv "+l+";R_{bb}^{min}",100,0,2*TMath::Pi()); Book( none+"RCollMinIsoInv_"+l,"RCollMin IsoInv "+l+";R_{coll}^{min}",100,0,2*TMath::Pi()); + // study categorization + for(int i=0;i<=1;++i) + { + Book( dir + "Mt_"+Form("cat%d",i)+"_"+ l , ("Mt "+ l).c_str(),8000,0.,8000); // same binning in TauNu + Book( dir + "MtIsoInv_"+Form("cat%d",i)+"_"+ l , ("MtIsoInv "+ l).c_str(),8000,0.,8000.); + } } } @@ -314,6 +320,10 @@ int ChargedHiggsQCDPurity::analyze(Event*e,string systname) if (t->GetNProng()==1) hist+="_1p"; else hist+="_3p"; Fill( dir + hist +"_"+label,systname, e->GetMet().Pt(), e->weight() ); + + if( e->Bjets()> 1)hist = "Mt_cat0"; + else hist = "Mt_cat1"; + Fill(dir+hist+"_"+label,systname, e->Mt() ,e->weight(false)); } // ---------------------- INF TAU SF @@ -395,6 +405,10 @@ int ChargedHiggsQCDPurity::analyze(Event*e,string systname) hist = HistName(pt,false, true,"Upar"); Fill( dir+hist +"_"+label,systname, Uperp(e,tInv), e->weight(false) ); + if( e->Bjets()> 1)hist = "MtIsoInv_cat0"; + else hist = "MtIsoInv_cat1"; + Fill(dir+hist+"_"+label,systname, e->Mt(Event::MtTauInv) ,e->weight(false)); + hist = HistName(pt, false, true) ; if (flavor == 15) hist += "_T"; else if (flavor == 21 ) hist+="_G"; diff --git a/src/AnalysisChargedHiggsTauNu.cpp b/src/AnalysisChargedHiggsTauNu.cpp index 19cd8a23bf2d2..89d8ac8c3e206 100644 --- a/src/AnalysisChargedHiggsTauNu.cpp +++ b/src/AnalysisChargedHiggsTauNu.cpp @@ -13,24 +13,28 @@ void ChargedHiggsTauNu::Init() Log(__FUNCTION__,"INFO", "Booking Histo CutFlow_" + l); Book( "ChargedHiggsTauNu/CutFlow/CutFlow_"+ l , ("CutFlow "+ l).c_str(),100,-.5,100-.5); - GetHisto("ChargedHiggsTauNu/CutFlow/CutFlow_"+l,"")->GetXaxis()->SetBinLabel(Total+1,"Total"); // bin shift - GetHisto("ChargedHiggsTauNu/CutFlow/CutFlow_"+l,"")->GetXaxis()->SetBinLabel(OneTau+1,"N_{taus} #geq 1"); - GetHisto("ChargedHiggsTauNu/CutFlow/CutFlow_"+l,"")->GetXaxis()->SetBinLabel(NoLep+1,"N_{leps} = 0"); - GetHisto("ChargedHiggsTauNu/CutFlow/CutFlow_"+l,"")->GetXaxis()->SetBinLabel(ThreeJets,"N_{jets} #geq 3"); - GetHisto("ChargedHiggsTauNu/CutFlow/CutFlow_"+l,"")->GetXaxis()->SetBinLabel(OneBjet,"N_{Bjets} #geq 1"); - GetHisto("ChargedHiggsTauNu/CutFlow/CutFlow_"+l,"")->GetXaxis()->SetBinLabel(Met,"MET > 60 GeV"); - //GetHisto("ChargedHiggsTauNu/CutFlow/CutFlow_"+l,"")->GetXaxis()->SetBinLabel(7,"R_{sr}^{Max} < 1.96"); - //GetHisto("ChargedHiggsTauNu/CutFlow/CutFlow_"+l,"")->GetXaxis()->SetBinLabel(7,"R_{sr}^{Max} < 140"); - GetHisto("ChargedHiggsTauNu/CutFlow/CutFlow_"+l,"")->GetXaxis()->SetBinLabel(AngColl,"R_{coll}^{Min}>40"); - GetHisto("ChargedHiggsTauNu/CutFlow/CutFlow_"+l,"")->GetXaxis()->SetBinLabel(AngRbb,"R_{bb}^{Min}>40"); - //GetHisto("ChargedHiggsTauNu/CutFlow/CutFlow_"+l,"")->GetXaxis()->SetBinLabel(7,"#Delta #phi (Tau,Jet1)<2.09"); + { + GetHisto("ChargedHiggsTauNu/CutFlow/CutFlow_"+l,"")->GetXaxis()->SetBinLabel(Total+1,"Total"); // bin shift + GetHisto("ChargedHiggsTauNu/CutFlow/CutFlow_"+l,"")->GetXaxis()->SetBinLabel(OneTau+1,"N_{taus} #geq 1"); + GetHisto("ChargedHiggsTauNu/CutFlow/CutFlow_"+l,"")->GetXaxis()->SetBinLabel(NoLep+1,"N_{leps} = 0"); + GetHisto("ChargedHiggsTauNu/CutFlow/CutFlow_"+l,"")->GetXaxis()->SetBinLabel(ThreeJets,"N_{jets} #geq 3"); + GetHisto("ChargedHiggsTauNu/CutFlow/CutFlow_"+l,"")->GetXaxis()->SetBinLabel(OneBjet,"N_{Bjets} #geq 1"); + GetHisto("ChargedHiggsTauNu/CutFlow/CutFlow_"+l,"")->GetXaxis()->SetBinLabel(Met,"MET > 60 GeV"); + //GetHisto("ChargedHiggsTauNu/CutFlow/CutFlow_"+l,"")->GetXaxis()->SetBinLabel(7,"R_{sr}^{Max} < 1.96"); + //GetHisto("ChargedHiggsTauNu/CutFlow/CutFlow_"+l,"")->GetXaxis()->SetBinLabel(7,"R_{sr}^{Max} < 140"); + GetHisto("ChargedHiggsTauNu/CutFlow/CutFlow_"+l,"")->GetXaxis()->SetBinLabel(AngColl,"R_{coll}^{Min}>40"); + GetHisto("ChargedHiggsTauNu/CutFlow/CutFlow_"+l,"")->GetXaxis()->SetBinLabel(AngRbb,"R_{bb}^{Min}>40"); + //GetHisto("ChargedHiggsTauNu/CutFlow/CutFlow_"+l,"")->GetXaxis()->SetBinLabel(7,"#Delta #phi (Tau,Jet1)<2.09"); + } // Cut flow with QCD Book( "ChargedHiggsTauNu/CutFlowQCD/CutFlowQCD_"+l , ("CutFlowQCD "+ l).c_str(), 100, -.5, 100-.5); - GetHisto("ChargedHiggsTauNu/CutFlowQCD/CutFlowQCD_"+l,"")->GetXaxis()->SetBinLabel(1, "N_{taus} #geq 1 \\ N_{leps} = 0 \\ N_{jets} #geq 3 \\ Trigger"); - GetHisto("ChargedHiggsTauNu/CutFlowQCD/CutFlowQCD_"+l,"")->GetXaxis()->SetBinLabel(2,"N_{Bjets} #geq 1"); - GetHisto("ChargedHiggsTauNu/CutFlowQCD/CutFlowQCD_"+l,"")->GetXaxis()->SetBinLabel(3,"MET > 60 GeV"); - GetHisto("ChargedHiggsTauNu/CutFlowQCD/CutFlowQCD_"+l,"")->GetXaxis()->SetBinLabel(4,"R_{bb}^{Min}>40"); + { + GetHisto("ChargedHiggsTauNu/CutFlowQCD/CutFlowQCD_"+l,"")->GetXaxis()->SetBinLabel(1, "N_{taus} #geq 1 \\ N_{leps} = 0 \\ N_{jets} #geq 3 \\ Trigger"); + GetHisto("ChargedHiggsTauNu/CutFlowQCD/CutFlowQCD_"+l,"")->GetXaxis()->SetBinLabel(2,"N_{Bjets} #geq 1"); + GetHisto("ChargedHiggsTauNu/CutFlowQCD/CutFlowQCD_"+l,"")->GetXaxis()->SetBinLabel(3,"MET > 60 GeV"); + GetHisto("ChargedHiggsTauNu/CutFlowQCD/CutFlowQCD_"+l,"")->GetXaxis()->SetBinLabel(4,"R_{bb}^{Min}>40"); + } // -- cut flow 2 is the one used to synchronized with HIP Book( "ChargedHiggsTauNu/CutFlow/CutFlow2_"+ l , ("CutFlow "+ l).c_str(),100,-.5,100-.5); @@ -117,8 +121,13 @@ void ChargedHiggsTauNu::Init() * MT * **********************************************/ Book( "ChargedHiggsTauNu/Vars/Mt_"+l,"Mt "+l + ";m_{T} [GeV]",8000,0,8000); // the Vars directory contains the full selection + AddFinalHisto("ChargedHiggsTauNu/Vars/Mt_"+l); + // study categorization + for(int i=0;i<=1;++i) + { + Book( string("ChargedHiggsTauNu/Vars/Mt_")+Form("cat%d",i)+"_"+l,"Mt "+l + ";m_{T} [GeV]",8000,0,8000); // the Vars directory contains the full selection + } - // Study NLO Positive and negative shapes for interpolation and subtraction } @@ -597,7 +606,12 @@ int ChargedHiggsTauNu::analyze(Event*e,string systname) //if(e->IsRealData() and (systname=="NONE" or systname=="")) Log(__FUNCTION__,"SYNC",Form("%d,%d,%ld",e->runNum(),e->lumiNum(),e->eventNum()) ); // - if ( Unblind(e) and (e->IsRealData() or e->GetTau(0)->Rematch(e) == 15 )) Fill("ChargedHiggsTauNu/Vars/Mt_"+label,systname, e->Mt() ,e->weight()); + if ( Unblind(e) and (e->IsRealData() or e->GetTau(0)->Rematch(e) == 15 )) + { + Fill("ChargedHiggsTauNu/Vars/Mt_"+label,systname, e->Mt() ,e->weight()); + if (e->Bjets() >1) Fill("ChargedHiggsTauNu/Vars/Mt_cat0_"+label,systname, e->Mt() ,e->weight()); + else Fill("ChargedHiggsTauNu/Vars/Mt_cat1_"+label,systname, e->Mt() ,e->weight()); + } //if ( Unblind(e) ) Fill("ChargedHiggsTauNu/Vars/MtDecoQ_"+label,systname, e->MtDecoQ() ,e->weight()); //if ( Unblind(e) ) Fill("ChargedHiggsTauNu/Vars/MtDecoCosPhi_"+label,systname, e->MtDecoCosPhi() ,e->weight()); diff --git a/src/AnalysisDY.cpp b/src/AnalysisDY.cpp index f1f28f7dfe89c..4c18f471be887 100644 --- a/src/AnalysisDY.cpp +++ b/src/AnalysisDY.cpp @@ -1,10 +1,10 @@ #include "interface/AnalysisDY.hpp" -#warning DY ANALYSIS NON ISO +//#warning DY ANALYSIS NON ISO void DYAnalysis::SetLeptonCuts(Lepton *l){ l->SetIsoCut(-1); l->SetPtCut(25); - l->SetIsoRelCut(-1); + l->SetIsoRelCut(0.20); l->SetEtaCut(2.4); } @@ -46,6 +46,19 @@ void DYAnalysis::Init(){ Book ("DYAnalysis/Vars/MCloseJZ_"+ l ,"MCloseJZ", 1000,0,1000); // Book ("DYAnalysis/Vars/Pt20mm_"+ l ,"Ptmm20", 1000,0,1000); + + Book ("DYAnalysis/Vars/Accmm_"+ l ,";Events", 10,0,10); + { + GetHisto("DYAnalysis/Vars/Accmm_"+ l,"") ->GetXaxis() ->SetBinLabel(1,"Gen-Reco"); + GetHisto("DYAnalysis/Vars/Accmm_"+ l,"") ->GetXaxis() ->SetBinLabel(2,"Gen-!Reco"); + GetHisto("DYAnalysis/Vars/Accmm_"+ l,"") ->GetXaxis() ->SetBinLabel(3,"!Gen-Reco"); + } + Book ("DYAnalysis/Vars/Accee_"+ l ,";Events", 10,0,10); + { + GetHisto("DYAnalysis/Vars/Accee_"+ l,"") ->GetXaxis() ->SetBinLabel(1,"Gen-Reco"); + GetHisto("DYAnalysis/Vars/Accee_"+ l,"") ->GetXaxis() ->SetBinLabel(2,"Gen-!Reco"); + GetHisto("DYAnalysis/Vars/Accee_"+ l,"") ->GetXaxis() ->SetBinLabel(3,"!Gen-Reco"); + } } } @@ -62,16 +75,42 @@ int DYAnalysis::analyzeMM(Event *e, string systname) Jet *j0 = e->GetJet(0); Jet *j1 = e->GetJet(1); - if (mu0 == NULL or mu1 == NULL) return 0; + // Truth + GenParticle *genmu0=NULL; GenParticle *genmu1=NULL; - if (mu0->Pt() > 25 and fabs(mu0->Eta())< 2.4) + for( int iGen=0 ; /*empty*/ ; ++iGen) + { + GenParticle *g = e->GetGenParticle(iGen); + if (g==NULL ) break; // end loop statement + if (not g->IsDressed()) continue; + if (not abs(g->GetPdgId())==13) continue; + + if (genmu0== NULL) genmu0=g; + else if (genmu1==NULL) {genmu1=g; break;} + } + + bool genMuons = genmu0!=NULL and genmu1 !=NULL; + + bool isGen=false; + bool isReco=false; + if (genMuons) // no requirement on pT + { + Object Ztruth(*genmu0); + Ztruth += *genmu1; + if (Ztruth.M() > 60 and Ztruth.M()<120) isGen=true; + } + + bool recoMuons= mu0 != NULL and mu1 !=NULL; + //if (not recoMuons) return 0; + + if (mu0!=NULL and mu0->Pt() > 25 and fabs(mu0->Eta())< 2.4) { if (e->IsTriggered("HLT_IsoMu20") ) { Fill("DYAnalysis/Vars/MuonIso_"+ label,systname, mu0->Isolation(),e->weight()) ; } } - if ( mu1->Pt() >20) + if (recoMuons and mu1->Pt() >20) { // ------------------- 20 ------------------- Object Z(*mu0); Z += *mu1; @@ -82,7 +121,7 @@ int DYAnalysis::analyzeMM(Event *e, string systname) } // ---------------------- 25 ------------------- - if (mu1->Pt() >25) + if ( recoMuons and mu1->Pt() >25) { cut.SetCutBit(Leptons); if (e->IsTriggered("HLT_IsoMu20") ) cut.SetCutBit(Trigger); @@ -101,6 +140,7 @@ int DYAnalysis::analyzeMM(Event *e, string systname) Fill("DYAnalysis/Vars/Npvmm_"+ label,systname, e->Npv(),e->weight()) ; Fill("DYAnalysis/Vars/NJmm_"+ label,systname, e->NcentralJets(),e->weight()) ; Fill("DYAnalysis/Vars/PtmmUW_"+ label,systname, Z.Pt(),1.0) ; + isReco=true; } if ( Z.Pt() > 500) // NoSingleMuon Trigger -> ISO @@ -114,6 +154,10 @@ int DYAnalysis::analyzeMM(Event *e, string systname) if (j0!=NULL)Fill ("DYAnalysis/Vars/MCloseJZ_"+ label,systname,j0->InvMass(&Z) , e->weight()); } } + + if (isReco and isGen) Fill("DYAnalysis/Vars/Accmm_"+label,systname, 0); + else if ( isGen ) Fill("DYAnalysis/Vars/Accmm_"+label,systname, 1); + else if ( isReco ) Fill("DYAnalysis/Vars/Accmm_"+label,systname, 2); return 0; } @@ -132,9 +176,34 @@ int DYAnalysis::analyzeEE(Event *e, string systname) Jet *j0 = e->GetJet(0); Jet *j1 = e->GetJet(1); - if (e0 == NULL or e1 == NULL) return 0; + bool recoEles = e0 !=NULL and e1 !=NULL; + //if (e0 == NULL or e1 == NULL) return 0; + + GenParticle *genele0=NULL; GenParticle *genele1=NULL; + + for( int iGen=0 ; /*empty*/ ; ++iGen) + { + GenParticle *g = e->GetGenParticle(iGen); + if (g==NULL ) break; // end loop statement + if (not g->IsDressed()) continue; + if (not abs(g->GetPdgId())==11) continue; + + if (genele0== NULL) genele0=g; + else if (genele1==NULL) {genele1=g; break;} + } + + bool genEles = genele0!=NULL and genele1 !=NULL; + + bool isGen=false; + bool isReco=false; + if (genEles) // no requirement on pT + { + Object Ztruth(*genele0); + Ztruth += *genele1; + if (Ztruth.M() > 60 and Ztruth.M()<120) isGen=true; + } - if ( e1->Pt() >25) + if ( recoEles and e1->Pt() >25) { cut.SetCutBit(Leptons); //if (e->IsTriggered("HLT_Ele27_eta2p1_WPLoose_Gsf") ) cut.SetCutBit(Trigger); @@ -149,6 +218,7 @@ int DYAnalysis::analyzeEE(Event *e, string systname) Fill("DYAnalysis/Vars/Ptee_"+ label,systname, Z.Pt(),e->weight()) ; Fill("DYAnalysis/Vars/NJee_"+ label,systname, e->NcentralJets(),e->weight()) ; Fill("DYAnalysis/Vars/Npvee_"+ label,systname, e->Npv(),e->weight()) ; + isReco=true; } if ( Z.Pt() > 500) @@ -158,6 +228,10 @@ int DYAnalysis::analyzeEE(Event *e, string systname) } } + if (isReco and isGen) Fill("DYAnalysis/Vars/Accee_"+label,systname, 0); + else if ( isGen ) Fill("DYAnalysis/Vars/Accee_"+label,systname, 1); + else if ( isReco ) Fill("DYAnalysis/Vars/Accee_"+label,systname, 2); + return 0; } diff --git a/src/TmvaTrainer.cpp b/src/TmvaTrainer.cpp index d17b76dce863c..61b9c12a1e8f5 100644 --- a/src/TmvaTrainer.cpp +++ b/src/TmvaTrainer.cpp @@ -7,28 +7,18 @@ using namespace std; -TmvaTrainer::TmvaTrainer() : AnalysisBase(){ - factory_=NULL; - train = true; -} - -TmvaTrainer::~TmvaTrainer() { - if(factory_!=NULL) delete factory_; -} - void TmvaTrainer::AddVariable(string name, char type ,double xmin,double xmax) { cout<<"[TmvaTrainer]::[AddVariable]::[INFO] : "< AddVariable(name.c_str(),type,xmin,xmax); Branch("tmva_tree",name,type); } int TmvaTrainer::analyzeInvIso(Event*e,string systname) { - Jet* j1 = e->LeadJet(); - Jet * bj1 = e->LeadBjet(); + Jet* j1 = e->GetJetInvIso(0); + Jet * bj1 = e->GetBjetInvIso(0); Tau *t1 = e->GetTauInvIso(0); if (e->Nleps() >0 ) return 0; @@ -41,14 +31,15 @@ int TmvaTrainer::analyzeInvIso(Event*e,string systname) SetTreeVar("sig",0); SetTreeVar("mc",-200); // data driven bkg - SetTreeVar("NJets",e->Njets()); - SetTreeVar("NCJets",e->NcentralJets()); - SetTreeVar("BJets",e->Bjets()); + SetTreeVar("NJets",e->NjetsInvIso()); + SetTreeVar("NCJets",e->NcentralJetsInvIso()); + SetTreeVar("BJets",e->BjetsInvIso()); SetTreeVar("etat1",t1->Eta()); SetTreeVar("phit1",t1->Phi()); SetTreeVar("phimet",e->GetMet().Phi()); SetTreeVar("ht",e->Ht()); SetTreeVar("weight",e->weight()); + SetTreeVar("mt",e->Mt()); if (j1 != NULL ) SetTreeVar("pTj1",j1->Pt()); else SetTreeVar("pTj1",0); @@ -101,6 +92,7 @@ int TmvaTrainer::analyze(Event*e, string systname) SetTreeVar("phimet",e->GetMet().Phi()); SetTreeVar("ht",e->Ht()); SetTreeVar("weight",e->weight()); + SetTreeVar("mt",e->Mt()); if (j1 != NULL ) SetTreeVar("pTj1",j1->Pt()); else SetTreeVar("pTj1",0); @@ -120,27 +112,24 @@ int TmvaTrainer::analyze(Event*e, string systname) if (label.find("amcatnlo") != string::npos) { mc= 200; - 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-400") !=string::npos) mc += 6; - } - else if (label.find("Hplus") !=string::npos) - { - mc=100 ; - if (label.find("M200") !=string::npos) mc += 1; - if (label.find("M250") !=string::npos) mc += 2; - if (label.find("M500") !=string::npos) mc += 3; - if (label.find("M900") !=string::npos) mc += 4; + if (label.find("M-180_") !=string::npos) mc += 1; + else if (label.find("M-200_") !=string::npos) mc += 2; + else if (label.find("M-220_") !=string::npos) mc += 3; + else if (label.find("M-250_") !=string::npos) mc += 4; + else if (label.find("M-300_") !=string::npos) mc += 5; + else if (label.find("M-400_") !=string::npos) mc += 6; + else if (label.find("M-500_") !=string::npos) mc += 7; + else if (label.find("M-800_") !=string::npos) mc += 8; + else if (label.find("M-1000_") !=string::npos) mc += 9; + else if (label.find("M-2000_") !=string::npos) mc += 10; + else if (label.find("M-3000_") !=string::npos) mc += 11; } else // bkg { mc = -100; if(label.find("QCD") != string::npos) mc -=1 ; if(label.find("DY") != string::npos) mc -=2 ; - if(label.find("TTJets") != string::npos) mc -=3 ; + if(label.find("TT") != string::npos) mc -=3 ; if(label.find("WJets") != string::npos) mc -=4 ; if(label.find("WW") != string::npos) mc -=5 ; if(label.find("WZ") != string::npos) mc -=6 ; @@ -170,17 +159,11 @@ int TmvaTrainer::analyze(Event*e, string systname) void TmvaTrainer::Init(){ // output is already set - if(VERBOSE>0) cout<<"[TmvaTrainer]::[Init]::[DEBUG]::[1] InstanceTMVA "<0) cout<<"[TmvaTrainer]::[Init]::[DEBUG]::[1] Construct Factory "<0) cout<<"[TmvaTrainer]::[Init]::[DEBUG]::[1] AddVariables "<SetWeightExpression("weight"); } -void TmvaTrainer::End(){ - - // if I just want to save the tree - if (not train) return; - //TODO, outdated, update with the offline one - if(VERBOSE>0) cout<<"[TmvaTrainer]::[End]::[DEBUG]::[1] AddSignal and Bkg "<0) PrintTree("tmva_tree"); - - factory_->AddSignalTree( GetTree("tmva_tree")); - factory_->AddBackgroundTree( GetTree("tmva_tree")); - - TCut sigCut ("sig > 0.5"); - TCut bgCut ("sig <= 0.5"); - - factory_-> PrepareTrainingAndTestTree(sigCut, bgCut, - "nTrain_Signal=0:nTrain_Background=0:SplitMode=Random:NormMode=NumEvents:!V"); - - if(VERBOSE>0) cout<<"[TmvaTrainer]::[End]::[DEBUG]::[1] Book Methods "<BookMethod(TMVA::Types::kBDT, "BDT", - "!H:!V:NTrees=850:MinNodeSize=5%:MaxDepth=3:BoostType=AdaBoost:AdaBoostBeta=0.5:SeparationType=GiniIndex:nCuts=20:PruneMethod=NoPruning" - ); - if(VERBOSE>0) cout<<"[TmvaTrainer]::[End]::[DEBUG]::[1] Train"< TrainAllMethods(); - if(VERBOSE>0) cout<<"[TmvaTrainer]::[End]::[DEBUG]::[1] Test"< TestAllMethods(); - if(VERBOSE>0) cout<<"[TmvaTrainer]::[End]::[DEBUG]::[1] Evaluate"< EvaluateAllMethods(); - if(VERBOSE>0) cout<<"[TmvaTrainer]::[End]::[DEBUG]::[1] >-> DONE <-<"<=0) + { + Log(__FUNCTION__,"INFO",Form("step 6 (W) =%lf",pdfsWeights_[systPdf] * pdfsNeventReweight_[systPdf])); + Log(__FUNCTION__,"INFO",Form("step 7 (NeRW)=%lf",pdfsNeventReweight_[systPdf])); + + } + + if (syst != MC::none and systPdf<0) + { + Log(__FUNCTION__,"INFO",Form("step 6 (W) =%lf",scalesWeights_[syst] * pdfsNeventReweight_[syst])); + Log(__FUNCTION__,"INFO",Form("step 7 (NeRW)=%lf",scalesNeventReweight_[syst])); + + } + if (syst != MC::none){ Log(__FUNCTION__,"INFO"," --- SCALES ---"); for(int i=0;i< MC_MAX_SCALES ;++i) diff --git a/test/train_tree.C b/test/train_tree.C index 0c901ea0ee177..e57293a027274 100644 --- a/test/train_tree.C +++ b/test/train_tree.C @@ -54,15 +54,16 @@ void train( string fileName="test/mysub/Tmva/TmvaOutput.root",string bkg="QCD", int mcSig =0; if (sig == "200") mcSig = 202; - else if (sig == "400") mcSig = 206; else if (sig == "180") mcSig = 201; - else if (sig=="200LO") mcSig=101; - else if (sig=="500LO") mcSig=103; - else if (sig=="900LO") mcSig=104; + else if (sig == "400") mcSig = 206; + else if (sig == "500") mcSig = 207; + else if (sig == "800") mcSig = 208; + else if (sig == "1000") mcSig = 209; else cout<<"ERROR: NO sig "<