]> git.uio.no Git - u/mrichter/AliRoot.git/commitdiff
added new helper components to libAliHLTUtil (EsdCollector and AliHLTOUTPublisher...
authorrichterm <richterm@f7af4fe6-9843-0410-8265-dc069ae4e863>
Thu, 12 Jun 2008 20:14:05 +0000 (20:14 +0000)
committerrichterm <richterm@f7af4fe6-9843-0410-8265-dc069ae4e863>
Thu, 12 Jun 2008 20:14:05 +0000 (20:14 +0000)
17 files changed:
HLT/BASE/AliHLTOUT.cxx
HLT/BASE/AliHLTOUT.h
HLT/BASE/util/AliHLTAgentUtil.cxx
HLT/BASE/util/AliHLTBlockFilterComponent.cxx
HLT/BASE/util/AliHLTEsdCollectorComponent.cxx [new file with mode: 0644]
HLT/BASE/util/AliHLTEsdCollectorComponent.h [new file with mode: 0644]
HLT/BASE/util/AliHLTFileWriter.h
HLT/BASE/util/AliHLTOUTPublisherComponent.cxx [new file with mode: 0644]
HLT/BASE/util/AliHLTOUTPublisherComponent.h [new file with mode: 0644]
HLT/exa/hltout-collect-esd.C [new file with mode: 0644]
HLT/exa/split-hltout.C [new file with mode: 0644]
HLT/libAliHLTUtil.pkg
HLT/rec/AliHLTOUTDigitReader.cxx
HLT/rec/AliHLTOUTDigitReader.h
HLT/rec/AliHLTOUTHomerCollection.h
HLT/rec/AliHLTOUTRawReader.cxx
HLT/rec/AliHLTOUTRawReader.h

index eec3b1ad47f75b84c30ebeb4dc88e06ec1cf7db4..a92561684db9843fc4248cc77412d6bc1c5a21d9 100644 (file)
@@ -30,6 +30,9 @@
 #include <cerrno>
 #include <cassert>
 #include "AliHLTOUT.h"
+#include "TSystem.h"
+#include "TClass.h"
+#include "TROOT.h"
 
 /** ROOT macro for the implementation of ROOT specific class methods */
 ClassImp(AliHLTOUT)
@@ -458,3 +461,94 @@ AliHLTUInt32_t AliHLTOUT::ByteSwap32(AliHLTUInt32_t src)
     ((src & 0xFF0000ULL) >> 8) | 
     ((src & 0xFF000000ULL) >> 24);
 }
+
+AliHLTOUT* AliHLTOUT::New(AliRawReader* pRawReader)
+{
+  // see header file for class documentation
+  AliHLTOUT* instance=New("AliHLTOUTRawReader");
+  if (instance) {
+    instance->SetParam(pRawReader);
+  }
+  return instance;
+}
+
+AliHLTOUT* AliHLTOUT::New(TTree* pDigitTree, int event)
+{
+  // see header file for class documentation
+  AliHLTOUT* instance=New("AliHLTOUTDigitReader");
+  if (instance) {
+    instance->SetParam(pDigitTree, event);
+  }
+  return instance;
+}
+
+AliHLTOUT* AliHLTOUT::New(const char* classname)
+{
+  // see header file for class documentation
+  int iLibResult=0;
+  AliHLTOUT* instance=NULL;
+  AliHLTLogging log;
+  TClass* pCl=NULL;
+  ROOT::NewFunc_t pNewFunc=NULL;
+  do {
+    pCl=TClass::GetClass(classname);
+  } while (!pCl && (iLibResult=gSystem->Load("libHLTRec.so"))==0);
+  if (iLibResult>=0) {
+    if (pCl && (pNewFunc=pCl->GetNew())!=NULL) {
+      void* p=(*pNewFunc)(NULL);
+      if (p) {
+       instance=reinterpret_cast<AliHLTOUT*>(p);
+       if (!instance) {
+         log.Logging(kHLTLogError, "AliHLTOUT::New", "HLTOUT handling", "type cast to AliHLTOUT instance failed");
+       }
+      } else {
+       log.Logging(kHLTLogError, "AliHLTOUT::New", "HLTOUT handling", "can not create AliHLTOUT instance from class descriptor");
+      }
+    } else {
+      log.Logging(kHLTLogError, "AliHLTOUT::New", "HLTOUT handling", "can not find AliHLTOUT class descriptor");
+    }
+  } else {
+    log.Logging(kHLTLogError, "AliHLTOUT::New", "HLTOUT handling", "can not load libHLTrec library");
+  }
+  return instance;
+}
+
+void AliHLTOUT::Delete(AliHLTOUT* pInstance)
+{
+  // see header file for class documentation
+  if (!pInstance) return;
+
+  // check if the library is still there in order to have the
+  // destructor available
+  TClass* pCl1=TClass::GetClass("AliHLTOUTRawReader");
+  TClass* pCl2=TClass::GetClass("AliHLTOUTDigitReader");
+  if (!pCl1 && !pCl2) {
+    AliHLTLogging log;
+    log.Logging(kHLTLogError, "AliHLTOUT::Delete", "HLTOUT handling", "potential memory leak: libHLTrec library not available, skipping destruction %p", pInstance);    
+    return;
+  }
+
+  delete pInstance;  
+}
+
+void AliHLTOUT::SetParam(AliRawReader* /*pRawReader*/)
+{
+  // see header file for class documentation
+  // default implementation, we should never get here
+  // this function can only be called from the class itsself and
+  // is intended to be used with the New functions. If we get into
+  // the default implementation there is a class mismatch.
+  assert(0);
+  HLTFatal("severe internal error: class mismatch");
+}
+
+void AliHLTOUT::SetParam(TTree* /*pDigitTree*/, int /*event*/)
+{
+  // see header file for class documentation
+  // default implementation, we should never get here
+  // this function can only be called from the class itsself and
+  // is intended to be used with the New functions. If we get into
+  // the default implementation there is a class mismatch.
+  assert(0);
+  HLTFatal("severe internal error: class mismatch");
+}
index 00eb8ee39d85c5d99a9db4beb51328eb1bfc5f67..82c338cce73c616ce30d46ac92e2eb552b18882e 100644 (file)
@@ -21,6 +21,8 @@ class AliHLTOUTHandler;
 class AliHLTOUTHandlerDesc; // AliHLTModuleAgent.h
 class AliESDEvent;
 class AliHLTReconstructor;
+class AliRawReader;
+class TTree;
 
 #define AliHLTOUTInvalidIndex (~(AliHLTUInt32_t)0)
 
@@ -42,6 +44,28 @@ class AliHLTOUT : public AliHLTLogging {
   /** standard destructor */
   virtual ~AliHLTOUT();
 
+  /**
+   * Create an AliHLTOUTRawReader instance.
+   * Helper function to transparently access classes from the
+   * libHLTrec library.
+   */
+  static AliHLTOUT* New(AliRawReader* pRawReader);
+
+  /**
+   * Create an AliHLTOUTDigitReader instance
+   * Helper function to transparently access classes from the
+   * libHLTrec library.
+   */
+  static AliHLTOUT* New(TTree* pDigitTree, int event=-1);
+
+  /**
+   * Delete an instance of the HLTOUT.
+   * Helper function to transparently access classes from the
+   * libHLTrec library. Before deleting, the availability of the
+   * library is checked.
+   */
+  static void Delete(AliHLTOUT* pInstance);
+
   /**
    * Locking guard for the AliHLTOUT object.
    * If the object is locked, the selection of data blocks can not be changed.
@@ -231,7 +255,7 @@ class AliHLTOUT : public AliHLTLogging {
    * @param dt    [in]  data type to match                                <br>
    * @param spec  [in]  data specification to match                       <br>
    * @param handlerType [in]  type of the handler
-   * @return identifier >0 if success, 0 if no block found                <br>
+   * @return block index: >= 0 if success, -ENOENT if no block found      <br>
    *         neg. error code if failed                                    <br>
    *                        -EPERM if access denied (object locked)
    */
@@ -242,7 +266,7 @@ class AliHLTOUT : public AliHLTLogging {
   /**
    * Select the next data block of data type and specification of the previous
    * call to @ref SelectFirstDataBlock.
-   * @return identifier >0 if success, 0 if no block found                <br>
+   * @return block index: >= 0 if success, -ENOENT if no block found      <br>
    *         neg. error code if failed                                    <br>
    *                        -EPERM if access denied (object locked)
    */
@@ -474,6 +498,27 @@ class AliHLTOUT : public AliHLTLogging {
    */
   const AliHLTOUTHandlerListEntry& FindHandlerDesc(AliHLTUInt32_t blockIndex);
 
+  /**
+   * Internal New function for the external HLTOUT instances.
+   * Currently supported classes are AliHLTOUTRawReader and
+   * AliHLTOUTDigitReader, both implemented in libHLTrec.so.
+   */
+  static AliHLTOUT* New(const char* classname);
+
+  /**
+   * Set the RawReader as parameter.
+   * The function is for internal use only in conjunction with the
+   * New() functions.
+   */
+  virtual void SetParam(AliRawReader* pRawReader);
+
+  /**
+   * Set the RunLoader as parameter
+   * The function is for internal use only in conjunction with the
+   * New() functions.
+   */
+  virtual void SetParam(TTree* pDigitTree, int event=-1);
+
   /** data type for the current block search, set from @ref SelectFirstDataBlock */
   AliHLTComponentDataType fSearchDataType; //!transient
 
index 29991ccc22a79056a739cae3d161f4e7892d2846..60f4a99acaad2857c9730b0fdc56f68899af2b90 100644 (file)
@@ -36,6 +36,8 @@
 #include "AliHLTFileWriter.h"
 #include "AliHLTFilePublisher.h"
 #include "AliHLTBlockFilterComponent.h"
+#include "AliHLTEsdCollectorComponent.h"
+#include "AliHLTOUTPublisherComponent.h"
 
 /** global instance for agent registration */
 AliHLTAgentUtil gAliHLTAgentUtil;
@@ -94,5 +96,7 @@ int AliHLTAgentUtil::RegisterComponents(AliHLTComponentHandler* pHandler) const
   pHandler->AddComponent(new AliHLTFileWriter);
   pHandler->AddComponent(new AliHLTFilePublisher);
   pHandler->AddComponent(new AliHLTBlockFilterComponent);
+  pHandler->AddComponent(new AliHLTEsdCollectorComponent);
+  pHandler->AddComponent(new AliHLTOUTPublisherComponent);
   return 0;
 }
index 3e613403b0b3c93f7e2207e90fd3561d1e94b3e1..46f322b0a2ec1bf1209d79eb408164b90440ee9f 100644 (file)
@@ -1,32 +1,26 @@
 // @(#) $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.                  *
- **************************************************************************/
+//**************************************************************************
+//* 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   AliHLTBlockFilterComponent.cxx
     @author Matthias Richter
     @date   
     @brief  A simple data block filter and merger, merges block descriptors
-
-                                                                          */
-// see header file for class documentation
-// or
-// refer to README to build package
-// or
-// visit http://web.ift.uib.no/~kjeks/doc/alice-hlt
+*/
 
 #include <cstdlib>
 #include "AliHLTBlockFilterComponent.h"
@@ -176,16 +170,6 @@ int AliHLTBlockFilterComponent::DoEvent( const AliHLTComponentEventData& /*evtDa
       HLTDebug("block type %s %#x discarded by filter rules", DataType2Text(pBlock->fDataType).c_str(), pBlock->fSpecification);
     }
   }
-//   for (int n=0; n<(int)evtData.fBlockCnt; n++ ) {
-//     if (IsSelected(blocks[n])) {
-//       HLTDebug("block %d type %s %#x (ptr=%p offset=%d size=%d) selected by filter rules", 
-//            n, DataType2Text(blocks[n].fDataType).c_str(), blocks[n].fSpecification, 
-//            blocks[n].fPtr, blocks[n].fOffset, blocks[n].fSize);
-//       outputBlocks.push_back(blocks[n]);
-//     } else {
-//       HLTDebug("block %d type %s %#x discarded by filter rules", n, DataType2Text(blocks[n].fDataType).c_str(), blocks[n].fSpecification);
-//     }
-//   }
   size=0;
   return iResult;
 }
diff --git a/HLT/BASE/util/AliHLTEsdCollectorComponent.cxx b/HLT/BASE/util/AliHLTEsdCollectorComponent.cxx
new file mode 100644 (file)
index 0000000..c7ba030
--- /dev/null
@@ -0,0 +1,108 @@
+// $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   AliHLTEsdCollectorComponent.cxx
+    @author Matthias Richter
+    @date   
+    @brief  Base class for writer components to store data in a ROOT file
+
+                                                                          */
+
+#include "AliHLTEsdCollectorComponent.h"
+#include "AliHLTEsdManager.h"
+#include "TString.h"
+
+/** ROOT macro for the implementation of ROOT specific class methods */
+ClassImp(AliHLTEsdCollectorComponent)
+
+AliHLTEsdCollectorComponent::AliHLTEsdCollectorComponent()
+  :
+  AliHLTFileWriter(),
+  fpManager(NULL)
+{
+  // see header file for class documentation
+  // or
+  // refer to README to build package
+  // or
+  // visit http://web.ift.uib.no/~kjeks/doc/alice-hlt
+
+  // all event go into the same file, but there are individual files for
+  // different data blocks
+  SetMode(kConcatenateEvents);
+}
+
+AliHLTEsdCollectorComponent::~AliHLTEsdCollectorComponent()
+{
+  // see header file for class documentation
+}
+
+int AliHLTEsdCollectorComponent::InitWriter()
+{
+  // see header file for class documentation
+  int iResult=0;
+
+  // choose .root as default extension
+  if (GetExtension().IsNull()) SetExtension("root");
+
+  if ((fpManager=AliHLTEsdManager::New())) {
+    fpManager->SetDirectory(GetDirectory().Data());
+  } else {
+    HLTError("can not find AliHLTEsdManager class descriptor");
+    iResult=-ENODEV;
+  }
+
+  return iResult;
+}
+
+int AliHLTEsdCollectorComponent::CloseWriter()
+{
+  // see header file for class documentation
+  if (fpManager!=NULL) {
+    AliHLTEsdManager::Delete(fpManager);
+    fpManager=NULL;
+  }
+  return 0;
+}
+
+int AliHLTEsdCollectorComponent::DumpEvent( const AliHLTComponentEventData& /*evtData*/,
+                                           const AliHLTComponentBlockData* /*blocks*/, 
+                                           AliHLTComponentTriggerData& /*trigData*/ )
+{
+  // see header file for class documentation
+  int iResult=0;
+  if (!fpManager) return -ENODEV;
+
+  for (const AliHLTComponentBlockData* pBlock=GetFirstInputBlock();
+       pBlock && iResult>=0;
+       pBlock=GetNextInputBlock()) {
+    if (pBlock->fDataType!=kAliHLTDataTypeESDObject &&
+       pBlock->fDataType!=kAliHLTDataTypeESDTree) continue;
+    HLTInfo("writing ESD, data type %s", (DataType2Text(pBlock->fDataType).c_str()));
+    iResult=fpManager->WriteESD(reinterpret_cast<const AliHLTUInt8_t*>(pBlock->fPtr),
+                               pBlock->fSize, pBlock->fDataType, NULL, GetEventCount());
+  }
+  return iResult;
+}
+
+int AliHLTEsdCollectorComponent::ScanArgument(int /*argc*/, const char** /*argv*/)
+{
+  // see header file for class documentation
+  // no other arguments known
+  int iResult=-EINVAL;
+  return iResult;
+}
diff --git a/HLT/BASE/util/AliHLTEsdCollectorComponent.h b/HLT/BASE/util/AliHLTEsdCollectorComponent.h
new file mode 100644 (file)
index 0000000..7a87f96
--- /dev/null
@@ -0,0 +1,82 @@
+// -*- Mode: C++ -*-
+// $Id$
+
+#ifndef ALIHLTESDCOLLECTORCOMPONENT_H
+#define ALIHLTESDCOLLECTORCOMPONENT_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   AliHLTEsdCollectorComponent.h
+    @author Matthias Richter
+    @date   
+    @brief  Collect ESDs of multiple events and write toi file
+*/
+
+#include "AliHLTFileWriter.h"
+
+class AliHLTEsdManager;
+
+/**
+ * @class AliHLTEsdCollectorComponent
+ * The EsdCollector component merges ESDs from multiple events into one
+ * ESD file per origin using the AliHLTEsdManager class.
+ * \b Note: The component just merges ESDs of the same type/origin from
+ * multiple events into one file. It does not implement merging of ESDs
+ * from one event but several origins.
+ *
+ * Component ID: \b EsdCollector <br>
+ * Library: \b libAliHLTUtil.so
+ *
+ * Mandatory arguments: <br>
+ * <!-- NOTE: ignore the \li. <i> and </i>: it's just doxygen formatting -->
+ *
+ * Optional arguments: <br>
+ * <!-- NOTE: ignore the \li. <i> and </i>: it's just doxygen formatting -->
+ * The only AliHLTFileWriter argument of relevance is the -directory argument.
+ *
+ * See AliHLTFileWriter for full list of arguments.
+ */
+class AliHLTEsdCollectorComponent : public AliHLTFileWriter
+{
+ public:
+  /** standard constructor */
+  AliHLTEsdCollectorComponent();
+  /** destructor */
+  virtual ~AliHLTEsdCollectorComponent();
+
+  /**
+   * The id of the component.
+   * @return component id (string)
+   */
+  const char* GetComponentID() {return "EsdCollector";};
+
+  /**
+   * Spawn function.
+   * @return new class instance
+   */
+  AliHLTComponent* Spawn() {return new AliHLTEsdCollectorComponent;}
+
+ protected:
+  // interface functions
+  int InitWriter();
+  int CloseWriter();
+  int DumpEvent( const AliHLTComponentEventData& evtData,
+                const AliHLTComponentBlockData* blocks, 
+                AliHLTComponentTriggerData& trigData );
+  
+  using AliHLTFileWriter::DumpEvent;
+  int ScanArgument(int argc, const char** argv);
+
+private:
+  /** copy constructor prohibited */
+  AliHLTEsdCollectorComponent(const AliHLTEsdCollectorComponent&);
+  /** assignment operator prohibited */
+  AliHLTEsdCollectorComponent& operator=(const AliHLTEsdCollectorComponent&);
+
+  /** the ESD manager instance writes the ESDs */
+  AliHLTEsdManager* fpManager; //! transient
+
+  ClassDef(AliHLTEsdCollectorComponent, 0)
+};
+#endif
index 297d507561f6fa01b5406cf9361b5f4fb0d27553..fdabbec103cd4a6c576113756ca075ba7f05ed55 100644 (file)
@@ -206,6 +206,11 @@ class AliHLTFileWriter : public AliHLTDataSink  {
    */
   void SetExtension(const char* extension) {fExtension=extension!=NULL?extension:"";}
 
+  /**
+   * Get the target directory
+   */
+  TString GetDirectory() {return fDirectory;}
+
   /**
    * Working modes of the writer
    * @internal
diff --git a/HLT/BASE/util/AliHLTOUTPublisherComponent.cxx b/HLT/BASE/util/AliHLTOUTPublisherComponent.cxx
new file mode 100644 (file)
index 0000000..e70181e
--- /dev/null
@@ -0,0 +1,287 @@
+// $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   AliHLTOUTPublisherComponent.cxx
+    @author Matthias Richter
+    @date   2008-06-11
+    @brief  A data publisher for data block out of the HLTOUT data
+*/
+
+#include <cstdlib>
+#include "AliHLTOUTPublisherComponent.h"
+#include "AliHLTOUT.h"
+#include "TString.h"
+#include "AliRawReader.h"
+
+/** ROOT macro for the implementation of ROOT specific class methods */
+ClassImp(AliHLTOUTPublisherComponent)
+
+AliHLTOUTPublisherComponent::AliHLTOUTPublisherComponent()
+  :
+  fFilterRules(),
+  fMaxSize(0)
+{
+  // see header file for class documentation
+  // or
+  // refer to README to build package
+  // or
+  // visit http://web.ift.uib.no/~kjeks/doc/alice-hlt
+}
+
+AliHLTOUTPublisherComponent::~AliHLTOUTPublisherComponent()
+{
+  // see header file for class documentation
+}
+
+const char* AliHLTOUTPublisherComponent::GetComponentID()
+{
+  // see header file for class documentation
+  return "AliHLTOUTPublisher";
+}
+
+AliHLTComponentDataType AliHLTOUTPublisherComponent::GetOutputDataType()
+{
+  // see header file for class documentation
+  if (fFilterRules.size()==1) return fFilterRules[0].fDataType;
+  if (fFilterRules.size()==0) return kAliHLTAnyDataType;
+  return kAliHLTMultipleDataType;
+}
+
+int AliHLTOUTPublisherComponent::GetOutputDataTypes(AliHLTComponentDataTypeList& tgtList)
+{
+  // see header file for class documentation
+  tgtList.clear();
+  AliHLTComponentBlockDataList::iterator desc=fFilterRules.begin();
+  while (desc!=fFilterRules.end()) {
+    AliHLTComponentDataTypeList::iterator type=tgtList.begin();
+    while (type!=tgtList.end()) {
+      if (*type==(*desc).fDataType) break;
+      type++;
+    }
+    if (type==tgtList.end()) tgtList.push_back((*desc).fDataType);
+    desc++;
+  }
+  return tgtList.size();
+}
+
+void AliHLTOUTPublisherComponent::GetOutputDataSize( unsigned long& constBase, double& inputMultiplier )
+{
+  // see header file for class documentation
+  constBase=fMaxSize;
+  inputMultiplier=0.0; // there is no new data, just forwarded descriptors
+}
+
+AliHLTComponent* AliHLTOUTPublisherComponent::Spawn()
+{
+  // see header file for class documentation
+  return new AliHLTOUTPublisherComponent;
+}
+
+int AliHLTOUTPublisherComponent::DoInit( int argc, const char** argv )
+{
+  // see header file for class documentation
+  int iResult=0;
+  TString argument="";
+  int bMissingParam=0;
+  AliHLTComponentBlockData rule;
+  FillBlockData(rule);
+  for (int i=0; i<argc && iResult>=0; i++) {
+    argument=argv[i];
+    if (argument.IsNull()) continue;
+
+    // -datatype
+    if (argument.CompareTo("-datatype")==0) {
+      if ((bMissingParam=(i+2>=argc))) break;
+
+      if (!MatchExactly(rule.fDataType,kAliHLTAnyDataType)) {
+       // the data type has already been set, add to list
+       // and reset
+       fFilterRules.push_back(rule);
+       FillBlockData(rule);
+      }
+
+      SetDataType(rule.fDataType, argv[i+1], argv[i+2]);
+      i+=2;
+
+      // -origin
+    } else if (argument.CompareTo("-origin")==0) {
+      if ((bMissingParam=(i+1>=argc))) break;
+
+      if (!MatchExactly(rule.fDataType,kAliHLTAnyDataType)) {
+       // the data type has already been set, add to list
+       // and reset
+       fFilterRules.push_back(rule);
+       FillBlockData(rule);
+      }
+
+      SetDataType(rule.fDataType, NULL, argv[i+1]);
+      i+=1;
+
+      // -typeid
+    } else if (argument.CompareTo("-typeid")==0) {
+      if ((bMissingParam=(i+1>=argc))) break;
+
+      if (!MatchExactly(rule.fDataType,kAliHLTAnyDataType)) {
+       // the data type has already been set, add to list
+       // and reset
+       fFilterRules.push_back(rule);
+       FillBlockData(rule);
+      }
+
+      SetDataType(rule.fDataType, argv[i+1], NULL);
+      i+=1;
+
+      // -dataspec
+    } else if (argument.CompareTo("-dataspec")==0) {
+      if ((bMissingParam=(++i>=argc))) break;
+
+      if (rule.fSpecification!=kAliHLTVoidDataSpec) {
+       // the specification has already been set, add to list
+       // and reset
+       fFilterRules.push_back(rule);
+       FillBlockData(rule);
+      }
+
+      TString parameter(argv[i]);
+      parameter.Remove(TString::kLeading, ' '); // remove all blanks
+      char* pRemnant=NULL;
+      rule.fSpecification=strtoul(parameter.Data(), &pRemnant, 0);
+      if (pRemnant!=NULL && pRemnant[0]!=0) {
+       HLTError("invalid parameter/remnant (%s) for argument %s, number expected", pRemnant, argument.Data());
+       iResult=-EINVAL;
+      }
+    } else {
+      HLTError("unknown argument %s", argument.Data());
+      iResult=-EINVAL;
+      break;
+    }
+  }
+  if (iResult>=0) {
+    // add the pending rule or at least the empty default rule
+    fFilterRules.push_back(rule);
+    FillBlockData(rule);
+  }
+  return iResult;
+}
+
+int AliHLTOUTPublisherComponent::DoDeinit()
+{
+  // see header file for class documentation
+  int iResult=0;
+  fFilterRules.clear();
+  return iResult;
+}
+
+int AliHLTOUTPublisherComponent::GetEvent( const AliHLTComponentEventData& /*evtData*/,
+                                          AliHLTComponentTriggerData& /*trigData*/,
+                                          AliHLTUInt8_t* outputPtr, 
+                                          AliHLTUInt32_t& size,
+                                          AliHLTComponentBlockDataList& outputBlocks )
+{
+  // see header file for class documentation
+  int iResult=0;
+  unsigned int offset=0;
+  AliHLTOUT* pHLTOUT=NULL;
+  AliRawReader* pRawReader=GetRawReader();
+  if (pRawReader) {
+    pRawReader->Reset();
+    pHLTOUT=AliHLTOUT::New(pRawReader);
+//   } else {
+    // this is just a hack and work-around for the missing HLT AliLoader.
+    // Because of that the AliRoot framework does not provide the digit tree.
+    // The HLTDigits.root file is opened directly in the AliHLTOUTDigitReader.
+    // Later, the TTree digit tree object must be fetched here and passed to
+    // the HLTOUT instance.
+    // Maybe it's obsolete anyhow: 
+    // 1. AliHLT reconstruction from digit data is not supported
+    // 2. When integrated into HLTOUHandler of type kChain, most likely the
+    //    AliRawReaderMemory will be used.
+    // The functionality is tested also with the AliHLTOUTDigitReader, for the
+    // mentioned reasons I comment this branch.
+//     pHLTOUT=AliHLTOUT::New(NULL, GetEventCount());
+  } else {
+    if (GetEventCount()==0) {
+      HLTFatal("can not get RunLoader or RawReader, event processing aborted for current and subsequent events");
+    }
+    iResult=-ENODEV;
+  }
+  if (iResult>=0 && pHLTOUT) {
+    if ((iResult=pHLTOUT->Init())>=0) {
+      for (iResult=pHLTOUT->SelectFirstDataBlock();
+          iResult>=0;
+          iResult=pHLTOUT->SelectNextDataBlock()) {
+       AliHLTComponentDataType dt=kAliHLTVoidDataType;
+       AliHLTUInt32_t spec=kAliHLTVoidDataSpec;
+       pHLTOUT->GetDataBlockDescription(dt, spec);
+       if (fFilterRules.size()>0) {
+         // check if the block is selected
+         unsigned int rule=0;
+         for (; rule<fFilterRules.size(); rule++) {
+           if (fFilterRules[rule].fDataType!=dt) continue;
+           if (fFilterRules[rule].fSpecification!=kAliHLTVoidDataSpec &&
+               fFilterRules[rule].fSpecification!=spec) continue;
+           break;
+         }
+         // skip the block if none of the filter rules matches
+         if (rule>=fFilterRules.size()) continue;
+       }
+       const AliHLTUInt8_t* pBuffer=NULL;
+       AliHLTUInt32_t bufferSize=0;
+       if ((iResult=pHLTOUT->GetDataBuffer(pBuffer, bufferSize))>=0) {
+         if (bufferSize+offset<=size) {
+           memcpy(outputPtr+offset, pBuffer, bufferSize);
+           AliHLTComponentBlockData bd;
+           FillBlockData( bd );
+           bd.fOffset = offset;
+           bd.fSize = bufferSize;
+           bd.fDataType = dt;
+           bd.fSpecification = spec;
+           outputBlocks.push_back( bd );
+         } else {
+           // we keep the loop going in order to collect the full size
+           fMaxSize=offset+bufferSize;
+         }
+         offset+=bufferSize;
+       }
+      }
+      // -ENOENT is not an error but the return value for 'no more data block'
+      if (iResult==-ENOENT) iResult=0;
+
+      // indicate too little space in buffer for repeated processing
+      if (offset>size) {
+       iResult=-ENOSPC;
+      }
+    } else if (GetEventCount()<5) {
+      const char* message="";
+      if (GetEventCount()==4) message=", suppressing further messages";
+      HLTError("failed initializing HLTOUT%s", message);
+    }
+    AliHLTOUT::Delete(pHLTOUT);
+    pHLTOUT=NULL;
+  } else {
+    if (GetEventCount()==0) {
+      HLTFatal("can not create HLTOUT instance, event processing aborted for current and most likely subsequent events");
+    }
+    iResult=-ENODEV;
+  }
+
+  // finally set the output size
+  size=offset;
+
+  return iResult;
+}
diff --git a/HLT/BASE/util/AliHLTOUTPublisherComponent.h b/HLT/BASE/util/AliHLTOUTPublisherComponent.h
new file mode 100644 (file)
index 0000000..b37fed6
--- /dev/null
@@ -0,0 +1,116 @@
+//-*- Mode: C++ -*-
+// $Id$
+
+#ifndef ALIHLTOUTPUBLISHERCOMPONENT_H
+#define ALIHLTOUTPUBLISHERCOMPONENT_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   AliHLTOUTPublisherComponent.h
+    @author Matthias Richter
+    @date   2008-06-11
+    @brief  A data publisher for data block out of the HLTOUT data
+*/
+
+#include "AliHLTOfflineDataSource.h"
+
+/**
+ * @class AliHLTOUTPublisherComponent
+ * A data publisher component for data blocks out of the HLTOUT data.
+ * All data blocks forwarded to the HLTOUT (either real or simulated),
+ * are encoded in HOMER format and stored in the HLT data links, or
+ * eventually the HLT digit file in case of simulation.
+ *
+ * This component publishes data blocks out of the HLTOUT data. To the
+ * subscribing components the data blocks seem to come directly from
+ * the producing component in the HLT analysis chain. The HLTOUT is just
+ * a transparent transport layer. Filter rules by data type and
+ * specification can be applied.
+ * 
+ * Component ID: \b AliHLTOUTPublisher <br>
+ * Library: \b libAliHLTUtil.
+ *
+ * Mandatory arguments: <br>
+ * <!-- NOTE: ignore the \li. <i> and </i>: it's just doxygen formatting -->
+ *      
+ * Optional arguments:<br>
+ * <!-- NOTE: ignore the \li. <i> and </i>: it's just doxygen formatting -->
+ * \li -datatype     <i> id origin      </i>
+ *      e.g. <tt> -datatype 'ESD_TREE' 'TPC ' </tt> <br>
+ *      \b Note: due to the 4-character data origin it might be necessary to
+ *      append a blank to the detectorname, e.g. TPC -> 'TPC '
+ * \li -origin  <i> origin      </i>
+ *      e.g. -origin 'TPC ', \b Note:  the filter rule has type id 'ANY'
+ * \li -typeid  <i> id      </i>
+ *      e.g. -typeid ESD_TREE, \b Note: the filter rule has origin 'ANY'
+ * \li -dataspec     <i> specification </i> <br>
+ *      data specification treated as decimal number or hex number if
+ *      prepended by '0x'
+ * \li -verbose<br>
+ *      print out some more info messages, mainly for the sake of tutorials
+ *
+ * By default, all blocks will be published. By means of the -datatype,
+ * -origin, and -typeid arguments, the blocks can be selected. A list of filter
+ * rules can be built up by multiple usage of the arguments. Each time a new
+ * filter rule is added.
+ *
+ * No filtering by the data specification is applied unless the -specification
+ * argument is used. The specification applies to to the current filter rule,
+ * regardless of the sequence of -datatype/-specification arguments.
+ *
+ * @ingroup alihlt_system
+ */
+class AliHLTOUTPublisherComponent : public AliHLTOfflineDataSource {
+ public:
+  /** standard constructor */
+  AliHLTOUTPublisherComponent();
+  /** destructor */
+  virtual ~AliHLTOUTPublisherComponent();
+
+  const char* GetComponentID();
+  AliHLTComponentDataType GetOutputDataType();
+  int GetOutputDataTypes(AliHLTComponentDataTypeList& tgtList);
+  void GetOutputDataSize( unsigned long& constBase, double& inputMultiplier );
+  virtual AliHLTComponent* Spawn();
+
+ protected:
+  int DoInit( int argc, const char** argv );
+  int DoDeinit();
+
+  /**
+   * Data source method.
+   * @param evtData       event data structure
+   * @param trigData     trigger data structure
+   * @param outputPtr    pointer to target buffer
+   * @param size         <i>input</i>: size of target buffer
+   *                     <i>output</i>:size of produced data
+   * @param outputBlocks  list to receive output block descriptors
+   * @return neg. error code if failed
+   */
+  int GetEvent( const AliHLTComponentEventData& evtData,
+               AliHLTComponentTriggerData& trigData,
+               AliHLTUInt8_t* outputPtr, 
+               AliHLTUInt32_t& size,
+               AliHLTComponentBlockDataList& outputBlocks );
+
+  using AliHLTOfflineDataSource::GetEvent;
+
+ protected:
+
+ private:
+  /** copy constructor prohibited */
+  AliHLTOUTPublisherComponent(const AliHLTOUTPublisherComponent&);
+  /** assignment operator prohibited */
+  AliHLTOUTPublisherComponent& operator=(const AliHLTOUTPublisherComponent&);
+
+  /** filtering rules, only the data type and specification members are use */
+  AliHLTComponentBlockDataList fFilterRules;                       //! transient
+
+  /** maximum output size */
+  int fMaxSize; //!
+
+  ClassDef(AliHLTOUTPublisherComponent, 0);
+};
+
+#endif
diff --git a/HLT/exa/hltout-collect-esd.C b/HLT/exa/hltout-collect-esd.C
new file mode 100644 (file)
index 0000000..40dc971
--- /dev/null
@@ -0,0 +1,64 @@
+// $Id$
+/**
+ * @file hltout-collect-esd.C
+ * @brief Example for the AliHLTEsdCollectorComponent
+ *
+ * Example macro to run a small chain with the AliHLTOUTPublisherComponent
+ * and the AliHLTEsdCollectorComponent. The AliHLTOUTPublisherComponent
+ * is configured to publish all ESD objects from the HLTOUT data, the
+ * AliHLTEsdCollectorComponent writes the files using the AliHLTEsdManager.
+ *
+ * Usage: aliroot -b -q hltout-collect-esd.C | tee hltout-collect-esd.log
+ *
+ * The macro asumes HLTOUT raw data ddl files in order to open an
+ * AliRawReaderFile, e.g. simulated using the default AliSimulation with
+ * at least SetWriteRawData("HLT") enabled.
+ *
+ * \b Note: The example disables a few steps in the AliReconstruction,
+ * mainly because of crashes in various parts of AliRoot. This does not
+ * have any impact to the HLT features to be presented.
+ *
+ * @author Matthias.Richter@ift.uib.no
+ * @ingroup alihlt_tutorial
+ */
+void hltout_collect_esd()
+{
+  /////////////////////////////////////////////////////////////////////////
+  /////////////////////////////////////////////////////////////////////////
+  //
+  // setup of the HLT system
+  gSystem->Load("libHLTrec");
+  AliHLTSystem* pHLT=AliHLTReconstructorBase::GetInstance();
+  if (!pHLT) {
+    cerr << "fatal error: can not get HLT instance" << endl;
+  }
+
+  /////////////////////////////////////////////////////////////////////////
+  /////////////////////////////////////////////////////////////////////////
+  //
+  // the configuration chain
+  TString arg;
+
+  // the publisher configuration
+  arg.Form("-typeid ESD_TREE -typeid ALIESDV0");
+  AliHLTConfiguration publisher("hltout-publisher", "AliHLTOUTPublisher" , NULL, arg.Data());
+
+  // the writer configuration
+  arg.Form("");
+  AliHLTConfiguration collector("sink1", "EsdCollector"   , "hltout-publisher", arg.Data());
+
+  /////////////////////////////////////////////////////////////////////////
+  /////////////////////////////////////////////////////////////////////////
+  //
+  // setup of the reconstruction
+  AliReconstruction rec;
+  rec.SetInput("./");
+  rec.SetRunLocalReconstruction("HLT");
+  rec.SetRunTracking("");
+  rec.SetFillESD("");
+  rec.SetRunQA(kFALSE);
+  rec.SetFillTriggerESD(kFALSE);
+  rec.SetRunVertexFinder(kFALSE);
+  rec.SetOption("HLT", "libAliHLTUtil.so loglevel=0x7c chains=sink1");
+  rec.Run();
+}
diff --git a/HLT/exa/split-hltout.C b/HLT/exa/split-hltout.C
new file mode 100644 (file)
index 0000000..773dd2b
--- /dev/null
@@ -0,0 +1,64 @@
+// $Id$
+/**
+ * @file split-hltout.C
+ * @brief Example for the AliHLTOUTPublisherComponent
+ *
+ * Example macro to run a small chain with the AliHLTOUTPublisherComponent.
+ * The AliHLTOUTPublisherComponent is a tool to publish data blocks from
+ * the HLTOUT data stream into an AliHLT reconstruction chain.
+ *
+ * Usage: aliroot -b -q split-hltout.C | tee split-hltout.log
+ *
+ * The macro asumes HLTOUT raw data ddl files in order to open an
+ * AliRawReaderFile, e.g. simulated by sim-hlt-rawddl.C. A small chain with
+ * just a FileWriter connected is run embedded into AliReconstruction.
+ *
+ * \b Note: The example disables a few steps in the AliReconstruction,
+ * mainly because of crashes in various parts of AliRoot. This does not
+ * have any impact to the HLT features to be presented.
+ *
+ * @author Matthias.Richter@ift.uib.no
+ * @ingroup alihlt_tutorial
+ */
+void split_hltout()
+{
+  /////////////////////////////////////////////////////////////////////////
+  /////////////////////////////////////////////////////////////////////////
+  //
+  // setup of the HLT system
+  gSystem->Load("libHLTrec");
+  AliHLTSystem* pHLT=AliHLTReconstructorBase::GetInstance();
+  if (!pHLT) {
+    cerr << "fatal error: can not get HLT instance" << endl;
+  }
+
+  /////////////////////////////////////////////////////////////////////////
+  /////////////////////////////////////////////////////////////////////////
+  //
+  // the configuration chain
+  TString arg;
+
+  // the publisher configuration
+  arg.Form("");
+  AliHLTConfiguration publisher("hltout-publisher", "AliHLTOUTPublisher" , NULL, arg.Data());
+
+  // the writer configuration
+  arg.Form("-subdir=out%%d -datafile hltout.dat -specfmt=_0x%%x");
+  // see AliHLTFileWriter
+  AliHLTConfiguration fwconf("sink1", "FileWriter"   , "hltout-publisher", arg.Data());
+
+  /////////////////////////////////////////////////////////////////////////
+  /////////////////////////////////////////////////////////////////////////
+  //
+  // setup of the reconstruction
+  AliReconstruction rec;
+  rec.SetInput("./");
+  rec.SetRunLocalReconstruction("HLT");
+  rec.SetRunTracking("");
+  rec.SetFillESD("");
+  rec.SetRunQA(kFALSE);
+  rec.SetFillTriggerESD(kFALSE);
+  rec.SetRunVertexFinder(kFALSE);
+  rec.SetOption("HLT", "libAliHLTUtil.so loglevel=0x7c chains=sink1");
+  rec.Run();
+}
index fd7fb407c2f755471c2133799581a800f00496df..40ae1bb4337b8e3d03d80b22fbef9f22210deb1b 100644 (file)
@@ -8,6 +8,8 @@ CLASS_HDRS:=    AliHLTFilePublisher.h \
                AliHLTRootFileStreamerComponent.h \
                AliHLTLoaderPublisherComponent.h \
                AliHLTRawReaderPublisherComponent.h \
+               AliHLTOUTPublisherComponent.h \
+               AliHLTEsdCollectorComponent.h \
                AliHLTDataGenerator.h \
                AliHLTBlockFilterComponent.h \
                AliHLTAgentUtil.h
index 2b6d0a048c403ded9fada2cbb000dfc4fff47e2b..f4e58f105093602f2b2539cb25deeb3757f467a0 100644 (file)
@@ -212,3 +212,14 @@ int AliHLTOUTDigitReader::CloseTree()
 
   return iResult;
 }
+
+void AliHLTOUTDigitReader::SetParam(TTree* /*pDigitTree*/, int event)
+{
+  // see header file for class documentation
+
+  // TODO: here we have the implemented to correct loading of
+  // the digit file from the run loader. At time of writing
+  // (Jun 2008) the AliLoader for the HLT is missing in the AliRoot
+  // framework.
+  fEvent=event;
+}
index 59197d10059b7ce0d928d6ad813e97e33a4866cb..510e6e4559e8759f3e1fc91a44d1b41e6b296584 100644 (file)
@@ -61,6 +61,13 @@ class AliHLTOUTDigitReader : public AliHLTOUTHomerCollection {
    */
   int CloseTree();
 
+  /**
+   * Set the RunLoader as parameter
+   * The function is for internal use only in conjunction with the
+   * AliHLTOUT::New() functions.
+   */
+  void SetParam(TTree* pDigitTree, int event=-1);
+
   /** name of the digit file */
   TString fDigitFileName; //! transient
 
index e5e62c3cceb0fbcfa4efd33f9ceef18394986740..084164328ca507ff91f675d50b3f0c82a19522bf 100644 (file)
@@ -110,9 +110,11 @@ class AliHLTOUTHomerCollection : public AliHLTOUTHomerBuffer {
   /** current instance of the HOMER reader */
   AliHLTHOMERReader* fpCurrent;  //!transient
 
+protected:
   /** current event no */
   int fEvent; //!transient
 
+private:
   /** instance of the ESD manager for writing and merging */
   AliHLTEsdManager* fpEsdManager; //!transient
 
index e63b0e8383dc8f899346246f24d5c961cdfbd0ae..9a6f012e516d9123d1380c4bc6f5fd94475e3e7f 100644 (file)
 /** ROOT macro for the implementation of ROOT specific class methods */
 ClassImp(AliHLTOUTRawReader)
 
+AliHLTOUTRawReader::AliHLTOUTRawReader()
+  :
+  AliHLTOUTHomerCollection(),
+  fpRawreader(NULL)
+{
+  // see header file for class documentation
+  // or
+  // refer to README to build package
+  // or
+  // visit http://web.ift.uib.no/~kjeks/doc/alice-hlt
+}
+
 AliHLTOUTRawReader::AliHLTOUTRawReader(AliRawReader* pRawreader, int event, AliHLTEsdManager* pEsdManager)
   :
   AliHLTOUTHomerCollection(event, pEsdManager),
index 27dc223d5f56d2de4f143f86d502f0df12c8f564..16eaf4759a5bcb29a54ef8addfa95c0497179290 100644 (file)
@@ -24,6 +24,8 @@ class AliHLTHOMERReader;
  */
 class AliHLTOUTRawReader : public AliHLTOUTHomerCollection {
  public:
+  /** standard constructor */
+  AliHLTOUTRawReader();
   /** constructor */
   AliHLTOUTRawReader(AliRawReader* pRawReader, int event=-1, AliHLTEsdManager* pEsdManager=NULL);
   /** destructor */
@@ -39,13 +41,18 @@ class AliHLTOUTRawReader : public AliHLTOUTHomerCollection {
   int GetEquipmentId();
 
  private:
-  /** standard constructor prohibited */
-  AliHLTOUTRawReader();
   /** copy constructor prohibited */
   AliHLTOUTRawReader(const AliHLTOUTRawReader&);
   /** assignment operator prohibited */
   AliHLTOUTRawReader& operator=(const AliHLTOUTRawReader&);
 
+  /**
+   * Set the RawReader as parameter.
+   * The function is for internal use only in conjunction with the
+   * AliHLTOUT::New() functions.
+   */
+  void SetParam(AliRawReader* pRawReader) {fpRawreader=pRawReader;}
+
   /** the rawreader */
   AliRawReader* fpRawreader; //!transient