Subversion Repositories f9daq

Compare Revisions

Ignore whitespace Rev 127 → Rev 128

/lab/sipmscan/trunk/README
37,6 → 37,7
- scope IP -> sets the oscilloscope IP address
- LASER settings info panel -> this will be written to the output file and is used for supplying additional information
- chamber temperature -> the chamber temperature to be written to the output file
- incidence angle -> the angle at which the sample is rotated around its axis, relative to the LASER beam (0 degrees is perpendicular to LASER beam)
 
b) Main measurement window:
- settings for table position and bias voltage
53,6 → 54,7
- if using multiple files, use multiple file select or select all listed files
- files will be used in order displayed on the list
- to clear the complete list, use the clear list button
- any opened measurement has an info display of its header at the bottom for easier navigation
 
d) Histogram window:
- displays the currently selected histogram in the histogram file selection window
76,12 → 78,16
- Fit spectrum -> fit the currently open spectrum for peaks
- Fit all selected -> fit all the selected ADC spectra selected in the histogram file selection window for peaks and display the breakdown voltage plots
- Integrate spectrum (X, Y) -> integrate the ADC spectrum for multiple files with an X or Y scan (used for edge scans)
- Relative PDE -> calculation of the relative PDE for the currently selected files
 
c) Windows:
- Specific tiling
c) Tools:
- Fieldpoint temperature sensor -> direct graphing of the fieldpoint temperature sensor (with settings for fieldpoint channel, start time and end time), output is a graph (if exporting) and a comma separated list saved to folder ./fieldpoint
 
d) Windows:
- Specific window tiling
- Switch between active windows
 
d) Help information
e) Help information
 
Important!
When using any analysis method (surface 2D plot, fitting, integration, ADC spectra display) only events inside the selected TDC window will be used so set the TDC range accordingly.
89,12 → 95,18
______________
4. Change log:
 
9.4.2015:
5.5.2015 (Current Rev):
a) Added a header display for opened files in the histogram file selection window. This enables a quicker view of the measurement information.
b) Added an incidence angle input to be able to save sample rotation angle to headers of files.
c) Added support for the fieldpoint temperature sensor (FP RTD 122). Can now plot and export data from the sensor for a specific channel and specific time range. For now, this option only works if the PC you are using this program on is connected to an internet/ethernet connection at IJS.
d) Added a limited relative PDE analysis option. At this time, it takes the selected files and calculates the PDE, relative to the first selected file. The first file should be measured at incidence angle 0, with others having an incidence angle shift of +15 (1st file -> 0, 2nd file -> 15, 3rd file -> 30,...).
 
9.4.2015 (Rev 127):
a) Added communications panel for connecting to a Tektronix scope.
b) Added limited support for waveform analysis with a Tektronix scope. For now it only works when linking it to CAMAC acquisition.
b) Added limited support for waveform analysis with a Tektronix scope. For now, it only works when linking it to CAMAC acquisition.
c) Added a manual chamber temperature entry field.
 
16.3.2015:
16.3.2015 (Rev 117):
a) First version of sipmscan.
b) Added support for CAMAC, bias voltage settings and table position settings.
c) Added support for opening measured histograms.
/lab/sipmscan/trunk/root_include.h
211,4 → 211,15
#include "TRandom.h"
#endif
 
// ROOT MYSQL includes
#ifndef ROOT_TSQLServer
#include <TSQLServer.h>
#endif
#ifndef ROOT_TSQLResult
#include <TSQLResult.h>
#endif
#ifndef ROOT_TSQLRow
#include <TSQLRow.h>
#endif
 
#endif
/lab/sipmscan/trunk/windowed_test.C
5,7 → 5,6
 
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <unistd.h>
 
#include "daqscope.h"
39,12 → 38,13
TGMdiMainFrame *fMainFrame;
TGMdiMenuBar *fMenuBar;
TGLayoutHints *fMenuBarItemLayout;
TGPopupMenu *fMenuFile, *fMenuAnalysis, *fMenuWindow, *fMenuHelp;
TGPopupMenu *fMenuFile, *fMenuAnalysis, *fMenuTools, *fMenuWindow, *fMenuHelp;
TGPopupMenu *fMenuHisttype;
TGMdiSubwindow *settingsPane, *mainSubwindow, *histogramPane, *histogramPaneFile, *histogramPaneCtr;
 
void InitMenu();
void MeasurementLayout();
void OpenWindow(int winid);
void CloseWindow();
Bool_t About();
public:
91,7 → 91,13
void FitSpectrum(TList *files, int q);
void EdgeDetection(TGraph *pdf, TGraph *cdf, char *outname, TCanvas *g1dCanvas, double pdfmax, int direction);
void IntegSpectrum(TList *files, int direction);
void PhotonMu(TList *files);
 
void UpdateTempPlot();
void TempEndToggle();
void ExportTempPlot();
void GetTempFile(int set);
 
void RunMeas(void *ptr, int runCase, int zaxisscan);
};
 
99,7 → 105,7
const char *histExtAll = "*.root";
daq *gDaq;
daqscope *gScopeDaq;
int debugSig = 0;
//int debugSig = 0;
int retTemp;
int gStop=0;
unsigned int gBuf[BSIZE];
118,6 → 124,7
int ypos;
int zpos;
double temperature;
double angle;
char laserinfo[256];
} evtheader;
 
150,6 → 157,7
TGNumberEntry *NCH;
TGTextEntry *laserInfo;
TGNumberEntry *chtemp;
TGNumberEntry *incangle;
TGCheckButton *cleanOn;
 
TGTab *setTab;
194,6 → 202,13
TGTextButton *prevFile;
TGTextButton *nextFile;
 
TGTextEntry *disptime;
TGNumberEntry *dispbias;
TGTextEntry *disppos;
TGNumberEntry *disptemp;
TGNumberEntry *dispangle;
TGTextEntry *displaser;
 
TGNumberEntry *adcMinRange;
TGNumberEntry *adcMaxRange;
TGNumberEntry *tdcMinwindow;
223,6 → 238,20
TGComboBox *sMeasgroup;
TGTextButton *scopeInit;
 
TRootEmbeddedCanvas *displayCanvas;
TGComboBox *tempCh;
TGComboBox *tempDay[2];
TGComboBox *tempMonth[2];
TGComboBox *tempYear[2];
TGComboBox *tempHour[2];
TGComboBox *tempMinute[2];
TGComboBox *tempSecond[2];
TGTextButton *tempFile[2];
TGCheckButton *tempEndOn;
TGTextButton *updateTemp;
TGTextButton *exportTemp;
//TGTextButton *closeTemp;
 
Bool_t firstrun = kTRUE;
Bool_t started;
Bool_t cleanPlots = kTRUE;
286,7 → 315,7
ctemp[i] = inname[i];
}
 
if(debugSig)
if(debug)
printf("Outfile (remove_ext): %s\n", outname);
}
 
309,7 → 338,7
ctemp[searchpos] = '\0';
sprintf(outname, "%s", ctemp);
 
if(debugSig)
if(debug)
printf("Outfile (remove_from_last): %s\n", outname);
}
 
393,6 → 422,452
return result;
}
 
// Temperature sensor functions -----------------------------
const char* dbname = "mysql://f9lab08.ijs.si/f9phdet";
const char* tblname = "fprtd122";
const char* username = "f9daq";
const char* userpass = "f9lab";
 
// Get the temperature from MYSQL database
double GetTemperature(int ch, const char *s)
{
int bin=5+7*4-ch*4;
char hex[16];
strncpy(hex, (const char *) &s[bin], 4);
hex[4]=0;
int ix;
sscanf (hex,"%x",&ix);
//printf("0x%s\t",hex);
return (ix/65535.)*1050.-200.;
}
 
// Transform local time to timestamp
int GetTimeStamp(int *intime)
{
time_t rawtime;
struct tm * timeinfo;
time(&rawtime);
timeinfo = localtime(&rawtime);
 
printf("%d.%d.%d, %d:%d:%d\n", intime[0], intime[1], intime[2], intime[3], intime[4], intime[5]);
 
timeinfo->tm_mday = intime[0];
timeinfo->tm_mon = intime[1] - 1;
timeinfo->tm_year = intime[2] - 1900;
timeinfo->tm_hour = intime[3];
timeinfo->tm_min = intime[4];
timeinfo->tm_sec = intime[5];
return (int)mktime(timeinfo);
}
 
// Get data from MYSQL database
void fieldpoint(int *timerange, int selch)
{
char humantime[256];
 
// Display selected timestamps
GetTime(timerange[0], humantime);
printf("Minimum time set to: %s (%d)\n", humantime, timerange[0]);
if(timerange[1] != -1)
{
GetTime(timerange[1], humantime);
printf("Maximum time set to: %s (%d)\n", humantime, timerange[1]);
}
printf("Selected fieldpoint channel: %d\n", selch);
printf("\n");
 
// Database settings
TSQLServer *db = TSQLServer::Connect(dbname, username, userpass);
printf("Server info: %s\n", db->ServerInfo());
TSQLRow *row;
TSQLResult *res;
 
// list databases available on server
printf("\nList all databases on server %s\n", db->GetHost());
res = db->GetDataBases();
while ((row = res->Next())) {
printf("%s\n", row->GetField(0));
delete row;
}
delete res;
 
// list tables in database "test" (the permission tables)
printf("\nList all tables in database \"f9phdet\" on server %s\n", db->GetHost());
res = db->GetTables("f9phdet");
while ((row = res->Next())) {
printf("%s\n", row->GetField(0));
delete row;
}
delete res;
// list columns in table "runcatalog" in database "mysql"
printf("\nList all columns in table \"f9phdet\" in database \"f9rtd122\" on server %s\n", db->GetHost());
res = db->GetColumns("f9phdet", "fprtd122");
while ((row = res->Next())) {
printf("%s\n", row->GetField(0));
delete row;
}
delete res;
 
// query database and print results
char sql[1000] = "SELECT status,data,timestamp FROM fprtd122 WHERE status='A272727272727272748' AND substring(data,1,4)='A00C' ";
if(timerange[1] == -1)
sprintf(sql,"%s AND timestamp>='%d'", sql, timerange[0]);
else
sprintf(sql,"%s AND timestamp>='%d' AND timestamp<='%d'", sql, timerange[0], timerange[1]);
printf("%s\n",sql);
res = db->Query(sql);
 
int nrows = res->GetRowCount();
printf("\nGot %d rows in result\n", nrows);
// Printing and plotting
char timeval[256];
TGraph *gr;
gr = new TGraph(nrows);
gr->SetLineColor(kRed);
gr->SetLineWidth(1);
gr->SetMarkerColor(kRed);
gr->SetMarkerStyle(20);
gr->SetTitle("Temperature sensor;Time;Temperature (deg.)");
 
FILE *fp;
fp = fopen("./fieldpoint/dataout_fieldpoint.txt", "w");
 
if(debug)
printf("Time\tTemperature\n");
for (int i = 0; i < nrows; i++) {
row = res->Next();
 
GetTime((int)atof(row->GetField(2)), timeval);
double x = atof(row->GetField(2));
double y = GetTemperature(selch,row->GetField(1));
gr->SetPoint(i,x,y);
 
fprintf(fp, "%s\t%f\n",timeval,y);
 
if(debug)
printf("%s\t%f\n",timeval,y);
delete row;
}
 
fclose(fp);
 
delete res;
delete db;
 
TCanvas *gCanvas = displayCanvas->GetCanvas();
gCanvas->SetGrid();
gr->GetXaxis()->SetTimeDisplay(1);
gr->GetXaxis()->SetTimeFormat("%d.%m.%H:%M");
gr->GetXaxis()->SetLabelSize(0.027);
gr->GetXaxis()->SetTitleSize(0.038);
gr->GetYaxis()->SetLabelSize(0.027);
gr->GetYaxis()->SetTitleSize(0.038);
gr->GetXaxis()->SetNdivisions(515,kTRUE);
gr->Draw("AL");
 
gCanvas->Modified();
gCanvas->Update();
}
 
// Update the temperature plot
void TGAppMainFrame::UpdateTempPlot()
{
int stime[6];
int etime[6];
 
int timestamp[2];
 
time_t rtime;
int curyear;
time(&rtime);
curyear = (int)(localtime(&rtime))->tm_year+1900;
 
int leapy = 0;
 
// Getting the start time
stime[0] = (int)(tempDay[0]->GetSelected())+1;
stime[2] = curyear - (int)(tempYear[0]->GetSelected());
printf("%d, %d, %d\n", stime[2], curyear, (int)(tempYear[0]->GetSelected()));
stime[3] = (int)(tempHour[0]->GetSelected());
stime[4] = (int)(tempMinute[0]->GetSelected());
stime[5] = (int)(tempSecond[0]->GetSelected());
 
switch( tempMonth[0]->GetSelected() )
{
case 0:
stime[1] = (int)(tempMonth[0]->GetSelected())+1;
break;
case 1:
if( stime[2]%4 == 0)
leapy = 1;
 
if( (leapy == 1) && (stime[0] > 29) )
{
stime[0] = 29;
tempDay[0]->Select(28);
}
else if( (leapy == 0) && (stime[0] > 28) )
{
stime[0] = 28;
tempDay[0]->Select(27);
}
stime[1] = (int)(tempMonth[0]->GetSelected())+1;
break;
case 2:
stime[1] = (int)(tempMonth[0]->GetSelected())+1;
break;
case 3:
if(stime[0] > 30)
{
stime[0] = 30;
tempDay[0]->Select(29);
}
stime[1] = (int)(tempMonth[0]->GetSelected())+1;
break;
case 4:
stime[1] = (int)(tempMonth[0]->GetSelected())+1;
break;
case 5:
if(stime[0] > 30)
{
stime[0] = 30;
tempDay[0]->Select(29);
}
stime[1] = (int)(tempMonth[0]->GetSelected())+1;
break;
case 6:
stime[1] = (int)(tempMonth[0]->GetSelected())+1;
break;
case 7:
stime[1] = (int)(tempMonth[0]->GetSelected())+1;
break;
case 8:
if(stime[0] > 30)
{
stime[0] = 30;
tempDay[0]->Select(29);
}
stime[1] = (int)(tempMonth[0]->GetSelected())+1;
break;
case 9:
stime[1] = (int)(tempMonth[0]->GetSelected())+1;
break;
case 10:
if(stime[0] > 30)
{
stime[0] = 30;
tempDay[0]->Select(29);
}
stime[1] = (int)(tempMonth[0]->GetSelected())+1;
break;
case 11:
stime[1] = (int)(tempMonth[0]->GetSelected())+1;
break;
default:
break;
}
 
timestamp[0] = GetTimeStamp(stime);
printf("Start time: %d\n", timestamp[0]);
 
// Getting the end time
etime[0] = (int)(tempDay[1]->GetSelected())+1;
etime[2] = curyear - (int)(tempYear[1]->GetSelected());
etime[3] = (int)(tempHour[1]->GetSelected());
etime[4] = (int)(tempMinute[1]->GetSelected());
etime[5] = (int)(tempSecond[1]->GetSelected());
 
switch( tempMonth[1]->GetSelected() )
{
case 0:
etime[1] = (int)(tempMonth[1]->GetSelected())+1;
break;
case 1:
if( etime[2]%4 == 0)
leapy = 1;
 
if( (leapy == 1) && (etime[0] > 29) )
{
etime[0] = 29;
tempDay[1]->Select(28);
}
else if( (leapy == 0) && (etime[0] > 28) )
{
etime[0] = 28;
tempDay[1]->Select(27);
}
etime[1] = (int)(tempMonth[1]->GetSelected())+1;
break;
case 2:
etime[1] = (int)(tempMonth[1]->GetSelected())+1;
break;
case 3:
if(etime[0] > 30)
{
etime[0] = 30;
tempDay[1]->Select(29);
}
etime[1] = (int)(tempMonth[1]->GetSelected())+1;
break;
case 4:
etime[1] = (int)(tempMonth[1]->GetSelected())+1;
break;
case 5:
if(etime[0] > 30)
{
etime[0] = 30;
tempDay[1]->Select(29);
}
etime[1] = (int)(tempMonth[1]->GetSelected())+1;
break;
case 6:
etime[1] = (int)(tempMonth[1]->GetSelected())+1;
break;
case 7:
etime[1] = (int)(tempMonth[1]->GetSelected())+1;
break;
case 8:
if(etime[0] > 30)
{
etime[0] = 30;
tempDay[1]->Select(29);
}
etime[1] = (int)(tempMonth[1]->GetSelected())+1;
break;
case 9:
etime[1] = (int)(tempMonth[1]->GetSelected())+1;
break;
case 10:
if(etime[0] > 30)
{
etime[0] = 30;
tempDay[1]->Select(29);
}
etime[1] = (int)(tempMonth[1]->GetSelected())+1;
break;
case 11:
etime[1] = (int)(tempMonth[1]->GetSelected())+1;
break;
default:
break;
}
 
if( tempEndOn->IsDown() )
timestamp[1] = -1;
else
timestamp[1] = GetTimeStamp(etime);
printf("End time: %d\n", timestamp[1]);
 
fieldpoint(timestamp, tempCh->GetSelected());
}
 
// Export the temperature plot to pdf
void TGAppMainFrame::ExportTempPlot()
{
TCanvas *gCanvas = displayCanvas->GetCanvas();
gCanvas->Modified();
gCanvas->Update();
gCanvas->SaveAs("./fieldpoint/plotout_fieldpoint.pdf");
}
 
// Get time information from a saved file
void TGAppMainFrame::GetTempFile(int set)
{
TGFileInfo file_info;
const char *filetypes[] = {"Histograms",histExtAll,0,0};
file_info.fFileTypes = filetypes;
file_info.fIniDir = StrDup("./results");
file_info.fMultipleSelection = kFALSE;
new TGFileDialog(gClient->GetDefaultRoot(), fMain, kFDOpen, &file_info);
int i = 0;
 
TTree *header_data;
time_t rtime, ctime;
struct tm * timeinfo;
 
int curyear;
time(&ctime);
curyear = (int)(localtime(&ctime))->tm_year+1900;
 
TList *files = file_info.fFileNamesList;
TString fname;
// If multiple files were selected, only use the first one
if(files)
{
printf("Using only the first selected file.\n");
 
TSystemFile *file;
TIter next(files);
while(i == 0)
{
file=(TSystemFile*)next();
fname = file->GetName();
i++;
}
}
// If only one file was selected, use it
else
fname = file_info.fFilename;
 
if((int)fname.Length() > 0)
{
inroot = new TFile(fname, "READ");
inroot->GetObject("header_data", header_data);
// Reading the timestamp information
header_data->SetBranchAddress("timestamp", &evtheader.timestamp);
header_data->GetEntry(0);
rtime = (time_t)evtheader.timestamp;
timeinfo = localtime(&rtime);
// printf("Time: %d.%d.%d, %d:%d:%d\n", timeinfo->tm_mday, timeinfo->tm_mon+1, timeinfo->tm_year+1900, timeinfo->tm_hour, timeinfo->tm_min, timeinfo->tm_sec);
 
tempDay[set]->Select(timeinfo->tm_mday - 1);
tempMonth[set]->Select(timeinfo->tm_mon);
tempYear[set]->Select(curyear - (timeinfo->tm_year+1900));
tempHour[set]->Select(timeinfo->tm_hour);
tempMinute[set]->Select(timeinfo->tm_min);
tempSecond[set]->Select(timeinfo->tm_sec);
}
else
printf("No file selected.\n");
delete inroot;
}
 
// Toggle the endtime settings for temperature sensor
void TGAppMainFrame::TempEndToggle()
{
if( tempEndOn->IsDown() )
{
tempDay[1]->SetEnabled(kFALSE);
tempMonth[1]->SetEnabled(kFALSE);
tempYear[1]->SetEnabled(kFALSE);
tempHour[1]->SetEnabled(kFALSE);
tempMinute[1]->SetEnabled(kFALSE);
tempSecond[1]->SetEnabled(kFALSE);
tempFile[1]->SetEnabled(kFALSE);
}
else
{
tempDay[1]->SetEnabled(kTRUE);
tempMonth[1]->SetEnabled(kTRUE);
tempYear[1]->SetEnabled(kTRUE);
tempHour[1]->SetEnabled(kTRUE);
tempMinute[1]->SetEnabled(kTRUE);
tempSecond[1]->SetEnabled(kTRUE);
tempFile[1]->SetEnabled(kTRUE);
}
}
 
// --------------------------------------------------------------
 
// Class related functions --------------------------------------
 
// Apply the upper voltage limit from settings pane to main window
889,6 → 1364,11
#if WORKSTAT == 'I' || WORKSTAT == 'S'
scopeReturn->SetText(ret);
#endif
 
#if WORKSTAT == 'O'
sprintf(ret, "Program running in offline mode. Use I or S when configuring...");
scopeReturn->SetText(ret);
#endif
}
 
// When we select the measurement type, change other scope settings accordingly
1182,16 → 1662,23
// Write out parameters to a file
fp = fopen(paramname, "a");
fprintf(fp, "%d\t", nrfit);
TMath::Sort(nrfit, meanparam, sortindex, kFALSE);
for(int i = 0; i < nrfit; i++)
// 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(debugSig)
printf("Peak %d: %lf\t%lf\n", i+1, meanparam[sortindex[i]], meanparamerr[sortindex[i]]);
fprintf(fp, "%le\t%le\t", meanparam[sortindex[i]], meanparamerr[sortindex[i]]);
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");
}
printf("\n");
fprintf(fp, "\n");
 
fclose(fp);
 
1222,7 → 1709,7
volt[p] = dtemp;
volterr[p] = 1.e-4;
if(debugSig)
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]);
// Accept only the points with a small enough error
1444,7 → 1931,7
{
zb = i-j+za;
integralCount[zb] = integralAcc[za]/maxInteg;
if(debugSig)
if(debug)
printf("Integral check 2 (i=%d,j=%d,za=%d,z=%.2lf,zb=%d): %lf\t%lf\n", i, j, za, surfz[i-j], zb, integralCount[zb], integralAcc[za]/maxInteg);
}
 
1501,7 → 1988,7
if(surfz[i] == curzval)
{
integralAcc[j] = integralCount[i];
if(debugSig)
if(debug)
printf("Integral check 1 (i=%d,j=%d,z=%.2lf): %lf\t%lf\n", i, j, surfz[i], integralCount[i], integralAcc[j]);
j++;
acc++;
1519,7 → 2006,7
{
zb = i-j+za;
integralCount[zb] = integralAcc[za]/maxInteg;
if(debugSig)
if(debug)
printf("Integral check 2 (i=%d,j=%d,za=%d,z=%.2lf,zb=%d): %lf\t%lf\n", i, j, za, surfz[i-j], zb, integralCount[zb], integralAcc[za]/maxInteg);
}
1602,13 → 2089,13
{
if(direction == 1)
{
if(debugSig)
if(debug)
printf("%.2lf\t%.2lf\t%lf\n", surfx[i], surfz[i], integralCount[i]);
gScan2D->SetPoint(i, surfx[i], surfz[i], integralCount[i]);
}
else if(direction == 2)
{
if(debugSig)
if(debug)
printf("%.2lf\t%.2lf\t%lf\n", surfy[i], surfz[i], integralCount[i]);
gScan2D->SetPoint(i, surfy[i], surfz[i], integralCount[i]);
}
1655,6 → 2142,226
}
}
 
// Integrate the spectrum
void TGAppMainFrame::PhotonMu(TList *files)
{
unsigned int nrfiles = fileList->GetNumberOfEntries();
char ctemp[256];
int j, k = 0, m = 0, n = 0, k2 = 0, m2 = 0;
 
// TCanvas *gCanvas = new TCanvas("canv","canv",900,900);
TTree *header_data, *meas_data;
double *integralCount, *integralPedestal;
integralCount = new double[nrfiles];
integralPedestal = new double[nrfiles];
// double xsurfmin, ysurfmin, zsurfmin;
double *angle;
double *muval;
angle = 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;
TH1F *h2;
float *xpeaks;
TF1 *fit;
TF1 *fittingfunc;
double *fparam;
double meanparam;
int adcpedestal[2];
double paramsigma = 0;
 
if(files->GetSize() > 0)
{
for(int i = 0; i < (int)files->GetSize(); i++)
{
n++;
if(files->At(i))
{
// Find the pedestal peak and the first minimum after pedestal ----------------
DisplayHistogram( (char*)(files->At(i)->GetTitle()), 0);
histCanvas->GetCanvas()->Modified();
histCanvas->GetCanvas()->Update();
histtemp = (TH1F*)histCanvas->GetCanvas()->GetPrimitive(histname);
npeaks = 1;
double par[300];
spec = new TSpectrum(npeaks);
// Find spectrum background
histback = spec->Background(histtemp, (int)fitInter->GetNumber(), "same");
// Clone histogram and subtract background from it
h2 = (TH1F*)histtemp->Clone("h2");
h2->Add(histback, -1);
// Search for the peaks
int found = spec->Search(h2, fitSigma->GetNumber(), "goff", fitTresh->GetNumber() );
printf("Found %d candidates to fit.\n",found);
npeaks = found;
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->GetNumber();
}
// Fit the histogram
fit = new TF1("fit", FindPeaks, 0, 400, 3*npeaks);
TVirtualFitter::Fitter(histtemp, 3*npeaks);
fit->SetParameters(par);
fit->SetNpx(300);
h2->Fit("fit","Q"); // for quiet mode, add Q
fittingfunc = h2->GetFunction("fit");
fparam = fittingfunc->GetParameters();
// Gather the parameters (mean peak value for now)
j = 1;
 
meanparam = fparam[j];
paramsigma = fparam[j+1];
 
/* while(1)
{
if( (fparam[j] < 1.E-30) || (fparamerr[j] < 1.E-10) )
break;
else
{
if(fparam[j] > 0)
{
meanparam = fparam[j];
meanparamerr = fparamerr[j];
paramsigma = fparam[j+1];
nrfit++;
}
}
j+=3;
}
*/
histCanvas->GetCanvas()->Modified();
histCanvas->GetCanvas()->Update();
j = 0;
adcpedestal[0] = 0;
adcpedestal[1] = -1;
while(1)
{
int bin = histtemp->GetXaxis()->FindBin((int)(j+meanparam+paramsigma));
int yp = histtemp->GetBinContent(bin);
if(adcpedestal[1] == -1)
{
adcpedestal[0] = j+meanparam+paramsigma;
adcpedestal[1] = yp;
}
else
{
if(adcpedestal[1] >= yp)
{
adcpedestal[0] = j+meanparam+paramsigma;
adcpedestal[1] = yp;
}
else
break;
}
j++;
if(j > 50) break;
}
cout << "Pedestal ends with ADC value: " << adcpedestal[0] << endl;
 
// ----------------------------------------------------------------------------
 
sprintf(ctemp, "%s", files->At(i)->GetTitle());
inroot = new TFile(ctemp, "READ");
inroot->GetObject("header_data", header_data);
inroot->GetObject("meas_data", meas_data);
// Reading the header
// header_data->SetBranchAddress("angle", &evtheader.angle);
// header_data->GetEntry(0);
char rdc[256];
j = selectCh->GetNumber();
double rangetdc[2];
rangetdc[0] = tdcMinwindow->GetNumber();
rangetdc[1] = tdcMaxwindow->GetNumber();
k = 0;
k2 = 0;
m = 0;
m2 = 0;
// Reading the data
for(int e = 0; e < meas_data->GetEntries(); e++)
{
sprintf(rdc, "ADC%d", j);
meas_data->SetBranchAddress(rdc, &evtdata.adcdata[j]);
meas_data->GetEntry(e);
sprintf(rdc, "TDC%d", j);
meas_data->SetBranchAddress(rdc, &evtdata.tdcdata[j]);
meas_data->GetEntry(e);
// If our data point is inside the TDC window
if( ((double)evtdata.tdcdata[j]/tdctimeconversion >= rangetdc[0]) && ((double)evtdata.tdcdata[j]/tdctimeconversion <= rangetdc[1]) )
{
// Gather only the integral of the pedestal
if((double)evtdata.adcdata[j] < (double)adcpedestal[0]+0.5 )
{
k2++;
m2 += evtdata.adcdata[j];
}
 
// Gather the complete integral
k++;
m += evtdata.adcdata[j];
}
}
 
// angle[i] = (double)(evtheader.angle);
angle[i] = (double)(i*15.*TMath::ACos(-1.)/180.); // angle in radians
cout << "Angle = " << angle[i] << endl;
 
// integralCount[i] += ((double)m)/((double)k);
integralCount[i] += (double)m;
cout << "Integral (" << k << " evts) = " << integralCount[i] << endl;
 
integralPedestal[i] += (double)m2;
cout << "Integral (" << k2 << " evts) = " << integralPedestal[i] << endl;
 
muval[i] = -TMath::Log((double)k2/(double)k);
cout << "Mu = " << muval[i] << endl;
delete inroot;
}
}
 
nrentries = n;
printf("%d files were selected.\n", nrentries);
 
cout << "angle\tmu\trelative PDE\n" << endl;
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;
}
}
}
 
void TGAppMainFrame::RunMeas(void *ptr, int runCase, int zaxisscan)
{
printf("Start of Run, run case %d\n", runCase);
1773,6 → 2480,7
evtheader.ypos = (int)yPos->GetNumber();
evtheader.zpos = (int)zPos->GetNumber();
evtheader.temperature = (double)chtemp->GetNumber();
evtheader.angle = (double)incangle->GetNumber();
sprintf(evtheader.laserinfo, "%s", laserInfo->GetText());
 
char histtime[256];
2311,7 → 3019,7
{
if(files->At(i))
{
if(debugSig)
if(debug)
printf("Filename: %s\n", files->At(i)->GetTitle());
if( fMenuHisttype->IsEntryChecked(M_ANALYSIS_HISTTYPE_1DADC) )
DisplayHistogram( (char*)(files->At(i)->GetTitle()), 0);
2330,7 → 3038,7
// Display the currently selected histogram in file list
void TGAppMainFrame::DisplayHistogram(char* histfile, int histtype)
{
if(debugSig)
if(debug)
printf("Selected file: %s\n", histfile);
 
TCanvas *gCanvas = histCanvas->GetCanvas();
2356,6 → 3064,8
header_data->GetEntry(0);
header_data->SetBranchAddress("temperature", &evtheader.temperature);
header_data->GetEntry(0);
header_data->SetBranchAddress("angle", &evtheader.angle);
header_data->GetEntry(0);
header_data->SetBranchAddress("laserinfo", &evtheader.laserinfo);
header_data->GetEntry(0);
 
2362,7 → 3072,8
char histtime[256];
GetTime(evtheader.timestamp, histtime);
 
if(debugSig)
// Displaying header information (debug and on the GUI)
if(debug)
{
printf("Opened file header information:\n");
printf("- Number of channels: %d\n", evtheader.nrch);
2369,10 → 3080,28
printf("- Timestamp: %d (%s)\n", evtheader.timestamp, histtime);
printf("- Bias voltage: %lf\n", evtheader.biasvolt);
printf("- Table position (X,Y,Z): %d, %d, %d\n", evtheader.xpos, evtheader.ypos, evtheader.zpos);
printf("- Temperature: %lf\n", evtheader.temperature);
if(evtheader.temperature)
printf("- Temperature: %lf\n", evtheader.temperature);
if(evtheader.angle)
printf("- Incidence angle: %lf\n", evtheader.angle);
printf("- Laser and filter settings: %s\n", evtheader.laserinfo);
}
 
char ctemp[512];
disptime->SetText(histtime);
dispbias->SetNumber(evtheader.biasvolt);
sprintf(ctemp, "%d, %d, %d", evtheader.xpos, evtheader.ypos, evtheader.zpos);
disppos->SetText(ctemp);
if(evtheader.temperature)
disptemp->SetNumber(evtheader.temperature);
else
disptemp->SetNumber(0.0);
if(evtheader.angle)
dispangle->SetNumber(evtheader.angle);
else
dispangle->SetNumber(0.0);
displaser->SetText(evtheader.laserinfo);
 
int j;
char rdc[256];
char rdcsel[256];
2741,7 → 3470,7
{
if(files->At(i))
{
if(debugSig)
if(debug)
printf("Filename: %s\n", files->At(i)->GetTitle());
if( fMenuHisttype->IsEntryChecked(M_ANALYSIS_HISTTYPE_1DADC) )
DisplayHistogram( (char*)(files->At(i)->GetTitle()), 0);
2771,7 → 3500,7
{
if(files->At(i))
{
if(debugSig)
if(debug)
printf("Filename: %s\n", files->At(i)->GetTitle());
if( fMenuHisttype->IsEntryChecked(M_ANALYSIS_HISTTYPE_1DADC) )
DisplayHistogram( (char*)(files->At(i)->GetTitle()), 0);
2900,7 → 3629,7
{
remove_ext((char*)files->At(i)->GetTitle(), ctemp);
if(debugSig)
if(debug)
printf("Filename: %s\n", files->At(i)->GetTitle());
if( fMenuHisttype->IsEntryChecked(M_ANALYSIS_HISTTYPE_1DADC) )
{
3021,6 → 3750,18
IntegSpectrum(files, 2);
break;
 
case M_ANALYSIS_PHOTMU:
// Integrate the current spectra and calculate mean of detected photons: mu = -log(Nped/Ntot)
files = new TList();
fileList->GetSelectedEntries(files);
 
PhotonMu(files);
break;
 
case M_TOOLS_FIELDPOINT:
OpenWindow(1);
break;
 
case M_WINDOW_HOR:
fMainFrame->TileHorizontal();
break;
3066,7 → 3807,12
fMenuAnalysis->AddEntry(new TGHotString("Fit &all selected"), M_ANALYSIS_FITSEL);
fMenuAnalysis->AddEntry(new TGHotString("Integrate spectrum (&X direction)"), M_ANALYSIS_INTEGX);
fMenuAnalysis->AddEntry(new TGHotString("Integrate spectrum (&Y direction)"), M_ANALYSIS_INTEGY);
fMenuAnalysis->AddEntry(new TGHotString("Relative &PDE"), M_ANALYSIS_PHOTMU);
 
// Popup menu in menubar for External tools
fMenuTools = new TGPopupMenu(gClient->GetRoot()); // adds a new popup menu to the menubar
fMenuTools->AddEntry(new TGHotString("&Fieldpoint temperature sensor"), M_TOOLS_FIELDPOINT);
 
// Popup menu in menubar for Window controls
fMenuWindow = new TGPopupMenu(gClient->GetRoot()); // adds a new popup menu to the menubar
fMenuWindow->AddEntry(new TGHotString("Tile &Horizontally"), M_WINDOW_HOR);
3080,6 → 3826,7
// Connect all menu items with actions - handled by HandleMenu()
fMenuFile->Connect("Activated(Int_t)", "TGAppMainFrame", this, "HandleMenu(Int_t)");
fMenuAnalysis->Connect("Activated(Int_t)", "TGAppMainFrame", this, "HandleMenu(Int_t)");
fMenuTools->Connect("Activated(Int_t)", "TGAppMainFrame", this, "HandleMenu(Int_t)");
fMenuWindow->Connect("Activated(Int_t)", "TGAppMainFrame", this, "HandleMenu(Int_t)");
fMenuHelp->Connect("Activated(Int_t)", "TGAppMainFrame", this, "HandleMenu(Int_t)");
 
3086,6 → 3833,7
// Draw the created popup menus on the menubar
fMenuBar->AddPopup(new TGHotString("&File"), fMenuFile, fMenuBarItemLayout);
fMenuBar->AddPopup(new TGHotString("&Analysis"),fMenuAnalysis,fMenuBarItemLayout);
fMenuBar->AddPopup(new TGHotString("&Tools"),fMenuTools,fMenuBarItemLayout);
fMenuBar->AddPopup(new TGHotString("&Windows"),fMenuWindow,fMenuBarItemLayout);
fMenuBar->AddPopup(new TGHotString("&Help"), fMenuHelp, fMenuBarItemLayout);
}
3194,6 → 3942,15
chtemp->Resize(60,22);
fH1->AddFrame(chtemp, f0center2d);
mdiFrame->AddFrame(fH1, f2);
// Incidence angle (will only be manually set until we can make it motorized)
fH1 = new TGHorizontalFrame(mdiFrame, subgroup[0], 30);
lab = new TGLabel(fH1, "Incid. angle:");
fH1->AddFrame(lab, f0center2d);
incangle = new TGNumberEntry(fH1, 0.0, 6, 999, TGNumberFormat::kNESRealOne, TGNumberFormat::kNEAAnyNumber, TGNumberFormat::kNELLimitMinMax, -180., 180.);
incangle->Resize(60,22);
fH1->AddFrame(incangle, f0center2d);
mdiFrame->AddFrame(fH1, f2);
 
mdiFrame->SetMdiHints(kMdiMinimize);
mdiFrame->SetWindowName("Settings pane");
3666,7 → 4423,7
// List view of the opened files
fileList = new TGListBox(mdiFrame,1);
fileList->GetVScrollbar();
fileList->Resize(300, (subwin[1]/2)-10 );
fileList->Resize(300, (3*subwin[1]/7)-10 );
mdiFrame->AddFrame(fileList, f2);
 
// Multiple file selection toggle, previous/next controls and clear list
3700,6 → 4457,57
fH1->AddFrame(prevFile, f0right);
mdiFrame->AddFrame(fH1, f2);
 
// Header information of opened file
fG1 = new TGGroupFrame(mdiFrame, "Opened file header information");
fH1 = new TGHorizontalFrame(fG1, subgroup[0], 30);
lab = new TGLabel(fH1, "Time:");
fH1->AddFrame(lab, f0centery);
disptime = new TGTextEntry(fH1, "");
disptime->Resize(440,22);
disptime->SetState(kFALSE);
fH1->AddFrame(disptime, f0centery);
fG1->AddFrame(fH1, f2);
 
fH1 = new TGHorizontalFrame(fG1, subgroup[0], 30);
lab = new TGLabel(fH1, "Bias voltage:");
fH1->AddFrame(lab, f0centery);
dispbias = new TGNumberEntry(fH1, 0.00, 4, 999, TGNumberFormat::kNESRealThree, TGNumberFormat::kNEAAnyNumber);
dispbias->Resize(80,22);
dispbias->SetState(kFALSE);
fH1->AddFrame(dispbias, f0centery);
 
lab = new TGLabel(fH1, "Position:");
fH1->AddFrame(lab, f0centery);
disppos = new TGTextEntry(fH1, "");
disppos->Resize(200,22);
disppos->SetState(kFALSE);
fH1->AddFrame(disppos, f0centery);
 
lab = new TGLabel(fH1, "Temperature:");
fH1->AddFrame(lab, f0centery);
disptemp = new TGNumberEntry(fH1, 0.0, 6, 999, TGNumberFormat::kNESRealOne, TGNumberFormat::kNEAAnyNumber);
disptemp->Resize(80,22);
disptemp->SetState(kFALSE);
fH1->AddFrame(disptemp, f0centery);
 
lab = new TGLabel(fH1, "Angle:");
fH1->AddFrame(lab, f0centery);
dispangle = new TGNumberEntry(fH1, 0.0, 6, 999, TGNumberFormat::kNESRealOne, TGNumberFormat::kNEAAnyNumber);
dispangle->Resize(80,22);
dispangle->SetState(kFALSE);
fH1->AddFrame(dispangle, f0centery);
fG1->AddFrame(fH1, f2);
 
fH1 = new TGHorizontalFrame(fG1, subgroup[0], 30);
lab = new TGLabel(fH1, "Laser settings:");
fH1->AddFrame(lab, f0centery);
displaser = new TGTextEntry(fH1, "");
displaser->Resize(440,22);
displaser->SetState(kFALSE);
fH1->AddFrame(displaser, f0centery);
fG1->AddFrame(fH1, f2);
mdiFrame->AddFrame(fG1, f2);
 
mdiFrame->SetMdiHints(kMdiMinimize);
mdiFrame->SetWindowName("Histogram file selection");
mdiFrame->MapSubwindows();
3814,7 → 4622,7
fH1 = new TGHorizontalFrame(fG1, subgroup[0], 30);
lab = new TGLabel(fH1, "Peak sigma:");
fH1->AddFrame(lab, f0centery);
fitSigma = new TGNumberEntry(fH1, 1.5, 3, 999, TGNumberFormat::kNESRealThree, TGNumberFormat::kNEANonNegative);
fitSigma = new TGNumberEntry(fH1, 1.2, 3, 999, TGNumberFormat::kNESRealThree, TGNumberFormat::kNEANonNegative);
fitSigma->Resize(60,22);
fH1->AddFrame(fitSigma, f0centery);
fG1->AddFrame(fH1, f2);
3830,7 → 4638,7
fH1 = new TGHorizontalFrame(fG1, subgroup[0], 30);
lab = new TGLabel(fH1, "Background interpolation:");
fH1->AddFrame(lab, f0centery);
fitInter = new TGNumberEntry(fH1, 8, 3, 999, TGNumberFormat::kNESInteger, TGNumberFormat::kNEANonNegative);
fitInter = new TGNumberEntry(fH1, 7, 3, 999, TGNumberFormat::kNESInteger, TGNumberFormat::kNEANonNegative);
fitInter->Resize(60,22);
fH1->AddFrame(fitInter, f0centery);
fG1->AddFrame(fH1, f2);
3845,7 → 4653,7
 
exfitplots = new TGCheckButton(fG1, "Export fitting plots ON/OFF");
exfitplots->Resize(50,22);
exfitplots->SetState(kButtonDown);
exfitplots->SetState(kButtonUp);
fG1->AddFrame(exfitplots, f0centerx);
mdiFrame->AddFrame(fG1, f2);
 
3927,6 → 4735,342
}
 
//---------------------------------------------------------------
// Opening a new subwindow
 
void TGAppMainFrame::OpenWindow(int winid)
{
/* WinID:
* - 1 = fieldpoint temperature sensor
*/
 
TGMdiFrame *mdiFrame;
 
// Generic horizontal and vertical frames
TGHorizontalFrame *fH1, *fH2;
TGGroupFrame *fG1;
TGLabel *lab;
 
int subwin[2];
int subgroup[2];
 
char ctemp[256];
 
// Fieldpoint pane -------------------------------------------------------------------------
if(winid == 1)
{
time_t rtime;
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();
subgroup[0] = subwin[0]-10;
subgroup[1] = 7*subwin[1]/12;
 
// Display canvas for temperature sensor
displayCanvas = new TRootEmbeddedCanvas("displayCanvas",mdiFrame,subgroup[0],subgroup[1]);
mdiFrame->AddFrame(displayCanvas, f0centerx);
TCanvas *gCanvas = displayCanvas->GetCanvas();
gCanvas->SetGridx();
gCanvas->SetGridy();
 
fG1 = new TGGroupFrame(mdiFrame, "Temperature sensor settings");
// Channel selector
fH1 = new TGHorizontalFrame(fG1, subgroup[0], 30);
lab = new TGLabel(fH1, "Fieldpoint channel:");
fH1->AddFrame(lab, f0centery);
tempCh = new TGComboBox(fH1, 200);
tempCh->AddEntry("0", 0);
tempCh->AddEntry("1", 1);
tempCh->AddEntry("2", 2);
tempCh->AddEntry("3", 3);
tempCh->AddEntry("4", 4);
tempCh->AddEntry("5", 5);
tempCh->AddEntry("6", 6);
tempCh->AddEntry("7", 7);
tempCh->Resize(50,22);
tempCh->Select(1);
fH1->AddFrame(tempCh, f0centery);
fG1->AddFrame(fH1, f2);
 
// Start and stop time ------------------------
time(&rtime);
 
lab = new TGLabel(fG1, "Start time:");
fG1->AddFrame(lab, f0);
fH1 = new TGHorizontalFrame(fG1, subgroup[0], 30);
// Start day
lab = new TGLabel(fH1, "\tDay: ");
fH1->AddFrame(lab, f0centery);
tempDay[0] = new TGComboBox(fH1, 200);
for(int i = 0; i < 31; i++)
{
sprintf(ctemp, "%d", i+1);
tempDay[0]->AddEntry(ctemp, i);
}
tempDay[0]->Resize(50,22);
tempDay[0]->Select((int)(localtime(&rtime))->tm_mday-1);
fH1->AddFrame(tempDay[0], f0centery);
 
// Start month
lab = new TGLabel(fH1, " Month: ");
fH1->AddFrame(lab, f0centery);
tempMonth[0] = new TGComboBox(fH1, 200);
tempMonth[0]->AddEntry("January", 0);
tempMonth[0]->AddEntry("February", 1);
tempMonth[0]->AddEntry("March", 2);
tempMonth[0]->AddEntry("April", 3);
tempMonth[0]->AddEntry("May", 4);
tempMonth[0]->AddEntry("June", 5);
tempMonth[0]->AddEntry("July", 6);
tempMonth[0]->AddEntry("August", 7);
tempMonth[0]->AddEntry("September", 8);
tempMonth[0]->AddEntry("October", 9);
tempMonth[0]->AddEntry("November", 10);
tempMonth[0]->AddEntry("December", 11);
tempMonth[0]->Resize(80,22);
tempMonth[0]->Select((int)(localtime(&rtime))->tm_mon);
fH1->AddFrame(tempMonth[0], f0centery);
 
// Start year
yearrange[0] = 2010;
yearrange[1] = (int)(localtime(&rtime))->tm_year+1900;
 
lab = new TGLabel(fH1, " Year: ");
fH1->AddFrame(lab, f0centery);
tempYear[0] = new TGComboBox(fH1, 200);
for(int i = 0; i < (yearrange[1]-yearrange[0])+1; i++)
{
sprintf(ctemp, "%d", yearrange[1]-i);
tempYear[0]->AddEntry(ctemp, i);
}
tempYear[0]->Resize(60,22);
tempYear[0]->Select(0);
fH1->AddFrame(tempYear[0], f0centery);
 
// Start hour
lab = new TGLabel(fH1, " Hour: ");
fH1->AddFrame(lab, f0centery);
tempHour[0] = new TGComboBox(fH1, 200);
for(int i = 0; i < 24; i++)
{
if(i < 10)
sprintf(ctemp, "0%d", i);
else
sprintf(ctemp, "%d", i);
tempHour[0]->AddEntry(ctemp, i);
}
tempHour[0]->Resize(50,22);
tempHour[0]->Select(7);
fH1->AddFrame(tempHour[0], f0centery);
 
// Start minute
lab = new TGLabel(fH1, " Minute: ");
fH1->AddFrame(lab, f0centery);
tempMinute[0] = new TGComboBox(fH1, 200);
for(int i = 0; i < 60; i++)
{
if(i < 10)
sprintf(ctemp, "0%d", i);
else
sprintf(ctemp, "%d", i);
tempMinute[0]->AddEntry(ctemp, i);
}
tempMinute[0]->Resize(50,22);
tempMinute[0]->Select(0);
fH1->AddFrame(tempMinute[0], f0centery);
 
// Start second
lab = new TGLabel(fH1, " Second: ");
fH1->AddFrame(lab, f0centery);
tempSecond[0] = new TGComboBox(fH1, 200);
for(int i = 0; i < 60; i++)
{
if(i < 10)
sprintf(ctemp, "0%d", i);
else
sprintf(ctemp, "%d", i);
tempSecond[0]->AddEntry(ctemp, i);
}
tempSecond[0]->Resize(50,22);
tempSecond[0]->Select(0);
fH1->AddFrame(tempSecond[0], f0centery);
 
// Get start time from file
lab = new TGLabel(fH1, " ");
fH1->AddFrame(lab, f0centery);
tempFile[0] = new TGTextButton(fH1, "Get from file...");
tempFile[0]->SetTextJustify(36);
tempFile[0]->SetWrapLength(-1);
tempFile[0]->Resize(100,22);
fH1->AddFrame(tempFile[0], f0centery);
 
fG1->AddFrame(fH1, f2);
 
// Use the end time or not
tempEndOn = new TGCheckButton(fG1, "Draw to last time point (ON/OFF)");
tempEndOn->Resize(100,22);
tempEndOn->SetState(kButtonUp);
fG1->AddFrame(tempEndOn, f0);
 
lab = new TGLabel(fG1, "End time:");
fG1->AddFrame(lab, f0);
fH1 = new TGHorizontalFrame(fG1, subgroup[0], 30);
// End day
lab = new TGLabel(fH1, "\tDay: ");
fH1->AddFrame(lab, f0centery);
tempDay[1] = new TGComboBox(fH1, 200);
for(int i = 0; i < 31; i++)
{
sprintf(ctemp, "%d", i+1);
tempDay[1]->AddEntry(ctemp, i);
}
tempDay[1]->Resize(50,22);
tempDay[1]->Select((int)(localtime(&rtime))->tm_mday-1);
fH1->AddFrame(tempDay[1], f0centery);
 
// End month
lab = new TGLabel(fH1, " Month: ");
fH1->AddFrame(lab, f0centery);
tempMonth[1] = new TGComboBox(fH1, 200);
tempMonth[1]->AddEntry("January", 0);
tempMonth[1]->AddEntry("February", 1);
tempMonth[1]->AddEntry("March", 2);
tempMonth[1]->AddEntry("April", 3);
tempMonth[1]->AddEntry("May", 4);
tempMonth[1]->AddEntry("June", 5);
tempMonth[1]->AddEntry("July", 6);
tempMonth[1]->AddEntry("August", 7);
tempMonth[1]->AddEntry("September", 8);
tempMonth[1]->AddEntry("October", 9);
tempMonth[1]->AddEntry("November", 10);
tempMonth[1]->AddEntry("December", 11);
tempMonth[1]->Resize(80,22);
tempMonth[1]->Select((int)(localtime(&rtime))->tm_mon);
fH1->AddFrame(tempMonth[1], f0centery);
 
// End year
time(&rtime);
yearrange[0] = 2010;
yearrange[1] = (int)(localtime(&rtime))->tm_year+1900;
 
lab = new TGLabel(fH1, " Year: ");
fH1->AddFrame(lab, f0centery);
tempYear[1] = new TGComboBox(fH1, 200);
for(int i = 0; i < (yearrange[1]-yearrange[0])+1; i++)
{
sprintf(ctemp, "%d", yearrange[1]-i);
tempYear[1]->AddEntry(ctemp, i);
}
tempYear[1]->Resize(60,22);
tempYear[1]->Select(0);
fH1->AddFrame(tempYear[1], f0centery);
 
// End hour
lab = new TGLabel(fH1, " Hour: ");
fH1->AddFrame(lab, f0centery);
tempHour[1] = new TGComboBox(fH1, 200);
for(int i = 0; i < 24; i++)
{
if(i < 10)
sprintf(ctemp, "0%d", i);
else
sprintf(ctemp, "%d", i);
tempHour[1]->AddEntry(ctemp, i);
}
tempHour[1]->Resize(50,22);
tempHour[1]->Select(18);
fH1->AddFrame(tempHour[1], f0centery);
 
// End minute
lab = new TGLabel(fH1, " Minute: ");
fH1->AddFrame(lab, f0centery);
tempMinute[1] = new TGComboBox(fH1, 200);
for(int i = 0; i < 60; i++)
{
if(i < 10)
sprintf(ctemp, "0%d", i);
else
sprintf(ctemp, "%d", i);
tempMinute[1]->AddEntry(ctemp, i);
}
tempMinute[1]->Resize(50,22);
tempMinute[1]->Select(0);
fH1->AddFrame(tempMinute[1], f0centery);
 
// End second
lab = new TGLabel(fH1, " Second: ");
fH1->AddFrame(lab, f0centery);
tempSecond[1] = new TGComboBox(fH1, 200);
for(int i = 0; i < 60; i++)
{
if(i < 10)
sprintf(ctemp, "0%d", i);
else
sprintf(ctemp, "%d", i);
tempSecond[1]->AddEntry(ctemp, i);
}
tempSecond[1]->Resize(50,22);
tempSecond[1]->Select(0);
fH1->AddFrame(tempSecond[1], f0centery);
 
// Get start time from file
lab = new TGLabel(fH1, " ");
fH1->AddFrame(lab, f0centery);
tempFile[1] = new TGTextButton(fH1, "Get from file...");
tempFile[1]->SetTextJustify(36);
tempFile[1]->SetWrapLength(-1);
tempFile[1]->Resize(100,22);
fH1->AddFrame(tempFile[1], f0centery);
 
fG1->AddFrame(fH1, f2);
// Start and stop time ------------------------
// Control buttons
fH2 = new TGHorizontalFrame(fG1, subgroup[0], 30);
fH1 = new TGHorizontalFrame(fH2, subgroup[0], 30);
updateTemp = new TGTextButton(fH1, "Update");
updateTemp->SetTextJustify(36);
updateTemp->SetWrapLength(-1);
updateTemp->Resize(80,22);
fH1->AddFrame(updateTemp, f0);
 
exportTemp = new TGTextButton(fH1, "Export");
exportTemp->SetTextJustify(36);
exportTemp->SetWrapLength(-1);
exportTemp->Resize(80,22);
fH1->AddFrame(exportTemp, f0);
 
/* closeTemp = new TGTextButton(fH1, "Close");
closeTemp->SetTextJustify(36);
closeTemp->SetWrapLength(-1);
closeTemp->Resize(80,22);
fH1->AddFrame(closeTemp, f0);*/
fH2->AddFrame(fH1, f0centerx);
 
fG1->AddFrame(fH2, f2);
mdiFrame->AddFrame(fG1, f1);
mdiFrame->SetMdiHints(kMdiMinimize | kMdiMaximize | kMdiClose);
mdiFrame->SetWindowName("Fieldpoint FP RTD 122 temperature sensor");
mdiFrame->MapSubwindows();
mdiFrame->Layout();
mdiFrame->Move(1*((winWidth/12)-5)+10,(int)(1*((winHeight/12)-5)));
 
// Action connections
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)");
// closeTemp->Connect("Clicked()", "TGAppMainFrame", this, "UpdateTempPlot()");
}
// Fieldpoint pane -------------------------------------------------------------------------
}
 
//---------------------------------------------------------------
// Closing the main application window and checking the about information
 
void TGAppMainFrame::CloseWindow()
/lab/sipmscan/trunk/windowed_test.h
1,13 → 1,17
#ifndef _windowedtest_h_
#define _windowedtest_h_
 
#define debug 1
#define winWidth 1200
#define winHeight 800
#define debug 0
#define winWidth 1240
#define winHeight 900
#define WINDOW_NAME "CAMAC/MPOD/4MM DAQ software"
#define BSIZE 10000
#define histname "hdata"
 
#include <time.h>
 
//int debugSig = 0;
 
enum EMenuIds {
M_FILE_NEW,
// M_FILE_CLOSE,
22,7 → 26,10
M_ANALYSIS_FITSEL,
M_ANALYSIS_INTEGX,
M_ANALYSIS_INTEGY,
M_ANALYSIS_PHOTMU,
 
M_TOOLS_FIELDPOINT,
 
M_WINDOW_HOR,
M_WINDOW_VERT,
 
29,4 → 36,7
M_HELP_ABOUT
};
 
// Function that transforms timestamp to local time
void GetTime(int intime, char *outtime);
 
#endif