Commit 0ee77083 authored by Jérémie Dudouet's avatar Jérémie Dudouet
Browse files

Add corrections for online reading

parent 792044b7
...@@ -39,6 +39,11 @@ int main(int argc, char **argv) ...@@ -39,6 +39,11 @@ int main(int argc, char **argv)
} }
gEnv->SetValue("Gui.IconPath",Form("%s/icons:%s/icons",getenv("ROOTSYS"),getenv("gammaSoftware_DIR"))); gEnv->SetValue("Gui.IconPath",Form("%s/icons:%s/icons",getenv("ROOTSYS"),getenv("gammaSoftware_DIR")));
TString RunInit="";
if(argc > 1){
RunInit = argv[1];
}
TInterruptHandler *fxInterruptHandler = new TInterruptHandler(); TInterruptHandler *fxInterruptHandler = new TInterruptHandler();
fxInterruptHandler->Add(); fxInterruptHandler->Add();
...@@ -55,7 +60,7 @@ int main(int argc, char **argv) ...@@ -55,7 +60,7 @@ int main(int argc, char **argv)
TApplication::NeedGraphicsLibs(); TApplication::NeedGraphicsLibs();
gApplication->InitializeGraphics(); gApplication->InitializeGraphics();
fFSMainWindow = new FSMainWindow(gClient->GetRoot(), 800, 600 ); fFSMainWindow = new FSMainWindow(gClient->GetRoot(), 800, 600, RunInit );
theApp->Run(false); theApp->Run(false);
if (fFSMainWindow) { if (fFSMainWindow) {
......
...@@ -30,9 +30,12 @@ ...@@ -30,9 +30,12 @@
/// AGAPRO includes /// AGAPRO includes
FSMainWindow::FSMainWindow(const TGWindow *p, UInt_t w, UInt_t h) : FSMainWindow::FSMainWindow(const TGWindow *p, UInt_t w, UInt_t h, TString RunInit) :
TGMainFrame(p, w, h) TGMainFrame(p, w, h)
{ {
fLastRun = RunInit;
if(fLastRun.Atoi()>0) INFO_MESS<<"Starting using run "<<fLastRun<<" as initializer"<<ENDL;
ReadLUT(); ReadLUT();
ReadCal(); ReadCal();
InitParameters(); InitParameters();
...@@ -539,31 +542,52 @@ TString FSMainWindow::GetStdoutFromCommand(string cmd) ...@@ -539,31 +542,52 @@ TString FSMainWindow::GetStdoutFromCommand(string cmd)
void FSMainWindow::ReadHistograms() void FSMainWindow::ReadHistograms()
{ {
const char* FIPPSSpy_version = (char*) FIPPSSpy_VERSION;
TString DataDir = getenv("FSRawDataDir"); TString DataDir = getenv("FSRawDataDir");
TString Command = Form("ls -ltr %s | grep ^- | tail -1 | awk '{ print $(NF) }'",DataDir.Data()); TString FileName;
TString Run = GetStdoutFromCommand(Command.Data()); TString Run;
TString FileName = Form("%s/%s",getenv("FSRawDataDir"),Run.Data());
if(fLastRun.Atoi()==0){
TString Command = Form("ls -ltr %s | grep ^- | tail -1 | awk '{ print $(NF) }'",DataDir.Data());
Run = GetStdoutFromCommand(Command.Data());
Run.ReplaceAll(".lst","");
FileName = Form("%s/%s",getenv("FSRawDataDir"),Run.Data());
}
else {
bool ok = true;
Int_t Test=fLastRun.Atoi();
while(ok){
Test++;
FileName = Form("%s/%.06d",getenv("FSRawDataDir"),Test);
ok = gSystem->IsFileInIncludePath(FileName);
}
Test=Test-1;
Run=Form("%.06d",Test);
FileName = Form("%s/%s",getenv("FSRawDataDir"),Run.Data());
}
ifstream file(FileName.Data()); ifstream file(FileName.Data());
if(!file){ if(!file){
ERR_MESS<<FileName<<" not found"<<ENDL; ERR_MESS<<FileName<<" not found"<<ENDL;
return; return;
} }
else INFO_MESS<<"Reading run: "<<Run<<":"<<ENDL; else INFO_MESS<<"Reading run: "<<Run<<ENDL;
struct stat result; struct stat result;
if(stat(FileName.Data(), &result)==0) { if(stat(FileName.Data(), &result)==0) {
fCurrentDate = Form("%s",asctime(localtime(&result.st_mtime))); TString date = Form("%s",asctime(localtime(&result.st_mtime)));
INFO_MESS<<"Run date: "<<fCurrentDate<<ENDL; date.ReplaceAll("\n","");
INFO_MESS<<"Run date: "<<date<<ENDL;
fCurrentDate = date;
} }
else { else {
WARN_MESS<<"Unable to get file time modification"<<ENDL; WARN_MESS<<"Unable to get file time modification"<<ENDL;
fCurrentDate = "Undef"; fCurrentDate = "Undef";
SetWindowName(Form("FIPPSSpy v%s: Run %s - %s !! Disk not Available !!", FIPPSSpy_version,Run.Data(),fCurrentDate.Data()));
return;
} }
const char* FIPPSSpy_version = (char*) FIPPSSpy_VERSION;
SetWindowName(Form("FIPPSSpy v%s: Run %s - %s", FIPPSSpy_version,Run.Data(),fCurrentDate.ReplaceAll("\n","").Data()));
map<Int_t, TH1I*>::iterator itr; map<Int_t, TH1I*>::iterator itr;
for (itr = fListOfSpectra.begin(); itr != fListOfSpectra.end(); ++itr) { for (itr = fListOfSpectra.begin(); itr != fListOfSpectra.end(); ++itr) {
TH1I *h = itr->second; TH1I *h = itr->second;
...@@ -576,7 +600,7 @@ void FSMainWindow::ReadHistograms() ...@@ -576,7 +600,7 @@ void FSMainWindow::ReadHistograms()
Buffer=line; Buffer=line;
Buffer.ReplaceAll("FIPPintern ",""); Buffer.ReplaceAll("FIPPintern ","");
while(Buffer.EndsWith(" ")) Buffer.Remove(Buffer.Length()-1); while(Buffer.EndsWith(" ")) Buffer.Remove(Buffer.Length()-1);
fCurrentDate = Buffer; //fCurrentDate = Buffer;
TObjArray *arr; TObjArray *arr;
...@@ -642,6 +666,10 @@ void FSMainWindow::ReadHistograms() ...@@ -642,6 +666,10 @@ void FSMainWindow::ReadHistograms()
fListOfSpectra[id]->SetEntries(fListOfSpectra[id]->Integral()); fListOfSpectra[id]->SetEntries(fListOfSpectra[id]->Integral());
} }
file.close(); file.close();
fLastRun = Run;
SetWindowName(Form("FIPPSSpy v%s: Run %s - %s", FIPPSSpy_version,fLastRun.Data(),fCurrentDate.Data()));
} }
void FSMainWindow::DoCalMode(Bool_t on) void FSMainWindow::DoCalMode(Bool_t on)
......
...@@ -88,9 +88,11 @@ private: ...@@ -88,9 +88,11 @@ private:
Int_t fCalOrder = 0; Int_t fCalOrder = 0;
Color_t fColor[48]; Color_t fColor[48];
TString fLastRun="";
public: public:
FSMainWindow(const TGWindow *p, UInt_t w, UInt_t h); FSMainWindow(const TGWindow *p, UInt_t w, UInt_t h, TString RunInit="");
~FSMainWindow(); ~FSMainWindow();
void CloseWindow(); void CloseWindow();
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment