Skip to content

Commit

Permalink
Updated datacards producer (MSSM em)
Browse files Browse the repository at this point in the history
  • Loading branch information
raspereza committed Apr 25, 2021
1 parent b3520f3 commit fdcc47d
Show file tree
Hide file tree
Showing 6 changed files with 243 additions and 94 deletions.
5 changes: 5 additions & 0 deletions NTupleMaker/bin/AnalysisNTupleFakeRate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -276,6 +276,7 @@ int main(int argc, char * argv[]) {
Float_t jetPt_;
Float_t jetEta_;
Float_t jetPhi_;
Int_t jetFlavor_;

Float_t jettauPt_;
Float_t jettauEta_;
Expand Down Expand Up @@ -470,6 +471,7 @@ int main(int argc, char * argv[]) {
ntuple_->Branch("jetPt", &jetPt_, "jetPt/F");
ntuple_->Branch("jetEta",&jetEta_,"jetEta/F");
ntuple_->Branch("jetPhi",&jetPhi_,"jetPhi/F");
ntuple_->Branch("jetFlavor",&jetFlavor_,"jetFlavor/I");

ntuple_->Branch("jettauPt",&jettauPt_,"jettauPt/F");
ntuple_->Branch("jettauEta",&jettauEta_,"jettauEta/F");
Expand Down Expand Up @@ -835,6 +837,7 @@ int main(int argc, char * argv[]) {
jetPt_ = -9999;
jetEta_ = -9999;
jetPhi_ = -9999;
jetFlavor_ = 0;

jettauPt_ = 0;
jettauEta_ = 0;
Expand Down Expand Up @@ -1640,6 +1643,8 @@ int main(int argc, char * argv[]) {
jetPt_ = analysisTree.pfjet_pt[indexJet0];
jetEta_ = analysisTree.pfjet_eta[indexJet0];
jetPhi_ = analysisTree.pfjet_phi[indexJet0];
jetFlavor_ = analysisTree.pfjet_flavour[indexJet0];

jetChargedMult_ = analysisTree.pfjet_chargedmulti[indexJet0];
jetNeutralMult_ = analysisTree.pfjet_neutralmulti[indexJet0];
jetChargedHadMult_ = analysisTree.pfjet_chargedhadronmulti[indexJet0];
Expand Down
34 changes: 24 additions & 10 deletions NTupleMaker/bin/CreateCards_emu.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@

#include "DesyTauAnalyses/NTupleMaker/interface/settings.h"
//#include "DesyTauAnalyses/NTupleMaker/interface/settings.h"
#include "TFile.h"
#include "TTree.h"
#include "TString.h"
Expand Down Expand Up @@ -28,10 +27,24 @@ int main(int argc, char * argv[]) {
double binsBTag[16] =
{40,60,80,100,120,140,160,180,200,250,300,350,400,500,700,5000};

int nBinsBTag2 = 7;
double binsBTag2[8] =
{40,80,120,160,200,300,500,5000};

int nBinsTTbar = 12;
double binsTTbar[13] = {40, 60, 80, 100,
120, 150, 200, 250, 300,
500, 700, 1000, 5000};
120, 150, 200, 250,
300, 400, 500, 1000,5000};

// std::vector<double> binsVector = {0, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200, 210, 220, 230, 240, 250, 260, 270, 280, 290, 300, 310, 320, 330, 340, 350, 360, 370, 380, 390, 400, 410, 420, 430, 440, 450, 460, 470, 480, 490, 500, 525, 550, 575, 600, 625, 650, 675, 700, 725, 750, 775, 800, 825, 850, 875, 900, 925, 950, 975, 1000, 1050, 1100, 1150, 1200, 1250, 1300, 1350, 1400, 1450, 1500, 1550, 1600, 1650, 1700, 1750, 1800, 1850, 1900, 1950, 2000, 2100, 2200, 2300, 2400, 2500, 2600, 2700, 2800, 2900, 3000, 3100, 3200, 3300, 3400, 3500, 3600, 3700, 3800, 3900, 4000, 4100, 4200, 4300, 4400, 4500, 4600, 4700, 4800, 4900, 5000};

std::vector<double> binsNoBTagVector = {0,50,60,70,80,90,100,110,120,130,140,150,160,170,180,190,200,225,250,275,300,325,350,400,450,500,600,700,800,900,1100,1300,1500,1700,1900,2100,2300,2500,2700,2900,3100,3300,3500,3700,3900,4100,4300,4500,4700,5000};

std::vector<double> binsBTagVector = {0,60,80,100,120,140,160,180,200,250,300,350,400,500,600,700,800,900,1100,1300,1500,1700,1900,2100,2300,2500,2700,2900,3100,3300,3500,3700,3900,4100,4300,4500,4700,5000};

// int nBinsFine = binsVector.size()-1;
nBinsBTag = binsBTagVector.size()-1;
nBinsNoBTag = binsNoBTagVector.size()-1;

TString era(argv[1]);
TString sample(argv[2]);
Expand Down Expand Up @@ -65,18 +78,19 @@ int main(int argc, char * argv[]) {

cardsEMu->PrintSamples();
cardsEMu->PrintShapeSystematics();
cardsEMu->PrintWeightSystematics();
cardsEMu->PrintWeightSystematics();

if (category.Contains("_DZetaLtm35"))
cardsEMu->SetVariableToPlot(variable,nBinsTTbar,binsTTbar);
cardsEMu->SetVariableToPlot(variable,nBinsNoBTag,binsNoBTagVector);
else {
if (category.Contains("_NbtagGt1"))
cardsEMu->SetVariableToPlot(variable,nBinsBTag,binsBTag);
if (category.Contains("_NbtagGt1")||
category.Contains("_Nbtag1"))
cardsEMu->SetVariableToPlot(variable,nBinsBTag,binsBTagVector);
else
cardsEMu->SetVariableToPlot(variable,nBinsNoBTag,binsNoBTag);
cardsEMu->SetVariableToPlot(variable,nBinsNoBTag,binsNoBTagVector);
}
cardsEMu->Run();
cardsEMu->CloseFile();
delete cardsEMu;


}
34 changes: 18 additions & 16 deletions NTupleMaker/bin/PlotDatacards_EMu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,17 +26,22 @@ void Plot(
float yLower = 20;
float scaleYUpper = 50;
TString xtitle = "m_{T}^{tot}";
TString ytitle = "Events / bin";
TString ytitle = "";


TH1D * histData = (TH1D*)file->Get(category+"/data_obs");
if (histData==NULL) {
std::cout << " category " << category << " does not exist" << std::endl;
std::cout << " nothing is done.. " << std::endl;
std::cout << " era/category " << era << "/" << category << " does not exist" << std::endl;
std::cout << " nothing is done... " << std::endl;
std::cout << std::endl;
std::cout << "+++++++++++++++++++++++++++++++" << std::endl;
std::cout << std::endl;
return;
}
else {
std::cout << " processing category " << category << std::endl;
std::cout << std::endl;
std::cout << "processing category era/category : " << era << "/" << category << std::endl;
std::cout << std::endl;
}
TH1D * TT = (TH1D*)file->Get(category+"/TTL");
TH1D * ZTT = (TH1D*)file->Get(category+"/EMB");
Expand Down Expand Up @@ -150,6 +155,7 @@ void Plot(

histData->GetXaxis()->SetTitle(xtitle);
histData->GetYaxis()->SetTitle(ytitle);
histData->GetXaxis()->SetRangeUser(61,3900);
histData->GetYaxis()->SetTitleOffset(1.3);
histData->GetYaxis()->SetTitleSize(0.06);
float yUpper = histData->GetMaximum();
Expand Down Expand Up @@ -209,16 +215,17 @@ void Plot(
}
}
std::cout << std::endl;
std::cout << "Chi2 = " << chi2 << std::endl;
std::cout << "Chi2/ndof = " << chi2 << "/" << nBins << std::endl;
std::cout << "Prob = " << TMath::Prob(chi2,double(nBins)) << std::endl;
std::cout << std::endl;

TLegend * leg;
if (legRight) leg = new TLegend(0.61,0.40,0.90,0.70);
if (legRight) leg = new TLegend(0.7,0.40,0.90,0.70);
else leg = new TLegend(0.20,0.40,0.50,0.70);
SetLegendStyle(leg);
leg->SetTextSize(0.044);
leg->SetTextSize(0.04);
leg->AddEntry(histData,"Data","lp");
leg->AddEntry(ZTT,"embedded Z#rightarrow#tau#tau","f");
leg->AddEntry(ZTT,"embedded #tau#tau","f");
leg->AddEntry(ZLL,"Z#rightarrow ll","f");
leg->AddEntry(QCD,"QCD","f");
leg->AddEntry(W,"electroweak","f");
Expand All @@ -243,7 +250,7 @@ void Plot(
ratioH->SetMarkerStyle(20);
ratioH->SetMarkerSize(1.2);
ratioH->SetLineColor(1);
ratioH->GetYaxis()->SetRangeUser(0.801,1.199);
ratioH->GetYaxis()->SetRangeUser(0.301,1.699);
ratioH->GetYaxis()->SetNdivisions(505);
ratioH->GetXaxis()->SetLabelFont(42);
ratioH->GetXaxis()->SetLabelOffset(0.04);
Expand Down Expand Up @@ -361,6 +368,7 @@ void Plot(
}

std::cout << std::endl;
std::cout << "+++++++++++++++++++++++++++++++++++++++++" << std::endl;
std::cout << std::endl;

}
Expand All @@ -379,13 +387,7 @@ int main(int argc, char * argv[]) {
"em_Nbtag0_DZetaGt30",
"em_NbtagGt1_DZetam35Tom10",
"em_NbtagGt1_DZetam10To30",
"em_NbtagGt1_DZetaGt30",
"em_Nbtag0_NjetLt1_DZetam35Tom10",
"em_Nbtag0_NjetLt1_DZetam10To30",
"em_Nbtag0_NjetLt1_DZetaGt30",
"em_NbtagGt1_NjetLt1_DZetam35Tom10",
"em_NbtagGt1_NjetLt1_DZetam10To30",
"em_NbtagGt1_NjetLt1_DZetaGt30",
"em_NbtagGt1_DZetaGt30"
};

for (auto era : eras) {
Expand Down
115 changes: 86 additions & 29 deletions NTupleMaker/interface/CardsEMu.h
Original file line number Diff line number Diff line change
Expand Up @@ -112,10 +112,10 @@ class CardsEMu {
{"TTTo2L2Nu" , 88.29}, // NNLO (21)
{"TTToHadronic" , 377.96}, // NNLO (22)
{"TTToSemiLeptonic" , 365.35}, // NNLO (23)
{"ST_t-channel_top_4f" , 136.02}, // ? (24) -> could be improved
{"ST_t-channel_antitop_4f" , 80.95}, // ? (25) -> could be improved
{"ST_tW_top_5f" , 35.85}, // ? (26) -> could be improved
{"ST_tW_antitop_5f" , 35.85}, // ? (27) -> could be improved
{"ST_t-channel_top_4f" , 136.02},
{"ST_t-channel_antitop_4f" , 80.95},
{"ST_tW_top_5f" , 35.85},
{"ST_tW_antitop_5f" , 35.85},
{"VVTo2L2Nu" , 13.84},
{"WWToLNuQQ" , 49.997},
{"WZTo2L2Q" , 5.52},
Expand All @@ -125,6 +125,22 @@ class CardsEMu {
{"WZTo3LNu" , 4.43},
{"ZZTo4L" , 1.26},
{"ZZTo2L2Q" , 3.38},
{"TTTo2L2Nu_corrMET" , 88.29}, // NNLO (21)
{"TTToHadronic_corrMET" , 377.96}, // NNLO (22)
{"TTToSemiLeptonic_corrMET" , 365.35}, // NNLO (23)
{"ST_t-channel_top_4f_corrMET" , 136.02},
{"ST_t-channel_antitop_4f_corrMET" , 80.95},
{"ST_tW_top_5f_corrMET" , 35.85},
{"ST_tW_antitop_5f_corrMET" , 35.85},
{"VVTo2L2Nu_corrMET" , 13.84},
{"WWToLNuQQ_corrMET" , 49.997},
{"WZTo2L2Q_corrMET" , 5.52},
{"WZTo1L1Nu2Q_corrMET" , 10.71},
{"WZTo1L3Nu_corrMET" , 3.05},
{"WZJToLLLNu_corrMET" , 4.708},
{"WZTo3LNu_corrMET" , 4.43},
{"ZZTo4L_corrMET" , 1.26},
{"ZZTo2L2Q_corrMET" , 3.38},
{"GluGluHToTauTau_M125" , 3.00},
{"VBFHToTauTau_M125" , 0.237},
{"WplusHToTauTau_M125" , 0.0527},
Expand Down Expand Up @@ -158,12 +174,6 @@ class CardsEMu {
"MuonEG_Run2018D"
};

const vector<TString> EmbeddedElMu_2018 = {
"EmbeddedElMu_Run2018A",
"EmbeddedElMu_Run2018B",
"EmbeddedElMu_Run2018C",
"EmbeddedElMu_Run2018D"
};

// ****** 2017 ********

Expand Down Expand Up @@ -191,13 +201,6 @@ class CardsEMu {
"MuonEG_Run2017F"
};

const vector<TString> EmbeddedElMu_2017 = {
"EmbeddedElMu_Run2017B",
"EmbeddedElMu_Run2017C",
"EmbeddedElMu_Run2017D",
"EmbeddedElMu_Run2017E",
"EmbeddedElMu_Run2017F",
};

// ******* 2016 ******

Expand Down Expand Up @@ -231,6 +234,8 @@ class CardsEMu {
"MuonEG_Run2016H"
};

// ****** embedded samples *************

const vector<TString> EmbeddedElMu_2016 = {
"EmbeddedElMu_Run2016B",
"EmbeddedElMu_Run2016C",
Expand All @@ -241,6 +246,24 @@ class CardsEMu {
"EmbeddedElMu_Run2016H"
};

const vector<TString> EmbeddedElMu_2017 = {
"EmbeddedElMu_Run2017B",
"EmbeddedElMu_Run2017C",
"EmbeddedElMu_Run2017D",
"EmbeddedElMu_Run2017E",
"EmbeddedElMu_Run2017F",
};

const vector<TString> EmbeddedElMu_2018 = {
"EmbeddedElMu_Run2018A",
"EmbeddedElMu_Run2018B",
"EmbeddedElMu_Run2018C",
"EmbeddedElMu_Run2018D"
};


// ******** MC samples *************

const vector<TString> WJets = {
"WJetsToLNu_0",
"WJetsToLNu_1",
Expand Down Expand Up @@ -324,6 +347,26 @@ class CardsEMu {
{"DY4JetsToTT_M-50","DY4JetsToLL_M-50"},
};

/*
vector<TString> EWK = {
"ST_t-channel_top_4f_corrMET",
"ST_t-channel_antitop_4f_corrMET",
"ST_tW_top_5f_corrMET",
"ST_tW_antitop_5f_corrMET",
"VVTo2L2Nu_corrMET",
"WZTo2L2Q_corrMET",
"WZTo3LNu_corrMET",
"ZZTo2L2Q_corrMET",
"ZZTo4L_corrMET",
};
vector<TString> TT = {
"TTTo2L2Nu_corrMET",
"TTToHadronic_corrMET",
"TTToSemiLeptonic_corrMET"
};
*/

vector<TString> EWK = {
"ST_t-channel_top_4f",
"ST_t-channel_antitop_4f",
Expand Down Expand Up @@ -377,6 +420,9 @@ class CardsEMu {
};

const vector<TString> masses = {
"60",
"80",
"100",
"110",
"120",
"125",
Expand Down Expand Up @@ -404,19 +450,20 @@ class CardsEMu {
"2300",
"2600",
"2900",
"3200"
"3200",
"3500"
};

const TString BaseTreeName = "TauCheck";
const TString baseNameBBH = "SUSYGluGluToBBHToTauTau_M-";
const TString baseNameGGH = "SUSYGluGluToHToTauTau_M-";
const TString baseNameBBH = "SUSYGluGluToBBHToTauTau_powheg_M";
const TString baseNameGGH = "SUSYGluGluToHToTauTau_powheg_M";
const TString notTauTau = "&&!(gen_match_1==3&&gen_match_2==4)";
const TString TauTau = "&&(gen_match_1==3&&gen_match_2==4)";

map<TString,TString> generatorName =
{
{"SUSYGluGluToBBHToTauTau_M-","amcatnlo"},
{"SUSYGluGluToHToTauTau_M-","pythia"}
{"SUSYGluGluToBBHToTauTau_M","amcatnlo"},
{"SUSYGluGluToHToTauTau_M","pythia"}
};

// *****************************
Expand All @@ -428,10 +475,10 @@ class CardsEMu {
{"CMS_scale_m","CMS_scale_mu_13TeV"},
};

const map<TString,TString> EmbeddedMetShapeSystematics = {
{"scale_embed_metDown","CMS_scale_met_embedded_13TeVUp"},
{"scale_embed_metUp","CMS_scale_met_embedded_13TeVDown"}
};
// const map<TString,TString> EmbeddedMetShapeSystematics = {
// {"scale_embed_metDown","CMS_scale_met_embedded_13TeVUp"},
// {"scale_embed_metUp","CMS_scale_met_embedded_13TeVDown"}
// };

const map<TString,TString> ShapeSystematics_Common = {
{"CMS_scale_e","CMS_scale_e_13TeV"},
Expand Down Expand Up @@ -551,9 +598,19 @@ class CardsEMu {
{"2018",0.67}
};

const map<TString,TString> systematics_ggH = {
const map<TString,TString> systematics_ggH_t = {
{"QCDscale_ggH_REWEIGHT","scale"},
{"Hdamp_ggH_t_REWEIGHT","hdamp"}
};

const map<TString,TString> systematics_ggH_b = {
{"QCDscale_ggH_REWEIGHT","scale"},
{"Hdamp_ggH_b_REWEIGHT","hdamp"}
};

const map<TString,TString> systematics_ggH_i = {
{"QCDscale_ggH_REWEIGHT","scale"},
{"Hdamp_ggH_REWEIGHT","hdamp"}
{"Hdamp_ggH_i_REWEIGHT","hdamp"}
};

// *******************************************************
Expand Down Expand Up @@ -582,7 +639,7 @@ class CardsEMu {

// for variables which are different from mt_tot;
int nBins;
double Bins[100];
double Bins[500];
double xMin;
double xMax;

Expand Down
Loading

0 comments on commit fdcc47d

Please sign in to comment.