26,12 → 26,13 |
const char *filetypes[] = {"Histograms",histextall,0,0}; |
char *cTemp; |
file_info.fFileTypes = filetypes; |
cTemp = new char[1024]; |
sprintf(cTemp, "%s/results", rootdir); |
file_info.fIniDir = StrDup(cTemp); |
// cTemp = new char[1024]; |
// sprintf(cTemp, "%s/results", rootdir); |
// file_info.fIniDir = StrDup(cTemp); |
file_info.fIniDir = StrDup(currentOpenDir); |
file_info.fMultipleSelection = kFALSE; |
new TGFileDialog(gClient->GetDefaultRoot(), fMain, kFDOpen, &file_info); |
delete[] cTemp; |
// delete[] cTemp; |
|
if(file_info.fFilename != NULL) |
{ |
245,7 → 246,7 |
} |
|
// X, Y and Z values from each file (table units or microns) |
if(posUnits->widgetCB->GetSelected() == 0) |
if(posUnitsPlot->widgetCB->GetSelected() == 0) |
{ |
if(direction == 1) |
surfxy[i] = (double)(evtheader.xpos); |
253,7 → 254,7 |
surfxy[i] = (double)(evtheader.ypos); |
surfz[i] = (double)(evtheader.zpos); |
} |
else if(posUnits->widgetCB->GetSelected() == 1) |
else if(posUnitsPlot->widgetCB->GetSelected() == 1) |
{ |
if(direction == 1) |
surfxy[i] = (double)(evtheader.xpos*lenconversion); |
417,7 → 418,7 |
gScan2D->GetYaxis()->SetTitleOffset(1.9); |
gScan2D->GetYaxis()->CenterTitle(kTRUE); |
gScan2D->GetYaxis()->SetLabelSize(0.027); |
gScan2D->GetXaxis()->SetLabelOffset(0.02); |
gScan2D->GetYaxis()->SetLabelOffset(0.02); |
gScan2D->GetYaxis()->SetRangeUser(range[2], range[3]); |
gScan2D->GetYaxis()->SetNoExponent(kTRUE); |
|
428,16 → 429,16 |
{ |
if(direction == 1) |
{ |
if(posUnits->widgetCB->GetSelected() == 0) |
if(posUnitsPlot->widgetCB->GetSelected() == 0) |
gScan2D->SetTitle("Laser focal point;X [table units];Z [table units]"); |
else if(posUnits->widgetCB->GetSelected() == 1) |
else if(posUnitsPlot->widgetCB->GetSelected() == 1) |
gScan2D->SetTitle("Laser focal point;X [#mum];Z [#mum]"); |
} |
else if(direction == 2) |
{ |
if(posUnits->widgetCB->GetSelected() == 0) |
if(posUnitsPlot->widgetCB->GetSelected() == 0) |
gScan2D->SetTitle("Laser focal point;Y [table units];Z [table units]"); |
else if(posUnits->widgetCB->GetSelected() == 1) |
else if(posUnitsPlot->widgetCB->GetSelected() == 1) |
gScan2D->SetTitle("Laser focal point;Y [#mum];Z [#mum]"); |
} |
} |
445,16 → 446,16 |
{ |
if(direction == 1) |
{ |
if(posUnits->widgetCB->GetSelected() == 0) |
if(posUnitsPlot->widgetCB->GetSelected() == 0) |
gScan2D->SetTitle(";X [table units];Z [table units]"); |
else if(posUnits->widgetCB->GetSelected() == 1) |
else if(posUnitsPlot->widgetCB->GetSelected() == 1) |
gScan2D->SetTitle(";X [#mum];Z [#mum]"); |
} |
else if(direction == 2) |
{ |
if(posUnits->widgetCB->GetSelected() == 0) |
if(posUnitsPlot->widgetCB->GetSelected() == 0) |
gScan2D->SetTitle(";Y [table units];Z [table units]"); |
else if(posUnits->widgetCB->GetSelected() == 1) |
else if(posUnitsPlot->widgetCB->GetSelected() == 1) |
gScan2D->SetTitle(";Y [#mum];Z [#mum]"); |
} |
} |
583,16 → 584,16 |
{ |
if(axis == 1) |
{ |
if(posUnits->widgetCB->GetSelected() == 0) |
if(posUnitsPlot->widgetCB->GetSelected() == 0) |
gScan[1]->SetTitle("SiPM edge detection;X [table units];Normalized ADC integral"); |
else if(posUnits->widgetCB->GetSelected() == 1) |
else if(posUnitsPlot->widgetCB->GetSelected() == 1) |
gScan[1]->SetTitle("SiPM edge detection;X [#mum];Normalized ADC integral"); |
} |
else if(axis == 2) |
{ |
if(posUnits->widgetCB->GetSelected() == 0) |
if(posUnitsPlot->widgetCB->GetSelected() == 0) |
gScan[1]->SetTitle("SiPM edge detection;Y [table units];Normalized ADC integral"); |
else if(posUnits->widgetCB->GetSelected() == 1) |
else if(posUnitsPlot->widgetCB->GetSelected() == 1) |
gScan[1]->SetTitle("SiPM edge detection;Y [#mum];Normalized ADC integral"); |
} |
} |
600,16 → 601,16 |
{ |
if(axis == 1) |
{ |
if(posUnits->widgetCB->GetSelected() == 0) |
if(posUnitsPlot->widgetCB->GetSelected() == 0) |
gScan[1]->SetTitle(";X [table units];Normalized ADC integral"); |
else if(posUnits->widgetCB->GetSelected() == 1) |
else if(posUnitsPlot->widgetCB->GetSelected() == 1) |
gScan[1]->SetTitle(";X [#mum];Normalized ADC integral"); |
} |
else if(axis == 2) |
{ |
if(posUnits->widgetCB->GetSelected() == 0) |
if(posUnitsPlot->widgetCB->GetSelected() == 0) |
gScan[1]->SetTitle(";Y [table units];Normalized ADC integral"); |
else if(posUnits->widgetCB->GetSelected() == 1) |
else if(posUnitsPlot->widgetCB->GetSelected() == 1) |
gScan[1]->SetTitle(";Y [#mum];Normalized ADC integral"); |
} |
} |
693,6 → 694,91 |
{ |
for(int i = 0; i < (int)nrfiles; i++) |
{ |
if( (nrfiles == 1) || (!multiSelect->widgetChBox[0]->IsDown()) ) |
{ |
printf("PhotonMu(): Only one file selected. Not running analysis, just showing the fit.\n"); |
|
// Replot the spectrum on analysisCanvas and do not close the input file |
DisplayHistogram( (char*)(files->At(i)->GetTitle()), 0, 1); |
analysisCanvas->GetCanvas()->Modified(); |
analysisCanvas->GetCanvas()->Update(); |
|
// Get the spectrum |
histtemp = (TH1F*)analysisCanvas->GetCanvas()->GetPrimitive(histname); |
npeaks = 15; |
double par[300]; |
spec = new TSpectrum(npeaks); |
// Find spectrum background |
histback = spec->Background(histtemp, (int)fitInter->widgetNE[0]->GetNumber(), "same"); |
// Clone histogram and subtract background from it if we select that option |
h2 = (TH1F*)histtemp->Clone("h2"); |
if(fitChecks->widgetChBox[0]->IsDown()) |
h2->Add(histback, -1); |
// Search for the peaks |
int found = spec->Search(h2, fitSigma->widgetNE[0]->GetNumber(), "goff", fitTresh->widgetNE[0]->GetNumber() ); |
printf("PhotonMu(): Found %d candidates to fit.\n",found); |
npeaks = found; |
|
// Set initial peak parameters |
xpeaks = spec->GetPositionX(); |
for(j = 0; j < found; j++) |
{ |
float xp = xpeaks[j]; |
int bin = h2->GetXaxis()->FindBin(xp); |
float yp = h2->GetBinContent(bin); |
par[3*j] = yp; |
par[3*j+1] = xp; |
par[3*j+2] = (double)fitSigma->widgetNE[0]->GetNumber(); |
} |
|
// Fit the histogram |
fit = new TF1("fit", FindPeaks, adcRange->widgetNE[0]->GetNumber(), adcRange->widgetNE[1]->GetNumber(), 3*npeaks); |
TVirtualFitter::Fitter(histtemp, 3*npeaks); |
fit->SetParameters(par); |
fit->SetNpx(300); |
h2->Fit("fit","Q"); |
// Get the fitted parameters |
fittingfunc = h2->GetFunction("fit"); |
fparam = fittingfunc->GetParameters(); |
fparamerr = fittingfunc->GetParErrors(); |
|
// Gather the parameters (mean peak value for now) |
int j = 1; |
int nrfit = 0; |
while(1) |
{ |
if( (fparam[j] < 1.E-30) || (nrfit > 8) ) |
break; |
else |
{ |
// Check if pedestal is above the lower limit and sigma is smaller than the mean |
if( (fparam[j] > pedesLow->widgetNE[0]->GetNumber()) && ((double)fparamerr[j]/fparam[j] < accError->widgetNE[0]->GetNumber()) ) |
{ |
// With the additional ADC offset, we can shift the mean values slightly, so they are not close to the X.5, but to the X.0 values |
meansel[nrfit] = fparam[j]+(adcOffset->widgetNE[0]->GetNumber()); |
sigmasel[nrfit] = fparam[j+1]; |
nrfit++; |
} |
} |
|
j+=3; |
} |
TMath::Sort(nrfit, meansel, sortindex, kFALSE); |
|
fittingfunc->Draw("SAME"); |
analysisCanvas->GetCanvas()->Modified(); |
analysisCanvas->GetCanvas()->Update(); |
|
meanparam = meansel[sortindex[0]]; |
paramsigma = sigmasel[sortindex[0]]; |
|
for(j = 0; j < nrfit; j++) |
printf("PhotonMu(): %d: peak mean = %lf\n", j, meansel[sortindex[j]]); |
|
|
|
return; |
} |
if(files->At(i)) |
{ |
if(strcmp(files->At(i)->GetTitle(),darkRun->widgetTE->GetText()) == 0) |
1011,6 → 1097,17 |
printf("PhotonMu(): %lf\t%lf\t%lf\n", angle[i], muval[i], pdeval[i]); |
} |
|
// Check for range of values to plot |
double plotMax = 0.; |
for(int i = 0; i < (int)nrfiles; i++) |
{ |
plotMax = TMath::Max(plotMax, muval[i]); |
plotMax = TMath::Max(plotMax, pdeval[i]); |
} |
if(plotMax <= 0.) |
plotMax = 1.1; |
printf("PhotonMu(): Maximum value: %lf\n", plotMax); |
|
if(DBGSIG) printf("\n"); |
if(darkhist != -1) |
printf("PhotonMu(): Number of excluded points: %d\n", (nrfiles-1-m)); |
1035,13 → 1132,15 |
pde->GetXaxis()->CenterTitle(); |
// pde->GetXaxis()->SetRange(angle[0],angle[nrfiles-1]); |
// pde->GetXaxis()->SetRangeUser(angle[0],angle[nrfiles-1]); |
pde->GetXaxis()->SetRange(-90,90); |
pde->GetXaxis()->SetRangeUser(-90,90); |
pde->GetXaxis()->SetLimits(-90,90); |
pde->GetXaxis()->SetRange(-90.0,90.0); |
pde->GetXaxis()->SetRangeUser(-90.0,90.0); |
pde->GetXaxis()->SetLimits(-90.0,90.0); |
pde->GetYaxis()->SetTitleOffset(1.2); |
pde->GetYaxis()->SetLabelSize(0.030); |
pde->GetYaxis()->CenterTitle(); |
pde->GetYaxis()->SetRangeUser(0., 1.2); |
pde->GetYaxis()->SetRange(0., 1.1*plotMax); |
pde->GetYaxis()->SetRangeUser(0., 1.1*plotMax); |
pde->GetYaxis()->SetLimits(0., 1.1*plotMax); |
pde->SetName("pde"); |
pde->Draw("ALP"); |
|
1139,6 → 1238,90 |
{ |
for(int i = 0; i < (int)nrfiles; i++) |
{ |
if( (nrfiles == 1) || (!multiSelect->widgetChBox[0]->IsDown()) ) |
{ |
printf("BreakdownVolt(): Only one file selected. Not running analysis, just showing the fit.\n"); |
|
// Replot the spectrum on analysisCanvas and do not close the input file |
DisplayHistogram( (char*)(files->At(i)->GetTitle()), 0, 1); |
analysisCanvas->GetCanvas()->Modified(); |
analysisCanvas->GetCanvas()->Update(); |
|
// Get the spectrum |
histtemp = (TH1F*)analysisCanvas->GetCanvas()->GetPrimitive(histname); |
npeaks = 15; |
double par[300]; |
spec = new TSpectrum(npeaks); |
// Find spectrum background |
histback = spec->Background(histtemp, (int)fitInter->widgetNE[0]->GetNumber(), "same"); |
// Clone histogram and subtract background from it if we select that option |
h2 = (TH1F*)histtemp->Clone("h2"); |
if(fitChecks->widgetChBox[0]->IsDown()) |
h2->Add(histback, -1); |
// Search for the peaks |
int found = spec->Search(h2, fitSigma->widgetNE[0]->GetNumber(), "goff", fitTresh->widgetNE[0]->GetNumber() ); |
printf("PhotonMu(): Found %d candidates to fit.\n",found); |
npeaks = found; |
|
// Set initial peak parameters |
xpeaks = spec->GetPositionX(); |
for(j = 0; j < found; j++) |
{ |
float xp = xpeaks[j]; |
int bin = h2->GetXaxis()->FindBin(xp); |
float yp = h2->GetBinContent(bin); |
par[3*j] = yp; |
par[3*j+1] = xp; |
par[3*j+2] = (double)fitSigma->widgetNE[0]->GetNumber(); |
} |
|
// Fit the histogram |
fit = new TF1("fit", FindPeaks, adcRange->widgetNE[0]->GetNumber(), adcRange->widgetNE[1]->GetNumber(), 3*npeaks); |
TVirtualFitter::Fitter(histtemp, 3*npeaks); |
fit->SetParameters(par); |
fit->SetNpx(300); |
h2->Fit("fit","Q"); |
// Get the fitted parameters |
fittingfunc = h2->GetFunction("fit"); |
fparam = fittingfunc->GetParameters(); |
fparamerr = fittingfunc->GetParErrors(); |
|
// Gather the parameters (mean peak value for now) |
int j = 1; |
int nrfit = 0; |
while(1) |
{ |
if( (fparam[j] < 1.E-30) || (nrfit > 8) ) |
break; |
else |
{ |
// Check if pedestal is above the lower limit and sigma is smaller than the mean |
if( (fparam[j] > pedesLow->widgetNE[0]->GetNumber()) && ((double)fparamerr[j]/fparam[j] < accError->widgetNE[0]->GetNumber()) ) |
{ |
// With the additional ADC offset, we can shift the mean values slightly, so they are not close to the X.5, but to the X.0 values |
meansel[nrfit] = fparam[j]+(adcOffset->widgetNE[0]->GetNumber()); |
sigmasel[nrfit] = fparam[j+1]; |
nrfit++; |
} |
} |
|
j+=3; |
} |
TMath::Sort(nrfit, meansel, sortindex, kFALSE); |
|
fittingfunc->Draw("SAME"); |
analysisCanvas->GetCanvas()->Modified(); |
analysisCanvas->GetCanvas()->Update(); |
|
meanparam = meansel[sortindex[0]]; |
meanparamerr = meanselerr[sortindex[0]]; |
paramsigma = sigmasel[sortindex[0]]; |
|
for(j = 0; j < nrfit; j++) |
printf("BreakdownVolt(): %d: peak mean = %lf, peak err = %lf\n", j, meansel[sortindex[j]], meanselerr[sortindex[j]]); |
|
return; |
} |
if(files->At(i)) |
{ |
// Replot the spectrum on analysisCanvas and do not close the input file |
1383,9 → 1566,10 |
latex = new TLatex(); |
latex->SetTextSize(0.039); |
latex->DrawLatex(volt[0], 0.97*sep[0][sortindex[p-1]], ctemp); |
printf("#Delta_{p}(U) = (%.6lf #pm %.8lf)#timesU + (%.6lf #pm %.8lf)}{U_{0} = %.6lf #pm %.8lf\n", meansel[0], meanselerr[0], meansel[1], meanselerr[1], meansel[2], meansel[2]*(TMath::Abs(meanselerr[0]/meansel[0]) + TMath::Abs(meanselerr[1]/meansel[1])) ); |
} |
else |
printf("#Delta_{p}(U) = (%.2lf #pm %.2lf)#timesU + (%.2lf #pm %.3lf)}{U_{0} = %.2lf #pm %.3lf", meansel[0], meanselerr[0], meansel[1], meanselerr[1], meansel[2], meansel[2]*(TMath::Abs(meanselerr[0]/meansel[0]) + TMath::Abs(meanselerr[1]/meansel[1])) ); |
printf("#Delta_{p}(U) = (%.2lf #pm %.2lf)#timesU + (%.2lf #pm %.3lf)}{U_{0} = %.2lf #pm %.3lf\n", meansel[0], meanselerr[0], meansel[1], meanselerr[1], meansel[2], meansel[2]*(TMath::Abs(meanselerr[0]/meansel[0]) + TMath::Abs(meanselerr[1]/meansel[1])) ); |
|
if(edit == 0) |
{ |
1423,9 → 1607,9 |
surfy = new double[nrfiles]; |
double xsurfmin = 0, ysurfmin = 0; |
int nrentries; |
// double minInteg, maxInteg; |
double minInteg, maxInteg; |
bool norm = surfScanOpt->widgetChBox[0]->IsDown(); |
// double curzval; |
double curyval; |
// bool edge2d = false; |
|
TCanvas *gCanvas; |
1487,7 → 1671,7 |
} |
|
// X, Y and Z values from each file (table units or microns) |
if(posUnits->widgetCB->GetSelected() == 0) |
if(posUnitsPlot->widgetCB->GetSelected() == 0) |
{ |
if(n == 1) |
{ |
1498,7 → 1682,7 |
surfx[i] = (double)(evtheader.xpos); |
surfy[i] = (double)(evtheader.ypos); |
} |
else if(posUnits->widgetCB->GetSelected() == 1) |
else if(posUnitsPlot->widgetCB->GetSelected() == 1) |
{ |
if(n == 1) |
{ |
1529,60 → 1713,24 |
nrentries = n; |
printf("SurfaceScan(): %d files were selected.\n", nrfiles); |
|
// // If only an integral is needed, do not plot and exit here |
// if( direction == 0 ) |
// { |
// delete[] integralCount; |
// delete[] surfxy; |
// delete[] surfz; |
// return; |
// } |
// |
// // Current z value and the accumulated counter |
// curzval = surfz[0]; |
// j = 0; |
// int acc = 0; |
// int zb; |
// for(int i = 0; i <= (int)nrfiles; i++) |
// { |
// // Collect the accumulated integral in order to produce a PDF from a CDF |
// // While we are at the same Z value, save under one set |
// if( (surfz[i] == curzval) && (acc != nrfiles) ) |
// { |
// integralAcc[j] = integralCount[i]; |
// if(DBGSIG) printf("IntegSpectrum(): Integral check 1 (i=%d,j=%d,z=%.2lf): %lf\t%lf\n", i, j, surfz[i], integralCount[i], integralAcc[j]); |
// j++; |
// acc++; |
// } |
// // When we switch to a new set of Z values and at the end, we must save the previous ones to make 1D edge plots |
// else |
// { |
// // Find minimal and maximal integral values to subtract the offset and normate PDF to 1 |
// NormateSet(i, j, &minInteg, &maxInteg, integralCount, integralAcc); |
// |
// if(acc != nrfiles) |
// { |
// curzval = surfz[i]; |
// // PDF and CDF plot |
// PlotEdgeDistribution(files, i, j, &minInteg, &maxInteg, surfxy, integralAcc, direction, edge2d, edit); |
// i--; |
// j = 0; |
// } |
// else |
// { |
// // PDF and CDF plot |
// PlotEdgeDistribution(files, i, j, &minInteg, &maxInteg, surfxy, integralAcc, direction, edge2d, edit); |
// i--; |
// break; |
// } |
// } |
// |
// // Update the progress bar |
// progVal = (float)(15.00/nrfiles)*i+75.00; |
// analysisProgress->widgetPB->SetPosition(progVal); |
// gVirtualX->Update(1); |
// } |
// Check for Minimum and Maximum values and normalize to 1, if normalization is selected |
if(norm) |
{ |
minInteg = TMath::MinElement(nrfiles, integralCount); |
for(int i = 0; i < nrfiles; i++) |
{ |
integralCount[i] -= minInteg; |
if(DBGSIG) printf("Subtraction: %lf\n", integralCount[i]); |
} |
|
maxInteg = TMath::MaxElement(nrfiles, integralCount); |
for(int i = 0; i < nrfiles; i++) |
{ |
integralCount[i] = integralCount[i]/maxInteg; |
if(DBGSIG) printf("Normalization: %lf\n", integralCount[i]); |
} |
} |
|
// Make the 2D surface plot |
if(edit == 0) |
gCanvas = new TCanvas("canv","canv",1100,900); |
1638,16 → 1786,16 |
|
if(!cleanPlots) |
{ |
if(posUnits->widgetCB->GetSelected() == 0) |
if(posUnitsPlot->widgetCB->GetSelected() == 0) |
gScan2D->SetTitle("Surface scan;X [table units];Y [table units]"); |
else if(posUnits->widgetCB->GetSelected() == 1) |
else if(posUnitsPlot->widgetCB->GetSelected() == 1) |
gScan2D->SetTitle("Surface scan;X [#mum];Y [#mum]"); |
} |
else |
{ |
if(posUnits->widgetCB->GetSelected() == 0) |
if(posUnitsPlot->widgetCB->GetSelected() == 0) |
gScan2D->SetTitle(";X [table units];Y [table units]"); |
else if(posUnits->widgetCB->GetSelected() == 1) |
else if(posUnitsPlot->widgetCB->GetSelected() == 1) |
gScan2D->SetTitle(";X [#mum];Y [#mum]"); |
} |
/* TGaxis *xax = (TGaxis*)gScan2D->GetXaxis(); |
1670,10 → 1818,10 |
gScan2D->GetYaxis()->SetTitleOffset(1.9); |
gScan2D->GetYaxis()->CenterTitle(kTRUE); |
gScan2D->GetYaxis()->SetLabelSize(0.027); |
gScan2D->GetXaxis()->SetLabelOffset(0.02); |
gScan2D->GetYaxis()->SetLabelOffset(0.02); |
gScan2D->GetYaxis()->SetRangeUser(range[2], range[3]); |
gScan2D->GetYaxis()->SetNoExponent(kTRUE); |
|
|
gCanvas->Modified(); |
gCanvas->Update(); |
|