-
Notifications
You must be signed in to change notification settings - Fork 0
/
PlotScintvsNhits.C
60 lines (45 loc) · 1.25 KB
/
PlotScintvsNhits.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
#include <TH1D.h>
#include <TGraphErrors.h>
#include <TCanvas.h>
#include <TLegend.h>
#include <TStyle.h>
#include "TFile.h"
#include "TPaveText.h"
#include "TTree.h"
#include <algorithm>
#include <cctype>
#include <string>
#include <TGraph.h>
#include <string>
void PlotScintvsNhits(){
gStyle->SetOptStat(0);
gStyle->SetFrameLineWidth(2);
TCanvas* c1 = new TCanvas("c1", "c1", 800,600);
gPad->SetGrid(1);
Int_t n = 4;
Double_t x[4] = {2.5,5.0,7.5,10.0};
Double_t xerr[4] = {0,0,0,0};
Double_t y[6] = {185.954830522, 185.25569251, 184.486478183, 183.710922616};
Double_t yerr[6] = {0.326,0.346,0.396,0.456};
Double_t hits[4];
for(int i=0; i<4; i++){
hits[i] = 252.149*x[i] + 166.108;
}
// create graph
TGraphErrors *gr = new TGraphErrors(n,hits,y,xerr,yerr);
gr->SetTitle("Effective Velocity vs Nhits");
gr->SetMarkerStyle(1);
gr->SetMarkerColor(kBlue);
gr->SetLineColor(kBlue);
gr->SetMarkerSize(2);
gr->SetLineWidth(2);
gr->GetXaxis()->SetRangeUser(0,12);
gr->GetYaxis()->SetRangeUser(180,190);
gr->GetXaxis()->SetTitle("Nhits");
gr->GetYaxis()->SetTitle("Effective Velocity mm/ns");
TF1 *g1 = new TF1("g1","pol1");
g1->SetLineWidth(2);
g1->SetLineColor(kRed);
gr->Fit("g1");
gr->Draw("AP");
}