]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - HLT/BASE/AliHLTOfflineInterface.cxx
Protection instead fatal in case of absent galice.root or Kinematics.root
[u/mrichter/AliRoot.git] / HLT / BASE / AliHLTOfflineInterface.cxx
index 0d1c3c6aee90df93e5933a6175487fb0f27e8ba0..5d89811e783221523fa468593d3eb71b1522bfaf 100644 (file)
@@ -1,10 +1,11 @@
 // $Id$
 
 /**************************************************************************
- * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
+ * This file is property of and copyright by the ALICE HLT Project        * 
+ * ALICE Experiment at CERN, All rights reserved.                         *
  *                                                                        *
- * Authors: Matthias Richter <Matthias.Richter@ift.uib.no>                *
- *          for The ALICE Off-line Project.                               *
+ * Primary Authors: Matthias Richter <Matthias.Richter@ift.uib.no>        *
+ *                  for The ALICE HLT Project.                            *
  *                                                                        *
  * Permission to use, copy, modify and distribute this software and its   *
  * documentation strictly for non-commercial purposes is hereby granted   *
@@ -31,7 +32,8 @@ AliHLTOfflineInterface::AliHLTOfflineInterface()
   :
   fpRunLoader(NULL),
   fpRawReader(NULL),
-  fpESD(NULL)
+  fpESD(NULL),
+  fpNext(NULL)
 {
   // see header file for class documentation
   // or
@@ -40,8 +42,9 @@ AliHLTOfflineInterface::AliHLTOfflineInterface()
   // visit http://web.ift.uib.no/~kjeks/doc/alice-hlt
 }
 
-TList AliHLTOfflineInterface::fgList;
-TObjLink* AliHLTOfflineInterface::fgCurrentLnk=NULL;
+AliHLTOfflineInterface* AliHLTOfflineInterface::fAnchor=NULL;
+AliHLTOfflineInterface* AliHLTOfflineInterface::fCurrent=NULL;
+int AliHLTOfflineInterface::fCount=0;
 AliRunLoader* AliHLTOfflineInterface::fgpRunLoader=NULL;
 AliRawReader* AliHLTOfflineInterface::fgpRawReader=NULL;
 
@@ -49,28 +52,11 @@ AliHLTOfflineInterface::AliHLTOfflineInterface(AliRunLoader* pRunLoader, AliRawR
   :
   fpRunLoader(pRunLoader),
   fpRawReader(pRawReader),
-  fpESD(NULL)
+  fpESD(NULL),
+  fpNext(NULL)
 {
 }
 
-AliHLTOfflineInterface::AliHLTOfflineInterface(const AliHLTOfflineInterface&)
-  :
-  TObject(),
-  fpRunLoader(NULL),
-  fpRawReader(NULL),
-  fpESD(NULL)
-{
-  // see header file for class documentation
-  //HLTFatal("copy constructor untested");
-}
-
-AliHLTOfflineInterface& AliHLTOfflineInterface::operator=(const AliHLTOfflineInterface&)
-{ 
-  // see header file for class documentation
-  //HLTFatal("assignment operator untested");
-  return *this;
-}
-
 AliHLTOfflineInterface::~AliHLTOfflineInterface()
 {
 }
@@ -85,13 +71,13 @@ AliRawReader* AliHLTOfflineInterface::GetRawReader() const
   return fpRawReader!=NULL?fpRawReader:fgpRawReader;
 }
 
-int AliHLTOfflineInterface::SetESD(Int_t eventNo, AliESD* pESD)
+int AliHLTOfflineInterface::SetESD(Int_t /*eventNo*/, AliESDEvent* pESD)
 {
   fpESD=pESD;
   return 0;
 }
 
-AliESD* AliHLTOfflineInterface::GetESD() const
+AliESDEvent* AliHLTOfflineInterface::GetESD() const
 {
   return fpESD;
 }
@@ -129,22 +115,21 @@ int AliHLTOfflineInterface::SetParamsToComponents(AliRunLoader* runLoader, AliRa
   int count=0;
   fgpRunLoader=runLoader;
   fgpRawReader=rawReader;
-  fgCurrentLnk=fgList.FirstLink();
-  while (fgCurrentLnk!=NULL) {
-    AliHLTOfflineInterface* pComponent=reinterpret_cast<AliHLTOfflineInterface*>(fgCurrentLnk->GetObject());
+  AliHLTOfflineInterface* pCurrent=fAnchor;
+  while (pCurrent!=NULL) {
     int iLocal=0;
-    if (pComponent) iLocal=pComponent->SetParams(runLoader, rawReader);
+    if (pCurrent) iLocal=pCurrent->SetParams(runLoader, rawReader);
     if (iLocal<0) {
       log.LoggingVarargs(kHLTLogWarning, "AliHLTOfflineInterface","SetParamsToComponents", __FILE__, __LINE__,
-                       "parameter initialization failed for component %p with result %d", pComponent, iLocal);
+                       "parameter initialization failed for component %p with result %d", pCurrent, iLocal);
       if (iResult>=0) iResult=iLocal;
     }
     count++;
-    fgCurrentLnk=fgCurrentLnk->Next();
+    pCurrent=pCurrent->fpNext;
   }
   if (iResult>=0) {
-      log.LoggingVarargs(kHLTLogInfo, "AliHLTOfflineInterface","SetParamsToComponents", __FILE__, __LINE__,
-                       "parameters set to %d offline interface component(s)", count);
+//       log.LoggingVarargs(kHLTLogInfo, "AliHLTOfflineInterface","SetParamsToComponents", __FILE__, __LINE__,
+//                     "parameters set to %d offline interface component(s)", count);
   }
   return iResult;
 }
@@ -153,38 +138,36 @@ int AliHLTOfflineInterface::ResetComponents()
 {
   // see header file for class documentation
   int iResult=0;
-  fgCurrentLnk=fgList.FirstLink();
-  while (fgCurrentLnk!=NULL) {
-    AliHLTOfflineInterface* pComponent=reinterpret_cast<AliHLTOfflineInterface*>(fgCurrentLnk->GetObject());
+  AliHLTOfflineInterface* pCurrent=fAnchor;
+  while (pCurrent!=NULL) {
     int iLocal=0;
-    if (pComponent) iLocal=pComponent->Reset();
+    if (pCurrent) iLocal=pCurrent->Reset();
     if (iLocal<0) {
       if (iResult>=0) iResult=iLocal;
     }
-    fgCurrentLnk=fgCurrentLnk->Next();
+    pCurrent=pCurrent->fpNext;
   }
   return iResult;
 }
 
-int AliHLTOfflineInterface::FillComponentESDs(int eventNo, AliRunLoader* runLoader, AliESD* esd)
+int AliHLTOfflineInterface::FillComponentESDs(int eventNo, AliRunLoader* runLoader, AliESDEvent* esd)
 {
   // see header file for class documentation
   int iResult=0;
-  fgCurrentLnk=fgList.FirstLink();
-  while (fgCurrentLnk!=NULL) {
-    AliHLTOfflineInterface* pComponent=reinterpret_cast<AliHLTOfflineInterface*>(fgCurrentLnk->GetObject());
+  AliHLTOfflineInterface* pCurrent=fAnchor;
+  while (pCurrent!=NULL) {
     int iLocal=0;
-    if (pComponent) {
-      pComponent->SetESD(eventNo, esd);
-      if (pComponent->GetRunLoader()!=runLoader) {
-       //HLTWarning("runLoader missmatch: component %p was reconstructed with runLoader %p, but got %p now", pComponent, pComponent->GetRunLoader(), runLoader);
+    if (pCurrent) {
+      pCurrent->SetESD(eventNo, esd);
+      if (pCurrent->GetRunLoader()!=runLoader) {
+       //HLTWarning("runLoader mismatch: component %p was reconstructed with runLoader %p, but got %p now", pCurrent, pCurrent->GetRunLoader(), runLoader);
       }
-      iLocal=pComponent->FillESD(eventNo, runLoader, esd);
+      iLocal=pCurrent->FillESD(eventNo, runLoader, esd);
     }
     if (iLocal<0) {
       if (iResult>=0) iResult=iLocal;
     }
-    fgCurrentLnk=fgCurrentLnk->Next();
+    pCurrent=pCurrent->fpNext;
   }
   return iResult;
 }
@@ -193,10 +176,13 @@ int AliHLTOfflineInterface::Register(AliHLTOfflineInterface* me)
 {
   // see header file for function documentation
   int iResult=0;
-  if (fgList.FindObject(me->GetName())==NULL) {
-    fgList.Add(me);
+  if (fAnchor==NULL) {
+    fAnchor=me;
   } else {
+    me->fpNext=fAnchor;
+    fAnchor=me;
   }
+  fCount++;
   return iResult;
 }
 
@@ -204,9 +190,20 @@ int AliHLTOfflineInterface::Unregister(AliHLTOfflineInterface* me)
 {
   // see header file for function documentation
   int iResult=0;
-  if (fgList.FindObject(me)!=NULL) {
-    fgList.Remove(me);
-  } else {
+  fCurrent=NULL;
+  AliHLTOfflineInterface* prev=NULL;
+  AliHLTOfflineInterface* handler=fAnchor;
+  while (handler!=NULL && handler!=me) {
+    prev=handler;
+    handler=handler->fpNext;
+  }
+  if (handler) {
+    if (prev==NULL) {
+      fAnchor=handler->fpNext;
+    } else {
+      prev->fpNext=handler->fpNext;
+    }
+    fCount--;
   }
   return iResult;
 }