Subversion Repositories f9daq

Rev

Rev 38 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
35 f9daq 1
#include "TROOT.h"
2
#include "TFile.h"
3
#include "TBenchmark.h"
4
#include "TH1F.h"
5
#include "TH2F.h"
6
#include "TH3F.h"
7
#include "TCanvas.h"
8
#include "TStyle.h"
9
#include "TPad.h"
10
#include "TF1.h"
11
#include "TGraph.h"
12
#include "TSpectrum.h"
13
#include "stdio.h"
14
 
15
#include "include/RTUtil.h"
16
 
17
double getNoise(TH2F*, int, int);
18
 
19
int thresholdScan(char filename[256] = "test", char plopt[256]="th", int chXstart=0, int chXend=7, int chYstart=0, int chYend=7, bool debug = false)
20
{
21
  const int c_nChannels = 64;
22
  const double c_xOffset = 1; // mm
23
  const double c_yOffset = 0.7;
24
 
25
  int map[8][8]={{32,34,53,55,40,42,61,63},
26
                 {48,50,37,39,56,58,45,47},
27
                 {33,35,52,54,41,43,60,62},
28
                 {49,51,36,38,57,59,44,46},
29
                 {17,19,4,6,25,27,12,14},
30
                 {1,3,20,22,9,11,28,30},
31
                 {16,18,5,7,24,26,13,15},
32
                 {0,2,21,23,8,10,29,31}
33
                };
34
 
38 f9daq 35
  // Set draw style
35 f9daq 36
  RTSetStyle(gStyle);
37
 
38
  // open the file with histograms
39
  char fnameroot[256];
40
  TFile* rootfile;
41
	sprintf(fnameroot, "root/%s.root", filename);
42
	rootfile = (TFile *) gROOT->FindObject(filename);
43
	if(rootfile==NULL) rootfile = new TFile(fnameroot);
44
	if(rootfile==NULL) {
45
	  printf("Cannot open root file %s!!!\n",fnameroot);
46
	  return(0);
47
	}
48
 
49
  if (strstr(plopt, "th") != NULL) {
50
   TCanvas* canvas1 = new TCanvas("canvas1","",800,800);
51
   canvas1->cd();
52
   //gPad->SetLogz();
53
   //canvas1->SetLogz();
54
   TH2F* h_threshold = (TH2F*) rootfile->Get("h_threshold");
55
   h_threshold->SetTitleOffset(1.5,"y");
56
   //h_threshold->GetZaxis()->SetRangeUser(0,1000);
57
   h_threshold->SetContour(20);
58
 
59
   h_threshold->Draw("colz");
60
 
61
   TCanvas* canvas2 = new TCanvas("canvas2","",1600,800);
38 f9daq 62
   //canvas2->Divide(2);
40 f9daq 63
   int channel = map[chXstart][chXend];
64
   TH1D* h_projection1 = h_threshold->ProjectionY("",channel+1,channel+1);
38 f9daq 65
   canvas2->cd();
35 f9daq 66
   //h_projection1->GetYaxis()->SetRangeUser(0,1000);
67
   //gPad->SetLogy();
40 f9daq 68
   h_projection1->SetTitle(";Threshold [V]; Events");
35 f9daq 69
   h_projection1->Draw();
38 f9daq 70
   /*
35 f9daq 71
   TH1D* h_projection2 = h_threshold->ProjectionY("Ch 38",39,39);
72
   canvas2->cd(2);
73
   //gPad->SetLogy();
38 f9daq 74
   h_projection2->Draw(); */
35 f9daq 75
  }
76
 
77
  if(strstr(plopt, "tdc") != NULL) {
78
    TCanvas *canvas21 = new TCanvas("canvas21","canvas21",1600,800);
79
    TH3F* h0 = (TH3F*) rootfile->Get("h_correctedTDC");
80
	  Int_t binsX = h0->GetXaxis()->GetNbins();
81
    Int_t minX  = h0->GetXaxis()->GetFirst();
82
    Int_t maxX  = h0->GetXaxis()->GetLast()+1;
83
    Int_t binsY = h0->GetYaxis()->GetNbins();
84
    Int_t minY  = h0->GetYaxis()->GetFirst();
85
    Int_t maxY  = h0->GetYaxis()->GetLast()+1;
86
    Int_t binsZ = h0->GetZaxis()->GetNbins();
87
    Int_t minZ  = h0->GetZaxis()->GetFirst();
88
    Int_t maxZ  = h0->GetZaxis()->GetLast()+1;
89
    Double_t xLowUser  = h0->GetXaxis()->GetBinLowEdge(minX);
90
    Double_t xUpUser = h0->GetXaxis()->GetBinUpEdge(maxX);
91
    Double_t yLowUser  = h0->GetYaxis()->GetBinLowEdge(minY);
92
    Double_t yUpUser = h0->GetYaxis()->GetBinUpEdge(maxY);
93
 
94
    canvas21->Divide(2);
95
    //h0->Draw();
96
    canvas21->cd(1);
97
    //h0->Project3D("xy")->Draw("colz");
98
    //canvas21->cd(2);
99
    //h0->Project3D("yz")->Draw("colz");
100
    //canvas21->cd(3);
101
    TH2D* h_correctedTDC = (TH2D*) h0->Project3D("xz");
102
    //h0->GetZaxis()->SetRangeUser(-5,5);
103
    //h0->Project3D("xzo")->Draw("colz");
104
    h_correctedTDC->SetTitle("; t [ns]; Channel");
105
    h_correctedTDC->Draw("colz");
106
    /*
107
    TH1F* tdc1 = new TH1F("tdc1",";TDC [ns];Events",binsZ, minZ, maxZ);
108
    //for(int j=minY; j<maxY; j++) {
109
      for(int k=minZ; k<maxZ; k++) {
110
        double signal = h0->GetBinContent(1,1,k);
111
        tdc1->Fill(k,signal);
112
        //}
113
        }
114
    tdc1->Draw();
115
    */
116
 
117
    TH2D* h_timeWalk = (TH2D*) h0->Project3D("zy");
118
    canvas21->cd(2);
119
    h_timeWalk->SetTitle(";Threshold [V]; t [ns]");
120
    h_timeWalk->Draw("colz");
121
  }
122
 
123
  if(strstr(plopt,"16") != NULL)
124
  {
125
  TH2F* h_threshold = (TH2F*) rootfile->Get("h_threshold");
126
  TCanvas* canvas = new TCanvas("canvas","",1600,1600);
127
  canvas->cd();
128
  TVirtualPad *main = new TPad("main","main",0,0,1,1,10,1);
129
  main->Draw();
130
  main->Divide(4,4);
131
  for(int i=chXstart; i<chXend; i++) {
132
    for(int j=chYstart; j<chYend; j++) {
133
      int channel = map[i][j];
134
      TH1D* h_projection = h_threshold->ProjectionY("",channel+1,channel+1);
135
      int canvasPosition = i-chXend+4*(chYend-j)+1;
136
      printf(" %d ", canvasPosition);
137
      main->cd(canvasPosition);
138
      char name[128];
139
      sprintf(name,"Channel %d",channel);
140
      h_projection->SetTitle(name);
141
      h_projection->DrawCopy();
142
    }
143
  }
144
  printf("\n");
145
  }
146
 
147
  if( strstr(plopt, "all") != NULL ) {
148
    TCanvas *canvas2 = new TCanvas("canvas2","Hits x;;",2000,2000);
149
    TCanvas *canvas3 = new TCanvas("canvas3","Hits y;;",2000,2000);
150
    canvas2->Divide(8,8);
151
    canvas3->Divide(8,8);
152
    TH1F* h_hitsx;
153
    TH1F* h_hitsy;
154
    for(int i=0; i<c_nChannels; i++) {
155
      canvas2->cd(i+1);
156
      char hname[128];
157
      sprintf(hname, "hnhitsx%d", i);
158
      h_hitsx = (TH1F*)rootfile->Get(hname);
159
      h_hitsx->Draw();
160
      canvas3->cd(i+1);
161
      sprintf(hname, "hnhitsy%d", i);
162
      h_hitsy = (TH1F*)rootfile->Get(hname);
163
      h_hitsy->Draw();
164
    }
165
  }
166
 
167
  if( strstr(plopt, "x") != NULL ) {
168
    TCanvas *canvas10 = new TCanvas("canvas10","Ch x;;",500,500);
169
    TH1F* h_hitsx;
170
    canvas10->cd();
171
    char hname[128];
172
    sprintf(hname, "hnhitsx%d", chXstart);
173
    h_hitsx = (TH1F*)rootfile->Get(hname);
174
    h_hitsx->Draw("colz");
175
  }
176
 
177
  if( strstr(plopt, "y") != NULL ) {
178
    TCanvas *canvas11 = new TCanvas("canvas11","Ch x;;",500,500);
179
    TH1F* h_hitsy;
180
    canvas11->cd();
181
    char hname[128];
182
    sprintf(hname, "hnhitsy%d", chXstart);
183
    h_hitsy = (TH1F*)rootfile->Get(hname);
184
    h_hitsy->Draw();
185
  }
186
 
187
  if( strstr(plopt, "share") != NULL ) {
188
   /*TCanvas *canvas4 = new TCanvas("canvas1","canvas1",1000,1000);
189
   int nChannels = chYend-chYstart+1;
190
   int ncols = nChannels/2;
191
   printf("nch %d nch\\2 %d\n", nChannels, ncols);
192
   canvas4->Divide(2,ncols);
193
   TH1F* h_hitsy;
194
   for(int i=chYstart; i<=chYend; i++){
195
     canvas4->cd(i-chYstart+1);
196
     char hname[128];
197
     int chPosition = map[0][i];
198
     sprintf(hname, "hnhitsy%d", chPosition);
199
     h_hitsy = (TH1F*)rootfile->Get(hname);
200
     h_hitsy->Draw();
201
   }*/
202
 
203
   TCanvas *canvas4 = new TCanvas("canvas4","canvas4",500,500);
204
   canvas4->cd();
205
   for(int i=chXstart; i<=chXend; i++) {
206
     TH1F* h_hitsx;
207
     char hname[128];
208
     int chPosition = map[i][chYstart];
209
     sprintf(hname, "hnhitsx%d", chPosition);
210
     h_hitsx = (TH1F*)rootfile->Get(hname);
211
     h_hitsx->SetTitle("Scan X;x [mm]; Entries");
212
     h_hitsx->GetYaxis()->SetTitleOffset(1.3);
213
     h_hitsx->SetStats(0);
214
     if (i == chXstart)
215
      h_hitsx->Draw();
216
     else {
217
      h_hitsx->SetLineColor(i+1);
218
      h_hitsx->Draw("same");
219
     }
220
   }
221
   //sprintf(fullname, "ps/%s_Yshare.eps", filename);
222
	 //canvas4->SaveAs(fullname);
223
 
224
   TCanvas *canvas5 = new TCanvas("canvas5","canvas5",500,500);
225
   canvas5->cd();
226
   for(int i=chYstart; i<=chYend; i++) {
227
     TH1F* h_hitsy;
228
     char hname[128];
229
     int chPosition = map[chXstart][i];
230
     sprintf(hname, "hnhitsy%d", chPosition);
231
     h_hitsy = (TH1F*)rootfile->Get(hname);
232
     h_hitsy->SetTitle("Scan Y;y [mm]; Entries");
233
     h_hitsy->GetYaxis()->SetTitleOffset(1.3);
234
     h_hitsy->SetStats(0);
235
     if (i == chYstart)
236
      h_hitsy->Draw();
237
     else {
238
      h_hitsy->SetLineColor(i+1);
239
      h_hitsy->Draw("same");
240
     }
241
   }
242
   //sprintf(fullname, "ps/%s_Yshare.eps", filename);
243
	 //canvas5->SaveAs(fullname);
244
  }
245
 
246
  /** Draws the signal from 8 channels in x-row
247
    * for one specific y bin, so the background and cross-talk
248
    * can be estimated.
249
    * Draws also a 2d scan of these channels.
250
    */
251
  if (strstr(plopt, "line") != NULL) {
252
    TCanvas* canvas6 = new TCanvas("canvas6","canvas6",500,500);
253
    canvas6->cd(0);
254
    gStyle->SetOptStat(0);
255
 
256
    TH2F* h0 = (TH2F*) rootfile->Get("h2d0");
257
	  Int_t binsX = h0->GetXaxis()->GetNbins();
258
    Int_t minX  = h0->GetXaxis()->GetFirst();
259
    Int_t maxX  = h0->GetXaxis()->GetLast()+1;
260
    Int_t binsY = h0->GetYaxis()->GetNbins();
261
    Int_t minY  = h0->GetYaxis()->GetFirst();
262
    Int_t maxY  = h0->GetYaxis()->GetLast()+1;
263
    Double_t xLowUser  = h0->GetXaxis()->GetBinLowEdge(minX);
264
    Double_t xUpUser = h0->GetXaxis()->GetBinUpEdge(maxX);
265
    Double_t yLowUser  = h0->GetYaxis()->GetBinLowEdge(minY);
266
    Double_t yUpUser = h0->GetYaxis()->GetBinUpEdge(maxY);
267
    if (debug) printf("xLow %f xUp %f\n",xLowUser,xUpUser);
268
 
269
    //! 1-dimension position in x vs. hits
270
    TH2F* h[8];
271
    TH1F* h_line[8];
272
    for(int j=0; j<8; j++) {
273
      h_line[j] = new TH1F("h_line", "h_line", binsX, xLowUser, xUpUser);
274
    }
275
 
276
    for(int j=chXstart; j<=chXend; j++) {
277
      int chPosition = map[j][chYstart];
278
      char hname[128];
279
      sprintf(hname, "h2d%d", chPosition);
280
      int histogram = j;
281
      h[histogram] = (TH2F *) rootfile->Get(hname);
282
      int noise = getNoise(h[histogram], 1, 160);
283
      for(int k=minX; k<=maxX; k++) {
284
        int l=chYstart*20+12;
285
        //for(int l=12; l<=16; l++) {
286
          double signal = h[histogram]->GetBinContent(k,l);
287
          //signal -= noise;
288
          //signal /= 5*10000.0;
289
          double eta = -log(1 - signal);
290
          double x = k*(xUpUser-xLowUser)/double(binsX);
291
          //double y = l*(yUpUser-yLowUser)/double(binsY);
292
          h_line[j]->Fill(x-c_xOffset, signal);
293
        //}
294
      }
295
      if (j == chXstart) {
296
        h_line[j]->SetTitle("SiPM#2 w/o noise subtraction;x[mm];Hits");
297
        //h_line[j]->GetYaxis()->SetRangeUser(-0.05, 0.3);
298
        //h_line[j]->GetYaxis()->SetRangeUser(-50, 2500);
299
        h_line[j]->Draw("");
300
      }
301
      else {
302
        h_line[j]->SetLineColor(j+1);
303
        h_line[j]->Draw("same");
304
      }
305
    }
306
 
307
 
308
    //! 2d scan
309
    TCanvas* canvas61 = new TCanvas("canvas61","canvas61",8*200,300);
310
    canvas61->cd();
311
    TH2F* h_corrected = new TH2F("h_corrected","h_corrected",binsX,xLowUser,xUpUser, binsY,yLowUser,yUpUser);
312
    for(int i=chXstart; i<=chXend; i++) {
313
      //int canvasPosition = nX*(i-chYstart)+(j-chXstart)+1;
314
      //int canvasPosition = nX*(chYend-i)+chXstart+1;
315
      //if (debug) printf("canvas %d\n",canvasPosition);
316
        int chPosition = map[i][chYstart];
317
        char hname[128];
318
	      sprintf(hname, "h2d%d", chPosition);
319
	      int histogram = i;
320
	      h[histogram] = (TH2F *) rootfile->Get(hname);
321
	      int noise = getNoise(h[histogram], 1, 100);
322
 
323
	      for(int k=minX; k<=maxX; k++) {
324
          for(int l=minY; l<=maxY; l++) {
325
            int signal = h[histogram]->GetBinContent(k,l); // detected
326
            //p /= 10000.;
327
            //double p0 = 1.0 - p; // events with zero photons
328
            //double eta = (-log(p0) * p0 ) / (1-p0-0.00001);
329
            //double eta = -log(p0);
330
            //printf("p=%f p0=%f log(p0)=%f eta=%f\n",p,p0,log(p0),eta);
331
            //double signal = ((p - noise) > 0.1) ? (p-noise) : 0.1;
332
            double p = signal - noise;
333
            p /= 10000.0;
334
            double eta = -log(1 - p);
335
            double x = k*(xUpUser-xLowUser)/double(binsX);
336
            double y = l*(yUpUser-yLowUser)/double(binsY);
337
            h_corrected->Fill(x-c_xOffset, y-c_yOffset, eta);
338
          }
339
        }
340
    }
341
    h_corrected->SetTitle("SiPM#2 n_pe = - ln(P0);x[mm];y[mm]");
342
    h_corrected->GetZaxis()->SetRangeUser(-0.05,0.30);
343
    h_corrected->Draw("colz");
344
 
345
  }
346
 
347
  /** Draws the sum of the channels
348
    * Each channel is a 2d plot
349
    * Intended for the study of 1 channel
350
    */
351
  if (strstr(plopt, "2d") != NULL) {
352
 
353
    int nX = chXend - chXstart + 1;
354
    int nY = chYend - chYstart + 1;
355
    TCanvas* canvas7 = new TCanvas("canvas7","canvas7", nX*400,nY*400);
356
    printf("nx %d ny %d\n",nX,nY);
357
    canvas7->Divide(nX,nY);
358
    for(int i=chYstart; i<=chYend; i++) {
359
      for(int j=chXstart; j<=chXend; j++) {
360
      //int canvasPosition = nX*(i-chYstart)+(j-chXstart)+1;
361
      int canvasPosition = nX*(chYend-i)+(j-chXstart)+1;
362
      if (debug) printf("canvas %d\n",canvasPosition);
363
        canvas7->cd(canvasPosition);
364
        char hname[128];
365
        int chPosition = map[j][i];
366
        sprintf(hname, "h2d%d", chPosition);
367
        TH2F* h_2d = (TH2F*)rootfile->Get(hname);
368
        h_2d->Draw("colz");
369
      } //x
370
    }
371
 
372
    // Number of photoelectrons - Poissonian correction
373
    TCanvas* canvas8 = new TCanvas("canvas8","canvas8", 1000,1000);
374
    canvas8->cd();
375
    gStyle->SetOptStat(0);
376
      char hname[128];
377
      int chPosition = map[1][2];
378
      sprintf(hname, "h2d%d", chPosition);
379
      TH2F* h_2d = (TH2F*)rootfile->Get(hname);
380
 
381
      Int_t binsX = h_2d->GetXaxis()->GetNbins();
382
      Int_t minX  = h_2d->GetXaxis()->GetFirst();
383
      Int_t maxX  = h_2d->GetXaxis()->GetLast()+1;
384
      Int_t binsY = h_2d->GetYaxis()->GetNbins();
385
      Int_t minY  = h_2d->GetYaxis()->GetFirst();
386
      Int_t maxY  = h_2d->GetYaxis()->GetLast()+1;
387
      Double_t xLowUser  = h_2d->GetXaxis()->GetBinLowEdge(minX);
388
      Double_t xUpUser   = h_2d->GetXaxis()->GetBinUpEdge(maxX);
389
      Double_t yLowUser  = h_2d->GetYaxis()->GetBinLowEdge(minY);
390
      Double_t yUpUser =   h_2d->GetYaxis()->GetBinUpEdge(maxY);
391
      if (debug) printf("xLow %f xUp %f\n",xLowUser,xUpUser);
392
      TH2F* h_corrected = new TH2F("h_corrected","h_corrected",binsX, xLowUser, xUpUser, binsY, yLowUser, yUpUser);
393
 
394
      double noise = getNoise(h_2d, 1, 89);
395
      if(debug) printf("Noise = %f\n", noise);
396
      for(int k=minX; k<=maxX; k++) {
397
        for(int j=minY; j<=maxY; j++) {
398
          double signal = h_2d->GetBinContent(k,j); // detected
399
          //double p = ((signal - noise) > 1) ? (signal-noise) : 1;
400
          double p = signal - noise;
401
          p /= 10000.;
402
          double p0 = 1.0 - p; // events with zero photons
403
          //double eta = (-log(p0) * p0 ) / (1-p0-0.00001);
404
          double eta = -log(p0); // constant of the poissonian statistics
405
          if (debug) printf("p=%f p0=%f log(p0)=%f eta=%f\n",p,p0,log(p0),eta);
406
          double x = k*(xUpUser-xLowUser)/double(binsX);
407
          double y = j*(yUpUser-yLowUser)/double(binsY);
408
          h_corrected->Fill(x+3,y+8, eta);
409
        }
410
       }
411
      h_corrected->SetTitle("n_pe = - ln P(0);x[mm];y[mm]");
412
      h_corrected->GetZaxis()->SetRangeUser(-0.05,0.3);
413
      h_corrected->Draw("colz");
414
 
415
      // collection efficiency
416
      int nPoints =0;
417
      double efficiency=0;
418
      for (int i=18; i<=58; i++) {
419
        for (int j=19; j<=59; j++) {
420
          double signal = h_corrected->GetBinContent(i,j);
421
          if(debug) printf("signal %f\n",signal);
422
          efficiency += signal;
423
          nPoints++;
424
        }
425
      }
426
    printf("Signal sum = %f\n   # of points = %d\n",efficiency,nPoints);
427
  }
428
 
429
  /** Draws the sum of channel signals
430
    * Each channel is a 2d ('h2d') histogram
431
    * Suitable for 8x8 chs scan
432
    */
433
  if( strstr(plopt, "sum") != NULL ) {
434
    int nX = chXend - chXstart + 1;
435
    int nY = chYend - chYstart + 1;
436
	  TCanvas* canvas12 = new TCanvas("canvas12","c2",8*200, 8*200);
437
	  canvas12->cd();
438
	  gStyle->SetOptStat(0);
439
 
440
    // final histogram parameters
441
    TH2F* h0 = (TH2F*) rootfile->Get("h2d0");
442
	  Int_t binsX = h0->GetXaxis()->GetNbins();
443
    Int_t minX  = h0->GetXaxis()->GetFirst();
444
    Int_t maxX  = h0->GetXaxis()->GetLast()+1;
445
    Int_t binsY = h0->GetYaxis()->GetNbins();
446
    Int_t minY  = h0->GetYaxis()->GetFirst();
447
    Int_t maxY  = h0->GetYaxis()->GetLast()+1;
448
    Double_t xLowUser  = h0->GetXaxis()->GetBinLowEdge(minX);
449
    Double_t xUpUser = h0->GetXaxis()->GetBinUpEdge(maxX);
450
    Double_t yLowUser  = h0->GetYaxis()->GetBinLowEdge(minY);
451
    Double_t yUpUser = h0->GetYaxis()->GetBinUpEdge(maxY);
452
    if (debug) printf("xLow %f xUp %f\n",xLowUser,xUpUser);
453
    TH2F* h_corrected = new TH2F("h_corrected","h_corrected",binsX,xLowUser,xUpUser, binsY,yLowUser,yUpUser);
454
    TH2F* h[9];
455
 
456
    // 2d histogram noise subtraction and poisson scaling
457
    for(int i=chYstart; i<=chYend; i++) {
458
      for(int j=chXstart; j<=chXend; j++) {
459
        int chPosition = map[j][i];
460
        char hname[128];
461
	      sprintf(hname, "h2d%d", chPosition);
462
	      int histogram = nX*(i-chYstart)+(j-chXstart);
463
	      h[histogram] = (TH2F *) rootfile->Get(hname);
464
	      int noise = getNoise(h[histogram], 1, 170);
465
	      if (debug) printf("noise: %d\n",noise);
466
	      for(int k=minX; k<=maxX; k++) {
467
          for(int l=minY; l<=maxY; l++) {
468
            int signal = h[histogram]->GetBinContent(k,l); // detected
469
            //double p = ((signal - noise) > 0.1) ? (signal-noise) : 0.1;
470
            double p = signal - noise;
471
            p /= 10000.;
472
            double p0 = 1.0 - p; // events with zero photons
473
            //double eta = (-log(p0) * p0 ) / (1-p0-0.00001);
474
            double eta = -log(p0);
475
            //printf("p=%f p0=%f log(p0)=%f eta=%f\n",p,p0,log(p0),eta);
476
            double x = k*(xUpUser-xLowUser)/double(binsX);
477
            double y = l*(yUpUser-yLowUser)/double(binsY);
478
            h_corrected->Fill(x-c_xOffset, y-c_yOffset, signal);
479
          }
480
        }
481
 
482
      }
483
    }
484
 
485
    h_corrected->SetTitle("SiPM#2 n_p.e.;x[mm];y[mm]");
486
    //h_corrected->GetZaxis()->SetRangeUser(-0.05,.30);
487
    h_corrected->Draw("colz");
488
 
489
    TCanvas* canvas13 = new TCanvas("canvas13","canvas13",600,300);
490
    canvas13->Divide(2);
491
    canvas13->cd(1);
492
    //h[16]->Draw("colz");
493
    canvas13->cd(2);
494
    //h[8]->Draw("colz");
495
  }
496
 
497
  return(0);
498
}
499
 
500
/** Function calculates the noise from one channel
501
  * it runs through the bins along x and returns the average value
502
  */
503
double getNoise(TH2F* histogram, int yStart, int yEnd)
504
{
505
  double noise=0;
506
  int count=0;
507
  for(int j=yStart; j<yEnd; j++) {
508
    double value = histogram->GetBinContent(j,2);
509
    //if (noise < value) noise = value;
510
    noise += value;
511
    count++;
512
    }
513
  return (noise/double(count));
514
}
515