-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathdraw.C
42 lines (25 loc) · 793 Bytes
/
draw.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
void draw(string filename, int ch, int event){
//TFile *f = TFile::Open(filename.c_str());//new TFile(file);
TFile *f = new TFile(filename.c_str(), "READ");
TTree *t = (TTree*)f->Get("data");
cout<<t->GetEntries()<<endl;
stringstream ss;
ss<<ch;
TString c = ss.str();
vector<double> *data = new vector<double>;
double xinc;
double tm;
t->SetBranchAddress("ch"+c, &data);
t->SetBranchAddress("time", &tm);
t->SetBranchAddress("xinc", &xinc);
t->GetEntry(event);
TGraph *gr = new TGraph();
for(int i=0; i<data->size(); i++){
gr->SetPoint(i, i*xinc/1e-6, data->at(i));
}
gr->GetXaxis()->SetTitle("time (#mus)");
gr->GetYaxis()->SetTitle("ADC counts");
gr->GetYaxis()->SetTitleOffset(1.42);
gr->Draw("AL");
f->Close();
}