forked from CMSAachen3B/PlottingTool
-
Notifications
You must be signed in to change notification settings - Fork 0
/
runPlotting.cc
65 lines (53 loc) · 1.64 KB
/
runPlotting.cc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
/////////////////////////////////////////////////
//
// plotting.cc: main macro to run in ROOT
// call like "root runPlotting.cc+" in your shell
//
/////////////////////////////////////////////////
#include "TROOT.h"
#include "TFile.h"
#include "TCanvas.h"
#include "TH1D.h"
#include "TLegend.h"
#include "TColor.h"
#include <vector>
#include "tdrstyle.C"
#include "CMS_lumi.C"
#include "userConfig.h"
#include "defineSamplesAndPlots.h"
#include "plottingHelpers.h"
void runPlotting(){
if(verbose) std::cout << "--> plotting()" << std::endl;
gROOT->LoadMacro("tdrstyle.C");
setTDRStyle();
gROOT->LoadMacro("CMS_lumi.C");
writeExtraText = true;
gStyle->SetOptStat(0);
// define which samples to use
std::vector<sample> samples = defineSamples();
// define which plots to draw
std::vector<plotInfo> plots = definePlots();
// todo: implement syst
// test validity of structs
testInputs(conf, samples, plots);
// create plots
if(testPlotting){
plotInfo testPlot = plots.at(0);
TH1D* datahist = getHisto(conf, testPlot.identifier+"Data", 1, 1);
manipulateHisto(datahist, testPlot);
drawPlot(conf, testPlot, datahist, samples);
}else{
std::vector<TH1D*> datahists;
for(unsigned p = 0; p < plots.size(); p++){
TH1D* datahist = getHisto(conf, plots.at(p).identifier+"Data", 1, 1);
manipulateHisto(datahist, plots.at(p));
datahists.push_back(datahist);
}
for(unsigned p = 0; p < plots.size(); p++){
drawPlot(conf, plots.at(p), datahists.at(p), samples);
}
}
// convert all created eps files into pdf
std::cout << "Plots created. Convert all eps into pdf..." << std::endl;
system("for i in `ls -1 *.eps`; do epstopdf $i; done");
}