]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - RAW/AliMDC.cxx
converted multiplicity selector into task
[u/mrichter/AliRoot.git] / RAW / AliMDC.cxx
index 44401e418970812740870218b626dafb4021ef42..06867a9ebfcdf5394a33868263ca03a380067a8c 100644 (file)
 #include <TSystem.h>
 #include <TROOT.h>
 #include <TStopwatch.h>
+#include <TPluginManager.h>
 
 #include <sys/uio.h>
 #ifdef USE_EB
 #include "libDateEb.h"
 #endif
 
+#include "AliMDC.h"
+
 #include <AliLog.h>
-#include <AliESD.h>
+#include <AliESDEvent.h>
 
 #include "AliRawEvent.h"
 #include "AliRawEventHeaderBase.h"
@@ -73,7 +76,7 @@
 #include "AliRawEventTag.h"
 #include "AliFilter.h"
 
-#include "AliMDC.h"
+
 
 ClassImp(AliMDC)
 
@@ -83,7 +86,8 @@ const char* const AliMDC::fgkFilterName[kNFilters] = {"AliHoughFilter"};
 
 //______________________________________________________________________________
 AliMDC::AliMDC(Int_t compress, Bool_t deleteFiles, EFilterMode filterMode, 
-              Double_t maxSizeTagDB, const char* fileNameTagDB) :
+              Double_t maxSizeTagDB, const char* fileNameTagDB,
+              const char *guidFileFolder) :
   fEvent(new AliRawEvent),
   fESD(NULL),
   fStats(NULL),
@@ -97,7 +101,8 @@ AliMDC::AliMDC(Int_t compress, Bool_t deleteFiles, EFilterMode filterMode,
   fStop(kFALSE),
   fIsTagDBCreated(kFALSE),
   fMaxSizeTagDB(maxSizeTagDB),
-  fFileNameTagDB(fileNameTagDB)
+  fFileNameTagDB(fileNameTagDB),
+  fGuidFileFolder(guidFileFolder)
 {
   // Create MDC processor object.
   // compress is the file compression mode.
@@ -111,24 +116,30 @@ AliMDC::AliMDC(Int_t compress, Bool_t deleteFiles, EFilterMode filterMode,
   // tag DB and then fileNameTagDB is the directory name for the tag DB.
   // Otherwise fileNameTagDB is the file name of the tag DB. If it is NULL
   // no tag DB will be created.
+  // Optional 'guidFileFolder' specifies the folder in which *.guid files
+  // will be stored. In case this option is not given, the *.guid files
+  // will be written to the same folder as the raw-data files.
  
+  // This line is needed in case of a stand-alone application w/o
+  // $ROOTSYS/etc/system.rootrc file
+  gROOT->GetPluginManager()->AddHandler("TVirtualStreamerInfo",
+                                       "*",
+                                       "TStreamerInfo",
+                                       "RIO",
+                                       "TStreamerInfo()");
 
   if (fFilterMode != kFilterOff) {
-    fESD = new AliESD;
+    fESD = new AliESDEvent();
   }
 
-// Tag DB is now created at the point where the header version is
-// already known
-//   if (fileNameTagDB) {
-//     if (maxSizeTagDB > 0) {
-//       fTagDB = new AliTagDB(fEvent->GetHeader(), NULL);
-//       fTagDB->SetMaxSize(maxSizeTagDB);
-//       fTagDB->SetFS(fileNameTagDB);
-//       fTagDB->Create();
-//     } else {
-//       fTagDB = new AliTagDB(fEvent->GetHeader(), fileNameTagDB);
-//     }
-//   }
+  // Create the guid files folder if it does not exist
+  if (!fGuidFileFolder.IsNull()) {
+    gSystem->ResetErrno();
+    gSystem->MakeDirectory(fGuidFileFolder.Data());
+    if (gSystem->GetErrno() && gSystem->GetErrno() != EEXIST) {
+      SysError("AliMDC", "mkdir %s", fGuidFileFolder.Data());
+    }
+  }
 
   // install SIGUSR1 handler to allow clean interrupts
   gSystem->AddSignalHandler(new AliMDCInterruptHandler(this));
@@ -184,17 +195,28 @@ Int_t AliMDC::Open(EWriteMode mode, const char* fileName,
     fRawDB = new AliRawDB(fEvent, fESD, fCompress, fileName);
   fRawDB->SetDeleteFiles(fDeleteFiles);
 
+  if (fRawDB->IsZombie()) {
+    delete fRawDB;
+    fRawDB = NULL;
+    return -1;
+  }
+
   if (fileName == NULL) {
     fRawDB->SetMaxSize(maxFileSize);
     fRawDB->SetFS(fs1, fs2);
-    fRawDB->Create();
+    if (!fRawDB->Create()) {
+      delete fRawDB;
+      fRawDB = NULL;
+      return -1;
+    }
   }
 
-  if (fRawDB->IsZombie()) {
+  if (!fRawDB->WriteGuidFile(fGuidFileFolder)) {
     delete fRawDB;
     fRawDB = NULL;
-    return -1;
+    return -2;
   }
+
   Info("Open", "Filling raw DB %s\n", fRawDB->GetDBName());
 
   // Create AliStats object
@@ -364,14 +386,15 @@ Int_t AliMDC::ProcessEvent(void* event, Bool_t isIovecArray)
   // Create Tag DB here only after the raw data header
   // version was already identified
   if (!fIsTagDBCreated) {
-    if (fFileNameTagDB) {
+    if (!fFileNameTagDB.IsNull()) {
       if (fMaxSizeTagDB > 0) {
        fTagDB = new AliTagDB(fEventTag, NULL);
        fTagDB->SetMaxSize(fMaxSizeTagDB);
-       fTagDB->SetFS(fFileNameTagDB);
-       fTagDB->Create();
+       fTagDB->SetFS(fFileNameTagDB.Data());
+       if (!fTagDB->Create()) return kErrTagFile;
       } else {
-       fTagDB = new AliTagDB(fEventTag, fFileNameTagDB);
+       fTagDB = new AliTagDB(fEventTag, fFileNameTagDB.Data());
+       if (fTagDB->IsZombie()) return kErrTagFile;
       }
     }
     fIsTagDBCreated = kTRUE;
@@ -545,7 +568,7 @@ Int_t AliMDC::Run(const char* inputFile, Bool_t loop,
        eventSize = 2 * hdr->GetEventSize();
        event = new char[eventSize];
       }
-      memcpy(event, hdr->HeaderBaseBegin(), hdr->HeaderBaseSize());
+      memcpy(event, header.HeaderBaseBegin(), header.HeaderBaseSize());
       memcpy(event+hdr->HeaderBaseSize(), hdr->HeaderBegin(), hdr->HeaderSize());
       if (hdr->GetExtendedDataSize() != 0)
        memcpy(event+hdr->HeaderBaseSize()+hdr->HeaderSize(),