]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - ITS/AliITSOnlineSPDphys.cxx
For Pythia with tune don't switch off MI in ConfigHeavyFlavor
[u/mrichter/AliRoot.git] / ITS / AliITSOnlineSPDphys.cxx
index 635211a2c3aa32c07d080f5abc277bfddfc6e8bb..64e833ec0424d53d7b68be7b8d0331d2778d6e24 100644 (file)
@@ -9,13 +9,12 @@
 ////////////////////////////////////////////////////////////
 
 #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),
@@ -26,21 +25,43 @@ AliITSOnlineSPDphys::AliITSOnlineSPDphys(const Char_t *fileName) :
   // 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) {
+
+  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*/) :
@@ -74,7 +95,8 @@ AliITSOnlineSPDphys::~AliITSOnlineSPDphys() {
     }
     fFile->Delete("AliITSOnlineSPDphysInfo;*");
     fFile->WriteTObject(fPhysInfo, "AliITSOnlineSPDphysInfo");
-    fFile->Close();
+  }
+  if (fFile!=NULL) {
     delete fFile;
   }
 }