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
90 changes: 78 additions & 12 deletions bin/draw_rates.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@
#include "TFile.h"
#include "TLegend.h"
#include "TROOT.h"
#include "THStack.h"

#include <map>
#include <string>
#include <vector>


int main()
{
// include comparisons between HW and data TPs
Expand All @@ -25,16 +25,19 @@ int main()
std::vector<std::string> rateTypes = {"singleJet", "doubleJet", "tripleJet", "quadJet",
"singleEg", "singleISOEg", "doubleEg", "doubleISOEg",
"singleTau", "singleISOTau", "doubleTau", "doubleISOTau",
"htSum", "etSum", "metSum", "metHFSum"};
"htSum", "mhtSum", "etSum", "metSum", "metHFSum"};
std::map<std::string, int> histColor;
histColor["singleJet"] = histColor["singleEg"] = histColor["singleTau"] = histColor["etSum"] = histColor["metSum"] = kRed;
histColor["doubleJet"] = histColor["singleISOEg"] = histColor["singleISOTau"] = histColor["htSum"] = histColor["metHFSum"] = kBlue;
histColor["tripleJet"] = histColor["doubleEg"] = histColor["doubleTau"] = kGreen;
histColor["doubleJet"] = histColor["singleISOEg"] = histColor["singleISOTau"] = histColor["htSum"] = histColor["mhtSum"] = kBlue;
histColor["tripleJet"] = histColor["doubleEg"] = histColor["doubleTau"] = histColor["metHFSum"] = kGreen;
histColor["quadJet"] = histColor["doubleISOEg"] = histColor["doubleISOTau"] = kBlack;

std::map<std::string, TH1F*> rateHists_def;
std::map<std::string, TH1F*> rateHists_new_cond;
std::map<std::string, TH1F*> rateHists_hw;
std::map<std::string, TH1F*> sumHists_def;
std::map<std::string, TH1F*> sumHists_new_cond;
std::map<std::string, TH1F*> sumHists_hw;
std::map<std::string, TH1F*> rateHistsRatio;

std::vector<TFile*> files;
Expand Down Expand Up @@ -69,18 +72,42 @@ int main()
rateHistsRatio[rateType]->SetMinimum(0.6);
rateHistsRatio[rateType]->SetMaximum(1.4);
rateHistsRatio[rateType]->SetLineWidth(2);

if (rateType.find("Sum") != std::string::npos) {
std::string histName(rateType);
std::string histNameHw(histName);
histName += "_emu";
histNameHw += "_hw";
sumHists_def[rateType] = dynamic_cast<TH1F*>(files.at(0)->Get(histName.c_str()));
sumHists_hw[rateType] = dynamic_cast<TH1F*>(files.at(0)->Get(histNameHw.c_str()));
sumHists_new_cond[rateType] = dynamic_cast<TH1F*>(files.at(1)->Get(histName.c_str()));
sumHists_def[rateType]->Rebin(rebinFactor);
sumHists_hw[rateType]->Rebin(rebinFactor);
sumHists_new_cond[rateType]->Rebin(rebinFactor);

sumHists_def[rateType]->SetLineColor(histColor[rateType]);
sumHists_hw[rateType]->SetLineColor(histColor[rateType]);
sumHists_new_cond[rateType]->SetLineColor(histColor[rateType]);
}
}
for(auto pair : rateHists_new_cond) pair.second->SetLineWidth(2);
for(auto pair : rateHists_hw) pair.second->SetLineStyle(kDashed);
for(auto pair : rateHists_def) pair.second->SetLineStyle(kDotted);

for(auto pair : sumHists_new_cond) pair.second->SetLineWidth(2);
for(auto pair : sumHists_hw) pair.second->SetLineStyle(kDashed);
for(auto pair : sumHists_def) pair.second->SetLineStyle(kDotted);

std::vector<std::string> jetPlots = {"singleJet", "doubleJet", "tripleJet", "quadJet"};
std::vector<std::string> egPlots = {"singleEg", "singleISOEg", "doubleEg", "doubleISOEg"};
std::vector<std::string> tauPlots = {"singleTau", "singleISOTau", "doubleTau", "doubleISOTau"};
std::vector<std::string> scalarSumPlots = {"etSum", "htSum"};
std::vector<std::string> vectorSumPlots = {"metSum", "metHFSum"};
std::vector<std::string> vectorSumPlots = {"metSum", "mhtSum", "metHFSum"};

std::vector<TCanvas*> canvases;
std::vector<TLegend*> legends;
std::vector<THStack*> stacks;
std::vector<TPad*> pad0;
std::vector<TPad*> pad1;
std::vector<TPad*> pad2;
std::map<std::string, std::vector<std::string> > plots;
Expand All @@ -101,23 +128,23 @@ int main()
pad2.push_back(new TPad("pad2", "pad2", 0, 0, 1, 0.3));
pad2.back()->SetGrid();
pad2.back()->Draw();

pad1.back()->cd();

rateHists_def[iplot.second.front()]->Draw("hist");
TLegend *leg = new TLegend(0.55, 0.9 - 0.1*iplot.second.size(), 0.95, 0.93);
legends.push_back(new TLegend(0.55, 0.9 - 0.1*iplot.second.size(), 0.95, 0.93));
for(auto hist : iplot.second) {
rateHists_def[hist]->Draw("hist same");
if(includeHW) rateHists_hw[hist]->Draw("hist same");
rateHists_new_cond[hist]->Draw("hist same");
TString name(rateHists_def[hist]->GetName());
TString nameHw(rateHists_hw[hist]->GetName());
leg->AddEntry(rateHists_def[hist], name + " (current)", "L");
if(includeHW) leg->AddEntry(rateHists_hw[hist], name + " (hw)", "L");
leg->AddEntry(rateHists_new_cond[hist], name + " (new)", "L");
legends.back()->AddEntry(rateHists_def[hist], name + " (current)", "L");
if(includeHW) legends.back()->AddEntry(rateHists_hw[hist], name + " (hw)", "L");
legends.back()->AddEntry(rateHists_new_cond[hist], name + " (new)", "L");
}
leg->SetBorderSize(0);
leg->Draw();
legends.back()->SetBorderSize(0);
legends.back()->Draw();

pad2.back()->cd();
rateHistsRatio[iplot.second.front()]->Draw("hist");
Expand All @@ -129,6 +156,45 @@ int main()

if(includeHW) canvases.back()->Print(Form("plots/%sRates_hw.pdf", iplot.first.c_str()));
else canvases.back()->Print(Form("plots/%sRates_emu.pdf", iplot.first.c_str()));

// For the case of "Sum" variables e.g. MET, HT, etc we make plots with out the ratios of the
// distribution itself
if (iplot.first.find("Sum") != std::string::npos) {

canvases.push_back(new TCanvas);
canvases.back()->SetWindowSize(canvases.back()->GetWw(), 1.3*canvases.back()->GetWh());

pad0.push_back(new TPad("pad0", "pad0", 0, 0, 1, 1));
pad0.back()->SetLogy();
pad0.back()->SetGrid();
pad0.back()->Draw();

pad0.back()->cd();

std::string xname = sumHists_def[iplot.second.front()]->GetXaxis()->GetTitle();
std::string yname = sumHists_def[iplot.second.front()]->GetYaxis()->GetTitle();
stacks.push_back(new THStack(Form("hs%s", iplot.first.c_str()), Form(";%s;%s", xname.c_str(),yname.c_str()))); stacks.back()->Draw();
legends.push_back(new TLegend(0.45, 0.9 - 0.05*iplot.second.size(), 0.95, 0.95));
legends.back()->SetNColumns(2);
for(auto hist : iplot.second) {
stacks.back()->Add(sumHists_def[hist]);
if(includeHW) stacks.back()->Add(sumHists_hw[hist]);
stacks.back()->Add(sumHists_new_cond[hist]);
TString name(sumHists_def[hist]->GetName());
TString nameHw(sumHists_hw[hist]->GetName());
legends.back()->AddEntry(sumHists_def[hist], name + " (current)", "L");
if(includeHW) legends.back()->AddEntry(sumHists_hw[hist], name + " (hw)", "L");
legends.back()->AddEntry(sumHists_new_cond[hist], name + " (new)", "L");
}
legends.back()->SetBorderSize(0);
stacks.back()->SetMaximum(4.0*stacks.back()->GetMaximum("nostack"));
stacks.back()->Draw("nostack");
legends.back()->Draw("same");

if(includeHW) canvases.back()->Print(Form("plots/%s_hw.pdf", iplot.first.c_str()));
else canvases.back()->Print(Form("plots/%s_emu.pdf", iplot.first.c_str()));

}
}

return 0;
Expand Down
33 changes: 33 additions & 0 deletions bin/rates.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,8 @@ void rates(bool newConditions, const std::string& inputFileDirectory){

std::string axR = ";Threshold E_{T} (GeV);rate (Hz)";
std::string axD = ";E_{T} (GeV);events/bin";
std::string axS = ";Scalar Sum (GeV);Events / bin";
std::string axV = ";Vector Sum (GeV);Events / bin";

//make histos
TH1F* singleJetRates_emu = new TH1F("singleJetRates_emu", axR.c_str(), nJetBins, jetLo, jetHi);
Expand All @@ -227,6 +229,11 @@ void rates(bool newConditions, const std::string& inputFileDirectory){
TH1F* etSumRates_emu = new TH1F("etSumRates_emu",axR.c_str(), nEtSumBins, etSumLo, etSumHi);
TH1F* metSumRates_emu = new TH1F("metSumRates_emu",axR.c_str(), nMetSumBins, metSumLo, metSumHi);
TH1F* metHFSumRates_emu = new TH1F("metHFSumRates_emu",axR.c_str(), nMetHFSumBins, metHFSumLo, metHFSumHi);
TH1F* htSum_emu = new TH1F("htSum_emu",axS.c_str(), nHtSumBins, htSumLo, htSumHi);
TH1F* mhtSum_emu = new TH1F("mhtSum_emu",axV.c_str(), nMhtSumBins, mhtSumLo, mhtSumHi);
TH1F* etSum_emu = new TH1F("etSum_emu",axS.c_str(), nEtSumBins, etSumLo, etSumHi);
TH1F* metSum_emu = new TH1F("metSum_emu",axV.c_str(), nMetSumBins, metSumLo, metSumHi);
TH1F* metHFSum_emu = new TH1F("metHFSum_emu",axV.c_str(), nMetHFSumBins, metHFSumLo, metHFSumHi);

TH1F* singleJetRates_hw = new TH1F("singleJetRates_hw", axR.c_str(), nJetBins, jetLo, jetHi);
TH1F* doubleJetRates_hw = new TH1F("doubleJetRates_hw", axR.c_str(), nJetBins, jetLo, jetHi);
Expand All @@ -245,6 +252,11 @@ void rates(bool newConditions, const std::string& inputFileDirectory){
TH1F* etSumRates_hw = new TH1F("etSumRates_hw",axR.c_str(), nEtSumBins, etSumLo, etSumHi);
TH1F* metSumRates_hw = new TH1F("metSumRates_hw",axR.c_str(), nMetHFSumBins, metHFSumLo, metHFSumHi);
TH1F* metHFSumRates_hw = new TH1F("metHFSumRates_hw",axR.c_str(), nMetHFSumBins, metHFSumLo, metHFSumHi);
TH1F* htSum_hw = new TH1F("htSum_hw",axS.c_str(), nHtSumBins, htSumLo, htSumHi);
TH1F* mhtSum_hw = new TH1F("mhtSum_hw",axV.c_str(), nMhtSumBins, mhtSumLo, mhtSumHi);
TH1F* etSum_hw = new TH1F("etSum_hw",axS.c_str(), nEtSumBins, etSumLo, etSumHi);
TH1F* metSum_hw = new TH1F("metSum_hw",axV.c_str(), nMetSumBins, metSumLo, metSumHi);
TH1F* metHFSum_hw = new TH1F("metHFSum_hw",axV.c_str(), nMetHFSumBins, metHFSumLo, metHFSumHi);

TH1F* hcalTP_emu = new TH1F("hcalTP_emu", ";TP E_{T}; # Entries", nTpBins, tpLo, tpHi);
TH1F* ecalTP_emu = new TH1F("ecalTP_emu", ";TP E_{T}; # Entries", nTpBins, tpLo, tpHi);
Expand Down Expand Up @@ -357,6 +369,11 @@ void rates(bool newConditions, const std::string& inputFileDirectory){
if( l1emu_->sumType[c] == L1Analysis::kMissingEtHF ) metHFSum = l1emu_->sumEt[c];
if( l1emu_->sumType[c] == L1Analysis::kMissingHt ) mhtSum = l1emu_->sumEt[c];
}
htSum_emu->Fill(htSum);
mhtSum_emu->Fill(mhtSum);
etSum_emu->Fill(etSum);
metSum_emu->Fill(metSum);
metHFSum_emu->Fill(metHFSum);

// for each bin fill according to whether our object has a larger corresponding energy
for(int bin=0; bin<nJetBins; bin++){
Expand Down Expand Up @@ -541,6 +558,11 @@ void rates(bool newConditions, const std::string& inputFileDirectory){
if( l1hw_->sumType[c] == L1Analysis::kMissingEtHF ) metHFSum = l1hw_->sumEt[c];
if( l1hw_->sumType[c] == L1Analysis::kMissingHt ) mhtSum = l1hw_->sumEt[c];
}
htSum_hw->Fill(htSum);
mhtSum_hw->Fill(mhtSum);
etSum_hw->Fill(etSum);
metSum_hw->Fill(metSum);
metHFSum_hw->Fill(metHFSum);

// for each bin fill according to whether our object has a larger corresponding energy
for(int bin=0; bin<nJetBins; bin++){
Expand Down Expand Up @@ -661,6 +683,11 @@ void rates(bool newConditions, const std::string& inputFileDirectory){
etSumRates_emu->Write();
metSumRates_emu->Write();
metHFSumRates_emu->Write();
htSum_emu->Write();
mhtSum_emu->Write();
etSum_emu->Write();
metSum_emu->Write();
metHFSum_emu->Write();
}

if (hwOn){
Expand Down Expand Up @@ -702,6 +729,12 @@ void rates(bool newConditions, const std::string& inputFileDirectory){
etSumRates_hw->Write();
metSumRates_hw->Write();
metHFSumRates_hw->Write();
htSum_hw->Write();
mhtSum_hw->Write();
etSum_hw->Write();
metSum_hw->Write();
metHFSum_hw->Write();

}
myfile << "using the following ntuple: " << inputFile << std::endl;
myfile << "number of colliding bunches = " << numBunch << std::endl;
Expand Down