-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathplotWF.C
More file actions
executable file
·100 lines (81 loc) · 2.35 KB
/
Copy pathplotWF.C
File metadata and controls
executable file
·100 lines (81 loc) · 2.35 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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
//pioooo
//pippo
#include <TFile.h>
#include <TTree.h>
#include <TH1F.h>
#include <TF1.h>
#include <TMath.h>
#include <TLegend.h>
#include <TLatex.h>
#include <TH2F.h>
#include <TCanvas.h>
#include <TFile.h>
#include <TGraphErrors.h>
#include <TStyle.h>
#include <TSystem.h>
#include <TROOT.h>
#include <TLine.h>
void plotWF(const char * filename,int i){
TFile * file= new TFile(filename);
TTree * WFTree = (TTree*)file->Get("wf");
TTree * digiTree = (TTree*)file->Get("digi");
Float_t tot_WF[6144],wf_time[6144],digi_time[60];
Float_t ch[6][1024], time[1024],startime[2];
int wf_sample,step[6144];
int j,k,LED300;
WFTree->SetBranchAddress("WF_time",&wf_time);
WFTree->SetBranchAddress("WF_val",&tot_WF);
WFTree->SetBranchAddress("WF_samples",&wf_sample);
digiTree->SetBranchAddress("time",&digi_time);
digiTree->SetBranchAddress("LED300",&LED300);
int p;
p=i;
for(k=0;k<WFTree->GetEntries();k++){
if (i==0) p=k;
cout<<p<<endl;
WFTree->GetEntry(p);
digiTree->GetEntry(p);
for(j=0;j<wf_sample;j++){
step[j]= j;
ch[(int)j/1024][j%1024]=tot_WF[j];
if(j<1024) time[j]= wf_time[j];
}//chiudo for j
startime[0]=digi_time[1+LED300];
startime[1]=digi_time[2+LED300];
TCanvas* wf_c =new TCanvas("wf","Plot wf",1000,650);
TGraph* graph[6];
TLine* start[2];
wf_c->Divide(3,2);
TLegend* leg[2];
for (j=0;j<6;j++){
graph[j] = new TGraph(wf_sample/6,wf_time,ch[j]);
wf_c->cd(j+1);
//graph[j]->GetXaxis()->SetTitleSize(10);
graph[j]->GetXaxis()->SetTitle("time [ns]");
//graph[j]->GetYaxis()->SetTitleSize(10);
graph[j]->GetYaxis()->SetTitle("amplitude [mV]");
graph[j]->Draw();
if(j==1){
start[0]=new TLine(startime[0],0,startime[0],500);
start[0]->SetLineColor(kRed);
start[0]->Draw("same");
leg[0]=new TLegend();
leg[0]->AddEntry(start[0],(to_string(startime[0])).c_str());
leg[0]->Draw("SAME");
cout<< startime[0]<<endl;
}
if(j==2){
start[1]=new TLine(startime[1],0,startime[1],500);
start[1]->SetLineColor(kRed);
start[1]->Draw("same");
leg[1]=new TLegend();
leg[1]->AddEntry(start[1],(to_string(startime[1])).c_str());
leg[1]->Draw("SAME");
cout<< startime[1]<<endl;
}
}//chiudo for j
wf_c->Update();
if(i!=0) break;
gPad->WaitPrimitive();
}//chiudo for k
}