added abstract AliEsdManager to libHLTbase and implementation to libHLTrec
authorrichterm <richterm@f7af4fe6-9843-0410-8265-dc069ae4e863>
Wed, 11 Jun 2008 11:02:24 +0000 (11:02 +0000)
committerrichterm <richterm@f7af4fe6-9843-0410-8265-dc069ae4e863>
Wed, 11 Jun 2008 11:02:24 +0000 (11:02 +0000)
HLT/BASE/AliHLTEsdManager.cxx [new file with mode: 0644]
HLT/BASE/AliHLTEsdManager.h [new file with mode: 0644]
HLT/libHLTbase.pkg
HLT/libHLTrec.pkg
HLT/rec/AliHLTEsdManagerImplementation.cxx [moved from HLT/rec/AliHLTEsdManager.cxx with 90% similarity]
HLT/rec/AliHLTEsdManagerImplementation.h [moved from HLT/rec/AliHLTEsdManager.h with 81% similarity]
HLT/rec/AliHLTReconstructor.cxx

diff --git a/HLT/BASE/AliHLTEsdManager.cxx b/HLT/BASE/AliHLTEsdManager.cxx
new file mode 100644 (file)
index 0000000..918c784
--- /dev/null
@@ -0,0 +1,97 @@
+// $Id$
+
+//**************************************************************************
+//* This file is property of and copyright by the ALICE HLT Project        * 
+//* ALICE Experiment at CERN, All rights reserved.                         *
+//*                                                                        *
+//* 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   *
+//* 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.                  *
+//**************************************************************************
+
+/** @file   AliHLTEsdManager.cxx
+    @author Matthias Richter
+    @date   
+    @brief  Manager for merging and writing of HLT ESDs
+*/
+
+#include "AliHLTEsdManager.h"
+#include "TSystem.h"
+#include "TClass.h"
+#include "TROOT.h"
+
+/** ROOT macro for the implementation of ROOT specific class methods */
+ClassImp(AliHLTEsdManager)
+
+AliHLTEsdManager::AliHLTEsdManager()
+  :
+  AliHLTLogging()
+{
+  // see header file for class documentation
+  // or
+  // refer to README to build package
+  // or
+  // visit http://web.ift.uib.no/~kjeks/doc/alice-hlt
+}
+
+AliHLTEsdManager::~AliHLTEsdManager()
+{
+  // see header file for class documentation
+}
+
+const char* AliHLTEsdManager::fgkImplName="AliHLTEsdManagerImplementation";
+const char* AliHLTEsdManager::fgkImplLibrary="libHLTrec.so";
+
+
+AliHLTEsdManager* AliHLTEsdManager::New()
+{
+  // see header file for class documentation
+  int iLibResult=0;
+  AliHLTEsdManager* instance=NULL;
+  AliHLTLogging log;
+  TClass* pCl=NULL;
+  ROOT::NewFunc_t pNewFunc=NULL;
+  do {
+    pCl=TClass::GetClass(fgkImplName);
+  } while (!pCl && (iLibResult=gSystem->Load(fgkImplLibrary))==0);
+  if (iLibResult>=0) {
+    if (pCl && (pNewFunc=pCl->GetNew())!=NULL) {
+      void* p=(*pNewFunc)(NULL);
+      if (p) {
+       instance=reinterpret_cast<AliHLTEsdManager*>(p);
+       if (!instance) {
+         log.Logging(kHLTLogError, "AliHLTEsdManager::New", "ESD handling", "type cast to AliHLTEsdManager instance failed");
+       }
+      } else {
+       log.Logging(kHLTLogError, "AliHLTEsdManager::New", "ESD handling", "can not create AliHLTEsdManager instance from class descriptor");
+      }
+      delete pCl;
+    } else {
+      log.Logging(kHLTLogError, "AliHLTEsdManager::New", "ESD handling", "can not find AliHLTEsdManager class descriptor");
+    }
+  } else {
+    log.Logging(kHLTLogError, "AliHLTEsdManager::New", "ESD handling", "can not load libHLTrec library");
+  }
+  return instance;
+}
+
+void AliHLTEsdManager::Delete(AliHLTEsdManager* instance)
+{
+  // see header file for class documentation
+  if (!instance) return;
+
+  // check if the library is still there in order to have the
+  // destructor available
+  TClass* pCl=TClass::GetClass("AliHLTEsdManagerImlementation");
+  if (!pCl) return;
+  delete pCl;
+
+  delete instance;
+}
diff --git a/HLT/BASE/AliHLTEsdManager.h b/HLT/BASE/AliHLTEsdManager.h
new file mode 100644 (file)
index 0000000..bfcff87
--- /dev/null
@@ -0,0 +1,112 @@
+//-*- Mode: C++ -*-
+// $Id$
+
+#ifndef ALIHLTESDMANAGER_H
+#define ALIHLTESDMANAGER_H
+//* This file is property of and copyright by the ALICE HLT Project        * 
+//* ALICE Experiment at CERN, All rights reserved.                         *
+//* See cxx source for full Copyright notice                               *
+
+/** @file   AliHLTEsdManager.h
+    @author Matthias Richter
+    @date   
+    @brief  Manager for merging and writing of HLT ESDs
+*/
+
+#include "AliHLTDataTypes.h"
+#include "AliHLTLogging.h"
+#include "TString.h"
+
+class AliESDEvent;
+
+/**
+ * @class AliHLTEsdManager
+ * Tool to write and merge HLT ESD objects.
+ *
+ * HLT components can produce ESD output. The ESD objects are sent via
+ * a TMessage like mechanism as part of the HLTOUT data. This class retrieves
+ * streamed AliESDEvent objects from an HLT output block. An ESD object can be
+ * copied to a global ESD provided by the caller or to files. The name of the
+ * ROOT files follows the scheme AliHLTDETESDs.root where DET denotes a detector.
+ * E.g. the ESD from a data block of type {ESD_TREE,TPC} will be added to the
+ * file AliHLTTPCESDs.root.
+ *
+ * For the sake of library (in)dependencies, the concrete implementation of
+ * the AliHLTEsdManager is separated from the libHLTbase class as this would
+ * introduce dependencies to AliRoot libraries. The user does not notice the
+ * handling apart from the fact that an instance can not be created and
+ * deleted directly. Instead 
+ * <pre>
+ *   AliHLTEsdManager* pManager=AliHLTEsdManager::New();
+ *   // ....
+ *   AliHLTEsdManager::Delete(pManager);
+ * </pre>
+ * must be used.
+ *
+ * @ingroup alihlt_aliroot_reconstruction
+ */
+class AliHLTEsdManager : public AliHLTLogging {
+ public:
+  /** create an instance of the manager */
+  static AliHLTEsdManager* New();
+  /** delete an instance of the manager */
+  static void Delete(AliHLTEsdManager* instance);
+
+  /**
+   * Convert data buffer to ESD.
+   * The buffer is supposed to describe a streamed AliESDEvent object.
+   * If no target object is specified, the ESD is written to a file AliHLTdetESDs.root,
+   * where 'det' is derived from the data type origin. Each time the function is invoked
+   * a new event is created. Dummy events are added if the previous events did not contain
+   *
+   * @param pBuffer  [in] the data buffer
+   * @param size     [in] data buffer size
+   * @param dt       [in] data type of the block
+   * @param tgtesd   [out] optional target
+   * @param eventno  [in] optional event no
+   */
+  virtual int WriteESD(const AliHLTUInt8_t* pBuffer, AliHLTUInt32_t size, AliHLTComponentDataType dt,
+              AliESDEvent* tgtesd=NULL, int eventno=-1)=0;
+
+  /**
+   * Align all ESD to the same number of events.
+   * The function adds empty events to all ESD files if their event number
+   * does not match the specified one.
+   * @param eventno     the desired event no
+   * @return neg. error code if failed
+   */
+  virtual int PadESDs(int eventno)=0;
+
+  /**
+   * Set the target directory for the ESD files.
+   */
+  virtual void SetDirectory(const char* directory)=0;
+
+  /**
+   * Get the list of the internally created files.
+   * Returns a blank separated list of the file names.
+   */
+  virtual TString GetFileNames(AliHLTComponentDataType dt=kAliHLTAnyDataType) const = 0;
+
+ protected:
+  /** constructor */
+  AliHLTEsdManager();
+  /** destructor */
+  virtual ~AliHLTEsdManager();
+
+ private:
+  /** copy constructor prohibited */
+  AliHLTEsdManager(const AliHLTEsdManager&);
+  /** assignment operator prohibited */
+  AliHLTEsdManager& operator=(const AliHLTEsdManager&);
+
+  /** the name of the actual implementation */
+  static const char* fgkImplName; //!
+
+  /** the library of the implementation */
+  static const char* fgkImplLibrary; //!
+
+  ClassDef(AliHLTEsdManager, 0)
+};
+
+#endif
index 349dc8d1838bc9295e18a54bf05466d702184d8f..7325391d6baecb140581d2b1f0a0e95319f0e5dc 100644 (file)
@@ -26,6 +26,7 @@ CLASS_HDRS:=          AliHLTComponent.h \
                AliHLTHOMERLibManager.h \
                AliHLTHOMERBlockDesc.h \
                AliHLTHOMERSourceDesc.h \
+               AliHLTEsdManager.h \
                AliHLTOUT.h \
                AliHLTOUTHomerBuffer.h \
                AliHLTOUTHandler.h \
index ff16272cb7c19082892c25bb908b38deaf9b5b01..88bbde4710ce2f7cdea0e774a4dd85f9c01b47df 100644 (file)
@@ -6,7 +6,7 @@ LIBHLTREC_VERSION := 1
 CLASS_HDRS:=   AliHLTReconstructor.h \
                AliRawReaderHLT.h \
                AliHLTOUTHomerCollection.h \
-               AliHLTEsdManager.h \
+               AliHLTEsdManagerImplementation.h \
                AliHLTOUTDigitReader.h \
                AliHLTOUTRawReader.h
 
similarity index 90%
rename from HLT/rec/AliHLTEsdManager.cxx
rename to HLT/rec/AliHLTEsdManagerImplementation.cxx
index 9bf6fa9ef650b9c5d20a2d258ef8883bd65b36d0..a886ee407d9dc195d91502b7e33292734ad3c45f 100644 (file)
 //* provided "as is" without express or implied warranty.                  *
 //**************************************************************************
 
-/** @file   AliHLTEsdManager.cxx
+/** @file   AliHLTEsdManagerImplementation.cxx
     @author Matthias Richter
     @date   
     @brief  Manager for merging and writing of HLT ESDs
 */
 
-#include "AliHLTEsdManager.h"
+#include "AliHLTEsdManagerImplementation.h"
 #include "AliHLTComponent.h"
 #include "AliESDEvent.h"
 #include "AliHLTMessage.h"
@@ -37,9 +37,9 @@
 #include "TList.h"
 
 /** ROOT macro for the implementation of ROOT specific class methods */
-ClassImp(AliHLTEsdManager)
+ClassImp(AliHLTEsdManagerImplementation)
 
-AliHLTEsdManager::AliHLTEsdManager()
+AliHLTEsdManagerImplementation::AliHLTEsdManagerImplementation()
   :
   fESDs(),
   fDirectory()
@@ -51,7 +51,7 @@ AliHLTEsdManager::AliHLTEsdManager()
   // visit http://web.ift.uib.no/~kjeks/doc/alice-hlt
 }
 
-AliHLTEsdManager::~AliHLTEsdManager()
+AliHLTEsdManagerImplementation::~AliHLTEsdManagerImplementation()
 {
   // see header file for class documentation
   for (unsigned int i=0; i<fESDs.size(); i++) {
@@ -62,7 +62,7 @@ AliHLTEsdManager::~AliHLTEsdManager()
   }
 }
 
-AliHLTEsdManager::AliHLTEsdListEntry* AliHLTEsdManager::Find(AliHLTComponentDataType dt) const
+AliHLTEsdManagerImplementation::AliHLTEsdListEntry* AliHLTEsdManagerImplementation::Find(AliHLTComponentDataType dt) const
 {
   // see header file for class documentation
   AliHLTEsdListEntry* pEntry=NULL;
@@ -74,7 +74,7 @@ AliHLTEsdManager::AliHLTEsdListEntry* AliHLTEsdManager::Find(AliHLTComponentData
   return pEntry;
 }
 
-int AliHLTEsdManager::WriteESD(const AliHLTUInt8_t* pBuffer, AliHLTUInt32_t size,
+int AliHLTEsdManagerImplementation::WriteESD(const AliHLTUInt8_t* pBuffer, AliHLTUInt32_t size,
                               AliHLTComponentDataType dt, AliESDEvent* tgtesd, int eventno)
 {
   // see header file for class documentation
@@ -152,7 +152,7 @@ int AliHLTEsdManager::WriteESD(const AliHLTUInt8_t* pBuffer, AliHLTUInt32_t size
   return iResult;
 }
 
-int AliHLTEsdManager::PadESDs(int eventno)
+int AliHLTEsdManagerImplementation::PadESDs(int eventno)
 {
   // see header file for class documentation
   int iResult=0;
@@ -165,7 +165,7 @@ int AliHLTEsdManager::PadESDs(int eventno)
   return iResult;
 }
 
-void AliHLTEsdManager::SetDirectory(const char* directory)
+void AliHLTEsdManagerImplementation::SetDirectory(const char* directory)
 {
   // see header file for class documentation
   if (!directory) return;
@@ -177,7 +177,7 @@ void AliHLTEsdManager::SetDirectory(const char* directory)
   }
 }
 
-TString AliHLTEsdManager::GetFileNames(AliHLTComponentDataType dt) const
+TString AliHLTEsdManagerImplementation::GetFileNames(AliHLTComponentDataType dt) const
 {
   TString result;
   for (unsigned int i=0; i<fESDs.size(); i++) {
@@ -189,7 +189,7 @@ TString AliHLTEsdManager::GetFileNames(AliHLTComponentDataType dt) const
   return result;
 }
 
-TTree* AliHLTEsdManager::EmbedIntoTree(AliESDEvent* pESD, const char* name, const char* title)
+TTree* AliHLTEsdManagerImplementation::EmbedIntoTree(AliESDEvent* pESD, const char* name, const char* title)
 {
   // see header file for class documentation
   int iResult=0;
@@ -210,7 +210,7 @@ TTree* AliHLTEsdManager::EmbedIntoTree(AliESDEvent* pESD, const char* name, cons
   return pTree;
 }
 
-AliHLTEsdManager::AliHLTEsdListEntry::AliHLTEsdListEntry(AliHLTComponentDataType dt)
+AliHLTEsdManagerImplementation::AliHLTEsdListEntry::AliHLTEsdListEntry(AliHLTComponentDataType dt)
   :
   fName(),
   fDirectory(),
@@ -222,7 +222,7 @@ AliHLTEsdManager::AliHLTEsdListEntry::AliHLTEsdListEntry(AliHLTComponentDataType
   // see header file for class documentation
 }
 
-AliHLTEsdManager::AliHLTEsdListEntry::~AliHLTEsdListEntry()
+AliHLTEsdManagerImplementation::AliHLTEsdListEntry::~AliHLTEsdListEntry()
 {
   // see header file for class documentation
   if (fpEsd) delete fpEsd;
@@ -235,13 +235,13 @@ AliHLTEsdManager::AliHLTEsdListEntry::~AliHLTEsdListEntry()
   fpFile=NULL;
 }
 
-bool AliHLTEsdManager::AliHLTEsdListEntry::operator==(AliHLTComponentDataType dt) const
+bool AliHLTEsdManagerImplementation::AliHLTEsdListEntry::operator==(AliHLTComponentDataType dt) const
 {
   // see header file for class documentation
   return fDt==dt;
 }
 
-int AliHLTEsdManager::AliHLTEsdListEntry::WriteESD(AliESDEvent* pSrcESD, int eventno)
+int AliHLTEsdManagerImplementation::AliHLTEsdListEntry::WriteESD(AliESDEvent* pSrcESD, int eventno)
 {
   // see header file for class documentation
   int iResult=0;
@@ -509,7 +509,7 @@ int AliHLTEsdManager::AliHLTEsdListEntry::WriteESD(AliESDEvent* pSrcESD, int eve
   return iResult;
 }
 
-TString AliHLTEsdManager::AliHLTEsdListEntry::WriteTempFile(AliESDEvent* pESD) const
+TString AliHLTEsdManagerImplementation::AliHLTEsdListEntry::WriteTempFile(AliESDEvent* pESD) const
 {
   // see header file for class documentation
   int iResult=0;
@@ -521,7 +521,7 @@ TString AliHLTEsdManager::AliHLTEsdListEntry::WriteTempFile(AliESDEvent* pESD) c
 
     TFile file(tmpfilename, "RECREATE");
     if (!file.IsZombie()) {
-      TTree* pTree=AliHLTEsdManager::EmbedIntoTree(pESD);
+      TTree* pTree=AliHLTEsdManagerImplementation::EmbedIntoTree(pESD);
       if (pTree) {
        file.cd();
        if (pTree->Write()>0) {
@@ -555,7 +555,7 @@ TString AliHLTEsdManager::AliHLTEsdListEntry::WriteTempFile(AliESDEvent* pESD) c
   return tmpfilename;
 }
 
-void AliHLTEsdManager::AliHLTEsdListEntry::SetDirectory(const char* directory)
+void AliHLTEsdManagerImplementation::AliHLTEsdListEntry::SetDirectory(const char* directory)
 {
   // see header file for class documentation
   if (!directory) return;
@@ -566,7 +566,7 @@ void AliHLTEsdManager::AliHLTEsdListEntry::SetDirectory(const char* directory)
   fDirectory=directory;
 }
 
-void AliHLTEsdManager::AliHLTEsdListEntry::Delete()
+void AliHLTEsdManagerImplementation::AliHLTEsdListEntry::Delete()
 {
   // see header file for class documentation
   if (fName.IsNull()) return;
@@ -578,7 +578,7 @@ void AliHLTEsdManager::AliHLTEsdListEntry::Delete()
   fName="";
 }
 
-const char* AliHLTEsdManager::AliHLTEsdListEntry::GetFileName() const
+const char* AliHLTEsdManagerImplementation::AliHLTEsdListEntry::GetFileName() const
 {
   // see header file for class documentation
   return fName.Data();
similarity index 81%
rename from HLT/rec/AliHLTEsdManager.h
rename to HLT/rec/AliHLTEsdManagerImplementation.h
index 8c32acc098571a7f2364e5cabe3f5c48917df8f2..830d9680420f17756bc11024fad489b75284b139 100644 (file)
@@ -1,20 +1,19 @@
 //-*- Mode: C++ -*-
 // $Id$
 
-#ifndef ALIHLTESDMANAGER_H
-#define ALIHLTESDMANAGER_H
+#ifndef ALIHLTESDMANAGERIMPLEMENTATION_H
+#define ALIHLTESDMANAGERIMPLEMENTATION_H
 //* This file is property of and copyright by the ALICE HLT Project        * 
 //* ALICE Experiment at CERN, All rights reserved.                         *
 //* See cxx source for full Copyright notice                               *
 
-/** @file   AliHLTEsdManager.h
+/** @file   AliHLTEsdManagerImplementation.h
     @author Matthias Richter
     @date   
-    @brief  Manager for merging and writing of HLT ESDs
+    @brief  Implementation of the AliHLTEsdManager
 */
 
-#include "AliHLTDataTypes.h"
-#include "AliHLTLogging.h"
+#include "AliHLTEsdManager.h"
 #include "TString.h"
 #include <vector>
 
@@ -23,25 +22,22 @@ class TTree;
 class TFile;
 
 /**
- * @class AliHLTEsdManager
- * Tool to write and merge HLT ESD objects.
+ * @class AliHLTEsdManagerImplementation
+ * Implementation of the AliHLTEsdManager.
  *
- * HLT components can produce ESD output. The ESD objects are sent via
- * a TMessage like mechanism as part of the HLTOUT data. This class retrieves
- * streamed AliESDEvent objects from an HLT output block. An ESD object can be
- * copied to a global ESD provided by the caller or to files. The name of the
- * ROOT files follows the scheme AliHLTDETESDs.root where DET denotes a detector.
- * E.g. the ESD from a data block of type {ESD_TREE,TPC} will be added to the
- * file AliHLTTPCESDs.root.
+ * For the sake of library (in)dependencies, the concrete implementation of
+ * the AliHLTEsdManager is separated from the libHLTbase class as this would
+ * introduce dependencies to AliRoot libraries. See AliHLTEsdManager for
+ * usage.
  *
  * @ingroup alihlt_aliroot_reconstruction
  */
-class AliHLTEsdManager : public AliHLTLogging {
+class AliHLTEsdManagerImplementation : public AliHLTEsdManager {
  public:
   /** constructor */
-  AliHLTEsdManager();
+  AliHLTEsdManagerImplementation();
   /** destructor */
-  virtual ~AliHLTEsdManager();
+  virtual ~AliHLTEsdManagerImplementation();
 
   /**
    * Convert data buffer to ESD.
@@ -89,9 +85,9 @@ class AliHLTEsdManager : public AliHLTLogging {
 
  private:
   /** copy constructor prohibited */
-  AliHLTEsdManager(const AliHLTEsdManager&);
+  AliHLTEsdManagerImplementation(const AliHLTEsdManagerImplementation&);
   /** assignment operator prohibited */
-  AliHLTEsdManager& operator=(const AliHLTEsdManager&);
+  AliHLTEsdManagerImplementation& operator=(const AliHLTEsdManagerImplementation&);
 
   class AliHLTEsdListEntry : public AliHLTLogging {
   public:
@@ -170,7 +166,7 @@ class AliHLTEsdManager : public AliHLTLogging {
   /** target directory */
   TString fDirectory; //!transient
 
-  ClassDef(AliHLTEsdManager, 1)
+  ClassDef(AliHLTEsdManagerImplementation, 1)
 };
 
 #endif
index c409c782097deb225bb07b87de12c26903ff6ec6..734a8d41dd62fa7330c321d985acedd524c4214e 100644 (file)
@@ -70,7 +70,7 @@ AliHLTReconstructor::~AliHLTReconstructor()
     }
   }
 
-  if (fpEsdManager) delete fpEsdManager;
+  if (fpEsdManager) AliHLTEsdManager::Delete(fpEsdManager);
   fpEsdManager=NULL;
 }
 
@@ -159,7 +159,7 @@ void AliHLTReconstructor::Init()
   gSystem->Load("libHLTinterface.so");
   fFctProcessHLTOUT=gSystem->DynFindSymbol("libHLTinterface.so", "AliHLTSystemProcessHLTOUT");
 
-  fpEsdManager=new AliHLTEsdManager;
+  fpEsdManager=AliHLTEsdManager::New();
 }
 
 void AliHLTReconstructor::Reconstruct(AliRawReader* /*rawReader*/, TTree* /*clustersTree*/) const