-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathset_plotter.cpp
More file actions
67 lines (53 loc) · 1.77 KB
/
set_plotter.cpp
File metadata and controls
67 lines (53 loc) · 1.77 KB
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
65
66
67
#include <iostream>
#include <map>
#include "TFile.h"
#include "TAxis.h"
#include "TGraph.h"
#include "TMultiGraph.h"
#include "TCanvas.h"
#include "TLegend.h"
static std::string plot_dir = "/home/matthew/gad_work/gad_utils/set_plots/";
int main(int argc, char* argv[]){
try{
if (argc != 4){
throw std::runtime_error("wrong args: usage is ./set_plotter <abs> <combchi2> <abschi2>");
}
std::map<TMultiGraph*, std::string> mvec = {};
TFile* abs = TFile::Open(argv[1], "OPEN");
TMultiGraph* m_abs = static_cast<TMultiGraph*>(abs->Get("Graph"));
mvec[m_abs] = plot_dir + "/absscaling";
abs->Close();
TFile* comb_chi2 = TFile::Open(argv[2], "OPEN");
TMultiGraph* m_combchi2 = static_cast<TMultiGraph*>(comb_chi2->Get("Graph"));
mvec[m_combchi2] = plot_dir + "/chicomb";
comb_chi2->Close();
TFile* abs_chi2 = TFile::Open(argv[3], "OPEN");
TMultiGraph* m_abschi2 = static_cast<TMultiGraph*>(abs_chi2->Get("Graph"));
mvec[m_abschi2] = plot_dir + "/chiabs";
abs_chi2->Close();
for (const auto& [g, fname] : mvec){
TCanvas c1 = TCanvas("c1", "c1", 2500, 2000);
c1.cd();
c1.SetGrid();
g->Draw("apl");
for (int i = 0; i < g->GetListOfGraphs()->GetSize(); ++i){
TGraph* f = static_cast<TGraph*>(g->GetListOfGraphs()->At(i));
f->SetMarkerStyle(9);
f->SetMarkerSize(10);
f->SetMarkerColor(static_cast<Color_t>(i+1));
f->SetLineColor(static_cast<Color_t>(i+1));
f->SetLineWidth(3);
}
TLegend* l1 = c1.BuildLegend(0.15, 0.7, 0.3, 0.85);
l1->SetLineWidth(0);
l1->SetFillColor(kGray);
c1.Modified();
c1.SaveAs((fname+".png").c_str());
}
}
catch (const std::exception& e){
std::cout << e.what() << std::endl;
return 1;
}
return 0;
}