Subversion Repositories f9daq

Compare Revisions

Ignore whitespace Rev 50 → Rev 91

/sipmScan/examples/sipm.C
1,3 → 1,15
// *****************************************************************************
// Jozef Stefan Institute
// Dino Tahirovic
// 2012-2014
//
// Options:
// 2d - 1 channel analysis
// s - save an image (png) after drawinv the canvas
// p - save every canvas as page in pdf
//
// *****************************************************************************
 
#include "TROOT.h"
#include "TFile.h"
#include "TBenchmark.h"
352,7 → 364,7
}
// Number of photoelectrons - Poissonian correction
TCanvas* canvas8 = new TCanvas("canvas8","canvas8", 1000,1000);
TCanvas* canvas8 = new TCanvas("canvas8","canvas8", 1600,1600);
canvas8->cd();
gStyle->SetOptStat(0);
char hname[128];
378,24 → 390,20
//TH2F* h_corrected = new TH2F("h_corrected","h_corrected",binsX, minX, maxX, binsY, minY, maxY);
double noise = getNoise(h_2d, 1, 70);
noise = 50;
if(debug) printf("Noise = %f\n", noise);
noise = 61;
printf("[2d scan] Average noise = %f\n", noise);
for(int k=minX; k<=maxX; k++) {
for(int j=minY; j<=maxY; j++) {
double signal = h_2d->GetBinContent(k,j); // detected
//double p = ((signal - noise) > 1) ? (signal-noise) : 1;
double p = signal - noise;
p /= 10000.;
double p0 = 1.0 - p; // events with zero photons
//double eta = (-log(p0) * p0 ) / (1-p0-0.00001);
double eta = -log(p0); // constant of the poissonian statistics
if (debug) printf("p=%f p0=%f log(p0)=%f eta=%f\n",p,p0,log(p0),eta);
//double x = xLowUser + k*(xUpUser - xLowUser) / double(binsX);
double x = h_2d->GetXaxis()->GetBinCenter(k);
//double y = yLowUser + j*(yUpUser-yLowUser)/double(binsY);
double y = h_2d->GetYaxis()->GetBinCenter(j);
if (debug) printf("x=%f y=%f\n", x, y);
h_corrected->Fill(x, y, p);
h_corrected->Fill(x, y, eta);
}
}
//h_corrected->SetTitle("n_pe = - ln P(0);x[mm];y[mm]");
403,25 → 411,28
//gStyle->SetPalette(52,0); // black and white for print
//gStyle->SetPalette(1); //black and white 2nd option
//SetGS(); // inverse
h_corrected->GetZaxis()->SetRangeUser(-0.05,0.30);
h_corrected->SetContour(30);
//h_corrected->GetZaxis()->SetRangeUser(-0.01,0.12);
h_corrected->SetContour(50);
h_corrected->Draw("colz");
// collection efficiency
int nPoints =0;
double efficiency=0;
for (int i=18; i<=58; i++) {
for (int j=19; j<=59; j++) {
for (int i=minX; i<=maxX; i++) {
for (int j=minY; j<=maxY; j++) {
double signal = h_corrected->GetBinContent(i,j);
if(debug) printf("signal %f\n",signal);
efficiency += signal;
if (signal > 0.02) efficiency += signal;
nPoints++;
}
}
printf("Signal sum = %f\n # of points = %d\n",efficiency,nPoints);
if(strstr(plopt, "p") != NULL) {
canvas8->Print("result.pdf");
if(strstr(plopt, "s") != NULL) {
char photo[128];
sprintf(photo, "ps/%s.png", filename);
//canvas8->Print("result.pdf");
canvas8->SaveAs(photo);
}
}
551,7 → 562,7
double noise=0;
int count=0;
for(int j=yStart; j<yEnd; j++) {
double value = histogram->GetBinContent(j,2);
double value = histogram->GetBinContent(j,1);
//if (noise < value) noise = value;
noise += value;
count++;