From a978c0d5eb886c196fd7ffb54d00216da649dcc3 Mon Sep 17 00:00:00 2001 From: richterm Date: Thu, 6 Dec 2007 13:27:37 +0000 Subject: [PATCH] - added general data type for ESD objects - implemented switch in TPCEsdConverter to send ESD either directly or embedded into a tree. The first method though does not give any meaningful ESD so far (written via ROOTFileWriter) - some trials to get rid of the TTree::Fill errors --- HLT/BASE/AliHLTDataTypes.cxx | 6 ++ HLT/BASE/AliHLTDataTypes.h | 9 ++- HLT/TPCLib/AliHLTTPCEsdWriterComponent.cxx | 64 +++++++++++++++++++--- HLT/TPCLib/AliHLTTPCEsdWriterComponent.h | 8 ++- 4 files changed, 77 insertions(+), 10 deletions(-) diff --git a/HLT/BASE/AliHLTDataTypes.cxx b/HLT/BASE/AliHLTDataTypes.cxx index b47554f0fed..3bb4c6a1a5a 100644 --- a/HLT/BASE/AliHLTDataTypes.cxx +++ b/HLT/BASE/AliHLTDataTypes.cxx @@ -78,6 +78,12 @@ const AliHLTComponentDataType kAliHLTDataTypeDDLRaw = (AliHLTComponentDataType) }; /** ESD data specification */ +const AliHLTComponentDataType kAliHLTDataTypeESDObject = (AliHLTComponentDataType) { + sizeof(AliHLTComponentDataType), + kAliHLTESDObjectDataTypeID, + kAliHLTDataOriginAny +}; +/** ESD tree data specification */ const AliHLTComponentDataType kAliHLTDataTypeESDTree = (AliHLTComponentDataType) { sizeof(AliHLTComponentDataType), kAliHLTESDTreeDataTypeID, diff --git a/HLT/BASE/AliHLTDataTypes.h b/HLT/BASE/AliHLTDataTypes.h index 9e7318ef757..c7beb3f7c6d 100644 --- a/HLT/BASE/AliHLTDataTypes.h +++ b/HLT/BASE/AliHLTDataTypes.h @@ -121,8 +121,12 @@ const int kAliHLTComponentDataTypefIDsize=8; /** ESD data block * an AliESD object of varying origin */ -# define kAliHLTESDTreeDataTypeID {'E','S','D','_','T','R','E','E'} +# define kAliHLTESDObjectDataTypeID {'A','L','I','E','S','D','V','0'} +/** ESD tree data block + * TTree with an AliESD object of varying origin + */ +# define kAliHLTESDTreeDataTypeID {'E','S','D','_','T','R','E','E'} /** HW Address selection data block * - a selection list for 16 bit HW addresses @@ -409,6 +413,9 @@ extern "C" { /** RAW DDL data specification, origin is 'any', data publisher origin correctly */ extern const AliHLTComponentDataType kAliHLTDataTypeDDLRaw; + /** ESD object data specification, origin is 'any' */ + extern const AliHLTComponentDataType kAliHLTDataTypeESDObject; + /** ESD Tree data specification, origin is 'any' */ extern const AliHLTComponentDataType kAliHLTDataTypeESDTree; diff --git a/HLT/TPCLib/AliHLTTPCEsdWriterComponent.cxx b/HLT/TPCLib/AliHLTTPCEsdWriterComponent.cxx index 00ab9fb4db2..451b576b6fc 100644 --- a/HLT/TPCLib/AliHLTTPCEsdWriterComponent.cxx +++ b/HLT/TPCLib/AliHLTTPCEsdWriterComponent.cxx @@ -34,6 +34,7 @@ #include "AliESDEvent.h" #include "AliESDtrack.h" #include "TTree.h" +#include "TFile.h" #include "AliHLTTPCTrack.h" #include "AliHLTTPCTrackArray.h" #include "AliHLTTPCTrackletDataFormat.h" @@ -90,6 +91,11 @@ int AliHLTTPCEsdWriterComponent::AliWriter::InitWriter() fESD = new AliESDEvent; if (fESD) { fESD->CreateStdContent(); + // we have to open a TFile in order to avoid warnings related to + // memory resident TTree's. Bad Root feature, yes ;-( + // Unfortunatly, opening a dummy file leads to the file to be + // created. + //TFile dummy("/tmp/dummy-to-avoid-ttree-warnigs", "CRAETE"); fTree = new TTree("esdTree", "Tree with HLT ESD objects"); if (fTree) { fESD->WriteToTree(fTree); @@ -152,7 +158,7 @@ int AliHLTTPCEsdWriterComponent::ProcessBlocks(TTree* pTree, AliESDEvent* pESD, { // see header file for class documentation int iResult=0; - if (pTree && pESD && blocks) { + if (pESD && blocks) { const AliHLTComponentBlockData* iter = NULL; AliHLTTPCTrackletData* inPtr=NULL; int bIsTrackSegs=0; @@ -191,13 +197,14 @@ int AliHLTTPCEsdWriterComponent::ProcessBlocks(TTree* pTree, AliESDEvent* pESD, } } } - if (iResult>=0) { + if (iResult>=0 && pTree) { pTree->Fill(); } pESD->Reset(); } else { + HLTError("invalid paremeter"); iResult=-EINVAL; } return iResult; @@ -237,7 +244,8 @@ int AliHLTTPCEsdWriterComponent::Tracks2ESD(AliHLTTPCTrackArray* pTracks, AliESD AliHLTTPCEsdWriterComponent::AliConverter::AliConverter() : - fBase(new AliHLTTPCEsdWriterComponent) + fBase(new AliHLTTPCEsdWriterComponent), + fWriteTree(1) { // see header file for class documentation // or @@ -275,7 +283,32 @@ void AliHLTTPCEsdWriterComponent::AliConverter::GetOutputDataSize(unsigned long& int AliHLTTPCEsdWriterComponent::AliConverter::DoInit(int argc, const char** argv) { // see header file for class documentation - return 0; + int iResult=0; + TString argument=""; + int bMissingParam=0; + for (int i=0; i=0; i++) { + argument=argv[i]; + if (argument.IsNull()) continue; + + // -notree + if (argument.CompareTo("-notree")==0) { + fWriteTree=0; + + // -tree + } else if (argument.CompareTo("-tree")==0) { + fWriteTree=1; + + } else { + HLTError("unknown argument %s", argument.Data()); + break; + } + } + if (bMissingParam) { + HLTError("missing parameter for argument %s", argument.Data()); + iResult=-EINVAL; + } + + return iResult; } int AliHLTTPCEsdWriterComponent::AliConverter::DoDeinit() @@ -294,19 +327,34 @@ int AliHLTTPCEsdWriterComponent::AliConverter::DoEvent(const AliHLTComponentEven // see header file for class documentation int iResult=0; assert(fBase); + // we have to open a TFile in order to avoid warnings related to + // memory resident TTree's. Bad Root feature, yes ;-( + // Unfortunatly, opening a dummy file leads to the file to be + // created. + //TFile dummy("/tmp/dummy-to-avoid-ttree-warnigs", "RECREATE"); AliESDEvent* pESD = new AliESDEvent; if (pESD && fBase) { pESD->CreateStdContent(); - TTree* pTree = new TTree("esdTree", "Tree with HLT ESD objects"); + TTree* pTree = NULL; + // TODO: Matthias 06.12.2007 + // Tried to write the ESD directly instead to a tree, but this did not work + // out. Information in the ESD is different, needs investigation. + if (fWriteTree) + 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) { + if ((iResult=fBase->ProcessBlocks(pTree, pESD, blocks, (int)evtData.fBlockCnt))>=0) { // TODO: set the specification correctly + if (pTree) iResult=PushBack(pTree, kAliHLTDataTypeESDTree|kAliHLTDataOriginTPC, 0); - } - delete pTree; + else + iResult=PushBack(pESD, kAliHLTDataTypeESDObject|kAliHLTDataOriginTPC, 0); } + if (pTree) + delete pTree; + delete pESD; } return iResult; diff --git a/HLT/TPCLib/AliHLTTPCEsdWriterComponent.h b/HLT/TPCLib/AliHLTTPCEsdWriterComponent.h index a729be70701..d7f4f9751a8 100644 --- a/HLT/TPCLib/AliHLTTPCEsdWriterComponent.h +++ b/HLT/TPCLib/AliHLTTPCEsdWriterComponent.h @@ -52,7 +52,11 @@ class AliHLTTPCTrackArray; * * Arguments TPCEsdConverter:
* - * none + * \li -notree + * write ESD directly to output (@ref kAliHLTDataTypeESDObject) + * \li -tree + * write ESD directly to TTree and to output (@ref kAliHLTDataTypeESDTree), + * this is the default behavior. * *
  * Example usage (HLT configuration file):
@@ -201,6 +205,8 @@ class AliHLTTPCEsdWriterComponent : public AliHLTLogging
     /** pointer to the basic ESD conversion methods */
     AliHLTTPCEsdWriterComponent* fBase; //! transient value
 
+    /** write object to TTree or directly */
+    int fWriteTree; //!transient
   };
 
  protected:
-- 
2.43.0