4 #ifndef ALIHLTESDMANAGERIMPLEMENTATION_H
5 #define ALIHLTESDMANAGERIMPLEMENTATION_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 AliHLTEsdManagerImplementation.h
11 @author Matthias Richter
13 @brief Implementation of the AliHLTEsdManager
16 #include "AliHLTEsdManager.h"
17 #include "AliESDEvent.h"
25 * @class AliHLTEsdManagerImplementation
26 * Implementation of the AliHLTEsdManager.
28 * For the sake of library (in)dependencies, the concrete implementation of
29 * the AliHLTEsdManager is separated from the libHLTbase class as this would
30 * introduce dependencies to AliRoot libraries. See AliHLTEsdManager for
33 * @ingroup alihlt_aliroot_reconstruction
35 class AliHLTEsdManagerImplementation : public AliHLTEsdManager {
38 AliHLTEsdManagerImplementation();
40 virtual ~AliHLTEsdManagerImplementation();
43 * Inherited from base class, see AliHLTEsdManager::SetOption() for
46 virtual int SetOption(const char* option);
49 * Convert data buffer to ESD.
50 * The buffer is supposed to describe a streamed AliESDEvent object.
51 * If no target object is specified, the ESD is written to a file AliHLTdetESDs.root,
52 * where 'det' is derived from the data type origin. Each time the function is invoked
53 * a new event is created. Dummy events are added if the previous events did not contain
55 * @param pBuffer [in] the data buffer
56 * @param size [in] data buffer size
57 * @param dt [in] data type of the block
58 * @param tgtesd [out] optional target
59 * @param eventno [in] optional event no
61 int WriteESD(const AliHLTUInt8_t* pBuffer, AliHLTUInt32_t size, AliHLTComponentDataType dt,
62 AliESDEvent* tgtesd=NULL, int eventno=-1);
65 * Merge content of source ESD into the target ESD.
66 * Merging is done on the level of objects in the ESD and for the
67 * moment it's only implemented for the TClonesArrays. In that case it's
68 * easy to detect whether the object is empty or not.
70 * \b Note: The function can not match entries of the same type, like e.g.
71 * tracks from the 'Tracks' member.
73 int Merge(AliESDEvent* pTgt, AliESDEvent* pSrc) const;
76 * Align all ESD to the same number of events.
77 * The function adds empty events to all ESD files if their event number
78 * does not match the specified one.
79 * @param eventno the desired event no
80 * @return neg. error code if failed
82 int PadESDs(int eventno);
85 * Set the target directory for the ESD files.
87 void SetDirectory(const char* directory);
90 * Get the list of the internally created files.
91 * Returns a blank separated list of the file names.
93 TString GetFileNames(AliHLTComponentDataType dt=kAliHLTAnyDataType) const;
96 * Embed an ESD into a TTree object.
97 * The tree object needs to be deleted by the caller.
99 static TTree* EmbedIntoTree(AliESDEvent* pESD, const char* name="esdTree", const char* title="Tree with HLT ESD objects");
101 class AliHLTESDEventHelper : public AliESDEvent {
103 static bool IsStdContent(const char* key);
106 int CheckClassConditions() const;
111 /** copy constructor prohibited */
112 AliHLTEsdManagerImplementation(const AliHLTEsdManagerImplementation&);
113 /** assignment operator prohibited */
114 AliHLTEsdManagerImplementation& operator=(const AliHLTEsdManagerImplementation&);
116 class AliHLTEsdListEntry : public AliHLTLogging {
119 AliHLTEsdListEntry(AliHLTComponentDataType dt);
121 ~AliHLTEsdListEntry();
124 * Write the ESD to the corresponding file.
125 * The tree is first synchronized with the eventno and additional empty
126 * events might be inserted if there was a gap. Since we are writing
127 * several files in parallel, we have to make sure that those files contain
128 * the same number of events.
129 * @param pESD ESD to write
130 * @param eventno optional event no for tree synchronization
132 int WriteESD(AliESDEvent* pESD, int eventno=-1);
135 * Set the target directory for the ESD file.
137 void SetDirectory(const char* directory);
140 * Delete the ESD file.
145 * Get name of the ESD file.
147 const char* GetFileName() const;
150 * Get the object name prefix generated from the data origin
151 * The prefix is added to the names of the ESD objects when copied to the
154 const char* GetPrefix();
156 bool operator==(AliHLTComponentDataType dt) const;
159 /** copy constructor prohibited */
160 AliHLTEsdListEntry(const AliHLTEsdListEntry& src);
161 /** assignment operator prohibited */
162 AliHLTEsdListEntry& operator=(const AliHLTEsdListEntry& src);
165 * Write ESD to temporary file.
166 * The ESD is embedded into a tree and saved to a temporary file.
167 * The file name is retrieved by TSystem::GetTempFileName and returned
169 * @return file name, empty on failure
171 TString WriteTempFile(AliESDEvent* pESD) const;
173 /** root file name */
174 TString fName; //!transient
175 /** target directory */
176 TString fDirectory; //!transient
177 /** data type of the corresponding block */
178 AliHLTComponentDataType fDt; //!transient
179 /** the root file for this esd */
180 TFile* fpFile; //!transient
181 /** the tree for this esd */
182 TTree* fpTree; //!transient
183 /** the esd to fill into the tree */
184 AliESDEvent* fpEsd; //!transient
185 /** Prefix for generated ESD objects in the master ESD */
186 TString fPrefix; //!transient
189 typedef vector<AliHLTEsdListEntry*> AliHLTEsdPList;
192 * Find list entry for given data type
194 AliHLTEsdListEntry* Find(AliHLTComponentDataType dt) const;
196 /** the list of the ESDs */
197 AliHLTEsdPList fESDs; //!transient
199 /** target directory */
200 TString fDirectory; //!transient
201 /** write local files */
202 bool fWriteLocal; //!transient
204 ClassDef(AliHLTEsdManagerImplementation, 2)