]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - ITS/AliITSOnlineSPDscanSingle.cxx
Savannah bug 54788. Removed tolerance on detector's size when searching for P-N cross...
[u/mrichter/AliRoot.git] / ITS / AliITSOnlineSPDscanSingle.cxx
index d937f72cf68723164d744a6a8908c0b06641634d..ffcd197d313cf47e9e52caf588de5178f1a7f07e 100644 (file)
@@ -1,32 +1,72 @@
+/**************************************************************************
+ * Copyright(c) 2007-2009, ALICE Experiment at CERN, All rights reserved. *
+ *                                                                        *
+ * Author: The ALICE Off-line Project.                                    *
+ * Contributors are mentioned in the code where appropriate.              *
+ *                                                                        *
+ * Permission to use, copy, modify and distribute this software and its   *
+ * documentation strictly for non-commercial purposes is hereby granted   *
+ * without fee, provided that the above copyright notice appears in all   *
+ * copies and that both the copyright notice and this permission notice   *
+ * appear in the supporting documentation. The authors make no claims     *
+ * about the suitability of this software for any purpose. It is          *
+ * provided "as is" without express or implied warranty.                  *
+ **************************************************************************/
+
+/* $Id$ */
+
 ////////////////////////////////////////////////////////////
 // Author: Henrik Tydesjo                                 //
 // Interface class to the containers of an online scan    //
 // with only one step.                                    //
 ////////////////////////////////////////////////////////////
 
+
 #include <TFile.h>
 #include "AliITSOnlineSPDscanSingle.h"
 #include "AliITSOnlineSPDscanInfo.h"
 
-ClassImp(AliITSOnlineSPDscanSingle)
-
-AliITSOnlineSPDscanSingle::AliITSOnlineSPDscanSingle(Char_t *fileName) {
+AliITSOnlineSPDscanSingle::AliITSOnlineSPDscanSingle(const Char_t *fileName, Bool_t readFromGridFile) {
   // constructor
-  sprintf(fFileName,"%s",fileName);
+  fFileName=fileName;
+  fModified=kFALSE;
+  fInfoModified=kFALSE;
   // look for a previously saved info object 
   // (if file not found create a new one and return, else read)
-  FILE* fp0 = fopen(fFileName, "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: AliITSOnlineSPDscan: File %s not found! Creating 'test999.root' file instead\n",fFileName.Data());
+      // create default empty file:
+      fFileName = "test999.root";
+      fScanInfo = new AliITSOnlineSPDscanInfo();
+      fInfoModified=kTRUE;
+      fFile = new TFile(fFileName.Data(), "RECREATE");
+      fWrite=kTRUE;
+    }
+    else { // read from file (grid or local)
+      fWrite=kFALSE;
+      fFile->GetObject("AliITSOnlineSPDscanInfo", fScanInfo);
+    }
+  }
+  else { // create new local file
     fScanInfo = new AliITSOnlineSPDscanInfo();
-    fFile = new TFile(fFileName, "RECREATE");
+    fInfoModified=kTRUE;
+    fFile = new TFile(fFileName.Data(), "RECREATE");
     fWrite=kTRUE;
   }
-  else {
-    fclose(fp0);
-    fFile = new TFile(fFileName, "READ");
-    fWrite=kFALSE;
-    fFile->GetObject("AliITSOnlineSPDscanInfo", fScanInfo);
-  }
+
   Init();
 }
 AliITSOnlineSPDscanSingle::~AliITSOnlineSPDscanSingle() {}