////////////////////////////////////////////////////////////
#include <math.h>
-
#include <TFile.h>
#include "AliITSOnlineSPDphys.h"
#include "AliITSOnlineSPDphysInfo.h"
#include "AliITSOnlineSPDHitArray.h"
-AliITSOnlineSPDphys::AliITSOnlineSPDphys(const Char_t *fileName) :
+AliITSOnlineSPDphys::AliITSOnlineSPDphys(const Char_t *fileName, Bool_t readFromGridFile) :
fFile(NULL),
fWrite(kFALSE),
fModified(kFALSE),
// constructor, open file for reading or writing
// look for a previously saved info object
// (if file not found create a new one and return, else read)
- FILE* fp0 = fopen(fFileName.Data(), "r");
- if (fp0 == NULL) {
+
+ for(Int_t ihs =0; ihs<6; ihs++) fHitArray[ihs]=0x0;
+
+ Bool_t bRead = readFromGridFile;
+
+ if (!bRead) {
+ FILE* fp0 = fopen(fFileName.Data(), "r");
+ if (fp0 != NULL) {
+ bRead=kTRUE;
+ fclose(fp0);
+ }
+ }
+
+ if (bRead) { // open file for reading
+ fFile = TFile::Open(fFileName.Data(), "READ");
+ if (fFile==NULL) { // grid file not found, create new local default file
+ printf("ERROR: AliITSOnlineSPDphys: File %s not found! Creating 'test999.root' file instead\n",fFileName.Data());
+ // create default empty file:
+ fFileName = "test999.root";
+ fPhysInfo = new AliITSOnlineSPDphysInfo();
+ fInfoModified=kTRUE;
+ fFile = new TFile(fFileName.Data(), "RECREATE");
+ fWrite=kTRUE;
+ InitHitmap();
+ }
+ else { // read from file (grid or local)
+ fWrite=kFALSE;
+ fFile->GetObject("AliITSOnlineSPDphysInfo", fPhysInfo);
+ ReadHitmap();
+ }
+ }
+ else { // create new local file
fPhysInfo = new AliITSOnlineSPDphysInfo();
fInfoModified=kTRUE;
fFile = new TFile(fFileName.Data(), "RECREATE");
fWrite=kTRUE;
InitHitmap();
}
- else {
- fclose(fp0);
- fFile = new TFile(fFileName.Data(), "READ");
- fWrite=kFALSE;
- fFile->GetObject("AliITSOnlineSPDphysInfo", fPhysInfo);
- ReadHitmap();
- }
+
}
AliITSOnlineSPDphys::AliITSOnlineSPDphys(const AliITSOnlineSPDphys& /*phys*/) :
fPhysInfo(NULL),
fFileName(".")
{
+ for(Int_t i=0; i<6; i++) fHitArray[i]=0x0;
printf("This object should not be copied!");
}
UInt_t AliITSOnlineSPDphys::GetNrEvents() const {
return fPhysInfo->GetNrEvents();
}
+
+