4 #ifndef ALIHLTESDMANAGER_H
5 #define ALIHLTESDMANAGER_H
6 //* This file is property of and copyright by the ALICE HLT Project *
7 //* ALICE Experiment at CERN, All rights reserved. *
8 //* See cxx source for full Copyright notice *
10 /** @file AliHLTEsdManager.h
11 @author Matthias Richter
13 @brief Manager for merging and writing of HLT ESDs
16 #include "AliHLTDataTypes.h"
17 #include "AliHLTLogging.h"
26 * @class AliHLTEsdManager
27 * Tool to write and merge HLT ESD objects.
29 * HLT components can produce ESD output. The ESD objects are sent via
30 * a TMessage like mechanism as part of the HLTOUT data. This class retrieves
31 * streamed AliESDEvent objects from an HLT output block. An ESD object can be
32 * copied to a global ESD provided by the caller or to files. The name of the
33 * ROOT files follows the scheme AliHLTDETESDs.root where DET denotes a detector.
34 * E.g. the ESD from a data block of type {ESD_TREE,TPC} will be added to the
35 * file AliHLTTPCESDs.root.
37 * @ingroup alihlt_aliroot_reconstruction
39 class AliHLTEsdManager : public AliHLTLogging {
44 virtual ~AliHLTEsdManager();
47 * Convert data buffer to ESD.
48 * The buffer is supposed to describe a streamed AliESDEvent object.
49 * If no target object is specified, the ESD is written to a file AliHLTdetESDs.root,
50 * where 'det' is derived from the data type origin. Each time the function is invoked
51 * a new event is created. Dummy events are added if the previous events did not contain
53 * @param pBuffer [in] the data buffer
54 * @param size [in] data buffer size
55 * @param dt [in] data type of the block
56 * @param tgtesd [out] optional target
57 * @param eventno [in] optional event no
59 int WriteESD(const AliHLTUInt8_t* pBuffer, AliHLTUInt32_t size, AliHLTComponentDataType dt,
60 AliESDEvent* tgtesd=NULL, int eventno=-1);
63 * Align all ESD to the same number of events.
64 * The function adds empty events to all ESD files if their event number
65 * does not match the specified one.
66 * @param eventno the desired event no
67 * @return neg. error code if failed
69 int PadESDs(int eventno);
72 * Set the target directory for the ESD files.
74 void SetDirectory(const char* directory);
77 * Get the list of the internally created files.
78 * Returns a blank separated list of the file names.
80 TString GetFileNames(AliHLTComponentDataType dt=kAliHLTAnyDataType) const;
83 * Embed an ESD into a TTree object.
84 * The tree object needs to be deleted by the caller.
86 static TTree* EmbedIntoTree(AliESDEvent* pESD, const char* name="esdTree", const char* title="Tree with HLT ESD objects");
91 /** copy constructor prohibited */
92 AliHLTEsdManager(const AliHLTEsdManager&);
93 /** assignment operator prohibited */
94 AliHLTEsdManager& operator=(const AliHLTEsdManager&);
96 class AliHLTEsdListEntry : public AliHLTLogging {
99 AliHLTEsdListEntry(AliHLTComponentDataType dt);
101 ~AliHLTEsdListEntry();
104 * Write the ESD to the corresponding file.
105 * The tree is first synchronized with the eventno and additional empty
106 * events might be inserted if there was a gap. Since we are writing
107 * several files in parallel, we have to make sure that those files contain
108 * the same number of events.
109 * @param pESD ESD to write
110 * @param eventno optional event no for tree synchronization
112 int WriteESD(AliESDEvent* pESD, int eventno=-1);
115 * Set the target directory for the ESD file.
117 void SetDirectory(const char* directory);
120 * Delete the ESD file.
125 * Get name of the ESD file.
127 const char* GetFileName() const;
129 bool operator==(AliHLTComponentDataType dt) const;
132 /** copy constructor prohibited */
133 AliHLTEsdListEntry(const AliHLTEsdListEntry& src);
134 /** assignment operator prohibited */
135 AliHLTEsdListEntry& operator=(const AliHLTEsdListEntry& src);
138 * Write ESD to temporary file.
139 * The ESD is embedded into a tree and saved to a temporary file.
140 * The file name is retrieved by TSystem::GetTempFileName and returned
142 * @return file name, empty on failure
144 TString WriteTempFile(AliESDEvent* pESD) const;
146 /** root file name */
147 TString fName; //!transient
148 /** target directory */
149 TString fDirectory; //!transient
150 /** data type of the corresponding block */
151 AliHLTComponentDataType fDt; //!transient
152 /** the root file for this esd */
153 TFile* fpFile; //!transient
154 /** the tree for this esd */
155 TTree* fpTree; //!transient
156 /** the esd to fill into the tree */
157 AliESDEvent* fpEsd; //!transient
160 typedef vector<AliHLTEsdListEntry*> AliHLTEsdPList;
163 * Find list entry for given data type
165 AliHLTEsdListEntry* Find(AliHLTComponentDataType dt) const;
167 /** the list of the ESDs */
168 AliHLTEsdPList fESDs; //!transient
170 /** target directory */
171 TString fDirectory; //!transient
173 ClassDef(AliHLTEsdManager, 1)