]> git.uio.no Git - u/mrichter/AliRoot.git/commitdiff
- added general data type for ESD objects
authorrichterm <richterm@f7af4fe6-9843-0410-8265-dc069ae4e863>
Thu, 6 Dec 2007 13:27:37 +0000 (13:27 +0000)
committerrichterm <richterm@f7af4fe6-9843-0410-8265-dc069ae4e863>
Thu, 6 Dec 2007 13:27:37 +0000 (13:27 +0000)
- 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
HLT/BASE/AliHLTDataTypes.h
HLT/TPCLib/AliHLTTPCEsdWriterComponent.cxx
HLT/TPCLib/AliHLTTPCEsdWriterComponent.h

index b47554f0fed6387c81c02e7e3ef5196ea029855d..3bb4c6a1a5a1d5d6386811c7cce6c6f5acaab703 100644 (file)
@@ -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,
index 9e7318ef7576252889d0a4463985088bf843b36d..c7beb3f7c6df41a9b5a6b4bf4dbbbff01bb0a6ee 100644 (file)
@@ -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;
 
index 00ab9fb4db267904d82a3aa05f2fbcd0d9703401..451b576b6fcc3fbb2baad44daceec42ae0aa09c4 100644 (file)
@@ -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<argc && iResult>=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;
index a729be707014e11d7fd0ef333189fe89bd0580e5..d7f4f9751a8462a9b53d8ffcd0dde37ff25d3ceb 100644 (file)
@@ -52,7 +52,11 @@ class AliHLTTPCTrackArray;
  *
  * Arguments TPCEsdConverter: <br>
  * <!-- NOTE: ignore the \li. <i> and </i>: it's just doxygen formating -->
- * 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.
  *
  * <pre>
  * 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: