Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 13 additions & 2 deletions README
Original file line number Diff line number Diff line change
@@ -1,2 +1,13 @@
#how to use the macro
root -l VHPlotter.C+\(\"histoname\",1\);
# how to run analysis code to read ntuples, apply selection and svae histogram

choose flag_xxx = 1/0 to decide which sample you want to run
choose macro = xAna_ele/xAna_mu to decide electron/muon channel you want to run
choose outputFolder = output_ele/output_mu for the output file folder

Then just one Go
./globalRun.sh


# how to use the make plot, just ONE GO
./runPlot.sh

43 changes: 30 additions & 13 deletions VHPlotter.C
Original file line number Diff line number Diff line change
Expand Up @@ -35,19 +35,24 @@
#include "TLegend.h"
#include "TLatex.h"
#include "TVirtualFitter.h"
#include "TString.h"

#include <fstream>
#include <sstream>
#include <iomanip>
#include <iostream>
#include <TSystemDirectory.h>
#include "interface/setNCUStyle.h"
#include "interface/readHists.h"


string path = "/afs/cern.ch/user/v/vieri/work/ZH_Analysis/CMSSW_8_0_15/src/ZHAnalysis/DataMC_comparison/";
//string path = "/afs/cern.ch/work/y/yuchang/public/show_vieri_DataMC_comparison/output_with_PUweight/";

string path = "/afs/cern.ch/work/y/yuchang/ZH_analysis_with_2016_data/CMSSW_8_0_8/src/DataMC_comparison/test_ele_with_PUweight/output_ele/";

//string path = "/afs/cern.ch/user/v/vieri/work/ZH_Analysis/CMSSW_8_0_15/src/ZHAnalysis/DataMC_comparison/";

//void VHPlotter(string title="", int plot=0) {
void VHPlotter(string title="", int plot=0, TCanvas* c1=0 ) {

void VHPlotter(string title="", int plot=0) {

string subdir="0";
string postfix="";
Expand Down Expand Up @@ -173,8 +178,8 @@ hs->Add(h_mc3);
hs->Add(h_mc2);
hs->Add(h_mcDY);

TCanvas* c1 = 0;
c1 = new TCanvas("c","c",10,10,800,600);
//TCanvas* c1 = 0;
//c1 = new TCanvas("c","c",10,10,800,600);
c1->cd();

TPad *pad1 = new TPad("pad1","pad1",0.0,0.3,1.0,1.0);
Expand All @@ -187,10 +192,10 @@ hs->Draw("HIST");
hs->GetYaxis()->SetTitle("Events");
hs->GetYaxis()->SetTitleSize(0.05);
hs->GetYaxis()->SetLabelSize(0.045);
hs->GetYaxis()->SetTitleOffset(0.7);
hs->GetYaxis()->SetTitleOffset(1.0);// 0.7
hs->SetMinimum(8);
hs->SetMaximum(1.2*hs->GetMaximum());

if (title=="ZHmass") { hs->GetXaxis()->SetRangeUser(0, 3000); }

h_data->Draw("EPX0SAMES");
h_data->SetMarkerColor(kBlack);
Expand All @@ -199,7 +204,10 @@ h_data->SetMarkerSize (1.0);
h_data->SetStats(0);

TLegend *leg;
leg = new TLegend(0.65, 0.547, 0.91, 0.88);

if (title=="FATjetTau2dvTau1") { leg = new TLegend(0.15, 0.547, 0.41, 0.88); }
else { leg = new TLegend(0.65, 0.547, 0.91, 0.88);}
//leg = new TLegend(0.65, 0.547, 0.91, 0.88);
leg->SetBorderSize(0);
leg->SetEntrySeparation(0.01);
leg->SetFillColor(0);
Expand All @@ -216,14 +224,21 @@ leg->AddEntry(h_mc8,"ZH powheg","f");

leg->Draw();

TLatex *lar = new TLatex();
lar->SetNDC(kTRUE);
lar->SetTextSize(0.04);
lar->SetLineWidth(5);
lar->DrawLatex(0.14, 0.94, "CMS #it{#bf{2016}}");
lar->DrawLatex(0.60, 0.94, "L = 4.327 fb^{-1} at #sqrt{s} = 13 TeV");

pad1->Update();
c1->Update();

c1->cd();

TH1F *h_ratio = (TH1F*)h_data->Clone("h_ratio");

TPad *pad2 = new TPad("pad2","pad2",0,0,1,0.3);
TPad *pad2 = new TPad("pad2","pad2",0,0,1,0.3);// 0.3
pad2->SetTopMargin(0);
pad2->SetBottomMargin(0.3);
pad2->Draw();
Expand Down Expand Up @@ -265,7 +280,7 @@ if (title=="Zpt") {
h_ratio->GetXaxis ()->SetTitle("FAT Jet #tau_{1}");
} else if (title=="FATjetTau2") {
h_ratio->GetXaxis ()->SetTitle("FAT Jet #tau_{2}");
} else if (title=="FATjetTau12dvTau1") {
} else if (title=="FATjetTau2dvTau1") {
h_ratio->GetXaxis ()->SetTitle("FAT Jet #tau_{21}");
} else if (title=="FATsubjetPt") {
h_ratio->GetXaxis ()->SetTitle("FAT SubJet p_{T} [GeV/c]");
Expand All @@ -275,9 +290,9 @@ if (title=="Zpt") {
h_ratio->GetXaxis ()->SetTitle("FAT SubJet Soft Drop CSV [GeV/c]");
} else if (title=="ZHmass") {
h_ratio->GetXaxis ()->SetTitle("ZH invariant mass [GeV/c^{2}]");
}



if (title=="ZHmass") { h_ratio->GetXaxis()->SetRangeUser(0, 3000); }
h_ratio->GetXaxis()->SetTitleSize(0.11);
h_ratio->GetXaxis()->SetLabelFont(42);
h_ratio->GetXaxis()->SetLabelSize(0.10);
Expand All @@ -298,12 +313,14 @@ OLine->SetLineColor(kRed);
OLine->SetLineWidth(2);
OLine->Draw();

/*
TLatex *lar = new TLatex();
lar->SetNDC(kTRUE);
lar->SetTextSize(0.04);
lar->SetLineWidth(5);
lar->DrawLatex(0.14, 0.94, "CMS #it{#bf{2016}}");
lar->DrawLatex(0.60, 0.94, "L = 4.327 fb^{-1} at #sqrt{s} = 13 TeV");
*/

c1->cd();
c1->SaveAs((path + title + ".pdf").c_str());
Expand Down
6 changes: 4 additions & 2 deletions XSecsLumi.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,14 @@ double Xsec_dy_amc1 = 147.40 *1.23;

//////////////////////// DY MadGraph_aMC@NLO + Pythia 8 HT200to400

double Ngen_dy_amc2 = 8348679;
//double Ngen_dy_amc2 = 8348679;
double Ngen_dy_amc2 = 9628177;
double Xsec_dy_amc2 = 41*1.23;

//////////////////////// DY MadGraph_aMC@NLO + Pythia 8 HT400to600

double Ngen_dy_amc3 = 1070450;
//double Ngen_dy_amc3 = 1070450;
double Ngen_dy_amc3 = 1070454;
double Xsec_dy_amc3 = 5.678*1.23;

//////////////////////// DY MadGraph_aMC@NLO + Pythia 8 HT600toInf
Expand Down
167 changes: 167 additions & 0 deletions globalRun.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,167 @@
#!/bin/sh

echo "start"
date

# -- decide run electron or muon variable here ----

channel=ele
#channel=mu

echo "channel=" $channel

# which sample you want to run? 1 for True and 0 for False

flag_DATA_ele=0
flag_DATA_mu=0

flag_MC_DY_100=1
flag_MC_DY_200=1
flag_MC_DY_400=1
flag_MC_DY_600=1

flag_MC_TT=0

flag_MC_diboson=0

echo "which sample are used?"
echo "flag_DATA_ele: $flag_DATA_ele , flag_DATA_mu: $flag_DATA_mu, flag_MC_DY_100: $flag_MC_DY_100 , flag_MC_DY_200: $flag_MC_DY_200 , flag_MC_DY_400: $flag_MC_DY_400 , flag_MC_DY_600: $flag_MC_DY_600 , flag_MC_TT: $flag_MC_TT , flag_MC_diboson: $flag_MC_diboson "

# ----------------------------------

if [ $channel == ele ];then
macro=xAna_ele
outputFolder=output_ele
fi

if [ $channel == mu ];then
macro=xAna_mu
outputFolder=output_mu
fi


# ----------------------------------
pcncu_path=/data7/yuchang/NCUGlobalTuples_80X

# ----------------------------------



function Macro(){

# $1=macro, $2=sample_name, $3=save_name

sample_path=$pcncu_path/$2

echo "root -q -b -l $1.C+\(\"$sample_path\"\,\"$outputFolder\"\,\"$3\"\) "
root -q -b -l $1.C+\(\"$sample_path\"\,\"$outputFolder\"\,\"$3\"\)
}

# ----------------------------------

if [ $flag_DATA_ele == 1 ];then

# SingleElectron

sample_name=SingleElectron
save_name=SingleElectron-Run2016B-v2
Macro $macro $sample_name $save_name

fi

if [ $flag_DATA_mu == 1 ];then

# SingleMuon

sample_name=SingleMuon
save_name=SingleMuon-Run2016B-v2
Macro $macro $sample_name $save_name

fi

# ----------------------------------

if [ $flag_MC_DY_100 == 1 ];then

# DY-Ht_100to200
sample_name=DYJetsToLL_M-50_HT-100to200_TuneCUETP8M1_13TeV-madgraphMLM-pythia8
save_name=DYJetsToLL_M-50_HT-100to200_13TeV
Macro $macro $sample_name $save_name
fi

if [ $flag_MC_DY_200 == 1 ];then
# DY-Ht_200to400
sample_name=DYJetsToLL_M-50_HT-200to400_TuneCUETP8M1_13TeV-madgraphMLM-pythia8
save_name=DYJetsToLL_M-50_HT-200to400_13TeV
Macro $macro $sample_name $save_name
fi

if [ $flag_MC_DY_400 == 1 ];then
# DY-Ht_400to600
sample_name=DYJetsToLL_M-50_HT-400to600_TuneCUETP8M1_13TeV-madgraphMLM-pythia8
save_name=DYJetsToLL_M-50_HT-400to600_13TeV
Macro $macro $sample_name $save_name
fi


if [ $flag_MC_DY_600 == 1 ];then
# DY-Ht_600toInf
sample_name=DYJetsToLL_M-50_HT-600toInf_TuneCUETP8M1_13TeV-madgraphMLM-pythia8
save_name=DYJetsToLL_M-50_HT-600toInf_13TeV
Macro $macro $sample_name $save_name

fi

# ----------------------------------

if [ $flag_MC_TT == 1 ];then

# TT
sample_name=TT_TuneCUETP8M1_13TeV-powheg-pythia8
save_name=TT_TuneCUETP8M1_13TeV
Macro $macro $sample_name $save_name

fi

# ----------------------------------

if [ $flag_MC_diboson == 1 ];then

# ZH
sample_name=ZH_HToBB_ZToLL_M125_13TeV_amcatnloFXFX_madspin_pythia8
save_name=ZH_HToBB_ZToLL_M125_13TeV_amcatnlo
Macro $macro $sample_name $save_name

sample_name=ZH_HToBB_ZToLL_M125_13TeV_powheg_pythia8
save_name=ZH_HToBB_ZToLL_M125_13TeV_powheg
Macro $macro $sample_name $save_name

# WW
sample_name=WW_TuneCUETP8M1_13TeV-pythia8
save_name=WW_TuneCUETP8M1_13TeV
Macro $macro $sample_name $save_name

# WZ
sample_name=WZ_TuneCUETP8M1_13TeV-pythia8
save_name=WZ_TuneCUETP8M1_13TeV
Macro $macro $sample_name $save_name

# ZZ
sample_name=ZZ_TuneCUETP8M1_13TeV-pythia8
save_name=ZZ_TuneCUETP8M1_13TeV
Macro $macro $sample_name $save_name

fi

# ----------------------------------

# delete temp file and end the code
rm -f inputdir.txt
rm -f *.pcm *.d *.so

echo "finish"
date

exit
# -------- end ----------

54 changes: 54 additions & 0 deletions interface/dataFilter.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
#include <iostream>
#include <string>
#include <vector>
#include "untuplizer.h"

bool TriggerStatus(TreeReader &data, std::string TRIGGERNAME){

std::string* trigName = data.GetPtrString("hlt_trigName");
vector<bool>& trigResult = *((vector<bool>*) data.GetPtr("hlt_trigResult"));

bool triggerStat = false;

for(int it = 0; it < data.GetPtrStringSize(); it++){

std::string thisTrig = trigName[it];
bool results = trigResult[it];

if( thisTrig.find(TRIGGERNAME) != std::string::npos && results ){

triggerStat = true;
break;

}

}

return triggerStat;

}

bool FilterStatus(TreeReader &data, std::string FILTERNAME){

std::string* filterName = data.GetPtrString("hlt_filterName");
vector<bool>& filterResult = *((vector<bool>*) data.GetPtr("hlt_filterResult"));

bool filterStat = false;

for(int it = 0; it < data.GetPtrStringSize(); it++){

std::string thisFilter = filterName[it];
bool results = filterResult[it];

if( thisFilter.find(FILTERNAME) != std::string::npos && results ){

filterStat = true;
break;

}

}

return filterStat;

}
Loading