Rev 40 | Rev 50 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 40 | Rev 47 | ||
---|---|---|---|
Line 4... | Line 4... | ||
4 | #include "TH1F.h" |
4 | #include "TH1F.h" |
5 | #include "TH2F.h" |
5 | #include "TH2F.h" |
6 | #include "TCanvas.h" |
6 | #include "TCanvas.h" |
7 | #include "TStyle.h" |
7 | #include "TStyle.h" |
8 | #include "TPad.h" |
8 | #include "TPad.h" |
- | 9 | #include "TPaveText.h" |
|
- | 10 | //#include "TLabel.h" |
|
9 | #include "TF1.h" |
11 | #include "TF1.h" |
10 | #include "TGraph.h" |
12 | #include "TGraph.h" |
11 | #include "TSpectrum.h" |
13 | #include "TSpectrum.h" |
12 | #include "stdio.h" |
14 | #include "stdio.h" |
13 | 15 | ||
14 | #include "include/RTUtil.h" |
16 | #include "include/RTUtil.h" |
15 | 17 | ||
16 | double getNoise(TH2F*, int, int); |
18 | double getNoise(TH2F*, int, int); |
17 | 19 | ||
18 | int sipm(char filename[256] = "test", char plopt[256]="all", int |
20 | int sipm(char filename[256] = "test", char plopt[256]="all", int parameter1=0, int parameter2=7, int chYstart=0, int chYend=7, bool debug = false) |
19 | { |
21 | { |
20 | const int c_nChannels = 64; |
22 | const int c_nChannels = 64; |
21 | const double c_xOffset = 0; // mm |
- | |
22 | const double c_yOffset = 0; |
- | |
23 | 23 | ||
24 | int map[8][8]={{32,34,53,55,40,42,61,63}, |
24 | int map[8][8]={{32,34,53,55,40,42,61,63}, |
25 | {48,50,37,39,56,58,45,47}, |
25 | {48,50,37,39,56,58,45,47}, |
26 | {33,35,52,54,41,43,60,62}, |
26 | {33,35,52,54,41,43,60,62}, |
27 | {49,51,36,38,57,59,44,46}, |
27 | {49,51,36,38,57,59,44,46}, |
Line 41... | Line 41... | ||
41 | return(0); |
41 | return(0); |
42 | } |
42 | } |
43 | 43 | ||
44 | // set draw style |
44 | // set draw style |
45 | RTSetStyle(gStyle); |
45 | RTSetStyle(gStyle); |
- | 46 | ||
- | 47 | // Print results to .pdf (option "p") |
|
- | 48 | if(strstr(plopt, "p") != NULL) { |
|
- | 49 | TCanvas* canvasFirst = new TCanvas("canvasFirst","",500,500); |
|
- | 50 | TPaveText* text = new TPaveText(.05,.1,.95,.8); |
|
- | 51 | text->AddText("SiPM Scan results"); |
|
- | 52 | canvasFirst->cd(); |
|
- | 53 | text->Draw(); |
|
- | 54 | canvasFirst->Print("result.pdf("); |
|
- | 55 | } |
|
46 | 56 | ||
47 | if( strstr(plopt, "all") != NULL ) { |
57 | if( strstr(plopt, "all") != NULL ) { |
48 | TCanvas *canvas2 = new TCanvas("canvas2","Hits x;;",2000,2000); |
58 | TCanvas *canvas2 = new TCanvas("canvas2","Hits x;;",2000,2000); |
49 | TCanvas *canvas3 = new TCanvas("canvas3","Hits y;;",2000,2000); |
59 | TCanvas *canvas3 = new TCanvas("canvas3","Hits y;;",2000,2000); |
50 | canvas2->Divide(8,8); |
60 | canvas2->Divide(8,8); |
Line 66... | Line 76... | ||
66 | 76 | ||
67 | if( strstr(plopt, "x") != NULL ) { |
77 | if( strstr(plopt, "x") != NULL ) { |
68 | TCanvas *canvas10 = new TCanvas("canvas10","Ch x;;",500,500); |
78 | TCanvas *canvas10 = new TCanvas("canvas10","Ch x;;",500,500); |
69 | TH1F* h_hitsx; |
79 | TH1F* h_hitsx; |
70 | canvas10->cd(); |
80 | canvas10->cd(); |
- | 81 | int chPosition = map[parameter1][parameter2]; |
|
71 | char hname[128]; |
82 | char hname[128]; |
72 | sprintf(hname, "hnhitsx%d", |
83 | sprintf(hname, "hnhitsx%d", chPosition); |
73 | h_hitsx = (TH1F*)rootfile->Get(hname); |
84 | h_hitsx = (TH1F*)rootfile->Get(hname); |
74 | h_hitsx->Draw(); |
85 | h_hitsx->Draw(); |
- | 86 | ||
- | 87 | if(strstr(plopt, "p") != NULL) { |
|
- | 88 | canvas10->Print("result.pdf"); |
|
- | 89 | } |
|
- | 90 | ||
75 | } |
91 | } |
76 | 92 | ||
77 | if( strstr(plopt, "y") != NULL ) { |
93 | if( strstr(plopt, "y") != NULL ) { |
78 | TCanvas *canvas11 = new TCanvas("canvas11","Ch x;;",500,500); |
94 | TCanvas *canvas11 = new TCanvas("canvas11","Ch x;;",500,500); |
79 | TH1F* h_hitsy; |
95 | TH1F* h_hitsy; |
80 | canvas11->cd(); |
96 | canvas11->cd(); |
- | 97 | int chPosition = map[parameter1][parameter2]; |
|
81 | char hname[128]; |
98 | char hname[128]; |
82 | sprintf(hname, "hnhitsy%d", |
99 | sprintf(hname, "hnhitsy%d", chPosition); |
83 | h_hitsy = (TH1F*)rootfile->Get(hname); |
100 | h_hitsy = (TH1F*)rootfile->Get(hname); |
84 | h_hitsy->Draw(); |
101 | h_hitsy->Draw(); |
- | 102 | ||
- | 103 | if(strstr(plopt, "p") != NULL) { |
|
- | 104 | canvas11->Print("result.pdf"); |
|
- | 105 | } |
|
85 | } |
106 | } |
86 | 107 | ||
87 | if( strstr(plopt, "share") != NULL ) { |
108 | if( strstr(plopt, "share") != NULL ) { |
88 | /*TCanvas *canvas4 = new TCanvas("canvas1","canvas1",1000,1000); |
109 | /*TCanvas *canvas4 = new TCanvas("canvas1","canvas1",1000,1000); |
89 | int nChannels = chYend-chYstart+1; |
110 | int nChannels = chYend-chYstart+1; |
Line 100... | Line 121... | ||
100 | h_hitsy->Draw(); |
121 | h_hitsy->Draw(); |
101 | }*/ |
122 | }*/ |
102 | 123 | ||
103 | TCanvas *canvas4 = new TCanvas("canvas4","canvas4",500,500); |
124 | TCanvas *canvas4 = new TCanvas("canvas4","canvas4",500,500); |
104 | canvas4->cd(); |
125 | canvas4->cd(); |
105 | for(int i= |
126 | for(int i=parameter1; i<=parameter2; i++) { |
106 | TH1F* h_hitsx; |
127 | TH1F* h_hitsx; |
107 | char hname[128]; |
128 | char hname[128]; |
108 | int chPosition = map[i][chYstart]; |
129 | int chPosition = map[i][chYstart]; |
109 | sprintf(hname, "hnhitsx%d", chPosition); |
130 | sprintf(hname, "hnhitsx%d", chPosition); |
110 | h_hitsx = (TH1F*)rootfile->Get(hname); |
131 | h_hitsx = (TH1F*)rootfile->Get(hname); |
111 | h_hitsx->SetTitle("Scan X;x [mm]; Entries"); |
132 | h_hitsx->SetTitle("Scan X;x [mm]; Entries"); |
112 | h_hitsx->GetYaxis()->SetTitleOffset(1.3); |
133 | h_hitsx->GetYaxis()->SetTitleOffset(1.3); |
113 | h_hitsx->SetStats(0); |
134 | h_hitsx->SetStats(0); |
114 | if (i == |
135 | if (i == parameter1) |
115 | h_hitsx->Draw(); |
136 | h_hitsx->Draw(); |
116 | else { |
137 | else { |
117 | h_hitsx->SetLineColor(i+1); |
138 | h_hitsx->SetLineColor(i+1); |
118 | h_hitsx->Draw("same"); |
139 | h_hitsx->Draw("same"); |
119 | } |
140 | } |
Line 124... | Line 145... | ||
124 | TCanvas *canvas5 = new TCanvas("canvas5","canvas5",500,500); |
145 | TCanvas *canvas5 = new TCanvas("canvas5","canvas5",500,500); |
125 | canvas5->cd(); |
146 | canvas5->cd(); |
126 | for(int i=chYstart; i<=chYend; i++) { |
147 | for(int i=chYstart; i<=chYend; i++) { |
127 | TH1F* h_hitsy; |
148 | TH1F* h_hitsy; |
128 | char hname[128]; |
149 | char hname[128]; |
129 | int chPosition = map[ |
150 | int chPosition = map[parameter1][i]; |
130 | sprintf(hname, "hnhitsy%d", chPosition); |
151 | sprintf(hname, "hnhitsy%d", chPosition); |
131 | h_hitsy = (TH1F*)rootfile->Get(hname); |
152 | h_hitsy = (TH1F*)rootfile->Get(hname); |
132 | h_hitsy->SetTitle("Scan Y;y [mm]; Entries"); |
153 | h_hitsy->SetTitle("Scan Y;y [mm]; Entries"); |
133 | h_hitsy->GetYaxis()->SetTitleOffset(1.3); |
154 | h_hitsy->GetYaxis()->SetTitleOffset(1.3); |
134 | h_hitsy->SetStats(0); |
155 | h_hitsy->SetStats(0); |
Line 151... | Line 172... | ||
151 | canvas51->cd(); |
172 | canvas51->cd(); |
152 | 173 | ||
153 | // Get the filled histogram from scan |
174 | // Get the filled histogram from scan |
154 | TH1F* h_x; |
175 | TH1F* h_x; |
155 | char name[32]; |
176 | char name[32]; |
156 | sprintf(name, "hnhitsx%d", |
177 | sprintf(name, "hnhitsx%d", parameter1); |
157 | h_x = (TH1F*)rootfile->Get(name); |
178 | h_x = (TH1F*)rootfile->Get(name); |
158 | h_x->DrawCopy(); |
179 | h_x->DrawCopy(); |
159 | 180 | ||
160 | TH1F* h_y; |
181 | TH1F* h_y; |
161 | sprintf(name, "hnhitsy%d", |
182 | sprintf(name, "hnhitsy%d", parameter1); |
162 | h_y = (TH1F*)rootfile->Get(name); |
183 | h_y = (TH1F*)rootfile->Get(name); |
163 | 184 | ||
164 | // Create and fill corrected histogram |
185 | // Create and fill corrected histogram |
165 | Int_t binsX = h_x->GetXaxis()->GetNbins(); |
186 | Int_t binsX = h_x->GetXaxis()->GetNbins(); |
166 | if(debug) printf("nBins: %d\n", binsX); |
187 | if(debug) printf("nBins: %d\n", binsX); |
Line 205... | Line 226... | ||
205 | * Draws also a 2d scan of these channels. |
226 | * Draws also a 2d scan of these channels. |
206 | */ |
227 | */ |
207 | if (strstr(plopt, "line") != NULL) { |
228 | if (strstr(plopt, "line") != NULL) { |
208 | TCanvas* canvas6 = new TCanvas("canvas6","canvas6",500,500); |
229 | TCanvas* canvas6 = new TCanvas("canvas6","canvas6",500,500); |
209 | canvas6->cd(0); |
230 | canvas6->cd(0); |
210 | gStyle->SetOptStat(0); |
231 | gStyle->SetOptStat(0); |
211 | 232 | ||
212 | TH2F* h0 = (TH2F*) rootfile->Get("h2d0"); |
233 | TH2F* h0 = (TH2F*) rootfile->Get("h2d0"); |
213 | Int_t binsX = h0->GetXaxis()->GetNbins(); |
234 | Int_t binsX = h0->GetXaxis()->GetNbins(); |
214 | Int_t minX = h0->GetXaxis()->GetFirst(); |
235 | Int_t minX = h0->GetXaxis()->GetFirst(); |
215 | Int_t maxX = h0->GetXaxis()->GetLast()+1; |
236 | Int_t maxX = h0->GetXaxis()->GetLast()+1; |
216 | Int_t binsY = h0->GetYaxis()->GetNbins(); |
237 | Int_t binsY = h0->GetYaxis()->GetNbins(); |
217 | Int_t minY = h0->GetYaxis()->GetFirst(); |
238 | Int_t minY = h0->GetYaxis()->GetFirst(); |
Line 227... | Line 248... | ||
227 | TH1F* h_line[8]; |
248 | TH1F* h_line[8]; |
228 | for(int j=0; j<8; j++) { |
249 | for(int j=0; j<8; j++) { |
229 | h_line[j] = new TH1F("h_line", "h_line", binsX, xLowUser, xUpUser); |
250 | h_line[j] = new TH1F("h_line", "h_line", binsX, xLowUser, xUpUser); |
230 | } |
251 | } |
231 | 252 | ||
232 | for(int j= |
253 | for(int j=parameter1; j<=parameter2; j++) { |
233 | int chPosition = map[j][chYstart]; |
254 | int chPosition = map[j][chYstart]; |
234 | char hname[128]; |
255 | char hname[128]; |
235 | sprintf(hname, "h2d%d", chPosition); |
256 | sprintf(hname, "h2d%d", chPosition); |
236 | int histogram = j; |
257 | int histogram = j; |
237 | h[histogram] = (TH2F *) rootfile->Get(hname); |
258 | h[histogram] = (TH2F *) rootfile->Get(hname); |
Line 243... | Line 264... | ||
243 | //signal -= noise; |
264 | //signal -= noise; |
244 | //signal /= 5*10000.0; |
265 | //signal /= 5*10000.0; |
245 | double eta = -log(1 - signal); |
266 | double eta = -log(1 - signal); |
246 | double x = xLowUser + k*(xUpUser-xLowUser)/double(binsX); |
267 | double x = xLowUser + k*(xUpUser-xLowUser)/double(binsX); |
247 | //double y = l*(yUpUser-yLowUser)/double(binsY); |
268 | //double y = l*(yUpUser-yLowUser)/double(binsY); |
248 | h_line[j]->Fill(x |
269 | h_line[j]->Fill(x, signal); |
249 | //} |
270 | //} |
250 | } |
271 | } |
251 | if (j == |
272 | if (j == parameter1) { |
252 | h_line[j]->SetTitle("SiPM#2 w/o noise subtraction;x[mm];Hits"); |
273 | h_line[j]->SetTitle("SiPM#2 w/o noise subtraction;x[mm];Hits"); |
253 | //h_line[j]->GetYaxis()->SetRangeUser(-0.05, 0.3); |
274 | //h_line[j]->GetYaxis()->SetRangeUser(-0.05, 0.3); |
254 | //h_line[j]->GetYaxis()->SetRangeUser(-50, 2500); |
275 | //h_line[j]->GetYaxis()->SetRangeUser(-50, 2500); |
255 | h_line[j]->Draw(""); |
276 | h_line[j]->Draw(""); |
256 | } |
277 | } |
Line 263... | Line 284... | ||
263 | 284 | ||
264 | //! 2d scan |
285 | //! 2d scan |
265 | TCanvas* canvas61 = new TCanvas("canvas61","canvas61",8*200,300); |
286 | TCanvas* canvas61 = new TCanvas("canvas61","canvas61",8*200,300); |
266 | canvas61->cd(); |
287 | canvas61->cd(); |
267 | TH2F* h_corrected = new TH2F("h_corrected","h_corrected",binsX,xLowUser,xUpUser, binsY,yLowUser,yUpUser); |
288 | TH2F* h_corrected = new TH2F("h_corrected","h_corrected",binsX,xLowUser,xUpUser, binsY,yLowUser,yUpUser); |
268 | for(int i= |
289 | for(int i=parameter1; i<=parameter2; i++) { |
269 | //int canvasPosition = nX*(i-chYstart)+(j- |
290 | //int canvasPosition = nX*(i-chYstart)+(j-parameter1)+1; |
270 | //int canvasPosition = nX*(chYend-i)+ |
291 | //int canvasPosition = nX*(chYend-i)+parameter1+1; |
271 | //if (debug) printf("canvas %d\n",canvasPosition); |
292 | //if (debug) printf("canvas %d\n",canvasPosition); |
272 | int chPosition = map[i][chYstart]; |
293 | int chPosition = map[i][chYstart]; |
273 | char hname[128]; |
294 | char hname[128]; |
274 | sprintf(hname, "h2d%d", chPosition); |
295 | sprintf(hname, "h2d%d", chPosition); |
275 | int histogram = i; |
296 | int histogram = i; |
Line 290... | Line 311... | ||
290 | double eta = -log(1 - p); |
311 | double eta = -log(1 - p); |
291 | //double x = k*(xUpUser-xLowUser)/double(binsX); |
312 | //double x = k*(xUpUser-xLowUser)/double(binsX); |
292 | //double y = l*(yUpUser-yLowUser)/double(binsY); |
313 | //double y = l*(yUpUser-yLowUser)/double(binsY); |
293 | double x = h[histogram]->GetXaxis()->GetBinCenter(k); |
314 | double x = h[histogram]->GetXaxis()->GetBinCenter(k); |
294 | double y = h[histogram]->GetYaxis()->GetBinCenter(l); |
315 | double y = h[histogram]->GetYaxis()->GetBinCenter(l); |
295 | h_corrected->Fill(x |
316 | h_corrected->Fill(x, y, eta); |
296 | } |
317 | } |
297 | } |
318 | } |
298 | } |
319 | } |
299 | h_corrected->SetTitle("SiPM#2 n_pe = - ln(P0);x[mm];y[mm]"); |
320 | h_corrected->SetTitle("SiPM#2 n_pe = - ln(P0);x[mm];y[mm]"); |
300 | h_corrected->GetZaxis()->SetRangeUser(-0.05,0.30); |
321 | h_corrected->GetZaxis()->SetRangeUser(-0.05,0.30); |
Line 313... | Line 334... | ||
313 | int nX = 3; |
334 | int nX = 3; |
314 | int nY = 3; |
335 | int nY = 3; |
315 | TCanvas* canvas7 = new TCanvas("canvas7","canvas7", nX*400,nY*400); |
336 | TCanvas* canvas7 = new TCanvas("canvas7","canvas7", nX*400,nY*400); |
316 | printf("nx %d ny %d\n",nX,nY); |
337 | printf("nx %d ny %d\n",nX,nY); |
317 | canvas7->Divide(nX,nY); |
338 | canvas7->Divide(nX,nY); |
318 | for(int i= |
339 | for(int i=parameter2-1; i<=parameter2+1; i++) { |
319 | for(int j= |
340 | for(int j=parameter1-1; j<=parameter1+1; j++) { |
320 | //int canvasPosition = nX*(i-chYstart)+(j- |
341 | //int canvasPosition = nX*(i-chYstart)+(j-parameter1)+1; |
321 | int canvasPosition = nX*( |
342 | int canvasPosition = nX*(parameter2+1-i) + (j-parameter1+1) +1; |
322 | if (debug) printf("canvas %d\n",canvasPosition); |
343 | if (debug) printf("canvas %d\n",canvasPosition); |
323 | canvas7->cd(canvasPosition); |
344 | canvas7->cd(canvasPosition); |
324 | char hname[128]; |
345 | char hname[128]; |
325 | int chPosition = map[j][i]; |
346 | int chPosition = map[j][i]; |
326 | sprintf(hname, "h2d%d", chPosition); |
347 | sprintf(hname, "h2d%d", chPosition); |
Line 332... | Line 353... | ||
332 | // Number of photoelectrons - Poissonian correction |
353 | // Number of photoelectrons - Poissonian correction |
333 | TCanvas* canvas8 = new TCanvas("canvas8","canvas8", 1000,1000); |
354 | TCanvas* canvas8 = new TCanvas("canvas8","canvas8", 1000,1000); |
334 | canvas8->cd(); |
355 | canvas8->cd(); |
335 | gStyle->SetOptStat(0); |
356 | gStyle->SetOptStat(0); |
336 | char hname[128]; |
357 | char hname[128]; |
337 | int chPosition = map[ |
358 | int chPosition = map[parameter1][parameter2]; |
338 | sprintf(hname, "h2d%d", chPosition); |
359 | sprintf(hname, "h2d%d", chPosition); |
339 | TH2F* h_2d = (TH2F*)rootfile->Get(hname); |
360 | TH2F* h_2d = (TH2F*)rootfile->Get(hname); |
340 | 361 | ||
341 | Int_t binsX = h_2d->GetXaxis()->GetNbins(); |
362 | Int_t binsX = h_2d->GetXaxis()->GetNbins(); |
342 | Int_t minX = h_2d->GetXaxis()->GetFirst(); |
363 | Int_t minX = h_2d->GetXaxis()->GetFirst(); |
Line 348... | Line 369... | ||
348 | Double_t xUpUser = h_2d->GetXaxis()->GetXmax(); |
369 | Double_t xUpUser = h_2d->GetXaxis()->GetXmax(); |
349 | Double_t yLowUser = h_2d->GetYaxis()->GetXmin(); |
370 | Double_t yLowUser = h_2d->GetYaxis()->GetXmin(); |
350 | Double_t yUpUser = h_2d->GetYaxis()->GetXmax(); |
371 | Double_t yUpUser = h_2d->GetYaxis()->GetXmax(); |
351 | if (debug) printf("xLow %f xUp %f\n",xLowUser,xUpUser); |
372 | if (debug) printf("xLow %f xUp %f\n",xLowUser,xUpUser); |
352 | TH2F* h_corrected = new TH2F("h_corrected","h_corrected",binsX, xLowUser, xUpUser, binsY, yLowUser, yUpUser); |
373 | TH2F* h_corrected = new TH2F("h_corrected","h_corrected",binsX, xLowUser, xUpUser, binsY, yLowUser, yUpUser); |
- | 374 | double diffX = xUpUser - xLowUser; |
|
- | 375 | double diffY = yUpUser - yLowUser; |
|
- | 376 | //TH2F* h_corrected = new TH2F("h_corrected","h_corrected",binsX, 3.00, 3.00+diffX, binsY, 8.00, 8.00+diffY); |
|
353 | //TH2F* h_corrected = new TH2F("h_corrected","h_corrected",binsX, minX, maxX, binsY, minY, maxY); |
377 | //TH2F* h_corrected = new TH2F("h_corrected","h_corrected",binsX, minX, maxX, binsY, minY, maxY); |
354 | 378 | ||
355 | double noise = getNoise(h_2d, 1, 70); |
379 | double noise = getNoise(h_2d, 1, 70); |
356 | if(debug) printf("Noise = %f\n", noise); |
380 | if(debug) printf("Noise = %f\n", noise); |
357 | for(int k=minX; k<=maxX; k++) { |
381 | for(int k=minX; k<=maxX; k++) { |
358 | for(int j=minY; j<=maxY; j++) { |
382 | for(int j=minY; j<=maxY; j++) { |
359 | double signal = h_2d->GetBinContent(k,j); // detected |
383 | double signal = h_2d->GetBinContent(k,j); // detected |
360 | //double p = ((signal - noise) > 1) ? (signal-noise) : 1; |
384 | //double p = ((signal - noise) > 1) ? (signal-noise) : 1; |
361 | double p = signal - noise; |
385 | double p = signal - noise; |
- | 386 | /* |
|
362 | p |
387 | p /= 1000.; |
363 | double p0 = 1.0 - p; // events with zero photons |
388 | double p0 = 1.0 - p; // events with zero photons |
364 | //double eta = (-log(p0) * p0 ) / (1-p0-0.00001); |
389 | //double eta = (-log(p0) * p0 ) / (1-p0-0.00001); |
365 | double eta = -log(p0); // constant of the poissonian statistics |
390 | double eta = -log(p0); // constant of the poissonian statistics |
366 | if (debug) printf("p=%f p0=%f log(p0)=%f eta=%f\n",p,p0,log(p0),eta); |
391 | if (debug) printf("p=%f p0=%f log(p0)=%f eta=%f\n",p,p0,log(p0),eta); |
- | 392 | */ |
|
367 | //double x = xLowUser + k*(xUpUser - xLowUser) / double(binsX); |
393 | //double x = xLowUser + k*(xUpUser - xLowUser) / double(binsX); |
368 | double x = h_2d->GetXaxis()->GetBinCenter(k); |
394 | double x = h_2d->GetXaxis()->GetBinCenter(k); |
369 | //double y = yLowUser + j*(yUpUser-yLowUser)/double(binsY); |
395 | //double y = yLowUser + j*(yUpUser-yLowUser)/double(binsY); |
370 | double y = h_2d->GetYaxis()->GetBinCenter(j); |
396 | double y = h_2d->GetYaxis()->GetBinCenter(j); |
371 | if (debug) printf("x=%f y=%f\n", x, y); |
397 | if (debug) printf("x=%f y=%f\n", x, y); |
372 | h_corrected->Fill(x |
398 | h_corrected->Fill(x, y, p); |
373 | } |
399 | } |
374 | } |
400 | } |
375 | h_corrected |
401 | //h_corrected->SetTitle("n_pe = - ln P(0);x[mm];y[mm]"); |
376 |
|
402 | h_corrected->SetTitle(";x[mm];y[mm]"); |
377 | gStyle |
403 | //gStyle->SetPalette(52,0); // black and white for print |
378 | h_corrected |
404 | //h_corrected->GetZaxis()->SetRangeUser(-0.05,1); |
379 | h_corrected |
405 | //h_corrected->SetContour(100); |
- | 406 | //gStyle->SetPalette(1); |
|
- | 407 | //SetGS(); |
|
380 | h_corrected->Draw("colz"); |
408 | h_corrected->Draw("colz"); |
381 | 409 | ||
382 | // collection efficiency |
410 | // collection efficiency |
383 | int nPoints =0; |
411 | int nPoints =0; |
384 | double efficiency=0; |
412 | double efficiency=0; |
Line 389... | Line 417... | ||
389 | efficiency += signal; |
417 | efficiency += signal; |
390 | nPoints++; |
418 | nPoints++; |
391 | } |
419 | } |
392 | } |
420 | } |
393 | printf("Signal sum = %f\n # of points = %d\n",efficiency,nPoints); |
421 | printf("Signal sum = %f\n # of points = %d\n",efficiency,nPoints); |
- | 422 | ||
- | 423 | if(strstr(plopt, "p") != NULL) { |
|
- | 424 | canvas8->Print("result.pdf"); |
|
- | 425 | } |
|
- | 426 | ||
394 | } |
427 | } |
395 | 428 | ||
396 | /** Draws the sum of channel signals |
429 | /** Draws the sum of channel signals |
397 | * Each channel is a 2d ('h2d') histogram |
430 | * Each channel is a 2d ('h2d') histogram |
398 | * Suitable for 8x8 chs scan |
431 | * Suitable for 8x8 chs scan |
399 | */ |
432 | */ |
400 | if( strstr(plopt, "sum") != NULL ) { |
433 | if( strstr(plopt, "sum") != NULL ) { |
401 | int nX = |
434 | int nX = parameter2 - parameter1 + 1; |
402 | int nY = chYend - chYstart + 1; |
435 | int nY = chYend - chYstart + 1; |
403 | TCanvas* canvas12 = new TCanvas("canvas12","c2",8*200, 8*200); |
436 | TCanvas* canvas12 = new TCanvas("canvas12","c2",8*200, 8*200); |
404 | canvas12->cd(); |
437 | canvas12->cd(); |
405 | gStyle->SetOptStat(0); |
438 | gStyle->SetOptStat(0); |
406 | 439 | ||
Line 420... | Line 453... | ||
420 | TH2F* h_corrected = new TH2F("h_corrected","h_corrected",binsX,xLowUser,xUpUser, binsY,yLowUser,yUpUser); |
453 | TH2F* h_corrected = new TH2F("h_corrected","h_corrected",binsX,xLowUser,xUpUser, binsY,yLowUser,yUpUser); |
421 | TH2F* h[nX*nY]; |
454 | TH2F* h[nX*nY]; |
422 | 455 | ||
423 | // 2d histogram noise subtraction and poisson scaling |
456 | // 2d histogram noise subtraction and poisson scaling |
424 | for(int i=chYstart; i<=chYend; i++) { |
457 | for(int i=chYstart; i<=chYend; i++) { |
425 | for(int j= |
458 | for(int j=parameter1; j<=parameter2; j++) { |
426 | int chPosition = map[j][i]; |
459 | int chPosition = map[j][i]; |
427 | char hname[128]; |
460 | char hname[128]; |
428 | sprintf(hname, "h2d%d", chPosition); |
461 | sprintf(hname, "h2d%d", chPosition); |
429 | int histogram = nX*(i-chYstart)+(j- |
462 | int histogram = nX*(i-chYstart)+(j-parameter1); |
430 | h[histogram] = (TH2F *) rootfile->Get(hname); |
463 | h[histogram] = (TH2F *) rootfile->Get(hname); |
431 | int noise = getNoise(h[histogram], 1, 170); |
464 | int noise = getNoise(h[histogram], 1, 170); |
432 | if (debug) printf("noise: %d\n",noise); |
465 | if (debug) printf("noise: %d\n",noise); |
433 | for(int k=minX; k<=maxX; k++) { |
466 | for(int k=minX; k<=maxX; k++) { |
434 | for(int l=minY; l<=maxY; l++) { |
467 | for(int l=minY; l<=maxY; l++) { |
Line 440... | Line 473... | ||
440 | //double eta = (-log(p0) * p0 ) / (1-p0-0.00001); |
473 | //double eta = (-log(p0) * p0 ) / (1-p0-0.00001); |
441 | double eta = -log(p0); |
474 | double eta = -log(p0); |
442 | //printf("p=%f p0=%f log(p0)=%f eta=%f\n",p,p0,log(p0),eta); |
475 | //printf("p=%f p0=%f log(p0)=%f eta=%f\n",p,p0,log(p0),eta); |
443 | double x = k*(xUpUser-xLowUser)/double(binsX); |
476 | double x = k*(xUpUser-xLowUser)/double(binsX); |
444 | double y = l*(yUpUser-yLowUser)/double(binsY); |
477 | double y = l*(yUpUser-yLowUser)/double(binsY); |
445 | h_corrected->Fill(x |
478 | h_corrected->Fill(x, y, eta); |
446 | } |
479 | } |
447 | } |
480 | } |
448 | 481 | ||
449 | } |
482 | } |
450 | } |
483 | } |
Line 467... | Line 500... | ||
467 | if (strstr(plopt, "beam") != NULL) { |
500 | if (strstr(plopt, "beam") != NULL) { |
468 | 501 | ||
469 | TCanvas* canvas9 = new TCanvas("canvas9","canvas9", 500,500); |
502 | TCanvas* canvas9 = new TCanvas("canvas9","canvas9", 500,500); |
470 | canvas9->cd(); |
503 | canvas9->cd(); |
471 | char hname[128]; |
504 | char hname[128]; |
472 | sprintf(hname, "hnhitsx%d", |
505 | sprintf(hname, "hnhitsx%d", 49); |
473 | TH1F* h_laser = (TH1F*)rootfile->Get(hname); |
506 | TH1F* h_laser = (TH1F*)rootfile->Get(hname); |
474 | h_laser->Draw(); |
507 | h_laser->Draw(); |
475 | h_laser->SetStats(1); |
508 | h_laser->SetStats(1); |
476 | 509 | ||
477 | TF1* err = new TF1("err","[0]+[1]*TMath::Erf((x-[2])/[3])", |
510 | TF1* err = new TF1("err","[0]+[1]*TMath::Erf((x-[2])/[3])",parameter1,parameter2); |
478 | err->SetParameter(0,2500); |
511 | err->SetParameter(0,2500); |
479 | err->SetParameter(1, h_laser->GetMaximum()); |
512 | err->SetParameter(1, h_laser->GetMaximum()); |
480 | err->SetParameter(2, h_laser->GetBinCenter(h_laser->GetMaximumBin())); |
513 | err->SetParameter(2, h_laser->GetBinCenter(h_laser->GetMaximumBin())); |
481 | err->SetParameter(3, 0.001); |
514 | err->SetParameter(3, 0.001); |
482 | h_laser->Fit(err,"qr"); |
515 | h_laser->Fit(err,"qr"); |
Line 498... | Line 531... | ||
498 | printf("\n"); |
531 | printf("\n"); |
499 | } |
532 | } |
500 | gStyle->SetOptStat(0); |
533 | gStyle->SetOptStat(0); |
501 | h_map->Draw("text"); |
534 | h_map->Draw("text"); |
502 | } |
535 | } |
- | 536 | ||
- | 537 | if(strstr(plopt, "p") != NULL) { |
|
- | 538 | TCanvas* canvasLast = new TCanvas("canvasLast","",500,500); |
|
- | 539 | canvasLast->Print("result.pdf)"); |
|
- | 540 | } |
|
- | 541 | ||
503 | 542 | ||
504 | return(0); |
543 | return(0); |
505 | } |
544 | } |
506 | 545 | ||
507 | /** Function calculates the noise from one channel |
546 | /** Function calculates the noise from one channel |