Commit 7b577d55 authored by Jérémie Dudouet's avatar Jérémie Dudouet
Browse files

Add corrections for online reading

parent 307a2be2
Pipeline #36348 passed with stage
in 6 minutes and 36 seconds
......@@ -39,6 +39,11 @@ int main(int argc, char **argv)
}
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();
fxInterruptHandler->Add();
......@@ -55,7 +60,7 @@ int main(int argc, char **argv)
TApplication::NeedGraphicsLibs();
gApplication->InitializeGraphics();
fFSMainWindow = new FSMainWindow(gClient->GetRoot(), 800, 600 );
fFSMainWindow = new FSMainWindow(gClient->GetRoot(), 800, 600, RunInit );
theApp->Run(false);
if (fFSMainWindow) {
......
......@@ -30,9 +30,12 @@
/// 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)
{
fLastRun = RunInit;
if(fLastRun.Atoi()>0) INFO_MESS<<"Starting using run "<<fLastRun<<" as initializer"<<ENDL;
ReadLUT();
ReadCal();
InitParameters();
......@@ -539,31 +542,52 @@ TString FSMainWindow::GetStdoutFromCommand(string cmd)
void FSMainWindow::ReadHistograms()
{
const char* FIPPSSpy_version = (char*) FIPPSSpy_VERSION;
TString DataDir = getenv("FSRawDataDir");
TString Command = Form("ls -ltr %s | grep ^- | tail -1 | awk '{ print $(NF) }'",DataDir.Data());
TString Run = GetStdoutFromCommand(Command.Data());
TString FileName = Form("%s/%s",getenv("FSRawDataDir"),Run.Data());
TString FileName;
TString Run;
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());
if(!file){
ERR_MESS<<FileName<<" not found"<<ENDL;
return;
}
else INFO_MESS<<"Reading run: "<<Run<<":"<<ENDL;
else INFO_MESS<<"Reading run: "<<Run<<ENDL;
struct stat result;
if(stat(FileName.Data(), &result)==0) {
fCurrentDate = Form("%s",asctime(localtime(&result.st_mtime)));
INFO_MESS<<"Run date: "<<fCurrentDate<<ENDL;
TString date = Form("%s",asctime(localtime(&result.st_mtime)));
date.ReplaceAll("\n","");
INFO_MESS<<"Run date: "<<date<<ENDL;
fCurrentDate = date;
}
else {
WARN_MESS<<"Unable to get file time modification"<<ENDL;
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;
for (itr = fListOfSpectra.begin(); itr != fListOfSpectra.end(); ++itr) {
TH1I *h = itr->second;
......@@ -576,7 +600,7 @@ void FSMainWindow::ReadHistograms()
Buffer=line;
Buffer.ReplaceAll("FIPPintern ","");
while(Buffer.EndsWith(" ")) Buffer.Remove(Buffer.Length()-1);
fCurrentDate = Buffer;
//fCurrentDate = Buffer;
TObjArray *arr;
......@@ -642,6 +666,10 @@ void FSMainWindow::ReadHistograms()
fListOfSpectra[id]->SetEntries(fListOfSpectra[id]->Integral());
}
file.close();
fLastRun = Run;
SetWindowName(Form("FIPPSSpy v%s: Run %s - %s", FIPPSSpy_version,fLastRun.Data(),fCurrentDate.Data()));
}
void FSMainWindow::DoCalMode(Bool_t on)
......
......@@ -88,9 +88,11 @@ private:
Int_t fCalOrder = 0;
Color_t fColor[48];
TString fLastRun="";
public:
FSMainWindow(const TGWindow *p, UInt_t w, UInt_t h);
FSMainWindow(const TGWindow *p, UInt_t w, UInt_t h, TString RunInit="");
~FSMainWindow();
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