Rev 202 | Rev 205 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 202 | Rev 204 | ||
---|---|---|---|
Line 2... | Line 2... | ||
2 | #include "TH2.h" |
2 | #include "TH2.h" |
3 | #include "TGraph.h" |
3 | #include "TGraph.h" |
4 | #include "TCanvas.h" |
4 | #include "TCanvas.h" |
5 | #include "TStyle.h" |
5 | #include "TStyle.h" |
6 | #include "TLegend.h" |
6 | #include "TLegend.h" |
- | 7 | #include "TFile.h" |
|
7 | //#include "TROOT.h" |
8 | //#include "TROOT.h" |
8 | 9 | ||
9 | #include <stdio.h> |
10 | #include <stdio.h> |
10 | #include <time.h> |
11 | #include <time.h> |
11 | 12 | ||
Line 72... | Line 73... | ||
72 | TH2F *h2_dpo[NCH]; |
73 | TH2F *h2_dpo[NCH]; |
73 | TH2F *h2_tdcadc[NCH]; |
74 | TH2F *h2_tdcadc[NCH]; |
74 | TH2F *h2_ctdcadc[NCH]; |
75 | TH2F *h2_ctdcadc[NCH]; |
75 | TH2F *h2_ctalk; |
76 | TH2F *h2_ctalk; |
76 | TGraph *gr_wfm[NCH]; |
77 | TGraph *gr_wfm[NCH]; |
- | 78 | ||
- | 79 | TFile *froot = new TFile(TString(FileName) + ".root","RECREATE"); |
|
- | 80 | ||
77 | TCanvas *c_wfm= new TCanvas("c_wfm","WFM",50,50,700,700); |
81 | TCanvas *c_wfm= new TCanvas("c_wfm","WFM",50,50,700,700); |
78 | TLegend *leg = new TLegend(0.8, 0.8, 1, 1); |
82 | TLegend *leg = new TLegend(0.8, 0.8, 1, 1); |
79 | c_wfm->Divide(1,1); |
83 | c_wfm->Divide(1,1); |
80 | c_wfm->cd(1); |
84 | c_wfm->cd(1); |
81 | 85 | ||
82 | for (i=0; i<nch; i++) { |
86 | for (i=0; i<nch; i++) { |
83 | sprintf(histname,"chmax_%02d",i); |
87 | sprintf(histname,"chmax_%02d",i); |
84 | h1_chmax[i]=new TH1F(histname,histname, |
88 | h1_chmax[i]=new TH1F(histname,histname,1100,-0.88,0.88); |
85 | sprintf(histname,"chmaxt_%02d",i); |
89 | sprintf(histname,"chmaxt_%02d",i); |
86 | h1_chmaxt[i]=new TH1F(histname,histname,DWIDTH,-0.1,204.7); |
90 | h1_chmaxt[i]=new TH1F(histname,histname,DWIDTH,-0.1,204.7); |
87 | sprintf(histname,"chmin_%02d",i); |
91 | sprintf(histname,"chmin_%02d",i); |
88 | h1_chmin[i]=new TH1F(histname,histname, |
92 | h1_chmin[i]=new TH1F(histname,histname,1100,-0.55,0.55); |
89 | sprintf(histname,"chmint_%02d",i); |
93 | sprintf(histname,"chmint_%02d",i); |
90 | h1_chmint[i]=new TH1F(histname,histname,DWIDTH,-0.1, |
94 | h1_chmint[i]=new TH1F(histname,histname,DWIDTH,-0.1,504.7); |
91 | sprintf(histname,"letime_%02d",i); |
95 | sprintf(histname,"letime_%02d",i); |
92 | h1_letime[i]=new TH1F(histname,histname,500,d[i].twin[0],d[i].twin[1]); |
96 | h1_letime[i]=new TH1F(histname,histname,500,d[i].twin[0],d[i].twin[1]); |
93 | sprintf(histname,"cftime_%02d",i); |
97 | sprintf(histname,"cftime_%02d",i); |
94 | h1_cftime[i]=new TH1F(histname,histname,500,d[i].twin[0],d[i].twin[1]); |
98 | h1_cftime[i]=new TH1F(histname,histname,500,d[i].twin[0],d[i].twin[1]); |
95 | sprintf(histname,"cftdif_%02d",i); |
99 | sprintf(histname,"cftdif_%02d",i); |
96 | h1_cftdif[i]=new TH1F(histname,histname,2000,d[i].twin[0]-d[trgch].twin[0],d[i].twin[1]-d[trgch].twin[0]); |
100 | h1_cftdif[i]=new TH1F(histname,histname,2000,d[i].twin[0]-d[trgch].twin[0],d[i].twin[1]-d[trgch].twin[0]); |
97 | sprintf(histname,"qdc_%02d",i); |
101 | sprintf(histname,"qdc_%02d",i); |
98 | h1_qdc[i]=new TH1F(histname,histname,500,-0.5,4.5); |
102 | h1_qdc[i]=new TH1F(histname,histname,500,-0.5,4.5); |
99 | sprintf(histname,"dpo_%02d",i); |
103 | sprintf(histname,"dpo_%02d",i); |
100 | h2_dpo[i]=new TH2F(histname,histname,DWIDTH,-0.1, |
104 | h2_dpo[i]=new TH2F(histname,histname,DWIDTH,-0.1,200.7,3000,-0.9,0.9); |
101 | sprintf(histname,"tdcadc_%02d",i); |
105 | sprintf(histname,"tdcadc_%02d",i); |
102 | h2_tdcadc[i]=new TH2F(histname,histname,250,-0.1,0.5,400,d[i].twin[0]-d[trgch].twin[0],d[i].twin[1]-d[trgch].twin[0]); |
106 | h2_tdcadc[i]=new TH2F(histname,histname,250,-0.1,0.5,400,d[i].twin[0]-d[trgch].twin[0],d[i].twin[1]-d[trgch].twin[0]); |
103 | sprintf(histname,"ctdcadc_%02d",i); |
107 | sprintf(histname,"ctdcadc_%02d",i); |
104 | h2_ctdcadc[i]=new TH2F(histname,histname,250,-0.1,0.5,400,d[i].twin[0]-d[trgch].twin[0],d[i].twin[1]-d[trgch].twin[0]); |
108 | h2_ctdcadc[i]=new TH2F(histname,histname,250,-0.1,0.5,400,d[i].twin[0]-d[trgch].twin[0],d[i].twin[1]-d[trgch].twin[0]); |
105 | gr_wfm[i]=new TGraph(DWIDTH); |
109 | gr_wfm[i]=new TGraph(DWIDTH); |
106 | gr_wfm[i]->SetMinimum(-0. |
110 | gr_wfm[i]->SetMinimum(-0.9); |
107 | gr_wfm[i]->SetMaximum(0. |
111 | gr_wfm[i]->SetMaximum(0.9); |
108 | gr_wfm[i]->SetLineColor(i+1); |
112 | gr_wfm[i]->SetLineColor(i+1); |
109 | gr_wfm[i]->SetMarkerColor(i+1); |
113 | gr_wfm[i]->SetMarkerColor(i+1); |
110 | sprintf(histname,"ch %d",i); |
114 | sprintf(histname,"ch %d",i); |
111 | leg->AddEntry(gr_wfm[i], histname, "l"); |
115 | leg->AddEntry(gr_wfm[i], histname, "l"); |
112 | if (i) gr_wfm[i]->Draw("LP"); else gr_wfm[i]->Draw("ALP"); |
116 | if (i) gr_wfm[i]->Draw("LP"); else gr_wfm[i]->Draw("ALP"); |
113 | gr_wfm[i]->GetHistogram()->SetTitle("WaveForms"); |
117 | gr_wfm[i]->GetHistogram()->SetTitle("WaveForms"); |
114 | } |
118 | } |
115 | 119 | ||
116 | leg->Draw(); |
120 | leg->Draw(); |
117 | h2_ctalk=new TH2F("ctalk","ctalk",250,0.,0.5,250,0.,0.5); |
121 | h2_ctalk=new TH2F("ctalk","ctalk",250,0.,0.5,250,0.,0.5); |
118 | 122 | ||
119 | fin=fopen(FileName,"rb"); |
123 | fin=fopen(FileName,"rb"); |
120 | if (fin==NULL) { |
124 | if (fin==NULL) { |
121 | printf("Error opening file %s\n",FileName); |
125 | printf("Error opening file %s\n",FileName); |
122 | return; |
126 | return; |
123 | } |
127 | } |
Line 221... | Line 225... | ||
221 | qdc[ich]=0; |
225 | qdc[ich]=0; |
222 | chmax[ich][0]=-1; chmax[ich][1]=-1; |
226 | chmax[ich][0]=-1; chmax[ich][1]=-1; |
223 | chmin[ich][0]=1; chmin[ich][1]=-1; |
227 | chmin[ich][0]=1; chmin[ich][1]=-1; |
224 | letime[ich]=-1.; letime[ich]=-1.; |
228 | letime[ich]=-1.; letime[ich]=-1.; |
225 | cftime[ich]=-1.; cftime[ich]=-1.; |
229 | cftime[ich]=-1.; cftime[ich]=-1.; |
226 | 230 | ||
227 | 231 | ||
228 | lwfm[ich]=1; |
232 | lwfm[ich]=1; |
229 | nwfm[ich]+=1; |
233 | nwfm[ich]+=1; |
230 | 234 | ||
231 | 235 | ||
Line 263... | Line 267... | ||
263 | 267 | ||
264 | // signal maximum |
268 | // signal maximum |
265 | if (y[i]<chmin[ich][0]) { |
269 | if (y[i]<chmin[ich][0]) { |
266 | chmin[ich][0]=y[i]; |
270 | chmin[ich][0]=y[i]; |
267 | chmin[ich][1]=t[i]; |
271 | chmin[ich][1]=t[i]; |
268 | } |
272 | } |
269 | float t0 = t[i]; |
273 | float t0 = t[i]; |
270 | float t0p = t[i+1]; |
274 | float t0p = t[i+1]; |
271 | float t0n = t[i-1]; |
275 | float t0n = t[i-1]; |
272 | // charge in the range |
276 | // charge in the range |
273 | if ((t0>d[ich].adcgate[0])&&(t0<d[ich].adcgate[1])) { |
277 | if ((t0>d[ich].adcgate[0])&&(t0<d[ich].adcgate[1])) { |
274 | float sign = (d[ich].edge)? 1: -1; |
278 | float sign = (d[ich].edge)? 1: -1; |
Line 286... | Line 290... | ||
286 | ( d[ich].edge)&&(y[i]>d[ich].threshold ) ) |
290 | ( d[ich].edge)&&(y[i]>d[ich].threshold ) ) |
287 | &&(letime[ich]<0.)) { |
291 | &&(letime[ich]<0.)) { |
288 | letime[ich]=t0n+(t0-t0n)*(d[ich].threshold-y[i-1])/(y[i]-y[i-1]); |
292 | letime[ich]=t0n+(t0-t0n)*(d[ich].threshold-y[i-1])/(y[i]-y[i-1]); |
289 | } |
293 | } |
290 | // constant fraction time in the range |
294 | // constant fraction time in the range |
- | 295 | if (cftime[ich]<0.){ |
|
- | 296 | // negative signals |
|
291 | if |
297 | if ((!d[ich].edge) && (chmin[ich][0]<d[ich].threshold)&&(y[i]<chmin[ich][0]*d[ich].cfrac )){ |
292 |
|
298 | cftime[ich]=t0n+(t0-t0n)*(chmin[ich][0]*d[ich].cfrac-y[i-1])/(y[i]-y[i-1]); |
- | 299 | } |
|
293 |
|
300 | // positive signals |
294 | - | ||
295 |
|
301 | if (( d[ich].edge) && (chmax[ich][0]>d[ich].threshold)&&(y[i]>chmax[ich][0]*d[ich].cfrac)){ |
296 | cftime[ich]=t0n+(t0-t0n)*( |
302 | cftime[ich]=t0n+(t0-t0n)*(chmax[ich][0]*d[ich].cfrac-y[i-1])/(y[i]-y[i-1]); |
297 | } |
303 | } |
- | 304 | } |
|
298 | } |
305 | } |
299 | } |
306 | } |
300 | 307 | ||
301 | if ((chmax[ich][1]>d[ich].twin[0])&&(chmax[ich][1]<d[ich].twin[1])) { |
308 | if ((chmax[ich][1]>d[ich].twin[0])&&(chmax[ich][1]<d[ich].twin[1])) { |
302 | h1_chmax[ich]->Fill(chmax[ich][0]); |
309 | h1_chmax[ich]->Fill(chmax[ich][0]); |
Line 325... | Line 332... | ||
325 | printf("number of events: %d\n",iev); |
332 | printf("number of events: %d\n",iev); |
326 | fclose(fin); |
333 | fclose(fin); |
327 | 334 | ||
328 | TCanvas* c_dpo= new TCanvas("c_dpo","DPO",750,50,700,700); |
335 | TCanvas* c_dpo= new TCanvas("c_dpo","DPO",750,50,700,700); |
329 | c_dpo->Divide(2,2); |
336 | c_dpo->Divide(2,2); |
330 | for (i=0; i<nch; i++) {c_dpo->cd(i+1); h2_dpo[i]-> |
337 | for (i=0; i<nch; i++) {c_dpo->cd(i+1); h2_dpo[i]->DrawCopy("colz");} |
331 | 338 | ||
332 | TCanvas* c_cftdif= new TCanvas("c_cftdif","DPO",750,50,700,700); |
339 | TCanvas* c_cftdif= new TCanvas("c_cftdif","DPO",750,50,700,700); |
333 | c_cftdif->Divide(2,2); |
340 | c_cftdif->Divide(2,2); |
334 | for (i=0; i<nch; i++) {c_cftdif->cd(i+1); h1_cftdif[i]-> |
341 | for (i=0; i<nch; i++) {c_cftdif->cd(i+1); h1_cftdif[i]->DrawCopy();} |
- | 342 | froot->Write(); |
|
- | 343 | froot->Close(); |
|
335 | return; |
344 | return; |
336 | } |
345 | } |
337 | 346 | ||
338 | 347 | ||
339 | void drsana(int nev=1000, int updfrq=20, char *FileName="./data/x1.dat", int trgch=0){ |
348 | void drsana(int nev=1000, int updfrq=20, char *FileName="./data/x1.dat", int trgch=0){ |