/sipmScan/src/analysisBias.cpp |
---|
103,7 → 103,7 |
int analysisBias(char* dfile0="test", int dbg=0, double tdcCut=5.0) |
{ |
const double c_tdcOffset = 372*TDC_BIN; // ns, SiPM4 |
const double c_tdcOffset = 97*TDC_BIN; // ns, SiPM4 |
printf(" Data to root conversion program\nUsage:\nd2r(input file name <without.dat>, debug on/off, TDC cut +-[ns])\n\n"); |
186,18 → 186,31 |
int nb; |
int status; |
char hname[256]; |
// Full range TDC data for every channel |
TH2F* htdc = new TH2F("htdc",";TDC channel;SiPM channel",512,-0.5,511.5,NCH,-0.5,NCH-0.5); |
// TDC data in specific time window |
TH3F* h_correctedTDC = new TH3F("h_correctedTDC",";SiPM channel; ASD threshold [V]; t [ns]", |
NCH, -0.5, NCH-0.5, |
101, 1.0, 2.0, |
33, -16.5*TDC_BIN, 16.5*TDC_BIN); |
// Hits distribution in every channel per stage position |
TH1F* hnhitsx[NCH]; // move to 2d with (channel, position) |
TH1F* hnhitsy[NCH]; //-||- |
// 2d hits distribution |
TH2F* h2d[NCH]; //-||- |
TH2F* h_bias = new TH2F("h_bias", "", 64, 0, 63, 20, 71.0,73.0); |
int nBiasSteps = 20; |
double biasLow = 71.0; |
double biasUp = 73.0; |
TH2F* h_bias = new TH2F("h_bias", "", 64, 0, 63, nBiasSteps, biasLow, biasUp); |
int nSteps = 51; |
double thrLow = 1.0; |
double thrUp = 2.0; |
TH2F* h_threshold = new TH2F("h_threshold",";SiPM ch;Threshold[V]", |
64,-0.5,63.5, |
101, 1.0, 2.0); |
nSteps, thrLow, thrUp); |
// Bias vs. ASD threshold per channel to estimate working point |
TH3F* h_biasThreshold = new TH3F("h_biasThreshold","", 64,-0.5, 63.5, |
31, 71.0, 74.0, 51, 1.0, 2.0); |
TH2F* h_ch33 = new TH2F("h_ch33","ch. 33;x;y",100,20000,30000,100,0,10000); |
TNtuple* nt = new TNtuple("nt", "nt", "ch:x:y:tdc"); |
212,9 → 225,9 |
if(dbg) printf("-----------------------------------------------\n"); |
if(dbg) printf("[%d] rec_id = %d | rec_len = %u\n", ceve, rec_id, rec_len); |
int nSteps = 0; |
int nBiasSteps = 0; |
switch(rec_id) |
{ |
case RUNREC_ID: |
283,18 → 296,15 |
} |
nBiasSteps = (run.biasUp - run.biasLow)/double(run.biasStep) + 1; |
h_correctedTDC = (TH3F*) gROOT->FindObject("h_correctedTDC"); |
if (h_correctedTDC) delete h_correctedTDC; |
nSteps = (run.thUp - run.thLow)/double(run.thStep) + 1; |
if (dbg) printf("nSteps %d\n", nSteps); |
biasLow = (run.biasLow - 0.5*run.biasStep)/1000.0; |
biasUp = (run.biasUp + 0.5*run.biasStep)/1000.0; |
h_correctedTDC = new TH3F("h_correctedTDC",";SiPM channel; ASD threshold [V]; t [ns]", |
NCH, |
-0.5, |
NCH-0.5, |
nBiasSteps, |
(run.biasLow - 0.5*run.biasStep)/1000.0, |
(run.biasUp + 0.5*run.biasStep)/1000.0, |
NCH, -0.5, NCH-0.5, |
nBiasSteps, biasLow, biasUp, |
2*tdcCut+1, |
-tdcCut*TDC_BIN - 0.5*TDC_BIN, |
tdcCut*TDC_BIN + 0.5*TDC_BIN); |
302,16 → 312,13 |
h_bias = (TH2F*) gROOT->FindObject("h_bias"); |
if (h_bias) delete h_bias; |
h_bias = new TH2F("h_bias",";Channel; Bias [V]", 64, -0.5, 63.5, |
nBiasSteps, |
(run.biasLow - 0.5*run.biasStep)/1000.0, |
(run.biasUp + 0.5*run.biasStep)/1000.0); |
nBiasSteps, biasLow, biasUp); |
if (h_threshold) delete h_threshold; |
thrLow = (run.thLow - 0.5*run.thStep)/1000.0; |
thrUp = (run.thUp + 0.5*run.thStep)/1000.0; |
h_threshold = new TH2F("h_threshold",";SiPM ch;Threshold[V]",64,-0.5,63.5, |
nSteps, |
(run.thLow - 0.5*run.thStep)/1000.0, |
(run.thUp + 0.5*run.thStep)/1000.0); |
nSteps, thrLow, thrUp); |
//h_threshold = new TH2F("h_threshold","Threshold scan;SiPM ch;Threshold[mV]",64,-0.5,63.5, |
// 101,995,2005); |
319,6 → 326,13 |
if (h_ch33) delete h_ch33; |
h_ch33 = new TH2F("h_ch33","ch. 33;x;y",100,20000,30000,100,0,10000); |
h_biasThreshold = (TH3F*) gROOT->FindObject("h_biasThreshold"); |
if (h_biasThreshold) delete h_biasThreshold; |
h_biasThreshold = new TH3F("h_biasThreshold", ";Channel;Bias[V];Threshold[V]", |
64, -0.5, 63.5, |
nBiasSteps, biasLow, biasUp, |
nSteps, thrLow, thrUp); |
if (dbg) printf("RUNREC: all histos created.\n"); |
break; |
362,6 → 376,7 |
nint = nb / ulsize; // no. of subrecords |
if (dbg) printf("No. of subrecords %d \n", nint); |
ii=0; |
while (ii<nint){ |
int recid = buf[ii++]; |
int len = buf[ii++]; |
391,9 → 406,11 |
htdc->Fill(data, channel); |
if (dbg) printf("ch: %d tdc: %d\n", channel, data); |
if (dbg) nt->Fill(channel, pos.ix, pos.iy, data); |
double tdcmin = tdcOffset[channel] - tdcCut; |
double tdcmax = tdcOffset[channel] + tdcCut; |
//double tdcmin = tdcOffset[channel] - tdcCut; |
//double tdcmax = tdcOffset[channel] + tdcCut; |
double time = data*TDC_BIN - tdcOffset[channel]; |
h_biasThreshold->Fill(channel, bias.bias/1000.0, thr.threshold/1000.0); |
if(time >= -tdcCut and time <= tdcCut) { |
h_correctedTDC->Fill(channel, bias.bias/1000.0, time); |
hnhitsx[channel]->Fill((pos.xset - OFFSETX) * MIKRO_BIN); |
401,10 → 418,11 |
h2d[channel]->Fill((pos.xset - OFFSETX) * MIKRO_BIN, (pos.yset - OFFSETY) * MIKRO_BIN); |
if (position(pos.xset-OFFSETX, pos.yset-OFFSETY, channel)) { |
h_ch33->Fill(pos.xset-OFFSETX, pos.yset-OFFSETY); |
//h_ch33->Fill(pos.xset-OFFSETX, pos.yset-OFFSETY); |
h_threshold->Fill(channel, thr.threshold/1000.0); |
h_bias->Fill(channel, bias.bias/1000.0); |
} |
} |
//gV673A->Fill(data,channel); |
//gsumV673A[channel/16]->Fill(data); |
/sipmScan/src/analysisScan.cpp |
---|
91,7 → 91,7 |
int analysisScan(char* dfile0="test", int dbg=0, double tdcCut=5.0) |
{ |
const double c_tdcOffset = +96*TDC_BIN; // ns, SiPM4 |
const double c_tdcOffset = +97*TDC_BIN; // ns, SiPM4 |
printf(" Data to root conversion program\nUsage:\nd2r(input file name <without .dat>, debug on/off, TDC cut +-[ns])\n\n"); |
printf(" OFFSETS: \n x: %d\n y: %d\n t:%f\n", OFFSETX, OFFSETY, c_tdcOffset); |
/sipmScan/examples/biasScan.C |
---|
99,8 → 99,105 |
canvas01->cd(); |
TH2F* h_bias = (TH2F*) rootfile->Get("h_bias"); |
h_bias->Draw("colz"); |
TCanvas* canvas02 = new TCanvas("canvas02","",800, 800); |
//canvas02->Divide(2,2); |
canvas02->cd(); |
TH3F* h_biasThreshold = (TH3F*) rootfile->Get("h_biasThreshold"); |
//h_biasThreshold->Draw(); |
//canvas02->cd(2); |
//h_biasThreshold->GetXaxis()->SetRange(1,5); |
h_biasThreshold->Project3D("zy"); |
h_biasThreshold_zy->DrawCopy("colz"); |
TCanvas* canvas03 = new TCanvas("canvas03","",1200, 1200); |
canvas03->Divide(4,4); |
int x1=0; |
int x2=3; |
int y1=0; |
int y2=3; |
for(int j=x1; j<=x2; j++){ |
for(int k=y1; k<=y2; k++){ |
int channel = map[j][k]; |
int canvasPosition = 4*(4-k-1) + 4 - j; |
canvas03->cd(canvasPosition); |
h_biasThreshold->GetXaxis()->SetRange(channel+1,channel+1); |
char histoName[128]; |
sprintf(histoName, "Ch %d", channel); |
h_biasThreshold->Project3D("zy"); |
//sprintf(option, "h_biasThresholsd_zy%f", channel); |
h_biasThreshold_zy->SetTitle(histoName); |
h_biasThreshold_zy->DrawCopy("colz"); |
} |
} |
TCanvas* canvas04 = new TCanvas("canvas04","",1200, 1200); |
canvas04->Divide(4,4); |
int x1=0; |
int x2=3; |
int y1=4; |
int y2=7; |
for(int j=x1; j<=x2; j++){ |
for(int k=y1; k<=y2; k++){ |
int channel = map[j][k]; |
int canvasPosition = 4*(8-k-1) + 4 - j; |
canvas04->cd(canvasPosition); |
h_biasThreshold->GetXaxis()->SetRange(channel+1,channel+1); |
char histoName[128]; |
sprintf(histoName, "Ch %d", channel); |
h_biasThreshold->Project3D("zy"); |
//sprintf(option, "h_biasThresholsd_zy%f", channel); |
h_biasThreshold_zy->SetTitle(histoName); |
h_biasThreshold_zy->DrawCopy("colz"); |
} |
} |
TCanvas* canvas05 = new TCanvas("canvas05","",1200, 1200); |
canvas05->Divide(4,4); |
int x1=4; |
int x2=7; |
int y1=0; |
int y2=3; |
for(int j=x1; j<=x2; j++){ |
for(int k=y1; k<=y2; k++){ |
int channel = map[j][k]; |
int canvasPosition = 4*(4-k-1) + 8 - j; |
canvas05->cd(canvasPosition); |
h_biasThreshold->GetXaxis()->SetRange(channel+1,channel+1); |
char histoName[128]; |
sprintf(histoName, "Ch %d", channel); |
h_biasThreshold->Project3D("zy"); |
//sprintf(option, "h_biasThresholsd_zy%f", channel); |
h_biasThreshold_zy->SetTitle(histoName); |
h_biasThreshold_zy->DrawCopy("colz"); |
} |
} |
TCanvas* canvas06 = new TCanvas("canvas06","",1200, 1200); |
canvas06->Divide(4,4); |
int x1=4; |
int x2=7; |
int y1=4; |
int y2=7; |
for(int j=x1; j<=x2; j++){ |
for(int k=y1; k<=y2; k++){ |
int channel = map[j][k]; |
int canvasPosition = 4*(8-k-1) + 8 - j; |
canvas06->cd(canvasPosition); |
h_biasThreshold->GetXaxis()->SetRange(channel+1,channel+1); |
char histoName[128]; |
sprintf(histoName, "Ch %d", channel); |
h_biasThreshold->Project3D("zy"); |
//sprintf(option, "h_biasThresholsd_zy%f", channel); |
h_biasThreshold_zy->SetTitle(histoName); |
h_biasThreshold_zy->DrawCopy("colz"); |
} |
} |
} |
if (strstr(plopt, "th") != NULL) { |
TCanvas* canvas1 = new TCanvas("canvas1","",800,800); |
canvas1->cd(); |
/sipmScan/examples/sipm.C |
---|
347,6 → 347,7 |
sprintf(hname, "h2d%d", chPosition); |
TH2F* h_2d = (TH2F*)rootfile->Get(hname); |
h_2d->Draw("colz"); |
if ( !((i == parameter2) and (j == parameter1)) ) h_2d->GetZaxis()->SetRangeUser(0,200); |
} //x |
} |
377,6 → 378,7 |
//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); |
for(int k=minX; k<=maxX; k++) { |
for(int j=minY; j<=maxY; j++) { |
383,13 → 385,11 |
double signal = h_2d->GetBinContent(k,j); // detected |
//double p = ((signal - noise) > 1) ? (signal-noise) : 1; |
double p = signal - noise; |
/* |
p /= 1000.; |
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); |
401,10 → 401,10 |
//h_corrected->SetTitle("n_pe = - ln P(0);x[mm];y[mm]"); |
h_corrected->SetTitle(";x[mm];y[mm]"); |
//gStyle->SetPalette(52,0); // black and white for print |
//h_corrected->GetZaxis()->SetRangeUser(-0.05,1); |
//h_corrected->SetContour(100); |
//gStyle->SetPalette(1); |
//SetGS(); |
//gStyle->SetPalette(1); //black and white 2nd option |
//SetGS(); // inverse |
h_corrected->GetZaxis()->SetRangeUser(-0.05,0.30); |
h_corrected->SetContour(30); |
h_corrected->Draw("colz"); |
// collection efficiency |