From 37513ae4b9ba52de2c7d683e0779bec8c7dc42e6 Mon Sep 17 00:00:00 2001 From: richterm Date: Mon, 26 Nov 2007 00:46:58 +0000 Subject: [PATCH] implemented TPCEsdConverter component --- HLT/TPCLib/AliHLTTPCEsdWriterComponent.cxx | 167 ++++++++++++++++++--- HLT/TPCLib/AliHLTTPCEsdWriterComponent.h | 124 +++++++++++++-- 2 files changed, 255 insertions(+), 36 deletions(-) diff --git a/HLT/TPCLib/AliHLTTPCEsdWriterComponent.cxx b/HLT/TPCLib/AliHLTTPCEsdWriterComponent.cxx index 742b9cf409b..7148724f253 100644 --- a/HLT/TPCLib/AliHLTTPCEsdWriterComponent.cxx +++ b/HLT/TPCLib/AliHLTTPCEsdWriterComponent.cxx @@ -23,6 +23,7 @@ mapping tracker in the AliESD format */ +#include #include "AliHLTTPCEsdWriterComponent.h" #include "AliESDEvent.h" #include "AliESDtrack.h" @@ -31,17 +32,34 @@ #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=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 || *pMaxSlicefSpecification, minslice); - if (minslice >=-1 && minslice<36) { + if (minslice >=-1 && minsliceFill(); } - 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; +} + diff --git a/HLT/TPCLib/AliHLTTPCEsdWriterComponent.h b/HLT/TPCLib/AliHLTTPCEsdWriterComponent.h index 3e9a75e39a8..b477ff977e8 100644 --- a/HLT/TPCLib/AliHLTTPCEsdWriterComponent.h +++ b/HLT/TPCLib/AliHLTTPCEsdWriterComponent.h @@ -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
- * componentlibrary libAliHLTTPC.so
- * Arguments:
+ * 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
+ * componentid: \b TPCEsdConverter
+ * componentlibrary: \b libAliHLTTPC.so
+ * Arguments TPCEsdWriter:
* * \li -datafile filename
* file name base * \li -directory directory
* target directory * + * Arguments TPCEsdConverter:
+ * + * none + * *
  * Example usage (HLT configuration file):
  *         \
@@ -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 
*/ 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) }; -- 2.39.3