-
Notifications
You must be signed in to change notification settings - Fork 0
/
plotFile_single.c
87 lines (63 loc) · 1.6 KB
/
plotFile_single.c
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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
#include <sstream> // class for parsing strings
#include <iostream>
#include <fstream>
#include <stdio.h>
#include <cmath>
#include <TROOT.h>
#include <TChain.h>
#include <TFile.h>
#include <TH1F.h>
#include <TCanvas.h>
#include <TPaveStats.h>
#include <TPad.h>
#include <TMath.h>
#include <TStyle.h>
#include <TSystem.h>
#include <TLegend.h>
#include <TString.h>
#include <TGraph.h>
#include <TLatex.h>
#include <TMultiGraph.h>
void plotFile_single() {
// Data file
TString input = "data/SingleGEM/gain_energy/results.txt";
// Output filename
TString output = "data/SingleGEM/gain_energy/results.pdf";
// Settings
TString title = "";
TString xaxis = "primary electron energy [eV]";
TString yaxis = "effective gain";
TString data = "Experiment";
// Graphical styles
gROOT->ProcessLine(".x rootstyle.c");
gROOT->SetStyle("newStyle");
TGraph *plot = new TGraph();
Int_t i = 0;
ifstream inp;
string line;
inp.open(input);
Double_t x, y;
// Read first line
getline(inp,line);
while(getline(inp,line)) {
stringstream ss(line);
//cout << line << endl;
ss >> x >> y;
plot->SetPoint(i, x, y);
i++;
}
TCanvas *c1 = new TCanvas("c1", "plot", 750, 500);
c1->cd();
TLegend *legend = new TLegend(0.2, 0.7, 0.4, 0.85);
legend->AddEntry(plot, data, "p");
plot->GetXaxis()->SetTitle(xaxis);
plot->GetYaxis()->SetTitle(yaxis);
plot->GetXaxis()->SetLimits(-5., 100.);
//plot->GetYaxis()->SetLimits(rangeLeft, rangeRight);
plot->Draw("AP");
plot->SetMarkerColor(kRed);
plot->SetMarkerSize(1.);
legend->Draw("SAME");
c1->Update();
c1->SaveAs(output);
}