Subversion Repositories f9daq

Compare Revisions

Ignore whitespace Rev 128 → Rev 129

/lab/sipmscan/trunk/windowed_test.C
40,7 → 40,7
TGLayoutHints *fMenuBarItemLayout;
TGPopupMenu *fMenuFile, *fMenuAnalysis, *fMenuTools, *fMenuWindow, *fMenuHelp;
TGPopupMenu *fMenuHisttype;
TGMdiSubwindow *settingsPane, *mainSubwindow, *histogramPane, *histogramPaneFile, *histogramPaneCtr;
TGMdiSubwindow *settingsPane, *mainSubwindow, *histogramPane, *histogramPaneFile, *histogramPaneCtr, *fieldpointPane, *headerPane;
 
void InitMenu();
void MeasurementLayout();
79,6 → 79,7
void ListMultiSelect();
void ListSelectAll();
void FileListNavigation(int pn);
void HeaderEdit();
 
void DisplayHistogram(char *histfile, int histtype);
void SetHistRange();
86,7 → 87,7
void ChangeChannel();
void HistogramExport();
void MakeSurfPlot(TList *files);
void MakeBreakdownPlot(int nrp, double *volt, double *volterr, double *psep1, double *pseperr1, double *psep2, double *pseperr2, double *psep3, double *pseperr3, char *plotfile);
void MakeBreakdownPlot(int nrp, double *volt, double *volterr, double *psep1, double *pseperr1, double *psep2, double *pseperr2, double *psep3, double *pseperr3, char *plotfile, int separations);
 
void FitSpectrum(TList *files, int q);
void EdgeDetection(TGraph *pdf, TGraph *cdf, char *outname, TCanvas *g1dCanvas, double pdfmax, int direction);
98,7 → 99,11
void ExportTempPlot();
void GetTempFile(int set);
 
void RunMeas(void *ptr, int runCase, int zaxisscan);
void EditTickToggle(int set);
void headerchange(char *histfile, bool *changetype);
void headeredit();
 
void RunMeas(void *ptr, int runCase, int zaxisscan, int &scanon);
};
 
const char *histExt = ".root";
201,6 → 206,7
TGCheckButton *multiSelectAll;
TGTextButton *prevFile;
TGTextButton *nextFile;
TGTextButton *editHeader;
 
TGTextEntry *disptime;
TGNumberEntry *dispbias;
226,9 → 232,10
TGNumberEntry *fitTresh;
TGNumberEntry *fitInter;
TGNumberEntry *accError;
TGNumberEntry *minPeak;
TGNumberEntry *pedesLow;
TGCheckButton *exfitplots;
 
//TGButtonGroup *sChangroup;
TGCheckButton *sCH[8];
TGComboBox *sMeasType;
TGCheckButton *sCamaclink;
252,6 → 259,18
TGTextButton *exportTemp;
//TGTextButton *closeTemp;
 
TGCheckButton *biasedittick;
TGNumberEntry *biasedit;
TGCheckButton *posedittick;
TGNumberEntry *posedit[3];
TGCheckButton *tempedittick;
TGNumberEntry *tempedit;
TGCheckButton *angleedittick;
TGNumberEntry *angleedit;
TGCheckButton *laseredittick;
TGTextEntry *laseredit;
TGTextButton *editHead;
 
Bool_t firstrun = kTRUE;
Bool_t started;
Bool_t cleanPlots = kTRUE;
834,6 → 853,8
tempHour[set]->Select(timeinfo->tm_hour);
tempMinute[set]->Select(timeinfo->tm_min);
tempSecond[set]->Select(timeinfo->tm_sec);
 
inroot->Close();
}
else
printf("No file selected.\n");
868,6 → 889,215
 
// --------------------------------------------------------------
 
// Header editor functions --------------------------------------
 
// Toggle the edit possibility for header entries
void TGAppMainFrame::EditTickToggle(int set)
{
if(set == 1)
{
if(biasedittick->IsDown()) biasedit->SetState(kTRUE);
else biasedit->SetState(kFALSE);
}
else if(set == 2)
{
if(posedittick->IsDown())
{
posedit[0]->SetState(kTRUE);
posedit[1]->SetState(kTRUE);
posedit[2]->SetState(kTRUE);
}
else
{
posedit[0]->SetState(kFALSE);
posedit[1]->SetState(kFALSE);
posedit[2]->SetState(kFALSE);
}
}
else if(set == 3)
{
if(tempedittick->IsDown()) tempedit->SetState(kTRUE);
else tempedit->SetState(kFALSE);
}
else if(set == 4)
{
if(angleedittick->IsDown()) angleedit->SetState(kTRUE);
else angleedit->SetState(kFALSE);
}
else if(set == 5)
{
if(laseredittick->IsDown()) laseredit->SetState(kTRUE);
else laseredit->SetState(kFALSE);
}
}
 
// Run the editing of file headers
void TGAppMainFrame::headerchange(char *histfile, bool *changetype)
{
if(debug)
printf("Selected file: %s\n", histfile);
 
// Preparing input file and the temporary output file
inroot = new TFile(histfile, "READ");
 
char outname[256];
sprintf(outname, "%s/results/temp.root", rootdir);
outroot = new TFile(outname, "RECREATE");
 
// Tree structure of input file
TTree *header_data, *meas_data, *scope_data;
 
inroot->GetObject("header_data", header_data);
inroot->GetObject("meas_data", meas_data);
inroot->GetObject("scope_data", scope_data);
 
// Tree structure of output file
TTree *new_meas_data = meas_data->CloneTree();
TTree *new_scope_data = scope_data->CloneTree();
 
// Save branches from the old header to temporary variables
header_data->SetBranchAddress("nrch", &evtheader.nrch);
header_data->GetEntry(0);
header_data->SetBranchAddress("timestamp", &evtheader.timestamp);
header_data->GetEntry(0);
header_data->SetBranchAddress("biasvolt", &evtheader.biasvolt);
header_data->GetEntry(0);
header_data->SetBranchAddress("xpos", &evtheader.xpos);
header_data->GetEntry(0);
header_data->SetBranchAddress("ypos", &evtheader.ypos);
header_data->GetEntry(0);
header_data->SetBranchAddress("zpos", &evtheader.zpos);
header_data->GetEntry(0);
header_data->SetBranchAddress("temperature", &evtheader.temperature);
header_data->GetEntry(0);
if( header_data->FindBranch("angle") )
{
header_data->SetBranchAddress("angle", &evtheader.angle);
header_data->GetEntry(0);
}
header_data->SetBranchAddress("laserinfo", &evtheader.laserinfo);
header_data->GetEntry(0);
 
int itemp[5] = {0,0,0,0,0};
double dtemp[3] = {0.,0.,0.};
char ctemp[256];
 
itemp[0] = evtheader.nrch;
itemp[1] = evtheader.timestamp;
itemp[2] = evtheader.xpos;
itemp[3] = evtheader.ypos;
itemp[4] = evtheader.zpos;
dtemp[0] = evtheader.biasvolt;
dtemp[1] = evtheader.temperature;
if( header_data->FindBranch("angle") )
dtemp[2] = evtheader.angle;
else
dtemp[2] = 0.;
sprintf(ctemp, "%s", evtheader.laserinfo);
 
delete header_data;
delete meas_data;
delete scope_data;
inroot->Close();
delete inroot;
// Prepare branches for the new header
TTree *new_header_data = new TTree("header_data", "Header information for the measurement.");
new_header_data->Branch("nrch", &evtheader.nrch, "nrch/I");
new_header_data->Branch("timestamp", &evtheader.timestamp, "timestamp/I");
new_header_data->Branch("biasvolt", &evtheader.biasvolt, "biasvolt/D");
new_header_data->Branch("xpos", &evtheader.xpos, "xpos/I");
new_header_data->Branch("ypos", &evtheader.ypos, "ypos/I");
new_header_data->Branch("zpos", &evtheader.zpos, "zpos/I");
new_header_data->Branch("temperature", &evtheader.temperature, "temperature/D");
new_header_data->Branch("angle", &evtheader.angle, "temperature/D");
new_header_data->Branch("laserinfo", &evtheader.laserinfo, "laserinfo/C");
 
// Save new values (and old ones where we don't want to edit anything)
evtheader.nrch = itemp[0];
evtheader.timestamp = itemp[1];
if(changetype[0])
evtheader.biasvolt = (double)biasedit->GetNumber();
else
evtheader.biasvolt = dtemp[0];
if(changetype[1])
{
evtheader.xpos = (int)posedit[0]->GetNumber();
evtheader.ypos = (int)posedit[1]->GetNumber();
evtheader.zpos = (int)posedit[2]->GetNumber();
}
else
{
evtheader.xpos = itemp[2];
evtheader.ypos = itemp[3];
evtheader.zpos = itemp[4];
}
if(changetype[2])
evtheader.temperature = (double)tempedit->GetNumber();
else
evtheader.temperature = dtemp[1];
if(changetype[3])
evtheader.angle = (double)angleedit->GetNumber();
else
evtheader.angle = dtemp[2];
if(changetype[4])
sprintf(evtheader.laserinfo, "%s", laseredit->GetText());
else
sprintf(evtheader.laserinfo, "%s", ctemp);
 
new_header_data->Fill();
 
// Write down the temporary output file
new_header_data->Write();
new_meas_data->Write();
new_scope_data->Write();
 
delete new_header_data;
delete new_meas_data;
delete new_scope_data;
outroot->Close();
delete outroot;
 
// Replace the original file with temporary output file (and delete temporary file)
sprintf(outname, "cp -f %s/results/temp.root %s", rootdir, histfile);
retTemp = system(outname);
sprintf(outname, "rm -f %s/results/temp.root", rootdir);
retTemp = system(outname);
 
printf("Edited header in file: %s\n", histfile);
}
 
// Setup the editing of file headers
void TGAppMainFrame::headeredit()
{
unsigned int nrfiles = fileList->GetNumberOfEntries();
TList *files;
// Changelist: Bias, Position, Temperature, Angle, Laser info
bool changelist[] = { biasedittick->IsDown(), posedittick->IsDown(), tempedittick->IsDown(), angleedittick->IsDown(), laseredittick->IsDown() };
 
if( nrfiles > 0 )
{
// check the selected file/files and return its name/their names
files = new TList();
fileList->GetSelectedEntries(files);
if(files)
{
for(int i = 0; i < (int)nrfiles; i++)
{
if(files->At(i))
{
if(debug)
printf("Filename: %s\n", files->At(i)->GetTitle());
 
headerchange( (char*)(files->At(i)->GetTitle()), changelist );
}
}
}
}
}
 
// --------------------------------------------------------------
 
// Class related functions --------------------------------------
 
// Apply the upper voltage limit from settings pane to main window
1425,7 → 1655,7
}
 
// Make breakdown voltage plot
void TGAppMainFrame::MakeBreakdownPlot(int nrp, double *volt, double *volterr, double *psep1, double *pseperr1, double *psep2, double *pseperr2, double *psep3, double *pseperr3, char *plotfile)
void TGAppMainFrame::MakeBreakdownPlot(int nrp, double *volt, double *volterr, double *psep1, double *pseperr1, double *psep2, double *pseperr2, double *psep3, double *pseperr3, char *plotfile, int separations)
{
double fparam[2], fparamerr[2], meanval;
TLatex *latex;
1432,12 → 1662,25
char ctemp[256];
int sortindex[nrp];
 
TCanvas *canvas = new TCanvas("canv","canv",900,1200);
canvas->Divide(1,3);
TCanvas *canvas;
 
if(separations == 1)
{
canvas = new TCanvas("canv","canv",900,400);
}
else if(separations == 2)
{
canvas = new TCanvas("canv","canv",900,800);
canvas->Divide(1,2);
}
else
{
canvas = new TCanvas("canv","canv",900,1200);
canvas->Divide(1,3);
}
 
// First graph is plotted always
TGraphErrors *gr1 = new TGraphErrors(nrp, volt, psep1, volterr, pseperr1);
TGraphErrors *gr2 = new TGraphErrors(nrp, volt, psep2, volterr, pseperr2);
TGraphErrors *gr3 = new TGraphErrors(nrp, volt, psep3, volterr, pseperr3);
if(!cleanPlots)
gr1->SetTitle("1st - 2nd peak separation");
1446,26 → 1689,7
gr1->SetLineColor(kBlue);
gr1->SetMarkerColor(kBlue);
gr1->SetMarkerStyle(20);
gr1->SetMarkerSize(0.6);
if(!cleanPlots)
gr2->SetTitle("2nd - 3rd peak separation");
else
gr2->SetTitle();
gr2->SetLineColor(kMagenta);
gr2->SetMarkerColor(kMagenta);
gr2->SetMarkerStyle(21);
gr2->SetMarkerSize(0.4);
if(!cleanPlots)
gr3->SetTitle("3rd - 4th peak separation");
else
gr3->SetTitle();
gr3->SetLineColor(kGreen);
gr3->SetMarkerColor(kGreen);
gr3->SetMarkerStyle(22);
gr3->SetMarkerSize(0.6);
gr1->SetMarkerSize(0.4);
// Plotting the first breakdown voltage plot
canvas->cd(1);
1492,67 → 1716,98
sprintf(ctemp, "#splitline{#Delta_{p}(U) = (%.2lf #pm %.2lf)#timesU + (%.2lf #pm %.3lf)}{U_{0} = %.2lf #pm %.3lf}", fparam[0], fparamerr[0], fparam[1], fparamerr[1], meanval, meanval*(TMath::Abs(fparamerr[0]/fparam[0]) + TMath::Abs(fparamerr[1]/fparam[1])) );
latex = new TLatex();
latex->SetTextSize(0.039);
latex->DrawLatex(volt[0]-(volt[1]-volt[0]), 0.97*psep1[sortindex[nrp-1]], ctemp);
latex->DrawLatex(volt[0], 0.97*psep1[sortindex[nrp-1]], ctemp);
}
else
printf("#Delta_p(U) = (%.2lf #pm %.2lf)*U + (%.2lf #pm %.3lf)\nU_0 = %.2lf #pm %.3lf", fparam[0], fparamerr[0], fparam[1], fparamerr[1], meanval, meanval*(TMath::Abs(fparamerr[0]/fparam[0]) + TMath::Abs(fparamerr[1]/fparam[1])) );
 
// Plotting the second breakdown voltage plot
canvas->cd(2);
gPad->SetGridx(1);
gPad->SetGridy(1);
 
gr2->Draw("AP");
gr2->GetXaxis()->SetTitle("Bias voltage (V)");
gr2->GetYaxis()->SetTitle("Peak separation");
gr2->GetYaxis()->CenterTitle();
gr2->Fit("pol1","Q");
TF1 *fit2 = gr2->GetFunction("pol1");
fparam[0] = fit2->GetParameter(0);
fparamerr[0] = fit2->GetParError(0);
fparam[1] = fit2->GetParameter(1);
fparamerr[1] = fit2->GetParError(1);
 
meanval = -fparam[0]/fparam[1];
if(!cleanPlots)
// Second graph
if(separations > 1)
{
sprintf(ctemp, "#splitline{#Delta_{p}(U) = (%.2lf #pm %.2lf)#timesU + (%.2lf #pm %.3lf)}{U_{0} = %.2lf #pm %.3lf}", fparam[0], fparamerr[0], fparam[1], fparamerr[1], meanval, meanval*(TMath::Abs(fparamerr[0]/fparam[0]) + TMath::Abs(fparamerr[1]/fparam[1])) );
latex = new TLatex();
latex->SetTextSize(0.039);
latex->DrawLatex(volt[0]-(volt[1]-volt[0]), 0.97*psep2[sortindex[nrp-1]], ctemp);
TGraphErrors *gr2 = new TGraphErrors(nrp, volt, psep2, volterr, pseperr2);
if(!cleanPlots)
gr2->SetTitle("2nd - 3rd peak separation");
else
gr2->SetTitle();
gr2->SetLineColor(kMagenta);
gr2->SetMarkerColor(kMagenta);
gr2->SetMarkerStyle(21);
gr2->SetMarkerSize(0.4);
// Plotting the second breakdown voltage plot
canvas->cd(2);
gPad->SetGridx(1);
gPad->SetGridy(1);
gr2->Draw("AP");
gr2->GetXaxis()->SetTitle("Bias voltage (V)");
gr2->GetYaxis()->SetTitle("Peak separation");
gr2->GetYaxis()->CenterTitle();
gr2->Fit("pol1","Q");
TF1 *fit2 = gr2->GetFunction("pol1");
fparam[0] = fit2->GetParameter(0);
fparamerr[0] = fit2->GetParError(0);
fparam[1] = fit2->GetParameter(1);
fparamerr[1] = fit2->GetParError(1);
meanval = -fparam[0]/fparam[1];
if(!cleanPlots)
{
sprintf(ctemp, "#splitline{#Delta_{p}(U) = (%.2lf #pm %.2lf)#timesU + (%.2lf #pm %.3lf)}{U_{0} = %.2lf #pm %.3lf}", fparam[0], fparamerr[0], fparam[1], fparamerr[1], meanval, meanval*(TMath::Abs(fparamerr[0]/fparam[0]) + TMath::Abs(fparamerr[1]/fparam[1])) );
latex = new TLatex();
latex->SetTextSize(0.039);
latex->DrawLatex(volt[0], 0.97*psep2[sortindex[nrp-1]], ctemp);
}
else
printf("#Delta_p(U) = (%.2lf #pm %.2lf)*U + (%.2lf #pm %.3lf)\nU_0 = %.2lf #pm %.3lf", fparam[0], fparamerr[0], fparam[1], fparamerr[1], meanval, meanval*(TMath::Abs(fparamerr[0]/fparam[0]) + TMath::Abs(fparamerr[1]/fparam[1])) );
}
else
printf("#Delta_p(U) = (%.2lf #pm %.2lf)*U + (%.2lf #pm %.3lf)\nU_0 = %.2lf #pm %.3lf", fparam[0], fparamerr[0], fparam[1], fparamerr[1], meanval, meanval*(TMath::Abs(fparamerr[0]/fparam[0]) + TMath::Abs(fparamerr[1]/fparam[1])) );
 
// Plotting the third breakdown voltage plot
canvas->cd(3);
gPad->SetGridx(1);
gPad->SetGridy(1);
 
gr3->Draw("AP");
gr3->GetXaxis()->SetTitle("Bias voltage (V)");
gr3->GetYaxis()->SetTitle("Peak separation");
gr3->GetYaxis()->CenterTitle();
gr3->Fit("pol1","Q");
TF1 *fit3 = gr3->GetFunction("pol1");
fparam[0] = fit3->GetParameter(0);
fparamerr[0] = fit3->GetParError(0);
fparam[1] = fit3->GetParameter(1);
fparamerr[1] = fit3->GetParError(1);
 
meanval = -fparam[0]/fparam[1];
if(!cleanPlots)
// Third graph
if(separations > 2)
{
sprintf(ctemp, "#splitline{#Delta_{p}(U) = (%.2lf #pm %.2lf)#timesU + (%.2lf #pm %.3lf)}{U_{0} = %.2lf #pm %.3lf}", fparam[0], fparamerr[0], fparam[1], fparamerr[1], meanval, meanval*(TMath::Abs(fparamerr[0]/fparam[0]) + TMath::Abs(fparamerr[1]/fparam[1])) );
latex = new TLatex();
latex->SetTextSize(0.039);
latex->DrawLatex(volt[0]-(volt[1]-volt[0]), 0.97*psep3[sortindex[nrp-1]], ctemp);
TGraphErrors *gr3 = new TGraphErrors(nrp, volt, psep3, volterr, pseperr3);
if(!cleanPlots)
gr3->SetTitle("3rd - 4th peak separation");
else
gr3->SetTitle();
gr3->SetLineColor(kGreen);
gr3->SetMarkerColor(kGreen);
gr3->SetMarkerStyle(22);
gr3->SetMarkerSize(0.4);
// Plotting the third breakdown voltage plot
canvas->cd(3);
gPad->SetGridx(1);
gPad->SetGridy(1);
gr3->Draw("AP");
gr3->GetXaxis()->SetTitle("Bias voltage (V)");
gr3->GetYaxis()->SetTitle("Peak separation");
gr3->GetYaxis()->CenterTitle();
gr3->Fit("pol1","Q");
TF1 *fit3 = gr3->GetFunction("pol1");
fparam[0] = fit3->GetParameter(0);
fparamerr[0] = fit3->GetParError(0);
fparam[1] = fit3->GetParameter(1);
fparamerr[1] = fit3->GetParError(1);
meanval = -fparam[0]/fparam[1];
if(!cleanPlots)
{
sprintf(ctemp, "#splitline{#Delta_{p}(U) = (%.2lf #pm %.2lf)#timesU + (%.2lf #pm %.3lf)}{U_{0} = %.2lf #pm %.3lf}", fparam[0], fparamerr[0], fparam[1], fparamerr[1], meanval, meanval*(TMath::Abs(fparamerr[0]/fparam[0]) + TMath::Abs(fparamerr[1]/fparam[1])) );
latex = new TLatex();
latex->SetTextSize(0.039);
latex->DrawLatex(volt[0], 0.97*psep3[sortindex[nrp-1]], ctemp);
}
else
printf("#Delta_p(U) = (%.2lf #pm %.2lf)*U + (%.2lf #pm %.3lf)\nU_0 = %.2lf #pm %.3lf", fparam[0], fparamerr[0], fparam[1], fparamerr[1], meanval, meanval*(TMath::Abs(fparamerr[0]/fparam[0]) + TMath::Abs(fparamerr[1]/fparam[1])) );
}
else
printf("#Delta_p(U) = (%.2lf #pm %.2lf)*U + (%.2lf #pm %.3lf)\nU_0 = %.2lf #pm %.3lf", fparam[0], fparamerr[0], fparam[1], fparamerr[1], meanval, meanval*(TMath::Abs(fparamerr[0]/fparam[0]) + TMath::Abs(fparamerr[1]/fparam[1])) );
 
// Saving the produced plot
canvas->SaveAs(plotfile);
}
 
1582,21 → 1837,24
fp = fopen(paramname, "w");
fclose(fp);
 
int peaklimit = 5;
int peaklimit = minPeak->GetNumber()+1; // +1 to account for the pedestal peak
printf("The minimum peak limit is set to: %d\n", peaklimit);
int p = 0;
double dtemp;
double volt[files->GetSize()], volterr[files->GetSize()], sep[3][files->GetSize()], seperr[3][files->GetSize()];
int first = 1;
 
// Initialize all values
for(int m = 0; m < files->GetSize(); m++)
{
volt[m] = 0; volterr[m] = 0;
for(int i = 0; i < 3; i++)
{ sep[i][m] = 0; seperr[i][m] = 0; }
if(m < 20) { meanparam[m] = 0; meanparamerr[m] = 0; }
}
 
for(int m = 0; m < files->GetSize(); m++)
{
for(int i = 0; i < 20; i++) { meanparam[20] = 0; meanparamerr[20] = 0; }
 
DisplayHistogram( (char*)(files->At(m)->GetTitle()), 0);
dtemp = evtheader.biasvolt;
gCanvas->Modified();
1624,9 → 1882,7
float yp = h2->GetBinContent(bin);
par[3*i] = yp;
par[3*i+1] = xp;
// par[3*i+2] = 3;
par[3*i+2] = (double)fitSigma->GetNumber();
// printf("Peak %d: %f\n", i+1, xp);
}
// Fit the histogram
1642,6 → 1898,7
// Gather the parameters (mean peak value for now)
int j = 1;
int nrfit = 0;
bool errors = false;
while(1)
{
if( (fparam[j] < 1.E-30) || (fparamerr[j] < 1.E-10) )
1648,7 → 1905,7
break;
else
{
if(fparam[j] > 0)
if(fparam[j] > pedesLow->GetNumber())
{
meanparam[nrfit] = fparam[j];
meanparamerr[nrfit] = fparamerr[j];
1658,68 → 1915,125
j+=3;
}
printf("%d peaks fitted.\n",nrfit);
 
// Write out parameters to a file
fp = fopen(paramname, "a");
TMath::Sort(nrfit, meanparam, sortindex, kFALSE);
// Only save the ones that do not have a too large error on peak separation for the first three peaks
if( ((TMath::Abs(meanparamerr[sortindex[2]]) + TMath::Abs(meanparamerr[sortindex[1]]))/(meanparam[sortindex[2]] - meanparam[sortindex[1]]) < accError->GetNumber()) && ((TMath::Abs(meanparamerr[sortindex[3]]) + TMath::Abs(meanparamerr[sortindex[2]]))/(meanparam[sortindex[3]] - meanparam[sortindex[2]]) < accError->GetNumber()) && ((TMath::Abs(meanparamerr[sortindex[4]]) + TMath::Abs(meanparamerr[sortindex[3]]))/(meanparam[sortindex[4]] - meanparam[sortindex[3]]) < accError->GetNumber()) )
// if( (seperr[0][0]/sep[0][0] < accError->GetNumber()) && (seperr[1][0]/sep[1][0] < accError->GetNumber()) && (seperr[2][0]/sep[2][0] < accError->GetNumber()) )
if(nrfit >= peaklimit)
{
fprintf(fp, "%le\t%d\t", dtemp, nrfit);
TMath::Sort(nrfit, meanparam, sortindex, kFALSE);
 
for(int i = 0; i < nrfit; i++)
// Write out parameters to a file
// fp = fopen(paramname, "a");
// Only save the ones that do not have a too large error on peak separation for the first three peaks
// if( ((TMath::Abs(meanparamerr[sortindex[2]]) + TMath::Abs(meanparamerr[sortindex[1]]))/(meanparam[sortindex[2]] - meanparam[sortindex[1]]) < accError->GetNumber()) && ((TMath::Abs(meanparamerr[sortindex[3]]) + TMath::Abs(meanparamerr[sortindex[2]]))/(meanparam[sortindex[3]] - meanparam[sortindex[2]]) < accError->GetNumber()) && ((TMath::Abs(meanparamerr[sortindex[4]]) + TMath::Abs(meanparamerr[sortindex[3]]))/(meanparam[sortindex[4]] - meanparam[sortindex[3]]) < accError->GetNumber()) )
// if( (seperr[0][0]/sep[0][0] < accError->GetNumber()) && (seperr[1][0]/sep[1][0] < accError->GetNumber()) && (seperr[2][0]/sep[2][0] < accError->GetNumber()) )
// {
// fprintf(fp, "%le\t%d\t", dtemp, nrfit);
 
// for(int i = 0; i < nrfit; i++)
// {
// if(debug)
// printf("Peak %d (%lfV): %lf\t%lf\n", i+1, dtemp, meanparam[sortindex[i]], meanparamerr[sortindex[i]]);
// fprintf(fp, "%le\t%le\t", meanparam[sortindex[i]], meanparamerr[sortindex[i]]);
// }
// printf("\n");
// fprintf(fp, "\n");
// }
 
// fclose(fp);
h2->SetStats(0);
gCanvas->Modified();
gCanvas->Update();
// Save each fitting plot
if(exfitplots->IsDown())
{
if(debug)
printf("Peak %d (%lfV): %lf\t%lf\n", i+1, dtemp, meanparam[sortindex[i]], meanparamerr[sortindex[i]]);
fprintf(fp, "%le\t%le\t", meanparam[sortindex[i]], meanparamerr[sortindex[i]]);
remove_ext((char*)files->At(m)->GetTitle(), ctemp);
sprintf(exportname, "%s_fit.pdf", ctemp);
gCanvas->SaveAs(exportname);
}
printf("\n");
fprintf(fp, "\n");
}
volt[p] = dtemp;
volterr[p] = 1.e-4;
 
fclose(fp);
if(nrfit == 3)
{
sep[0][p] = meanparam[sortindex[2]] - meanparam[sortindex[1]];
seperr[0][p] = TMath::Abs(meanparamerr[sortindex[2]]) + TMath::Abs(meanparamerr[sortindex[1]]);
 
h2->SetStats(0);
gCanvas->Modified();
gCanvas->Update();
errors = (seperr[0][p]/sep[0][p] < accError->GetNumber());
 
// Save each fitting plot
if(exfitplots->IsDown())
{
remove_ext((char*)files->At(m)->GetTitle(), ctemp);
sprintf(exportname, "%s_fit.pdf", ctemp);
gCanvas->SaveAs(exportname);
}
if(debug)
printf("p=%d:\t%lf\t%lf\t%lf\n", p, volt[p], sep[0][p], seperr[0][p]);
}
else if(nrfit == 4)
{
sep[0][p] = meanparam[sortindex[2]] - meanparam[sortindex[1]];
sep[1][p] = meanparam[sortindex[3]] - meanparam[sortindex[2]];
seperr[0][p] = TMath::Abs(meanparamerr[sortindex[2]]) + TMath::Abs(meanparamerr[sortindex[1]]);
seperr[1][p] = TMath::Abs(meanparamerr[sortindex[3]]) + TMath::Abs(meanparamerr[sortindex[2]]);
 
// Get points for mean peak values and create a breakdown voltage plot
if(nrfit >= peaklimit)
{
sep[0][p] = meanparam[sortindex[2]] - meanparam[sortindex[1]];
sep[1][p] = meanparam[sortindex[3]] - meanparam[sortindex[2]];
sep[2][p] = meanparam[sortindex[4]] - meanparam[sortindex[3]];
seperr[0][p] = TMath::Abs(meanparamerr[sortindex[2]]) + TMath::Abs(meanparamerr[sortindex[1]]);
seperr[1][p] = TMath::Abs(meanparamerr[sortindex[3]]) + TMath::Abs(meanparamerr[sortindex[2]]);
seperr[2][p] = TMath::Abs(meanparamerr[sortindex[4]]) + TMath::Abs(meanparamerr[sortindex[3]]);
volt[p] = dtemp;
volterr[p] = 1.e-4;
if(debug)
printf("p=%d:\t%lf\t%lf\t%lf\t%lf\t%lf\t%lf\t%lf\n", p, volt[p], sep[0][p], seperr[0][p], sep[1][p], seperr[1][p], sep[2][p], seperr[2][p]);
errors = ((seperr[0][p]/sep[0][p] < accError->GetNumber()) && (seperr[1][p]/sep[1][p] < accError->GetNumber()));
 
if(debug)
printf("p=%d:\t%lf\t%lf\t%lf\t%lf\t%lf\n", p, volt[p], sep[0][p], seperr[0][p], sep[1][p], seperr[1][p]);
}
else if(nrfit > 4)
{
sep[0][p] = meanparam[sortindex[2]] - meanparam[sortindex[1]];
sep[1][p] = meanparam[sortindex[3]] - meanparam[sortindex[2]];
sep[2][p] = meanparam[sortindex[4]] - meanparam[sortindex[3]];
seperr[0][p] = TMath::Abs(meanparamerr[sortindex[2]]) + TMath::Abs(meanparamerr[sortindex[1]]);
seperr[1][p] = TMath::Abs(meanparamerr[sortindex[3]]) + TMath::Abs(meanparamerr[sortindex[2]]);
seperr[2][p] = TMath::Abs(meanparamerr[sortindex[4]]) + TMath::Abs(meanparamerr[sortindex[3]]);
 
errors = ((seperr[0][p]/sep[0][p] < accError->GetNumber()) && (seperr[1][p]/sep[1][p] < accError->GetNumber()) && (seperr[2][p]/sep[2][p] < accError->GetNumber()));
 
if(debug)
printf("p=%d:\t%lf\t%lf\t%lf\t%lf\t%lf\t%lf\t%lf\n", p, volt[p], sep[0][p], seperr[0][p], sep[1][p], seperr[1][p], sep[2][p], seperr[2][p]);
}
 
// Write out parameters to a file
fp = fopen(paramname, "a");
 
// Accept only the points with a small enough error
if( (seperr[0][p]/sep[0][p] < accError->GetNumber()) && (seperr[1][p]/sep[1][p] < accError->GetNumber()) && (seperr[2][p]/sep[2][p] < accError->GetNumber()) )
if( errors )
{
if(first == 1)
{
fprintf(fp, "%le\t%d\t", dtemp, nrfit);
 
for(int i = 0; i < nrfit; i++)
{
if(debug)
printf("Peak %d (%lfV): %lf\t%lf\n", i+1, dtemp, meanparam[sortindex[i]], meanparamerr[sortindex[i]]);
fprintf(fp, "%le\t%le\t", meanparam[sortindex[i]], meanparamerr[sortindex[i]]);
}
printf("\n");
fprintf(fp, "\n");
first = 0;
}
 
p++;
}
else
printf("Point (at %.2lfV) rejected due to errors: %lf, %lf, %lf\n", volt[p], seperr[0][p]/sep[0][p], seperr[1][p]/sep[1][p], seperr[2][p]/sep[2][p]);
{
if(nrfit == 3)
printf("Point (at %.2lfV) rejected due to too large errors: %lf\n", volt[p], seperr[0][p]/sep[0][p]);
else if(nrfit == 4)
printf("Point (at %.2lfV) rejected due to too large errors: %lf, %lf\n", volt[p], seperr[0][p]/sep[0][p], seperr[1][p]/sep[1][p]);
else if(nrfit > 4)
printf("Point (at %.2lfV) rejected due to too large errors: %lf, %lf, %lf\n", volt[p], seperr[0][p]/sep[0][p], seperr[1][p]/sep[1][p], seperr[2][p]/sep[2][p]);
}
 
fclose(fp);
}
 
if(q == 1) break;
 
first = 1;
}
 
// Plot & fit breakdown voltage plots
1727,7 → 2041,7
{
remove_from_last((char*)files->At(0)->GetTitle(), '_', ctemp);
sprintf(paramname, "%s_breakdown.pdf", ctemp);
MakeBreakdownPlot(p, volt, volterr, sep[0], seperr[0], sep[1], seperr[1], sep[2], seperr[2], paramname);
MakeBreakdownPlot(p, volt, volterr, sep[0], seperr[0], sep[1], seperr[1], sep[2], seperr[2], paramname, peaklimit-2);
}
}
 
1905,6 → 2219,7
*/
integralCount[i] += ((double)m)/((double)k);
inroot->Close();
delete inroot;
}
}
2149,24 → 2464,22
char ctemp[256];
int j, k = 0, m = 0, n = 0, k2 = 0, m2 = 0;
 
// TCanvas *gCanvas = new TCanvas("canv","canv",900,900);
TCanvas *gCanvas;
TTree *header_data, *meas_data;
double *integralCount, *integralPedestal;
integralCount = new double[nrfiles];
integralPedestal = new double[nrfiles];
// double xsurfmin, ysurfmin, zsurfmin;
double *angle;
double *pdeval;
double *muval;
angle = new double[nrfiles];
pdeval = new double[nrfiles];
muval = new double[nrfiles];
for(int i = 0; i < (int)nrfiles; i++) {integralCount[i] = 0; integralPedestal[i] = 0; }
 
// TGraph *gScan[2]; // graph for angle dependence
int nrentries;
// double minInteg, maxInteg;
 
// char exportname[256];
 
TSpectrum *spec;
TH1F *histtemp;
TH1 *histback;
2291,8 → 2604,16
inroot->GetObject("meas_data", meas_data);
// Reading the header
// header_data->SetBranchAddress("angle", &evtheader.angle);
// header_data->GetEntry(0);
if( header_data->FindBranch("angle") )
{
header_data->SetBranchAddress("angle", &evtheader.angle);
header_data->GetEntry(0);
}
else
{
printf("Error! Selected file has no angle header value. Please edit header to add the angle header value.\n");
break;
}
char rdc[256];
j = selectCh->GetNumber();
2332,9 → 2653,7
}
}
 
// angle[i] = (double)(evtheader.angle);
angle[i] = (double)(i*15.*TMath::ACos(-1.)/180.); // angle in radians
cout << "Angle = " << angle[i] << endl;
angle[i] = (double)(evtheader.angle); // angle in radians
 
// integralCount[i] += ((double)m)/((double)k);
integralCount[i] += (double)m;
2344,8 → 2663,10
cout << "Integral (" << k2 << " evts) = " << integralPedestal[i] << endl;
 
muval[i] = -TMath::Log((double)k2/(double)k);
cout << "Mu = " << muval[i] << endl;
 
pdeval[i] = muval[i]/(muval[0]*TMath::Cos(angle[i]*TMath::ACos(-1.)/180.));
inroot->Close();
delete inroot;
}
}
2357,12 → 2678,45
for(int i = 0; i < (int)files->GetSize(); i++)
{
// Relative PDE calculation
cout << angle[i] << "\t" << muval[i] << "\t" << muval[i]/(muval[0]*TMath::Cos(angle[i])) << endl;
cout << angle[i] << "\t" << muval[i] << "\t" << pdeval[i] << endl;
}
 
// Plot mu and PDE angle dependance plots
gCanvas = new TCanvas("canv","canv",1200,900);
gCanvas->SetGrid();
 
TGraph *pde = new TGraph(nrentries, angle, pdeval);
pde->SetMarkerStyle(21);
pde->SetMarkerSize(1.0);
pde->SetMarkerColor(2);
pde->SetLineWidth(2);
pde->SetLineColor(2);
pde->GetXaxis()->SetLabelSize(0.030);
pde->GetXaxis()->CenterTitle();
pde->GetXaxis()->SetRange(-5,90);
pde->GetXaxis()->SetRangeUser(-5,90);
pde->GetYaxis()->SetTitleOffset(1.2);
pde->GetYaxis()->SetLabelSize(0.030);
pde->GetYaxis()->CenterTitle();
pde->GetYaxis()->SetRangeUser(0.3, 1.18);
pde->Draw("ALP");
 
pde->SetTitle(";Incidence angle (#circ);Relative PDE(#theta) / #mu(#theta)");
 
TGraph *mugr = new TGraph(nrentries, angle, muval);
mugr->SetMarkerStyle(20);
mugr->SetMarkerSize(1.0);
mugr->SetMarkerColor(4);
mugr->SetLineWidth(2);
mugr->SetLineColor(4);
mugr->Draw("SAME;LP");
 
gCanvas->Modified();
gCanvas->Update();
}
}
 
void TGAppMainFrame::RunMeas(void *ptr, int runCase, int zaxisscan)
void TGAppMainFrame::RunMeas(void *ptr, int runCase, int zaxisscan, int &scanon)
{
printf("Start of Run, run case %d\n", runCase);
float progVal;
2553,6 → 2907,11
 
if (gDaq)
{
if(scanon == 0)
{
gDaq->init(evtheader.nrch);
scanon = 1;
}
gDaq->fStop=0;
// Start gathering
gDaq->start();
2643,6 → 3002,9
// Start the acquisition
void TGAppMainFrame::StartAcq()
{
// Variable that will initialize camac only once (for scans)
int scanon = 0;
 
// Determine the type of measurement to perform
int vscan = 0, pscan = 0, zscan = 0;
if(voltscanOn->IsOn()) vscan = 1;
2715,7 → 3077,7
printf("Continuing...\n");
// Here comes function to start histogramming <<<<<<<<<<<<<<<<<<<<<<<<
RunMeas((void*)0, i, 0);
RunMeas((void*)0, i, 0, scanon);
fflush(stdout);
}
2828,7 → 3190,7
// for (k=0;k<(NTDCCH+NADCCH)/2;k++) gHisto2D[k]->Reset();
// Here comes function to start histogramming <<<<<<<<<<<<<<<<<<<<<<<<
RunMeas((void*)0, (j*repetX + i), zscan );
RunMeas((void*)0, (j*repetX + i), zscan , scanon);
fflush(stdout);
}
2893,7 → 3255,7
started = kTRUE;
 
printf("Running a single scan...\n");
RunMeas((void*)0, 0, 0);
RunMeas((void*)0, 0, 0, scanon);
printf("Measurement finished...\n");
printf("\n");
}
3035,6 → 3397,12
}
}
 
// Open the header edit window when pressing on editHeader button
void TGAppMainFrame::HeaderEdit()
{
OpenWindow(2);
}
 
// Display the currently selected histogram in file list
void TGAppMainFrame::DisplayHistogram(char* histfile, int histtype)
{
3064,8 → 3432,11
header_data->GetEntry(0);
header_data->SetBranchAddress("temperature", &evtheader.temperature);
header_data->GetEntry(0);
header_data->SetBranchAddress("angle", &evtheader.angle);
header_data->GetEntry(0);
if( header_data->FindBranch("angle") )
{
header_data->SetBranchAddress("angle", &evtheader.angle);
header_data->GetEntry(0);
}
header_data->SetBranchAddress("laserinfo", &evtheader.laserinfo);
header_data->GetEntry(0);
 
3082,8 → 3453,10
printf("- Table position (X,Y,Z): %d, %d, %d\n", evtheader.xpos, evtheader.ypos, evtheader.zpos);
if(evtheader.temperature)
printf("- Temperature: %lf\n", evtheader.temperature);
if(evtheader.angle)
if( header_data->FindBranch("angle") )
printf("- Incidence angle: %lf\n", evtheader.angle);
else
printf("- Incidence angle: No angle information!\n");
printf("- Laser and filter settings: %s\n", evtheader.laserinfo);
}
 
3096,7 → 3469,7
disptemp->SetNumber(evtheader.temperature);
else
disptemp->SetNumber(0.0);
if(evtheader.angle)
if( header_data->FindBranch("angle") )
dispangle->SetNumber(evtheader.angle);
else
dispangle->SetNumber(0.0);
3386,6 → 3759,7
printf("Progress = %lf\n", progVal);
}*/
 
inroot->Close();
delete inroot;
}
}
3836,6 → 4210,11
fMenuBar->AddPopup(new TGHotString("&Tools"),fMenuTools,fMenuBarItemLayout);
fMenuBar->AddPopup(new TGHotString("&Windows"),fMenuWindow,fMenuBarItemLayout);
fMenuBar->AddPopup(new TGHotString("&Help"), fMenuHelp, fMenuBarItemLayout);
 
// Disable fieldpoint if we are not connected to the IJS network
#if IJSNET == 0
fMenuTools->DisableEntry(M_TOOLS_FIELDPOINT);
#endif
}
 
//---------------------------------------------------------------
4426,7 → 4805,7
fileList->Resize(300, (3*subwin[1]/7)-10 );
mdiFrame->AddFrame(fileList, f2);
 
// Multiple file selection toggle, previous/next controls and clear list
// Multiple file selection toggle, previous/next controls, clear list and edit header
fH1 = new TGHorizontalFrame(mdiFrame, subgroup[0], 30);
multiSelect = new TGCheckButton(fH1, "Multiple file select");
multiSelect->Resize(50,22);
4444,6 → 4823,12
clearList->Resize(80,22);
fH1->AddFrame(clearList, f0right);
 
TGTextButton *editHeader = new TGTextButton(fH1, "Edit header");
editHeader->SetTextJustify(36);
editHeader->SetWrapLength(-1);
editHeader->Resize(80,22);
fH1->AddFrame(editHeader, f0right);
 
nextFile = new TGTextButton(fH1, ">>");
nextFile->SetTextJustify(36);
nextFile->SetWrapLength(-1);
4521,7 → 4906,7
mdiFrame = histogramPaneCtr->GetMdiFrame();
 
// Control for histogram X range
subgroup[0] = subwin[0]-10;
subgroup[0] = subwin[0]-6;
fG1 = new TGGroupFrame(mdiFrame, "Histogram display");
fH1 = new TGHorizontalFrame(fG1, subgroup[0], 30);
lab = new TGLabel(fH1, "ADC range (min, max):");
4620,37 → 5005,57
// Fitting controls for ADC spectrum
fG1 = new TGGroupFrame(mdiFrame, "Fit Settings");
fH1 = new TGHorizontalFrame(fG1, subgroup[0], 30);
lab = new TGLabel(fH1, "Peak sigma:");
fH1->AddFrame(lab, f0centery);
fitSigma = new TGNumberEntry(fH1, 1.2, 3, 999, TGNumberFormat::kNESRealThree, TGNumberFormat::kNEANonNegative);
fH2 = new TGHorizontalFrame(fH1, subgroup[0], 30);
lab = new TGLabel(fH2, "Peak sigma:");
fH2->AddFrame(lab, f0centery);
fitSigma = new TGNumberEntry(fH2, 1.2, 3, 999, TGNumberFormat::kNESRealThree, TGNumberFormat::kNEANonNegative);
fitSigma->Resize(60,22);
fH1->AddFrame(fitSigma, f0centery);
fG1->AddFrame(fH1, f2);
fH2->AddFrame(fitSigma, f0centery);
 
fH1 = new TGHorizontalFrame(fG1, subgroup[0], 30);
lab = new TGLabel(fH1, "Signal/Noise treshold:");
fH1->AddFrame(lab, f0centery);
fitTresh = new TGNumberEntry(fH1, 5.0E-3, 3, 999, TGNumberFormat::kNESReal, TGNumberFormat::kNEANonNegative);
lab = new TGLabel(fH2, " Signal/Noise treshold:");
fH2->AddFrame(lab, f0centery);
fitTresh = new TGNumberEntry(fH2, 5.0E-3, 3, 999, TGNumberFormat::kNESReal, TGNumberFormat::kNEANonNegative);
fitTresh->Resize(60,22);
fH1->AddFrame(fitTresh, f0centery);
fH2->AddFrame(fitTresh, f0centery);
fH1->AddFrame(fH2, f0centerx);
fG1->AddFrame(fH1, f2);
 
fH1 = new TGHorizontalFrame(fG1, subgroup[0], 30);
lab = new TGLabel(fH1, "Background interpolation:");
fH1->AddFrame(lab, f0centery);
fitInter = new TGNumberEntry(fH1, 7, 3, 999, TGNumberFormat::kNESInteger, TGNumberFormat::kNEANonNegative);
fH2 = new TGHorizontalFrame(fH1, subgroup[0], 30);
lab = new TGLabel(fH2, "Background interpolation:");
fH2->AddFrame(lab, f0centery);
fitInter = new TGNumberEntry(fH2, 7, 3, 999, TGNumberFormat::kNESInteger, TGNumberFormat::kNEANonNegative);
fitInter->Resize(60,22);
fH1->AddFrame(fitInter, f0centery);
fH2->AddFrame(fitInter, f0centery);
fH1->AddFrame(fH2, f0centerx);
fG1->AddFrame(fH1, f2);
 
fH1 = new TGHorizontalFrame(fG1, subgroup[0], 30);
lab = new TGLabel(fH1, "Peak fit max. acceptable error:");
fH1->AddFrame(lab, f0centery);
accError = new TGNumberEntry(fH1, 0.15, 3, 999, TGNumberFormat::kNESRealTwo, TGNumberFormat::kNEANonNegative);
fH2 = new TGHorizontalFrame(fH1, subgroup[0], 30);
lab = new TGLabel(fH2, "Peak fit max. acceptable error:");
fH2->AddFrame(lab, f0centery);
accError = new TGNumberEntry(fH2, 0.15, 3, 999, TGNumberFormat::kNESRealTwo, TGNumberFormat::kNEANonNegative);
accError->Resize(60,22);
fH1->AddFrame(accError, f0centery);
fH2->AddFrame(accError, f0centery);
fH1->AddFrame(fH2, f0centerx);
fG1->AddFrame(fH1, f2);
 
fH1 = new TGHorizontalFrame(fG1, subgroup[0], 30);
fH2 = new TGHorizontalFrame(fH1, subgroup[0], 30);
lab = new TGLabel(fH2, "Peak min. limit:");
fH2->AddFrame(lab, f0centery);
minPeak = new TGNumberEntry(fH2, 4, 3, 999, TGNumberFormat::kNESInteger, TGNumberFormat::kNEANonNegative, TGNumberFormat::kNELLimitMinMax, 2, 20);
minPeak->Resize(50,22);
fH2->AddFrame(minPeak, f0centery);
 
lab = new TGLabel(fH2, " Pedestal lower limit:");
fH2->AddFrame(lab, f0centery);
pedesLow = new TGNumberEntry(fH2, 0.00, 3, 999, TGNumberFormat::kNESRealTwo, TGNumberFormat::kNEANonNegative);
pedesLow->Resize(60,22);
fH2->AddFrame(pedesLow, f0centery);
fH1->AddFrame(fH2, f0centerx);
fG1->AddFrame(fH1, f2);
 
exfitplots = new TGCheckButton(fG1, "Export fitting plots ON/OFF");
exfitplots->Resize(50,22);
exfitplots->SetState(kButtonUp);
4686,6 → 5091,7
selectDir->Connect("Clicked()", "TGAppMainFrame", this, "SelectDirectory()");
multiSelect->Connect("Clicked()", "TGAppMainFrame", this, "ListMultiSelect()");
multiSelectAll->Connect("Clicked()", "TGAppMainFrame", this, "ListSelectAll()");
editHeader->Connect("Clicked()", "TGAppMainFrame", this, "HeaderEdit()");
prevFile->Connect("Clicked()", "TGAppMainFrame", this, "FileListNavigation(=-2)");
nextFile->Connect("Clicked()", "TGAppMainFrame", this, "FileListNavigation(=-3)");
fileList->Connect("DoubleClicked(Int_t)", "TGAppMainFrame", this, "FileListNavigation(Int_t)");
4741,6 → 5147,7
{
/* WinID:
* - 1 = fieldpoint temperature sensor
* - 2 = file header editor
*/
 
TGMdiFrame *mdiFrame;
4762,8 → 5169,8
int yearrange[2];
 
subwin[0] = 3*((winWidth/4)-5); subwin[1] = (int)(2*((winHeight/3)-5))+10;
histogramPaneCtr = new TGMdiSubwindow(fMainFrame, subwin[0], subwin[1]);
mdiFrame = histogramPaneCtr->GetMdiFrame();
fieldpointPane = new TGMdiSubwindow(fMainFrame, subwin[0], subwin[1]);
mdiFrame = fieldpointPane->GetMdiFrame();
subgroup[0] = subwin[0]-10;
subgroup[1] = 7*subwin[1]/12;
5068,6 → 5475,117
// closeTemp->Connect("Clicked()", "TGAppMainFrame", this, "UpdateTempPlot()");
}
// Fieldpoint pane -------------------------------------------------------------------------
//
// Header editor pane ----------------------------------------------------------------------
else if(winid == 2)
{
subwin[0] = 12*((winWidth/16)-5); subwin[1] = (int)(1*((winHeight/3)-10));
headerPane = new TGMdiSubwindow(fMainFrame, subwin[0], subwin[1]);
mdiFrame = headerPane->GetMdiFrame();
subgroup[0] = subwin[0]-10;
subgroup[1] = 7*subwin[1]/12;
 
// Changing header info (no timestamp change possible)
fG1 = new TGGroupFrame(mdiFrame, "Header edit information");
fH1 = new TGHorizontalFrame(fG1, subgroup[0], 30);
biasedittick = new TGCheckButton(fH1, "Bias voltage edit: ");
biasedittick->Resize(80,22);
biasedittick->SetState(kButtonUp);
fH1->AddFrame(biasedittick, f0centerx);
biasedit = new TGNumberEntry(fH1, 0.00, 4, 999, TGNumberFormat::kNESRealThree, TGNumberFormat::kNEANonNegative);
biasedit->Resize(80,22);
biasedit->SetState(kFALSE);
fH1->AddFrame(biasedit, f0centery);
fG1->AddFrame(fH1, f0);
 
fH1 = new TGHorizontalFrame(fG1, subgroup[0], 30);
posedittick = new TGCheckButton(fH1, "Table position edit (X, Y, Z): ");
posedittick->Resize(80,22);
posedittick->SetState(kButtonUp);
fH1->AddFrame(posedittick, f0centerx);
for(int i = 0; i < 3; i++)
{
posedit[i] = new TGNumberEntry(fH1, 0, 6, 999, TGNumberFormat::kNESInteger, TGNumberFormat::kNEAAnyNumber);
posedit[i]->Resize(80,22);
posedit[i]->SetState(kFALSE);
fH1->AddFrame(posedit[i], f0centery);
}
fG1->AddFrame(fH1, f0);
 
fH1 = new TGHorizontalFrame(fG1, subgroup[0], 30);
tempedittick = new TGCheckButton(fH1, "Chamber temperature edit: ");
tempedittick->Resize(80,22);
tempedittick->SetState(kButtonUp);
fH1->AddFrame(tempedittick, f0centerx);
tempedit = new TGNumberEntry(fH1, 0.00, 6, 999, TGNumberFormat::kNESRealOne, TGNumberFormat::kNEAAnyNumber);
tempedit->Resize(80,22);
tempedit->SetState(kFALSE);
fH1->AddFrame(tempedit, f0centery);
fG1->AddFrame(fH1, f0);
 
fH1 = new TGHorizontalFrame(fG1, subgroup[0], 30);
angleedittick = new TGCheckButton(fH1, "Incidence angle edit: ");
angleedittick->Resize(80,22);
angleedittick->SetState(kButtonUp);
fH1->AddFrame(angleedittick, f0centerx);
angleedit = new TGNumberEntry(fH1, 0.00, 6, 999, TGNumberFormat::kNESRealOne, TGNumberFormat::kNEAAnyNumber);
angleedit->Resize(80,22);
angleedit->SetState(kFALSE);
fH1->AddFrame(angleedit, f0centery);
fG1->AddFrame(fH1, f0);
 
fH1 = new TGHorizontalFrame(fG1, subgroup[0], 30);
laseredittick = new TGCheckButton(fH1, "Laser settings edit: ");
laseredittick->Resize(80,22);
laseredittick->SetState(kButtonUp);
fH1->AddFrame(laseredittick, f0centerx);
laseredit = new TGTextEntry(fH1, "");
laseredit->Resize(440,22);
laseredit->SetState(kFALSE);
fH1->AddFrame(laseredit, f0centery);
fG1->AddFrame(fH1, f0);
 
ULong_t fcolor;
gClient->GetColorByName("red", fcolor);
 
lab = new TGLabel(fG1, "Note: Tick checkbox in front of each header information you wish to change (for security, they are unticked by default).");
fG1->AddFrame(lab, f0centerx);
lab = new TGLabel(fG1, "Warning: Using button \"Edit header\" will edit headers in all files currently selected in the Histogram file selection window.");
lab->SetTextColor(fcolor);
fG1->AddFrame(lab, f0centerx);
 
mdiFrame->AddFrame(fG1, f2);
 
editHead = new TGTextButton(mdiFrame, "Edit header");
editHead->SetTextJustify(36);
editHead->SetWrapLength(-1);
editHead->Resize(80,22);
mdiFrame->AddFrame(editHead, f0centerx);
mdiFrame->SetMdiHints(kMdiMinimize | kMdiMaximize | kMdiClose);
mdiFrame->SetWindowName("Edit datafile header");
mdiFrame->MapSubwindows();
mdiFrame->Layout();
mdiFrame->Move(1*((winWidth/12)-5)-30,(int)(1*((winHeight/12)-5)));
 
// Action connections
biasedittick->Connect("Clicked()", "TGAppMainFrame", this, "EditTickToggle(=1)");
posedittick->Connect("Clicked()", "TGAppMainFrame", this, "EditTickToggle(=2)");
tempedittick->Connect("Clicked()", "TGAppMainFrame", this, "EditTickToggle(=3)");
angleedittick->Connect("Clicked()", "TGAppMainFrame", this, "EditTickToggle(=4)");
laseredittick->Connect("Clicked()", "TGAppMainFrame", this, "EditTickToggle(=5)");
editHead->Connect("Clicked()", "TGAppMainFrame", this, "headeredit()");
/* updateTemp->Connect("Clicked()", "TGAppMainFrame", this, "UpdateTempPlot()");
tempEndOn->Connect("Clicked()", "TGAppMainFrame", this, "TempEndToggle()");
exportTemp->Connect("Clicked()", "TGAppMainFrame", this, "ExportTempPlot()");
tempFile[0]->Connect("Clicked()", "TGAppMainFrame", this, "GetTempFile(=0)");
tempFile[1]->Connect("Clicked()", "TGAppMainFrame", this, "GetTempFile(=1)");
*/ }
// Header editor pane ----------------------------------------------------------------------
//
else
printf("Window not implemented yet.\n");
}
 
//---------------------------------------------------------------
5107,19 → 5625,15
 
Bool_t TGMdiSubwindow::CloseWindow()
{
int ret = 0;
/* int ret = 0;
 
// if(noq == 0)
// {
new TGMsgBox(gClient->GetRoot(), fMdiFrame,
fMdiFrame->GetWindowName(), "Really want to close the window?",
kMBIconExclamation, kMBYes | kMBNo, &ret);
if (ret == kMBYes) return fMdiFrame->CloseWindow();
new TGMsgBox(gClient->GetRoot(), fMdiFrame,
fMdiFrame->GetWindowName(), "Really want to close the window?",
kMBIconExclamation, kMBYes | kMBNo, &ret);
if (ret == kMBYes) return fMdiFrame->CloseWindow();
 
return kFALSE;
// }
// else
// return fMdiFrame->CloseWindow();
return kFALSE;*/
return fMdiFrame->CloseWindow();
}
 
//---------------------------------------------------------------