]> git.uio.no Git - u/mrichter/AliRoot.git/commitdiff
implemented TPCEsdConverter component
authorrichterm <richterm@f7af4fe6-9843-0410-8265-dc069ae4e863>
Mon, 26 Nov 2007 00:46:58 +0000 (00:46 +0000)
committerrichterm <richterm@f7af4fe6-9843-0410-8265-dc069ae4e863>
Mon, 26 Nov 2007 00:46:58 +0000 (00:46 +0000)
HLT/TPCLib/AliHLTTPCEsdWriterComponent.cxx
HLT/TPCLib/AliHLTTPCEsdWriterComponent.h

index 742b9cf409b12b21869943f945dff803e6df22fd..7148724f253b4b785dcd8d05c2e1f6a18cc40f72 100644 (file)
@@ -23,6 +23,7 @@
             mapping tracker in the AliESD format
 
                                                                           */
+#include <cassert>
 #include "AliHLTTPCEsdWriterComponent.h"
 #include "AliESDEvent.h"
 #include "AliESDtrack.h"
 #include "AliHLTTPCTrackArray.h"
 #include "AliHLTTPCTrackletDataFormat.h"
 #include "AliHLTTPCDefinitions.h"
+#include "AliHLTTPCTransform.h"
 
 /** global instance for component registration */
-AliHLTTPCEsdWriterComponent gTPCEsdWriter;
+AliHLTTPCEsdWriterComponent::AliWriter gTPCEsdWriter;
+AliHLTTPCEsdWriterComponent::AliConverter gTPCEsdConverter;
 
 /** ROOT macro for the implementation of ROOT specific class methods */
 ClassImp(AliHLTTPCEsdWriterComponent)
 
 AliHLTTPCEsdWriterComponent::AliHLTTPCEsdWriterComponent()
+{
+  // see header file for class documentation
+  // or
+  // refer to README to build package
+  // or
+  // visit http://web.ift.uib.no/~kjeks/doc/alice-hlt
+}
+
+AliHLTTPCEsdWriterComponent::~AliHLTTPCEsdWriterComponent()
+{
+  // see header file for class documentation
+}
+
+AliHLTTPCEsdWriterComponent::AliWriter::AliWriter()
   :
   fTree(NULL),
-  fESD(NULL)
+  fESD(NULL),
+  fBase(new AliHLTTPCEsdWriterComponent)
 {
   // see header file for class documentation
   // or
@@ -50,12 +68,20 @@ AliHLTTPCEsdWriterComponent::AliHLTTPCEsdWriterComponent()
   // visit http://web.ift.uib.no/~kjeks/doc/alice-hlt
 }
 
-AliHLTTPCEsdWriterComponent::~AliHLTTPCEsdWriterComponent()
+AliHLTTPCEsdWriterComponent::AliWriter::~AliWriter()
+{
+  // see header file for class documentation
+  if (fBase) delete fBase;
+  fBase=NULL;
+}
+
+void AliHLTTPCEsdWriterComponent::AliWriter::GetInputDataTypes(AliHLTComponentDataTypeList& list)
 {
   // see header file for class documentation
+  list.push_back(AliHLTTPCDefinitions::fgkTrackSegmentsDataType);
 }
 
-int AliHLTTPCEsdWriterComponent::InitWriter()
+int AliHLTTPCEsdWriterComponent::AliWriter::InitWriter()
 {
   // see header file for class documentation
   int iResult=0;
@@ -73,7 +99,7 @@ int AliHLTTPCEsdWriterComponent::InitWriter()
   return iResult;
 }
 
-int AliHLTTPCEsdWriterComponent::CloseWriter()
+int AliHLTTPCEsdWriterComponent::AliWriter::CloseWriter()
 {
   // see header file for class documentation
   int iResult=0;
@@ -89,22 +115,47 @@ int AliHLTTPCEsdWriterComponent::CloseWriter()
   return iResult;
 }
 
-int AliHLTTPCEsdWriterComponent::DumpEvent( const AliHLTComponentEventData& evtData,
+int AliHLTTPCEsdWriterComponent::AliWriter::DumpEvent( const AliHLTComponentEventData& evtData,
                                            const AliHLTComponentBlockData* blocks, 
                                            AliHLTComponentTriggerData& /*trigData*/ )
 {
   // see header file for class documentation
   int iResult=0;
   TTree* pTree=fTree;
-  if (pTree) {
+  assert(fBase);
+  if (pTree && fBase) {
     if (fESD) {
       AliESDEvent* pESD=fESD;
 
+      iResult=fBase->ProcessBlocks(pTree, pESD, blocks, (int)evtData.fBlockCnt);
+
+    } else {
+      iResult=-ENOMEM;
+    }
+  }
+  return iResult;
+}
+
+int AliHLTTPCEsdWriterComponent::AliWriter::ScanArgument(int argc, const char** argv)
+{
+  // see header file for class documentation
+  int iResult=AliHLTRootFileWriterComponent::ScanArgument(argc, argv);
+  return iResult;
+}
+
+int AliHLTTPCEsdWriterComponent::ProcessBlocks(TTree* pTree, AliESDEvent* pESD,
+                                              const AliHLTComponentBlockData* blocks,
+                                              int nBlocks, int* pMinSlice,
+                                              int* pMaxSlice)
+{
+  // see header file for class documentation
+  int iResult=0;
+  if (pTree && pESD && blocks) {
       const AliHLTComponentBlockData* iter = NULL;
       AliHLTTPCTrackletData* inPtr=NULL;
       int bIsTrackSegs=0;
  
-      for (int ndx=0; ndx<(int)evtData.fBlockCnt && iResult>=0; ndx++) {
+      for (int ndx=0; ndx<nBlocks && iResult>=0; ndx++) {
        iter = blocks+ndx;
        if ( (bIsTrackSegs=(iter->fDataType == AliHLTTPCDefinitions::fgkTrackSegmentsDataType))==1 ||
             iter->fDataType == AliHLTTPCDefinitions::fgkTracksDataType ) {
@@ -114,9 +165,14 @@ int AliHLTTPCEsdWriterComponent::DumpEvent( const AliHLTComponentEventData& evtD
            // slice parameter and data specification ignored, tracks already in global coordinates
            minslice=-1;
            maxslice=-1;
+           if (pMinSlice) *pMinSlice=0;
+           if (pMaxSlice) *pMaxSlice=AliHLTTPCTransform::GetNSlice()-1;
+         } else {
+           if (pMinSlice && (*pMinSlice==-1 || *pMinSlice>minslice)) *pMinSlice=minslice;
+           if (pMaxSlice && (*pMaxSlice==-1 || *pMaxSlice<maxslice)) *pMaxSlice=maxslice;
          }
          //HLTDebug("dataspec %#x minslice %d", iter->fSpecification, minslice);
-         if (minslice >=-1 && minslice<36) {
+         if (minslice >=-1 && minslice<AliHLTTPCTransform::GetNSlice()) {
            if (minslice!=maxslice) {
              HLTWarning("data from multiple sectors in one block: "
                         "possible missmatch in treatment of local coordinate system");
@@ -137,21 +193,14 @@ int AliHLTTPCEsdWriterComponent::DumpEvent( const AliHLTComponentEventData& evtD
        pTree->Fill();
       }
 
-      fESD->Reset();
-    } else {
-      iResult=-ENOMEM;
-    }
+      pESD->Reset();
+    
+  } else {
+    iResult=-EINVAL;
   }
   return iResult;
 }
 
-int AliHLTTPCEsdWriterComponent::ScanArgument(int argc, const char** argv)
-{
-  // see header file for class documentation
-  int iResult=AliHLTRootFileWriterComponent::ScanArgument(argc, argv);
-  return iResult;
-}
-
 int AliHLTTPCEsdWriterComponent::Tracks2ESD(AliHLTTPCTrackArray* pTracks, AliESDEvent* pESD)
 {
   // see header file for class documentation
@@ -183,3 +232,81 @@ int AliHLTTPCEsdWriterComponent::Tracks2ESD(AliHLTTPCTrackArray* pTracks, AliESD
   }
   return iResult;
 }
+
+AliHLTTPCEsdWriterComponent::AliConverter::AliConverter()
+  :
+  fBase(new AliHLTTPCEsdWriterComponent)
+{
+  // see header file for class documentation
+  // or
+  // refer to README to build package
+  // or
+  // visit http://web.ift.uib.no/~kjeks/doc/alice-hlt
+}
+
+AliHLTTPCEsdWriterComponent::AliConverter::~AliConverter()
+{
+  // see header file for class documentation
+  if (fBase) delete fBase;
+  fBase=NULL;
+}
+
+void AliHLTTPCEsdWriterComponent::AliConverter::GetInputDataTypes(AliHLTComponentDataTypeList& list)
+{
+  // see header file for class documentation
+  list.push_back(AliHLTTPCDefinitions::fgkTrackSegmentsDataType);
+}
+
+AliHLTComponentDataType AliHLTTPCEsdWriterComponent::AliConverter::GetOutputDataType()
+{
+  // see header file for class documentation
+  return kAliHLTDataTypeESDTree;
+}
+
+void AliHLTTPCEsdWriterComponent::AliConverter::GetOutputDataSize(unsigned long& constBase, double& inputMultiplier)
+{
+  // see header file for class documentation
+  constBase=1000000;
+  inputMultiplier=1.0;
+}
+
+int AliHLTTPCEsdWriterComponent::AliConverter::DoInit(int argc, const char** argv)
+{
+  // see header file for class documentation
+  return 0;
+}
+
+int AliHLTTPCEsdWriterComponent::AliConverter::DoDeinit()
+{
+  // see header file for class documentation
+  return 0;
+}
+
+int AliHLTTPCEsdWriterComponent::AliConverter::DoEvent(const AliHLTComponentEventData& evtData, 
+                                                      const AliHLTComponentBlockData* blocks, 
+                                                      AliHLTComponentTriggerData& /*trigData*/,
+                                                      AliHLTUInt8_t* /*outputPtr*/, 
+                                                      AliHLTUInt32_t& /*size*/,
+                                                      AliHLTComponentBlockDataList& /*outputBlocks*/ )
+{
+  // see header file for class documentation
+  int iResult=0;
+  assert(fBase);
+  AliESDEvent* pESD = new AliESDEvent;
+  if (pESD && fBase) {
+    pESD->CreateStdContent();
+    TTree* pTree = new TTree("esdTree", "Tree with HLT ESD objects");
+    if (pTree) {
+      pESD->WriteToTree(pTree);
+
+      if ((iResult=fBase->ProcessBlocks(pTree, pESD, blocks, (int)evtData.fBlockCnt))>=0) {
+       // TODO: set the specification correctly
+       iResult=PushBack(pTree, kAliHLTDataTypeESDTree|kAliHLTDataOriginTPC, 0);
+      }
+      delete pTree;
+    }
+    delete pESD;
+  }
+  return iResult;
+}
+
index 3e9a75e39a8e40b537bbca3070c274c1960b6cd4..b477ff977e84f9285677f3e89177383a76904509 100644 (file)
@@ -13,6 +13,7 @@
 
                                                                           */
 #include "AliHLTRootFileWriterComponent.h"
+#include "AliHLTProcessor.h"
 
 // forward declarations
 class TTree;
@@ -24,19 +25,29 @@ class AliHLTTPCTrackArray;
  * This class translates incoming track segments structures from the TPC
  * conformal mapping tracker (datatype TRAKSEGS/TPC) or tracks in global 
  * coordinates from the AliHLTTPCGlobalMergerComponent (TRACKS/TPC) into
- * the ESD fromat and writes it to a ROOT file. In case of TRAKSEGS, the
- * component can only process data block containing data of one slice, but
- * it can read an unlimeted number of data blocks.
+ * the ESD format.
  *
- * componentid: TPCEsdWriter <br>
- * componentlibrary libAliHLTTPC.so <br>
- * Arguments: <br>
+ * The \em TPCEsdWriter writes it to a ROOT file, the \em TPCEsdConverter
+ * to a TTree and sends the whole object to the output stream with data
+ * type @ref kAliHLTDataTypeESDTree and origin TPC.
+ *
+ * In case of TRAKSEGS, the component can only process data block containing
+ * data of one slice, but it can read an unlimeted number of data blocks.
+ *
+ * componentid: \b TPCEsdWriter <br>
+ * componentid: \b TPCEsdConverter <br>
+ * componentlibrary: \b libAliHLTTPC.so <br>
+ * Arguments TPCEsdWriter: <br>
  * <!-- NOTE: ignore the \li. <i> and </i>: it's just doxygen formating -->
  * \li -datafile     <i> filename   </i> <br>
  *      file name base
  * \li -directory    <i> directory  </i> <br>
  *      target directory
  *
+ * Arguments TPCEsdConverter: <br>
+ * <!-- NOTE: ignore the \li. <i> and </i>: it's just doxygen formating -->
+ * none
+ *
  * <pre>
  * Example usage (HLT configuration file):
  *         \<Proc ID="EsdWriter" type="prc">
@@ -54,7 +65,7 @@ class AliHLTTPCTrackArray;
  *
  * @see AliHLTFileWriter and AliHLTRootFileWriterComponent for more parameters
  */
-class AliHLTTPCEsdWriterComponent : public AliHLTRootFileWriterComponent
+class AliHLTTPCEsdWriterComponent : public AliHLTLogging
 {
  public:
   /** standard constructor */
@@ -62,17 +73,31 @@ class AliHLTTPCEsdWriterComponent : public AliHLTRootFileWriterComponent
   /** destructor */
   ~AliHLTTPCEsdWriterComponent();
 
+  /**
+   * class AliHLTTPCEsdWriterComponent::AliWriter
+   * The writer component of the AliHLTTPCEsdWriterComponent.
+   */
+  class AliWriter : public AliHLTRootFileWriterComponent
+  {
+  public:
+  /** standard constructor */
+  AliWriter();
+  /** destructor */
+  ~AliWriter();
+
   /**
    * The id of the component.
    * @return component id (string)
    */
   const char* GetComponentID() {return "TPCEsdWriter";};
 
+  void GetInputDataTypes(AliHLTComponentDataTypeList& list);
+
   /**
    * Spawn function.
    * @return new class instance
    */
-  AliHLTComponent* Spawn() {return new AliHLTTPCEsdWriterComponent;}
+  AliHLTComponent* Spawn() {return new AliHLTTPCEsdWriterComponent::AliWriter;}
 
  protected:
   /**
@@ -98,12 +123,11 @@ class AliHLTTPCEsdWriterComponent : public AliHLTRootFileWriterComponent
    *         -EPROTO parameter for argument missing <br>
    */
   int ScanArgument(int argc, const char** argv);
-
  private:
   /** copy constructor prohibited */
-  AliHLTTPCEsdWriterComponent(const AliHLTTPCEsdWriterComponent&);
+  AliWriter(const AliWriter&);
   /** assignment operator prohibited */
-  AliHLTTPCEsdWriterComponent& operator=(const AliHLTTPCEsdWriterComponent&);
+  AliWriter& operator=(const AliWriter&);
 
   /**
    * Init the writer.
@@ -119,6 +143,74 @@ class AliHLTTPCEsdWriterComponent : public AliHLTRootFileWriterComponent
    */
   int CloseWriter();
 
+  /** the ESD tree */
+  TTree* fTree; //! transient value
+
+  /** the ESD */
+  AliESDEvent* fESD; //! transient value
+
+  /** pointer to the basic ESD conversion methods */
+  AliHLTTPCEsdWriterComponent* fBase; //! transient value
+  };
+
+  /**
+   * class AliHLTTPCEsdWriterComponent::AliConverter
+   * The converter component of the AliHLTTPCEsdWriterComponent.
+   * 
+   */
+  class AliConverter : public AliHLTProcessor
+  {
+  public:
+    /** standard constructor */
+    AliConverter();
+    /** destructor */
+    ~AliConverter();
+
+    // interface methods of base class
+    const char* GetComponentID() {return "TPCEsdConverter";};
+    void GetInputDataTypes(AliHLTComponentDataTypeList& list);
+    AliHLTComponentDataType GetOutputDataType();
+    void GetOutputDataSize(unsigned long& constBase, double& inputMultiplier);
+    AliHLTComponent* Spawn() {return new AliHLTTPCEsdWriterComponent::AliConverter;}
+
+  protected:
+    // interface methods of base class
+    int DoInit(int argc, const char** argv);
+    int DoDeinit();
+    int DoEvent(const AliHLTComponentEventData& evtData,
+               const AliHLTComponentBlockData* blocks, 
+               AliHLTComponentTriggerData& trigData,
+               AliHLTUInt8_t* outputPtr, 
+               AliHLTUInt32_t& size,
+               AliHLTComponentBlockDataList& outputBlocks );
+
+    using AliHLTProcessor::DoEvent;
+
+  private:
+    /** copy constructor prohibited */
+    AliConverter(const AliConverter&);
+    /** assignment operator prohibited */
+    AliConverter& operator=(const AliConverter&);
+
+    /** pointer to the basic ESD conversion methods */
+    AliHLTTPCEsdWriterComponent* fBase; //! transient value
+
+  };
+
+ protected:
+  /**
+   * Process the input data blocks.
+   * @param pTree    tree to be filled
+   * @param pESD     ESD to be filled
+   * @param blocks   data block descriptor array
+   * @param nBlocks  size of the array
+   * @param pMinSize [OUT] receives the minimum slice no
+   * @param pMaxSize [OUT] receives the maximum slice no
+   * @return neg. error code if failed
+   */
+  int ProcessBlocks(TTree* pTree, AliESDEvent* pESD, const AliHLTComponentBlockData* blocks,
+                   int nBlocks, int* pMinSlice=NULL, int* pMaxSlice=NULL);
+
   /**
    * Covert tracks to AliTPCtracks (AliKalmanTracks) and add them to ESD.
    * @param pTracks  array of tracks
@@ -127,11 +219,11 @@ class AliHLTTPCEsdWriterComponent : public AliHLTRootFileWriterComponent
    */
   int Tracks2ESD(AliHLTTPCTrackArray* pTracks, AliESDEvent* pESD);
 
-  /** the ESD tree */
-  TTree* fTree; //! transient value
-
-  /** the ESD */
-  AliESDEvent* fESD; //! transient value
+ private:
+  /** copy constructor prohibited */
+  AliHLTTPCEsdWriterComponent(const AliHLTTPCEsdWriterComponent&);
+  /** assignment operator prohibited */
+  AliHLTTPCEsdWriterComponent& operator=(const AliHLTTPCEsdWriterComponent&);
 
   ClassDef(AliHLTTPCEsdWriterComponent, 1)
 };