Subversion Repositories f9daq

Compare Revisions

Ignore whitespace Rev 172 → Rev 173

/lab/sipmscan/trunk/doc/README
529,7 → 529,13
= 8. Change log ===
===================
 
??.8.2016 (Current Rev)
5.10.2016 (Current Rev)
a) Fixed a couple of bugs and layout positions.
b) Added settings files for measurement and analysis settings. With this, everytime a new measurement or a new analysis is
ran, the selected settings are saved to a file. This way, if the program crashes, the selected settings will be automatically
filled in.
 
30.9.2016 (Rev 172):
a) Fixed the time estimation for surface and Z-axis scans (TimeEstimateNew).
b) Did the same as c) in the previous revision, but separately for opening histogram files and for selecting the measurement
output file.
/lab/sipmscan/trunk/doc/documentation.html
511,8 → 511,22
<div class="backtop"><a href="#top">Back to top</a></div>
 
<h2 id="changelog">8. Change log</h2>
<p>11.8.2016 (Current Rev):</p>
<p>5.10.2016 (Current Rev):</p>
<ol type="a">
<li>Fixed a couple of bugs and layout positions.</li>
<li>Added settings files for measurement and analysis settings. With this, everytime a new measurement or a new analysis is ran, the selected settings are saved to a file. This way, if the program crashes, all settings will be automatically filled in.</li>
</ol><br/>
 
<p>30.9.2016 (Rev 172):</p>
<ol type="a">
<li>Fixed the time estimation for surface and Z-axis scans (TimeEstimateNew).</li>
<li>Did the same as c) in the previous revision, but separately for opening histogram files and for selecting the measurement output file.</li>
<li>Added an Emergency stop button to the movement of the table - just in case a wrong value is inserted and there is something in the way.</li>
<li>Added a way to integrate the surface scan, when using the "Start and Edit" option. This can be useful for determining the angular dependence of the light passing onto a complete camera pixel.</li>
</ol><br/>
 
<p>11.8.2016 (Rev 167):</p>
<ol type="a">
<li>When using breakdown voltage or relative PDE analysis and with only one file selected, the analysis is stopped and the fit is displayed on the graph. This makes it easier to setup fitting settings.</li>
<li>Added the possibility to export plots created through analysis ("Start and edit" option).</li>
<li>Everytime, when opening a histogram file, the following open and save dialog windows automatically open up in that directory. This makes it easier to find the directory that was used last.</li>
/lab/sipmscan/trunk/include/sipmscan.h
22,6 → 22,9
M_FILE_SAVE_LAYOUT,
M_FILE_SAVE_MSETTINGS,
M_FILE_SAVE_ASETTINGS,
M_FILE_DEF_MSETTINGS,
M_FILE_DEF_ASETTINGS,
M_FILE_DEF_SETTINGS,
M_FILE_CHECK_WIDTH,
M_FILE_EXIT,
 
129,6 → 132,10
void LayoutRead(int nrframes, int *w, int *h);
void LayoutSave();
void LayoutSet();
void SaveMeasSettings();
void SaveAnalSettings();
void GetMeasSettings();
void GetAnalSettings();
void ToolTipSet();
void ToolTipSetSurfaceScan();
void ToolTipSetRelativePDE();
172,6 → 179,7
TSubStructure *yPosStep;
TSubStructure *rotPos;
TSubStructure *rotButtons;
TSubStructure *rotButEmergency;
TSubStructure *rotPosMin;
TSubStructure *rotPosMax;
TSubStructure *rotPosStep;
/lab/sipmscan/trunk/src/MIKRO/Makefile
2,3 → 2,5
gcc mikro_ctrl.c rs232.c MIKRO.c -o mikro_ctrl -lm
mikro_ctrl_d: mikro_ctrl.c rs232.c rs232.h MIKRO.c
gcc mikro_ctrl.c rs232.c MIKRO.c -o mikro_ctrl_d -lm -DDEBUG
clean:
rm mikro_ctrl
/lab/sipmscan/trunk/src/analysis.cpp
59,6 → 59,7
else if(analTab->GetCurrent() == 1) // Relative PDE
{
relPde->widgetChBox[0]->SetState(kButtonDown);
relPde->widgetChBox[1]->SetState(kButtonUp);
midPeak->widgetChBox[0]->SetState(kButtonUp);
zeroAngle->widgetNE[0]->SetNumber(0.00);
}
96,6 → 97,9
else if( analtab == 3 )
analtype = 4;
 
// Save analysis settings any time we run a new analysis
SaveAnalSettings();
 
// Only integrate spectrum or make relative PDE
if(type == 0)
{
370,7 → 374,6
double range[4];
TGraph2D *gScan2D;
gScan2D = new TGraph2D();
gScan2D->SetName("edgescan");
range[0] = TMath::MinElement(nrfiles, surfxy);
range[1] = TMath::MaxElement(nrfiles, surfxy);
range[2] = TMath::MinElement(nrfiles, surfz);
679,6 → 682,7
int adcpedestal[2];
int zeromu = 0;
int darkhist = -1;
int nopeaks = -1;
 
double pointest[12];
bool exclude = false;
690,9 → 694,170
analysisProgress->widgetPB->SetPosition(progVal);
gVirtualX->Update(1);
 
// Check if the checkbox for no peaks is selected - TODO: Still need the situation when we do not have a peaked ADC spectrum
if(relPde->widgetChBox[1]->IsDown())
{
printf("PhotonMu(): ADC spectrum has no peak structure.\n");
nopeaks = 1;
 
// Error if there is no darkhist
if(strcmp("", darkRun->widgetTE->GetText()) == 0)
{
printf("PhotonMu(): Error! The no peak structure option needs a dark histogram.\n");
delete[] integralCount;
delete[] integralPedestal;
delete[] angle;
delete[] pdeval;
delete[] muval;
return;
}
 
}
 
// Start if we select at least one file
if(nrfiles > 0)
{
// Find the pedestal peak for the dark histogram, and use it for all if there are no peaks
if(nopeaks != -1)
{
// Replot the spectrum on analysisCanvas and do not close the input file
DisplayHistogram( (char*)(darkRun->widgetTE->GetText()), 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);
 
meanparam = meansel[sortindex[0]];
paramsigma = sigmasel[sortindex[0]];
 
for(j = 0; j < nrfit; j++)
if(DBGSIG)
printf("PhotonMu(): %d: peak mean = %lf\n", j, meansel[sortindex[j]]);
j = 0;
adcpedestal[0] = 0;
adcpedestal[1] = -1;
 
while(1)
{
int bin = histtemp->GetXaxis()->FindBin((int)(j+meanparam+paramsigma));
int yp = histtemp->GetBinContent(bin);
 
// Check where we get to first minimum after pedestal peak or where we get to the half maximum of the pedestal peak (in case there is only a pedestal peak)
if(adcpedestal[1] == -1)
{
adcpedestal[0] = j+meanparam+paramsigma;
adcpedestal[1] = yp;
}
else
{
if( (npeaks > 1) && (adcpedestal[1] >= yp) )
{
adcpedestal[0] = j+meanparam+paramsigma;
adcpedestal[1] = yp;
}
else if( (npeaks == 1) && (adcpedestal[0] < meanparam+5*paramsigma) ) // TODO -> Determining the pedestal when only one peak
{
adcpedestal[0] = j+meanparam+paramsigma;
adcpedestal[1] = yp;
}
else
break;
}
j++;
if(j > 50) break;
}
 
if(midPeak->widgetChBox[0]->IsDown())
{
if( (meanparam - (int)meanparam >= 0.) && (meanparam - (int)meanparam < 0.5) )
m = TMath::Floor(meanparam);
else if( (meanparam - (int)meanparam >= 0.5) && (meanparam - (int)meanparam < 1.) )
m = TMath::Ceil(meanparam);
int bin = histtemp->GetXaxis()->FindBin(m);
adcpedestal[0] = m;
printf("midpeak x = %d, ", adcpedestal[0]);
adcpedestal[1] = histtemp->GetBinContent(bin);
}
 
// Option to show the fit
fittingfunc->Draw("L SAME");
analysisCanvas->GetCanvas()->Modified();
analysisCanvas->GetCanvas()->Update();
printf("Pedestal ends = %d and nr. of counts = %d\n", adcpedestal[0], adcpedestal[1]);
 
// Delete the opened histogram and spectrum
delete spec;
delete inroot;
 
// return;
}
 
printf("PhotonMu(): Continuing with the rest of the spectra.\n");
 
// Check all histograms for pedestal peak values
for(int i = 0; i < (int)nrfiles; i++)
{
if( (nrfiles == 1) || (!multiSelect->widgetChBox[0]->IsDown()) )
788,145 → 953,148
darkhist = i;
}
 
// 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();
if(nopeaks == -1)
{
// 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;
// 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();
}
// 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();
// 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()) )
// 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
{
// 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++;
// 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);
j+=3;
}
TMath::Sort(nrfit, meansel, sortindex, kFALSE);
 
meanparam = meansel[sortindex[0]];
paramsigma = sigmasel[sortindex[0]];
meanparam = meansel[sortindex[0]];
paramsigma = sigmasel[sortindex[0]];
 
for(j = 0; j < nrfit; j++)
if(DBGSIG)
printf("PhotonMu(): %d: peak mean = %lf\n", j, meansel[sortindex[j]]);
for(j = 0; j < nrfit; j++)
if(DBGSIG)
printf("PhotonMu(): %d: peak mean = %lf\n", j, meansel[sortindex[j]]);
j = 0;
adcpedestal[0] = 0;
adcpedestal[1] = -1;
j = 0;
adcpedestal[0] = 0;
adcpedestal[1] = -1;
 
while(1)
{
int bin = histtemp->GetXaxis()->FindBin((int)(j+meanparam+paramsigma));
int yp = histtemp->GetBinContent(bin);
while(1)
{
int bin = histtemp->GetXaxis()->FindBin((int)(j+meanparam+paramsigma));
int yp = histtemp->GetBinContent(bin);
 
// Check where we get to first minimum after pedestal peak or where we get to the half maximum of the pedestal peak (in case there is only a pedestal peak)
if(adcpedestal[1] == -1)
{
adcpedestal[0] = j+meanparam+paramsigma;
adcpedestal[1] = yp;
}
else
{
if( (npeaks > 1) && (adcpedestal[1] >= yp) )
// Check where we get to first minimum after pedestal peak or where we get to the half maximum of the pedestal peak (in case there is only a pedestal peak)
if(adcpedestal[1] == -1)
{
adcpedestal[0] = j+meanparam+paramsigma;
adcpedestal[1] = yp;
}
else if( (npeaks == 1) && (adcpedestal[0] < meanparam+5*paramsigma) ) // TODO -> Determining the pedestal when only one peak
else
{
adcpedestal[0] = j+meanparam+paramsigma;
adcpedestal[1] = yp;
if( (npeaks > 1) && (adcpedestal[1] >= yp) )
{
adcpedestal[0] = j+meanparam+paramsigma;
adcpedestal[1] = yp;
}
else if( (npeaks == 1) && (adcpedestal[0] < meanparam+5*paramsigma) ) // TODO -> Determining the pedestal when only one peak
{
adcpedestal[0] = j+meanparam+paramsigma;
adcpedestal[1] = yp;
}
else
break;
}
else
break;
j++;
if(j > 50) break;
}
j++;
if(j > 50) break;
}
 
if( (npeaks > 1) && (nrfit > 1) )
{
int bin = histtemp->GetXaxis()->FindBin((int)(meanparam+meansel[sortindex[1]])/2);
adcpedestal[0] = (meanparam+meansel[sortindex[1]])/2;
printf("PhotonMu(): multipeak x = %d, ", adcpedestal[0]);
adcpedestal[1] = histtemp->GetBinContent(bin);
}
if(npeaks > 1)
{
int bin = histtemp->GetXaxis()->FindBin((int)(meanparam+meansel[sortindex[1]])/2);
adcpedestal[0] = (meanparam+meansel[sortindex[1]])/2;
printf("PhotonMu(): multipeak x = %d, ", adcpedestal[0]);
adcpedestal[1] = histtemp->GetBinContent(bin);
}
 
if(midPeak->widgetChBox[0]->IsDown())
{
if( (meanparam - (int)meanparam >= 0.) && (meanparam - (int)meanparam < 0.5) )
m = TMath::Floor(meanparam);
else if( (meanparam - (int)meanparam >= 0.5) && (meanparam - (int)meanparam < 1.) )
m = TMath::Ceil(meanparam);
int bin = histtemp->GetXaxis()->FindBin(m);
adcpedestal[0] = m;
printf("midpeak x = %d, ", adcpedestal[0]);
adcpedestal[1] = histtemp->GetBinContent(bin);
}
if(midPeak->widgetChBox[0]->IsDown())
{
if( (meanparam - (int)meanparam >= 0.) && (meanparam - (int)meanparam < 0.5) )
m = TMath::Floor(meanparam);
else if( (meanparam - (int)meanparam >= 0.5) && (meanparam - (int)meanparam < 1.) )
m = TMath::Ceil(meanparam);
int bin = histtemp->GetXaxis()->FindBin(m);
adcpedestal[0] = m;
printf("midpeak x = %d, ", adcpedestal[0]);
adcpedestal[1] = histtemp->GetBinContent(bin);
}
 
/* // Option to show the fit
fittingfunc->Draw("L SAME");
analysisCanvas->GetCanvas()->Modified();
analysisCanvas->GetCanvas()->Update();*/
/* // Option to show the fit
fittingfunc->Draw("L SAME");
analysisCanvas->GetCanvas()->Modified();
analysisCanvas->GetCanvas()->Update();*/
printf("Pedestal ends = %d and nr. of counts = %d\n", adcpedestal[0], adcpedestal[1]);
printf("Pedestal ends = %d and nr. of counts = %d\n", adcpedestal[0], adcpedestal[1]);
 
// Delete the opened histogram and spectrum
delete spec;
delete inroot;
// Delete the opened histogram and spectrum
delete spec;
delete inroot;
}
 
// Open the input file and read header, ADC and TDC values
sprintf(ctemp, "%s", files->At(i)->GetTitle());
994,14 → 1162,7
if( (angle[i] == zeroAngle->widgetNE[0]->GetNumber()) && (darkhist != i) )
zeromu = i;
 
// Checking for errors when fitting a histogram
if(k2 == 0)
{
printf("PhotonMu(): No pedestal entries found. Check the fitting results.\n");
muval[i] = -1;
}
else
muval[i] = -TMath::Log((double)k2/(double)k);
muval[i] = -TMath::Log((double)k2/(double)k);
printf("PhotonMu(): %lf: muval = %lf\n", angle[i], muval[i]);
 
inroot->Close();
1018,7 → 1179,7
 
printf("PhotonMu(): angle\tmu\trelative PDE\n");
m = 0;
 
// Set the 0 degree muval, reuse meansel[1]
meansel[1] = muval[zeromu];
printf("Zero value (id=%d, angle=%lf) = %lf\n", zeromu, angle[zeromu], meansel[1]);
1048,10 → 1209,6
if(i == darkhist)
exclude = false;
 
// Wrong fit
if(muval[i] == -1)
exclude = true;
 
// If nothing excluded, pass the points in pointest variable like in a FIFO
if(!exclude)
{
1312,6 → 1469,7
{
// 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());
meanselerr[nrfit] = fparamerr[j];
sigmasel[nrfit] = fparam[j+1];
nrfit++;
}
1488,6 → 1646,8
exclude = false;
}
 
printf("BreakdownVolt(): Calculated separation between peaks %d and %d: sep = %lf, seperr = %lf\n", (int)peakSepCalc->widgetNE[0]->GetNumber()-1, (int)peakSepCalc->widgetNE[0]->GetNumber(), sep[(int)peakSepCalc->widgetNE[0]->GetNumber()-1][p], seperr[(int)peakSepCalc->widgetNE[0]->GetNumber()-1][p]);
 
// Write out parameters to a file
fp = fopen(paramname, "a");
if(exclude)
1540,7 → 1700,7
bdplot = new TGraphErrors(p, volt, sep[k-1], volterr, seperr[k-1]);
else
{
printf("BreakdownVold(): Unsupported peak separation selected (%d).\n", k);
printf("BreakdownVolt(): Unsupported peak separation selected (%d).\n", k);
return;
}
 
1577,7 → 1737,7
sprintf(ctemp, "#splitline{#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])) );
latex = new TLatex();
latex->SetTextSize(0.039);
latex->DrawLatex(volt[0], 0.97*sep[0][sortindex[p-1]], ctemp);
latex->DrawLatex(volt[0], 0.97*sep[0][sortindex[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
1752,7 → 1912,6
double range[4];
TGraph2D *gScan2D;
gScan2D = new TGraph2D();
gScan2D->SetName("surfscan");
range[0] = TMath::MinElement(nrfiles, surfx);
range[1] = TMath::MaxElement(nrfiles, surfx);
range[2] = TMath::MinElement(nrfiles, surfy);
1855,8 → 2014,6
{
gCanvas->Modified();
gCanvas->Update();
 
UpdateIntegrateSurface(-1);
}
}
}
/lab/sipmscan/trunk/src/connections.cpp
1360,6 → 1360,9
// Start the acquisition
void TGAppMainFrame::StartAcq()
{
// Save measurement settings any time we run a new measurement
SaveMeasSettings();
 
// Variable that will initialize camac only once (for scans)
int scanon = 0;
 
/lab/sipmscan/trunk/src/daqscope.C
2,7 → 2,7
#include <stdlib.h>
#include <string.h>
 
#include "../include/vxi11_x86_64/vxi11_user.h"
#include "../include/vxi11_i686/vxi11_user.h"
#include "../include/daqscope.h"
#include "../include/workstation.h"
 
/lab/sipmscan/trunk/src/daqusb.C
7,7 → 7,7
#include <signal.h>
#include <ctype.h>
#include <time.h>
//#include "../include/wusbxx_dll.h" /* the header of the shared library */
#include "../include/wusbxx_dll.h" /* the header of the shared library */
#include "../include/daq.h"
 
//#define DEBUG /* vkljuci dodatni izpis */
26,11 → 26,11
//#define NADCCH 8
int ctrlc=0;
char *ccserial=(char*)"CC0126";
int devDetect; // variable to tell if we detect any devices
//int devDetect; // variable to tell if we detect any devices
 
int daq::connect(){
// odpri daq
/* xxusb_device_type devices[100];
xxusb_device_type devices[100];
//struct usb_device *dev;
devDetect = xxusb_devices_find(devices);
// printf("Detected devices: %d\n", devDetect);
44,16 → 44,16
printf("daq::connect()\n");
}
else
*/ printf("daq::connect() - No devices were detected!\n");
printf("daq::connect() - No devices were detected!\n");
return 0;
}
 
int daq::init(int chan = 0){
 
// int i;
// long k;
int i;
long k;
 
/* DBGFUNI(xxusb_register_write(udev,1,0x0)); // Stop DAQ mode
DBGFUNI(xxusb_register_write(udev,1,0x0)); // Stop DAQ mode
while (xxusb_usbfifo_read(udev, (int*) stackdump,BUFF_L,100)>0);
CCCZ;
115,27 → 115,26
// ret[0] = CAMAC_register_read(udev,1,&k);
// printf("k (return %d) -> 0x%08lX\n",ret[0],k);
*/ printf("daq::init()\n");
printf("daq::init()\n");
return 0;
}
 
int daq::start(){
// xxusb_register_write(udev,1,0x1); // Start DAQ mode
xxusb_register_write(udev,1,0x1); // Start DAQ mode
printf("daq::start()\n");
return 0;
}
 
int daq::stop(){
// xxusb_register_write(udev,1,0x0); // Stop DAQ mode
// while (xxusb_usbfifo_read(udev,(int *)stackdump,BUFF_L,30)>0);
xxusb_register_write(udev,1,0x0); // Stop DAQ mode
while (xxusb_usbfifo_read(udev,(int *)stackdump,BUFF_L,30)>0);
printf("daq::stop()\n");
return 0;
}
 
int daq::event(unsigned int *data, int maxn){
// int ib,count;
int count;
/* int events,evsize;
int ib,count;
int events,evsize;
short ret;
 
ib=0;
150,7 → 149,7
DBG(printf("Event:%d EvSize:%d\n", events, evsize);)
for (int i=0;i<(NTDCCH+NADCCH);i++,ib++) data[count++] =stackdata[ib++]&0xffff;
if (stackdata[ib++]!=0xfafb){
printf("Error!\n");,
printf("Error!\n");
return 0;
}
events--;
160,14 → 159,14
printf("Error!\n");
return 0;
}
*/
count = 1;
 
// count = 1;
return count;
}
int daq::disconnect(){
// zapri daq
// WUSBXX_close();
WUSBXX_close();
printf("daq::disconnect()\n");
return 0;
}
204,7 → 203,7
// intercept routine
if (signal (SIGINT, CatchSig) == SIG_E,RR) perror ("sigignore");
if (signal (SIGINT, CatchSig) == SIG_ERR) perror ("sigignore");
#define BSIZE 10000
int i,ieve,nc,nb;
212,8 → 211,8
int hdr[4]={1,(NTDCCH+NADCCH+4)*sizeof(int)};
unsigned short adc;
unsigned int data[BSIZE];
daq *d= new daq();,
time_t time_check;,
daq *d= new daq();
time_t time_check;
 
// odpremo datoteko za pisanje
FILE *fp=fopen(fname,"w");
/lab/sipmscan/trunk/src/sipmscan.cpp
150,7 → 150,7
 
void TGAppMainFrame::HandleMenu(Int_t id)
{
// int ret = 0;
int ret = 0;
char cmd[256];
 
switch(id)
164,13 → 164,33
break;
 
case M_FILE_SAVE_MSETTINGS:
// Here, we save the set values in the measurement layout (automatically done when we safely exit the application and after each start of measurement).
SaveMeasSettings();
break;
 
case M_FILE_SAVE_ASETTINGS:
// Here, we save the set values in the analysis layout (automatically done when we safely exit the application and after each start of analysis).
SaveAnalSettings();
break;
 
case M_FILE_DEF_MSETTINGS:
printf("Reseting measurement settings to default.\n");
sprintf(cmd, "cp %s/settings/default_measurement_settings.txt %s/settings/measurement_settings.txt", rootdir, rootdir);
ret = system(cmd);
break;
 
case M_FILE_DEF_ASETTINGS:
printf("Reseting analysis settings to default.\n");
sprintf(cmd, "cp %s/settings/default_analysis_settings.txt %s/settings/analysis_settings.txt", rootdir, rootdir);
ret = system(cmd);
break;
 
case M_FILE_DEF_SETTINGS:
printf("Reseting all settings to default.\n");
sprintf(cmd, "cp %s/settings/default_measurement_settings.txt %s/settings/measurement_settings.txt", rootdir, rootdir);
ret = system(cmd);
sprintf(cmd, "cp %s/settings/default_analysis_settings.txt %s/settings/analysis_settings.txt", rootdir, rootdir);
ret = system(cmd);
break;
 
case M_FILE_CHECK_WIDTH:
printf("\nSettings window: %dx%d\n", measLayout[0]->GetWidth(), measLayout[0]->GetHeight());
printf("Histogram window: %dx%d\n", measLayout[1]->GetWidth(), measLayout[1]->GetHeight());
302,6 → 322,9
fMenuFile->AddSeparator();
fMenuFile->AddEntry(new TGHotString("Save current &measurement settings"), M_FILE_SAVE_MSETTINGS);
fMenuFile->AddEntry(new TGHotString("Save current &analysis settings"), M_FILE_SAVE_ASETTINGS);
fMenuFile->AddEntry(new TGHotString("Set default measurement settings"), M_FILE_DEF_MSETTINGS);
fMenuFile->AddEntry(new TGHotString("Set default analysis settings"), M_FILE_DEF_ASETTINGS);
fMenuFile->AddEntry(new TGHotString("Set default settings"), M_FILE_DEF_SETTINGS);
fMenuFile->AddEntry(new TGHotString("&Check frame width (Testing)"), M_FILE_CHECK_WIDTH);
fMenuFile->AddSeparator();
fMenuFile->AddEntry(new TGHotString("E&xit"), M_FILE_EXIT);
533,12 → 556,12
fH2 = new TGCompositeFrame(fG1, 3*subgroup[0]/4, 30, kFixedWidth | kHorizontalFrame);
xPos = new TSubStructure();
for(int i = 0; i < 6; i++) numform[i] = 0;
numform[0] = 9; numform[3] = 2; numform[4] = -100; numform[5] = 215000;
numform[0] = 9; numform[3] = 2; numform[4] = -100; numform[5] = 375000; //numform[4] = -100; numform[5] = 215000; // use commented part if Z is the longer axis and X the shorter
if(xPos->TGLabelNEntry(fH2, 8*subgroup[0]/16, 30, "X:", 0, numform, "center"))
fH2->AddFrame(xPos->outsidebox, f0centerX);
 
zPosMin = new TSubStructure();
numform[5] = 375000;
numform[5] = 215000; //numform[5] = 375000; // use commented part if Z is the longer axis and X the shorter
if(zPosMin->TGLabelNEntry(fH2, 8*subgroup[0]/16, 30, "Z (min):", 0, numform, "center"))
fH2->AddFrame(zPosMin->outsidebox, f0centerX);
fG1->AddFrame(fH2, f1expandXpad);
550,7 → 573,7
fH2->AddFrame(yPos->outsidebox, f0centerX);
 
zPosMax = new TSubStructure();
numform[5] = 375000;
numform[5] = 215000; //numform[5] = 375000; // use commented part if Z is the longer axis and X the shorter
if(zPosMax->TGLabelNEntry(fH2, 8*subgroup[0]/16, 30, "Z (max):", 0, numform, "center"))
fH2->AddFrame(zPosMax->outsidebox, f0centerX);
fG1->AddFrame(fH2, f1expandXpad);
557,7 → 580,7
fH2 = new TGCompositeFrame(fG1, 3*subgroup[0]/4, 30, kFixedWidth | kHorizontalFrame);
zPos = new TSubStructure();
numform[5] = 375000;
numform[5] = 215000; //numform[5] = 375000; // use commented part if Z is the longer axis and X the shorter
if(zPos->TGLabelNEntry(fH2, 8*subgroup[0]/16, 30, "Z:", 0, numform, "center"))
fH2->AddFrame(zPos->outsidebox, f0centerX);
 
580,11 → 603,12
fH2 = new TGCompositeFrame(fG1, 3*subgroup[0]/4, 30, kFixedWidth | kHorizontalFrame);
xPosMin = new TSubStructure();
for(int i = 0; i < 6; i++) numform[i] = 0;
numform[0] = 9; numform[3] = 2; numform[4] = -100; numform[5] = 215000;
numform[0] = 9; numform[3] = 2; numform[4] = -100; numform[5] = 375000; //numform[5] = 215000; // use commented part if Z is the longer axis and X the shorter
if(xPosMin->TGLabelNEntry(fH2, 8*subgroup[0]/16, 30, "X (min):", 0, numform, "center"))
fH2->AddFrame(xPosMin->outsidebox, f0centerX);
 
yPosMin = new TSubStructure();
numform[5] = 215000;
if(yPosMin->TGLabelNEntry(fH2, 8*subgroup[0]/16, 30, "Y (min):", 0, numform, "center"))
fH2->AddFrame(yPosMin->outsidebox, f0centerX);
fG1->AddFrame(fH2, f1expandXpad);
591,10 → 615,12
 
fH2 = new TGCompositeFrame(fG1, 3*subgroup[0]/4, 30, kFixedWidth | kHorizontalFrame);
xPosMax = new TSubStructure();
numform[5] = 375000; //numform[5] = 215000; // use commented part if Z is the longer axis and X the shorter
if(xPosMax->TGLabelNEntry(fH2, 8*subgroup[0]/16, 30, "X (max):", 0, numform, "center"))
fH2->AddFrame(xPosMax->outsidebox, f0centerX);
 
yPosMax = new TSubStructure();
numform[5] = 215000;
if(yPosMax->TGLabelNEntry(fH2, 8*subgroup[0]/16, 30, "Y (max):", 0, numform, "center"))
fH2->AddFrame(yPosMax->outsidebox, f0centerX);
fG1->AddFrame(fH2, f1expandXpad);
629,11 → 655,18
fG1->AddFrame(rotPos->outsidebox, f1expandXpad);
// Set, get, home and reset rotation buttons
if(DBGSIG > 1) printf("AppLayout(): Creating TSubStructure *rotButtons -> 5 buttons (set rotation, read current rotation, home the motor, reset controller and emergency stop)\n");
if(DBGSIG > 1) printf("AppLayout(): Creating TSubStructure *rotButtons -> 4 buttons (set rotation, read current rotation, home the motor, reset controller)\n");
rotButtons = new TSubStructure();
selnames[0] = "Set"; selnames[1] = "Get"; selnames[2] = "Home"; selnames[3] = "Reset"; selnames[4] = "Emergency stop";
if(rotButtons->TGMultiButton(fG1, 3*subgroup[0]/4, 30, 5, selnames, "center"))
selnames[0] = "Set"; selnames[1] = "Get"; selnames[2] = "Home"; selnames[3] = "Reset";
if(rotButtons->TGMultiButton(fG1, 3*subgroup[0]/4, 30, 4, selnames, "center"))
fG1->AddFrame(rotButtons->outsidebox, f1expandXpad);
// Emergency stop rotation buttons
if(DBGSIG > 1) printf("AppLayout(): Creating TSubStructure *rotButEmergency -> 1 button (emergency stop)\n");
rotButEmergency = new TSubStructure();
selnames[0] = "Emergency stop";
if(rotButEmergency->TGMultiButton(fG1, 3*subgroup[0]/4, 30, 1, selnames, "center"))
fG1->AddFrame(rotButEmergency->outsidebox, f1expandXpad);
 
// Rotation scan controls
if(DBGSIG > 1) printf("AppLayout(): Creating TSubStructure *rotPosMin -> Number entry for starting angle\n");
714,10 → 747,10
Pixel_t pixel_color;
gClient->GetColorByName("white", pixel_color);
posButtons->widgetTB[4]->SetTextColor(pixel_color);
rotButtons->widgetTB[4]->SetTextColor(pixel_color);
rotButEmergency->widgetTB[0]->SetTextColor(pixel_color);
gClient->GetColorByName("red", pixel_color);
posButtons->widgetTB[4]->SetBackgroundColor(pixel_color);
rotButtons->widgetTB[4]->SetBackgroundColor(pixel_color);
rotButEmergency->widgetTB[0]->SetBackgroundColor(pixel_color);
 
// Actions for Main window //TODO
vOutOpt->widgetChBox[0]->Connect("Clicked()", "TGAppMainFrame", this, "NegativePolarity()");
733,7 → 766,7
rotButtons->widgetTB[1]->Connect("Clicked()", "TGAppMainFrame", this, "RotationSet(=1)");
rotButtons->widgetTB[2]->Connect("Clicked()", "TGAppMainFrame", this, "RotationSet(=2)");
rotButtons->widgetTB[3]->Connect("Clicked()", "TGAppMainFrame", this, "RotationSet(=3)");
rotButtons->widgetTB[4]->Connect("Clicked()", "TGAppMainFrame", this, "RotationSet(=4)");
rotButEmergency->widgetTB[0]->Connect("Clicked()", "TGAppMainFrame", this, "RotationSet(=4)");
fileName->widgetTB[0]->Connect("Clicked()", "TGAppMainFrame", this, "SaveFile()");
measProgress->widgetTB[0]->Connect("Clicked()", "TGAppMainFrame", this, "StartAcq()");
// TODO - Save file
1200,6 → 1233,10
exportHist->widgetTB[0]->Connect("Clicked()", "TGAppMainFrame", this, "UpdateHistogram(=1)");
 
// Histogram controls pane -----------------------------------------------------------------
 
// Setting starting settings (when opening program)
GetMeasSettings();
GetAnalSettings();
}
 
// -------------------------------------------------------------------
/lab/sipmscan/trunk/src/tooltips.cpp
103,7 → 103,7
SetToolTipText("Move the rotation sample holder to angle 0 deg.");
rotButtons->widgetTB[3]->
SetToolTipText("Reposition to 0 deg, reset and initialize controller for the rotation sample holder.\nOnly use, if there is a problem with moving the table. If further problems\noccur, check under \"Movement table\" in the \"Help\" file.");
rotButtons->widgetTB[4]->
rotButEmergency->widgetTB[0]->
SetToolTipText("Emergency stop of the rotation samble holder. Use if you know the motor is about to hit something.");
 
evtNum->widgetNE[0]->GetNumberEntry()->
/lab/sipmscan/trunk/src/window_layout.cpp
284,6 → 284,450
delete[] layoutdir;
}
 
// Function for saving all current measurement settings in a file and reopening them on next program open
void TGAppMainFrame::SaveMeasSettings()
{
char *cTemp;
cTemp = new char[1024];
sprintf(cTemp, "%s/settings/measurement_settings.txt", rootdir);
 
std::ofstream osettings;
osettings.open(cTemp, std::ofstream::out);
if(osettings.is_open())
{
osettings << "# Settings pane" << std::endl;
for(int i = 0; i < 4; i++)
osettings << (int)scansOn->widgetChBox[i]->IsDown() << std::endl;
osettings << vHardlimit->widgetNE[0]->GetNumber() << std::endl;
osettings << NCH->widgetNE[0]->GetNumber() << std::endl;
osettings << posUnits->widgetCB->GetSelected() << std::endl;
osettings << rotUnits->widgetCB->GetSelected() << std::endl;
osettings << oscConnect->widgetTE->GetText() << std::endl;
osettings << laserInfo->widgetTE->GetText() << std::endl;
osettings << chtemp->widgetNE[0]->GetNumber() << std::endl;
osettings << (int)liveDisp->widgetChBox[0]->IsDown() << std::endl;
osettings << std::endl;
osettings << "# Main measurement window" << std::endl;
osettings << vOutCh->widgetCB->GetSelected() << std::endl;
for(int i = 0; i < 2; i++)
osettings << (int)vOutOpt->widgetChBox[i]->IsDown() << std::endl;
osettings << vOutStart->widgetNE[0]->GetNumber() << std::endl;
osettings << vOutStop->widgetNE[0]->GetNumber() << std::endl;
osettings << vOutStep->widgetNE[0]->GetNumber() << std::endl;
 
osettings << zPosMin->widgetNE[0]->GetNumber() << std::endl;
osettings << zPosMax->widgetNE[0]->GetNumber() << std::endl;
osettings << zPosStep->widgetNE[0]->GetNumber() << std::endl;
osettings << xPosMin->widgetNE[0]->GetNumber() << std::endl;
osettings << xPosMax->widgetNE[0]->GetNumber() << std::endl;
osettings << xPosStep->widgetNE[0]->GetNumber() << std::endl;
osettings << yPosMin->widgetNE[0]->GetNumber() << std::endl;
osettings << yPosMax->widgetNE[0]->GetNumber() << std::endl;
osettings << yPosStep->widgetNE[0]->GetNumber() << std::endl;
 
osettings << rotPosMin->widgetNE[0]->GetNumber() << std::endl;
osettings << rotPosMax->widgetNE[0]->GetNumber() << std::endl;
osettings << rotPosStep->widgetNE[0]->GetNumber() << std::endl;
 
osettings << evtNum->widgetNE[0]->GetNumber() << std::endl;
osettings << fileName->widgetTE->GetText() << std::endl;
 
printf("Saving measurement settings to file.\n");
}
else
printf("Error! Save file can not be opened.\n");
osettings.close();
}
 
// Function for saving all current analysis settings in a file and reopening them on next program open
void TGAppMainFrame::SaveAnalSettings()
{
char *cTemp;
cTemp = new char[1024];
sprintf(cTemp, "%s/settings/analysis_settings.txt", rootdir);
 
std::ofstream osettings;
osettings.open(cTemp, std::ofstream::out);
if(osettings.is_open())
{
osettings << "# Analysis" << std::endl;
// Integrate spectrum
for(int i = 0; i < 3; i++)
osettings << (int)intSpect->widgetChBox[i]->IsDown() << std::endl;
for(int i = 0; i < 2; i++)
osettings << resol2d->widgetNE[i]->GetNumber() << std::endl;
 
// Relative PDE
osettings << (int)relPde->widgetChBox[0]->IsDown() << std::endl;
osettings << (int)midPeak->widgetChBox[0]->IsDown() << std::endl;
osettings << zeroAngle->widgetNE[0]->GetNumber() << std::endl;
 
// Breakdown voltage
osettings << minPeak->widgetNE[0]->GetNumber() << std::endl;
osettings << peakSepCalc->widgetNE[0]->GetNumber() << std::endl;
 
// Surface scan
for(int i = 0; i < 2; i++)
osettings << (int)surfScanOpt->widgetChBox[i]->IsDown() << std::endl;
for(int i = 0; i < 2; i++)
osettings << resolSurf->widgetNE[i]->GetNumber() << std::endl;
 
// Fitting
osettings << fitSigma->widgetNE[0]->GetNumber() << std::endl;
osettings << fitTresh->widgetNE[0]->GetNumber() << std::endl;
osettings << fitInter->widgetNE[0]->GetNumber() << std::endl;
osettings << adcOffset->widgetNE[0]->GetNumber() << std::endl;
osettings << accError->widgetNE[0]->GetNumber() << std::endl;
osettings << pedesLow->widgetNE[0]->GetNumber() << std::endl;
for(int i = 0; i < 2; i++)
osettings << (int)fitChecks->widgetChBox[i]->IsDown() << std::endl;
osettings << std::endl;
 
osettings << "# Histogram controls" << std::endl;
for(int i = 0; i < 2; i++)
osettings << adcRange->widgetNE[i]->GetNumber() << std::endl;
for(int i = 0; i < 2; i++)
osettings << tdcRange->widgetNE[i]->GetNumber() << std::endl;
for(int i = 0; i < 2; i++)
osettings << yRange->widgetNE[i]->GetNumber() << std::endl;
osettings << selectCh->widgetNE[0]->GetNumber() << std::endl;
for(int i = 0 ; i < 2; i++)
osettings << (int)histOpt->widgetChBox[i]->IsDown() << std::endl;
osettings << posUnitsPlot->widgetCB->GetSelected() << std::endl;
printf("Saving analysis settings to file.\n");
}
else
printf("Error! Save file can not be opened.\n");
osettings.close();
}
 
// Function for getting all measurement settings from a file
void TGAppMainFrame::GetMeasSettings()
{
char *cTemp, readTemp[1024];
cTemp = new char[1024];
sprintf(cTemp, "%s/settings/measurement_settings.txt", rootdir);
 
int iTemp, k = 0;
double dTemp;
 
std::ifstream isettings;
isettings.open(cTemp, std::ifstream::in);
if(isettings.is_open())
{
printf("Opening measurement settings from file.\n");
 
while(1)
{
if(isettings.peek() == '#')
{
isettings.getline(readTemp, 1024, '\n');
if(DBGSIG > 1) printf("GetMeasSettings(): readTemp = %s\n", readTemp);
}
else if(isettings.peek() == '\n')
isettings.ignore(1, '\n');
else
{
if(k == 0)
{
// Scan settings
for(int i = 0; i < 4; i++)
{
isettings >> iTemp;
isettings.ignore(1, '\n');
if(iTemp == 0) scansOn->widgetChBox[i]->SetState(kButtonUp);
else if(iTemp == 1) scansOn->widgetChBox[i]->SetState(kButtonDown);
}
// Hard voltage limit
isettings >> dTemp;
isettings.ignore(1, '\n');
vHardlimit->widgetNE[0]->SetNumber(dTemp);
// Number of channels
isettings >> iTemp;
isettings.ignore(1, '\n');
NCH->widgetNE[0]->SetNumber(iTemp);
// Position units
isettings >> iTemp;
isettings.ignore(1, '\n');
posUnits->widgetCB->Select(iTemp);
// Rotation units
isettings >> iTemp;
isettings.ignore(1, '\n');
rotUnits->widgetCB->Select(iTemp);
// Oscilloscope IP address
isettings.getline(readTemp, 1024, '\n');
oscConnect->widgetTE->SetText(readTemp);
// Laser info
isettings.getline(readTemp, 1024, '\n');
laserInfo->widgetTE->SetText(readTemp);
// Chamber temperature
isettings >> dTemp;
isettings.ignore(1, '\n');
chtemp->widgetNE[0]->SetNumber(dTemp);
// Live display
isettings >> iTemp;
isettings.ignore(1, '\n');
if(iTemp == 0) liveDisp->widgetChBox[0]->SetState(kButtonUp);
else if(iTemp == 1) liveDisp->widgetChBox[0]->SetState(kButtonDown);
 
k++;
}
else if(k == 1)
{
// Voltage supply channel
isettings >> iTemp;
isettings.ignore(1, '\n');
vOutCh->widgetCB->Select(iTemp);
// Voltage supply options
for(int i = 0; i < 2; i++)
{
isettings >> iTemp;
isettings.ignore(1, '\n');
if(iTemp == 0) vOutOpt->widgetChBox[i]->SetState(kButtonUp);
else if(iTemp == 1) vOutOpt->widgetChBox[i]->SetState(kButtonDown);
}
// Voltage supply min, max and step
isettings >> dTemp;
isettings.ignore(1, '\n');
vOutStart->widgetNE[0]->SetNumber(dTemp);
isettings >> dTemp;
isettings.ignore(1, '\n');
vOutStop->widgetNE[0]->SetNumber(dTemp);
isettings >> dTemp;
isettings.ignore(1, '\n');
vOutStep->widgetNE[0]->SetNumber(dTemp);
// Z axis scan min, max and step
isettings >> dTemp;
isettings.ignore(1, '\n');
zPosMin->widgetNE[0]->SetNumber(dTemp);
isettings >> dTemp;
isettings.ignore(1, '\n');
zPosMax->widgetNE[0]->SetNumber(dTemp);
isettings >> dTemp;
isettings.ignore(1, '\n');
zPosStep->widgetNE[0]->SetNumber(dTemp);
// X axis scan min, max and step
isettings >> dTemp;
isettings.ignore(1, '\n');
xPosMin->widgetNE[0]->SetNumber(dTemp);
isettings >> dTemp;
isettings.ignore(1, '\n');
xPosMax->widgetNE[0]->SetNumber(dTemp);
isettings >> dTemp;
isettings.ignore(1, '\n');
xPosStep->widgetNE[0]->SetNumber(dTemp);
// Y axis scan min, max and step
isettings >> dTemp;
isettings.ignore(1, '\n');
yPosMin->widgetNE[0]->SetNumber(dTemp);
isettings >> dTemp;
isettings.ignore(1, '\n');
yPosMax->widgetNE[0]->SetNumber(dTemp);
isettings >> dTemp;
isettings.ignore(1, '\n');
yPosStep->widgetNE[0]->SetNumber(dTemp);
// Rotation min, max and step
isettings >> dTemp;
isettings.ignore(1, '\n');
rotPosMin->widgetNE[0]->SetNumber(dTemp);
isettings >> dTemp;
isettings.ignore(1, '\n');
rotPosMax->widgetNE[0]->SetNumber(dTemp);
isettings >> dTemp;
isettings.ignore(1, '\n');
rotPosStep->widgetNE[0]->SetNumber(dTemp);
// Number of events
isettings >> iTemp;
isettings.ignore(1, '\n');
evtNum->widgetNE[0]->SetNumber(iTemp);
// Save filename
isettings.getline(readTemp, 1024, '\n');
fileName->widgetTE->SetText(readTemp);
 
k++;
}
else
break;
}
}
}
else
printf("Error! Measurement settings file can not be opened. Using defaults.\n");
}
 
// Function for getting all analysis settings from a file
void TGAppMainFrame::GetAnalSettings()
{
char *cTemp, readTemp[1024];
cTemp = new char[1024];
sprintf(cTemp, "%s/settings/analysis_settings.txt", rootdir);
 
int iTemp, k = 0;
double dTemp;
 
std::ifstream isettings;
isettings.open(cTemp, std::ifstream::in);
if(isettings.is_open())
{
printf("Opening analysis settings from file.\n");
 
while(1)
{
if(isettings.peek() == '#')
{
isettings.getline(readTemp, 1024, '\n');
if(DBGSIG > 1) printf("GetAnalSettings(): readTemp = %s\n", readTemp);
}
else if(isettings.peek() == '\n')
isettings.ignore(1, '\n');
else
{
if(k == 0)
{
// Integrate spectrum options
for(int i = 0; i < 3; i++)
{
isettings >> iTemp;
isettings.ignore(1, '\n');
if(iTemp == 0) intSpect->widgetChBox[i]->SetState(kButtonUp);
else if(iTemp == 1) intSpect->widgetChBox[i]->SetState(kButtonDown);
}
// Integrate spectrum 2D resolution
for(int i = 0; i < 2; i++)
{
isettings >> iTemp;
isettings.ignore(1, '\n');
resol2d->widgetNE[i]->SetNumber(iTemp);
}
// Relative PDE normalization
isettings >> iTemp;
isettings.ignore(1, '\n');
if(iTemp == 0) relPde->widgetChBox[0]->SetState(kButtonUp);
else if(iTemp == 1) relPde->widgetChBox[0]->SetState(kButtonDown);
// Relative PDE middle peak
isettings >> iTemp;
isettings.ignore(1, '\n');
if(iTemp == 0) midPeak->widgetChBox[0]->SetState(kButtonUp);
else if(iTemp == 1) midPeak->widgetChBox[0]->SetState(kButtonDown);
// Relative PDE zero angle setting
isettings >> dTemp;
isettings.ignore(1, '\n');
zeroAngle->widgetNE[0]->SetNumber(dTemp);
// Breakdown voltage minimum number of detected peaks
isettings >> iTemp;
isettings.ignore(1, '\n');
minPeak->widgetNE[0]->SetNumber(iTemp);
// Breakdown voltage separation calculation
isettings >> iTemp;
isettings.ignore(1, '\n');
peakSepCalc->widgetNE[0]->SetNumber(iTemp);
// Surface scan options
for(int i = 0; i < 2; i++)
{
isettings >> iTemp;
isettings.ignore(1, '\n');
if(iTemp == 0) surfScanOpt->widgetChBox[i]->SetState(kButtonUp);
else if(iTemp == 1) surfScanOpt->widgetChBox[i]->SetState(kButtonDown);
}
// Surface scan 2D resolution
for(int i = 0; i < 2; i++)
{
isettings >> iTemp;
isettings.ignore(1, '\n');
resolSurf->widgetNE[i]->SetNumber(iTemp);
}
// Fitting - sigma
isettings >> dTemp;
isettings.ignore(1, '\n');
fitSigma->widgetNE[0]->SetNumber(dTemp);
// Fitting - S/N ratio
isettings >> dTemp;
isettings.ignore(1, '\n');
fitTresh->widgetNE[0]->SetNumber(dTemp);
// Fitting - interpolation
isettings >> iTemp;
isettings.ignore(1, '\n');
fitInter->widgetNE[0]->SetNumber(iTemp);
// Fitting - ADC offset
isettings >> dTemp;
isettings.ignore(1, '\n');
adcOffset->widgetNE[0]->SetNumber(dTemp);
// Fitting - Acceptable error
isettings >> dTemp;
isettings.ignore(1, '\n');
accError->widgetNE[0]->SetNumber(dTemp);
// Fitting - Pedestal lower limit
isettings >> dTemp;
isettings.ignore(1, '\n');
pedesLow->widgetNE[0]->SetNumber(dTemp);
// Fitting - settings
for(int i = 0; i < 2; i++)
{
isettings >> iTemp;
isettings.ignore(1, '\n');
if(iTemp == 0) fitChecks->widgetChBox[i]->SetState(kButtonUp);
else if(iTemp == 1) fitChecks->widgetChBox[i]->SetState(kButtonDown);
}
 
k++;
}
else if(k == 1)
{
// ADC range
for(int i = 0; i < 2; i++)
{
isettings >> dTemp;
isettings.ignore(1, '\n');
adcRange->widgetNE[i]->SetNumber(dTemp);
}
// TDC range
for(int i = 0; i < 2; i++)
{
isettings >> dTemp;
isettings.ignore(1, '\n');
tdcRange->widgetNE[i]->SetNumber(dTemp);
}
// Y axis range
for(int i = 0; i < 2; i++)
{
isettings >> dTemp;
isettings.ignore(1, '\n');
yRange->widgetNE[i]->SetNumber(dTemp);
}
// Displayed channel
isettings >> iTemp;
isettings.ignore(1, '\n');
selectCh->widgetNE[0]->SetNumber(iTemp);
// Display options
for(int i = 0; i < 2; i++)
{
isettings >> iTemp;
isettings.ignore(1, '\n');
if(iTemp == 0) histOpt->widgetChBox[i]->SetState(kButtonUp);
else if(iTemp == 1) histOpt->widgetChBox[i]->SetState(kButtonDown);
}
// Display position units
isettings >> iTemp;
isettings.ignore(1, '\n');
posUnitsPlot->widgetCB->Select(iTemp);
 
k++;
}
else
break;
}
}
}
else
printf("Error! Measurement settings file can not be opened. Using defaults.\n");
}
 
// Layout function for the main window (width and height)
void layoutMainWindow(int *w, int *h)
{