Hi there,
I have the following code, which should bring up a window with an image whilest
calculations are happening in the background, then I want the window to close
once all calculations are finished, the problem is the window opens AFTER the
calculations, can anyone help?
p.s I am fairly new to ROOT, so that's why I'm using a TPictButton, because I
can't understand the TGPicture syntax
{
#include <fstream.h>
/////////////////////////////////////////////////
// Reset ROOT and run all calculations if needed
/////////////////////////////////////////////////
gROOT->Reset("a");
gROOT->LoadMacro("func.C");
gROOT->LoadMacro("dialogs.C");
ifstream data,data2,data3;
char selection;
int valid=0;
data.open("output_scp.dat", ios::in);
if(data.fail())
{
gROOT->Macro("calc.C");
data.open("output_scp.dat", ios::nocreate);
data2.open("output_ocp.dat", ios::nocreate);
data3.open("output_linear.dat", ios::nocreate);
}
data2.open("output_ocp.dat", ios::in);
if(data2.fail())
{
gROOT->Macro("calc.C");
data.open("output_ocp.dat", ios::nocreate);
data2.open("output_scp.dat", ios::nocreate);
data3.open("output_linear.dat", ios::nocreate);
}
data3.open("output_linear.dat", ios::in);
if(data3.fail())
{
gROOT->Macro("calc.C");
data.open("output_ocp.dat", ios::nocreate);
data2.open("output_scp.dat", ios::nocreate);
data3.open("output_linear.dat", ios::nocreate);
}
if (!data.fail()&&!data2.fail()&&!data3.fail())
{
char reply;
new ReuseDialog(valid);
if (valid==1)
{
gROOT->Macro("calc.C");
data.close();
data2.close();
data3.close();
data.open("output_ocp.dat", ios::nocreate);
data2.open("output_scp.dat", ios::nocreate);
data3.open("output_linear.dat", ios::nocreate);
}
}
/////////////////////////////////////////////////
// Declarations
/////////////////////////////////////////////////
ifstream param, blue;
Int_t p,q,i,j;
Double_t min, max, temp;
param.open("param.dat", ios::nocreate);
blue.open("shift.dat", ios::nocreate);
param >> selection>>p >> q >>temp>>min>>max;
// min and max are the rough estimates entered by the user +/- 2.5nm
// next two lines correct these back to the original estimates
min=(1.240472782e3/((1.240472782e3/min)+2.5));
max=(1.240472782e3/((1.240472782e3/max)-2.5));
param.close();
const Int_t x=p,y=q;
Double_t OD_scp[x][y], OD_ocp[x][y],OD_scp_r[x][y],
OD_ocp_r[x][y],DTS_scp[x][y],
DTS_ocp[x][y],DTS_scp_r[x][y], DTS_ocp_r[x][y],energy[x],time[y], weight[x],
binsenergy[x+1], binstime[y+1];
Double_t
_bleach_LH_OCP[y],_bleach_LH_SCP[y],_bleach_HH_OCP[y],_bleach_HH_SCP[y],
OD_scp_ref[x][y],OD_scp_ref_r[x][y],DTS_scp_ref[x][y],DTS_scp_ref_r[x][y],
_blueshift_LH_OCP[y],_blueshift_LH_SCP[y],_blueshift_HH_OCP[y],_blueshift_HH_SCP
[y],
HH_blueshift_max=0,LH_blueshift_max=0,HH_bleach_max=0,LH_bleach_max=0,
HH_blueshift_min=0,LH_blueshift_min=0,HH_bleach_min=0,LH_bleach_min=0;
TH2F *h;
TH2F *hs;
TH2F *hl;
TH1D *hp;
TH1D *hps;
TH1D *hpl;
TH1D *hp2;
TPad *pad2;
TPad *pad3;
TPad *pad4;
TPad *pad5;
TPad *pad6;
TPad *pad7;
TGraph *Bleach_LH_OCP;
TGraph *Bleach_HH_OCP;
TGraph *Bleach_LH_SCP;
TGraph *Bleach_HH_SCP;
TGraph *Blueshift_LH_OCP;
TGraph *Blueshift_HH_OCP;
TGraph *Blueshift_LH_SCP;
TGraph *Blueshift_HH_SCP;
TSlider *xslider;
TSlider *xslider2;
TSlider *xslider3;
TSlider *xslider4;
TSlider *xslide;
TPaveText *point;
const char *file;
TControlBar *bar;
TCanvas *blue_blea;
TCanvas *MyC;
TGCheckButton *fC[2];
TGTransientFrame *fMain;
TGPictureButton *fPictButton;
TGGroupFrame *fG1;
TGLayoutHints *fL3;
fMain = new TGTransientFrame(gClient->GetRoot(), fMain, 100, 200);
fMain->ChangeOptions((fMain->GetOptions() & ~kVerticalFrame) |
kHorizontalFrame);
fPictButton = new TGPictureButton(fMain, gClient->GetPicture("loading.xpm"));
fMain->Resize(fPictButton->GetDefaultWidth(), fMain->GetDefaultHeight());
fMain->MapSubwindows();
fMain->SetWindowName("Loading");
fMain->SetWMSize(300,135);
fMain->MapWindow();
fMain->Move(300,100);
/////////////////////////////////////////////////
// Read in Files
/////////////////////////////////////////////////
for(j=0;j<q;j++)
{
for(i=0;i<p;i++)
{
data >>
energy[i]>>time[j]>>OD_scp[i][j];//>>OD_scp_r[i][j]>>DTS_scp[i][j]>>DTS_scp_r[i]
[j];
data2 >>
energy[i]>>time[j]>>OD_ocp[i][j];//>>OD_ocp_r[i][j]>>DTS_ocp[i][j]>>DTS_ocp_r[i]
[j];
data3 >>
energy[i]>>time[j]>>OD_scp_ref[i][j];//>>OD_scp_ref_r[i][j]>>DTS_scp_ref[i][j]>>
DTS_scp_ref_r[i][j];
binsenergy[i] = energy[i];
binstime[j] = time[j];
}
blue >>
time[j]>>_bleach_LH_OCP[j]>>_bleach_LH_SCP[j]>>_bleach_HH_OCP[j]>>_bleach_HH_SCP
[j];
blue >>
_blueshift_LH_OCP[j]>>_blueshift_LH_SCP[j]>>_blueshift_HH_OCP[j]>>_blueshift_HH_
SCP[j];
////////////////////////////////////////////////
// Find max and min values for axis scale
////////////////////////////////////////////////
if (_blueshift_LH_OCP[j]>LH_blueshift_max)
LH_blueshift_max=_blueshift_LH_OCP[j];
if (_blueshift_LH_SCP[j]>LH_blueshift_max)
LH_blueshift_max=_blueshift_LH_SCP[j];
if (_blueshift_HH_OCP[j]>HH_blueshift_max)
HH_blueshift_max=_blueshift_HH_OCP[j];
if (_blueshift_HH_SCP[j]>HH_blueshift_max)
HH_blueshift_max=_blueshift_HH_SCP[j];
if (_bleach_LH_OCP[j]>LH_bleach_max)
LH_bleach_max=_bleach_LH_OCP[j];
if (_bleach_LH_SCP[j]>LH_bleach_max)
LH_bleach_max=_bleach_LH_SCP[j];
if (_bleach_HH_OCP[j]>HH_bleach_max)
HH_bleach_max=_bleach_HH_OCP[j];
if (_bleach_HH_SCP[j]>HH_bleach_max)
HH_bleach_max=_bleach_HH_SCP[j];
if (_blueshift_LH_OCP[j]<LH_blueshift_min)
LH_blueshift_min=_blueshift_LH_OCP[j];
if (_blueshift_LH_SCP[j]<LH_blueshift_min)
LH_blueshift_min=_blueshift_LH_SCP[j];
if (_blueshift_HH_OCP[j]<LH_blueshift_min)
HH_blueshift_min=_blueshift_HH_OCP[j];
if (_blueshift_HH_SCP[j]<LH_blueshift_min)
HH_blueshift_min=_blueshift_HH_SCP[j];
if (_bleach_LH_OCP[j]<LH_bleach_min)
LH_bleach_min=_bleach_LH_OCP[j];
if (_bleach_LH_SCP[j]<LH_bleach_min)
LH_bleach_min=_bleach_LH_SCP[j];
if (_bleach_HH_OCP[j]<HH_bleach_min)
HH_bleach_min=_bleach_HH_OCP[j];
if (_bleach_HH_SCP[j]<HH_bleach_min)
HH_bleach_min=_bleach_HH_SCP[j];
}
// since ROOT uses histograms, you must define the bins if they aren't
// equidistant, the next two set the bin values to the data points
binsenergy[x]=binsenergy[x-1]+((binsenergy[x-1]-binsenergy[0])/p);
binstime[y]=binstime[y-1]+((binstime[y-1]-binstime[0])/q);
///////////////////////////////////////////////////
// create contour plots
///////////////////////////////////////////////////
h = new TH2F("histo1", "", p, binsenergy, q, binstime);
hs = new TH2F("histo2", "", p, binsenergy, q, binstime);
hl = new TH2F("histo3", "", p, binsenergy, q, binstime);
for(j=0; j<q; j++)
for(i=0;i<p;i++)
{
h->Fill(energy[i], time[j], OD_ocp[i][j]);
hs->Fill(energy[i], time[j], OD_scp[i][j]);
hl->Fill(energy[i], time[j], OD_scp_ref[i][j]);
}
///////////////////////////////////////////////////
// Generate print Control Panel
///////////////////////////////////////////////////
bar = new TControlBar("vertical", "Controls",750,10);
bar->AddButton("Display Contour Plot","display_OCP_contour()", "Click To
Display Contour Plot");
bar->AddButton("Display Blueshift and Bleaching","display_blue_blea()", "Click
To Display Blueshift and Bleaching");
bar->AddButton("","","");
bar->AddButton("Quit",".q", "Click Here To End Your ROOT Session");
bar->Show();
print_options();
data.close();
blue.close();
}
This archive was generated by hypermail 2b29 : Tue Jan 01 2002 - 17:50:58 MET