-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathplot_ROI.C
More file actions
126 lines (104 loc) · 3.55 KB
/
plot_ROI.C
File metadata and controls
126 lines (104 loc) · 3.55 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
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
void restore_baseline(TH1F *htemp){
//correct baseline
double max = htemp->GetMaximum();
double min = htemp->GetMinimum();
int nbin_b = max - min;
Int_t nbin = htemp->GetNbinsX();
if (nbin_b ==0) nbin_b = 1;
TH1F *h1 = new TH1F("h1","h1",nbin_b,min,max);
for (int j=0;j!=nbin;j++){
h1->Fill(htemp->GetBinContent(j+1));
}
float ped = h1->GetMaximumBin()*(max-min)/(nbin_b*1.) + min;
float ave=0,ncount = 0;
for (int j=0;j!=nbin;j++){
if (fabs(htemp->GetBinContent(j+1)-ped)<400){
ave +=htemp->GetBinContent(j+1);
ncount ++;
}
}
if (ncount==0) ncount=1;
ave = ave/ncount;
for (int j=0;j!=nbin;j++){
double content = htemp->GetBinContent(j+1);
content -= ave;
htemp->SetBinContent(j+1,content);
}
delete h1;
}
void plot_ROI(Int_t run=3493){
Int_t plane = 0;
//Int_t run = 3493;
// Int_t run = 5366;
Int_t wire_bin_min;
Int_t wire_bin_max;
Int_t time_bin_min;
Int_t time_bin_max;
if (run == 3493){
wire_bin_min = 1170;
wire_bin_max = 1300;
// wire_bin_min = 3850-2400;
// wire_bin_max = 3930-2400;
time_bin_min = 6200;
time_bin_max = 7800;
}else if (run == 5366){
wire_bin_min = 1220;
wire_bin_max = 1350;
time_bin_min = 6300;
time_bin_max = 7500;
}
TFile *file = new TFile(Form("%d_2D_lf_all_25.root",run));
TH2F *hdecon;
TH2F *hdecon1;
TH1F *htemp;
if (plane == 0){
hdecon = (TH2F*)file->Get("hdecon_u");
}else if (plane == 1){
hdecon = (TH2F*)file->Get("hdecon_v");
}else if (plane == 2){
hdecon = (TH2F*)file->Get("hdecon_w");
}
Int_t nwire = wire_bin_max - wire_bin_min + 1;
Int_t ntime = time_bin_max - time_bin_min + 1;
hdecon1 = new TH2F("hdecon1","hdecon1",nwire,0,nwire,ntime,0,ntime);
htemp = new TH1F("htemp","htemp",ntime,0,ntime);
for (Int_t i=wire_bin_min; i!= wire_bin_max+1; i++){
for (Int_t j=time_bin_min; j!=time_bin_max+1; j++){
htemp->SetBinContent(j-time_bin_min+1,hdecon->GetBinContent(i+1,j+1));
}
restore_baseline(htemp);
for (Int_t j=time_bin_min; j!=time_bin_max+1; j++){
hdecon1->SetBinContent(i-wire_bin_min+1,j-time_bin_min+1,htemp->GetBinContent(j-time_bin_min+1));
}
}
hdecon1->Draw("COLZ");
Double_t factor1 = 6;
TFile *file1 = new TFile(Form("ROI_2D_25_%d.root",run));
TTree *T = (TTree*)file1->Get("T");
Int_t s_begin,s_end,s_channel,s_plane;
T->SetBranchAddress("begin",&s_begin);
T->SetBranchAddress("end",&s_end);
T->SetBranchAddress("channel",&s_channel);
T->SetBranchAddress("plane",&s_plane);
for (Int_t i=0;i!=T->GetEntries();i++){
T->GetEntry(i);
if (plane == s_plane && s_channel >= wire_bin_min && s_channel <= wire_bin_max){
TLine *l1 = new TLine(s_channel - wire_bin_min+0.5,s_begin*factor1-time_bin_min+0.5,s_channel - wire_bin_min+0.5,s_end*factor1-time_bin_min-0.5);
l1->Draw("same");
}
}
// TFile *file2 = new TFile(Form("ROI_1D_%d.root",run));
// TTree *T1 = (TTree*)file2->Get("T");
// T1->SetBranchAddress("begin",&s_begin);
// T1->SetBranchAddress("end",&s_end);
// T1->SetBranchAddress("channel",&s_channel);
// T1->SetBranchAddress("plane",&s_plane);
// for (Int_t i=0;i!=T1->GetEntries();i++){
// T1->GetEntry(i);
// if (plane == s_plane && s_channel >= wire_bin_min && s_channel <= wire_bin_max){
// TLine *l1 = new TLine(s_channel - wire_bin_min+0.5,s_begin*factor1-time_bin_min+0.5,s_channel - wire_bin_min+0.5,s_end*factor1-time_bin_min-0.5);
// l1->Draw("same");
// l1->SetLineColor(6);
// }
// }
}