adding methods for handling ESDEvent objects outside liHLTbase
[u/mrichter/AliRoot.git] / HLT / BASE / AliHLTEsdManager.h
CommitLineData
f1207f29 1//-*- Mode: C++ -*-
2// $Id$
3
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 *
9
10/** @file AliHLTEsdManager.h
11 @author Matthias Richter
12 @date
13 @brief Manager for merging and writing of HLT ESDs
14*/
15
16#include "AliHLTDataTypes.h"
17#include "AliHLTLogging.h"
18#include "TString.h"
19
20class AliESDEvent;
21
22/**
23 * @class AliHLTEsdManager
24 * Tool to write and merge HLT ESD objects.
25 *
26 * HLT components can produce ESD output. The ESD objects are sent via
27 * a TMessage like mechanism as part of the HLTOUT data. This class retrieves
28 * streamed AliESDEvent objects from an HLT output block. An ESD object can be
29 * copied to a global ESD provided by the caller or to files. The name of the
30 * ROOT files follows the scheme AliHLTDETESDs.root where DET denotes a detector.
31 * E.g. the ESD from a data block of type {ESD_TREE,TPC} will be added to the
32 * file AliHLTTPCESDs.root.
33 *
34 * For the sake of library (in)dependencies, the concrete implementation of
35 * the AliHLTEsdManager is separated from the libHLTbase class as this would
36 * introduce dependencies to AliRoot libraries. The user does not notice the
37 * handling apart from the fact that an instance can not be created and
38 * deleted directly. Instead
39 * <pre>
40 * AliHLTEsdManager* pManager=AliHLTEsdManager::New();
41 * // ....
42 * AliHLTEsdManager::Delete(pManager);
43 * </pre>
44 * must be used.
45 *
46 * @ingroup alihlt_aliroot_reconstruction
47 */
48class AliHLTEsdManager : public AliHLTLogging {
49 public:
50 /** create an instance of the manager */
51 static AliHLTEsdManager* New();
52 /** delete an instance of the manager */
53 static void Delete(AliHLTEsdManager* instance);
54
55 /**
794de106 56 * Set the options for the ESD merging and writing
57 * Takes a string of blank separated options.
58 * \li -writelocal use local file writing in the specified diectory
59 * The file name is derived from the data origin
60 * \li -directory=<> Set the directory path
61 * This makes the SetDirectory method obsolete
62 * @return neg error code if failed
63 */
64 virtual int SetOption(const char* option)=0;
65
66 /**
f1207f29 67 * Convert data buffer to ESD.
68 * The buffer is supposed to describe a streamed AliESDEvent object.
69 * If no target object is specified, the ESD is written to a file AliHLTdetESDs.root,
70 * where 'det' is derived from the data type origin. Each time the function is invoked
71 * a new event is created. Dummy events are added if the previous events did not contain
72 *
73 * @param pBuffer [in] the data buffer
74 * @param size [in] data buffer size
75 * @param dt [in] data type of the block
76 * @param tgtesd [out] optional target
77 * @param eventno [in] optional event no
78 */
79 virtual int WriteESD(const AliHLTUInt8_t* pBuffer, AliHLTUInt32_t size, AliHLTComponentDataType dt,
80 AliESDEvent* tgtesd=NULL, int eventno=-1)=0;
81
82 /**
57584811 83 * Merge content of source ESD into the target ESD.
84 * Merging is done on the level of objects in the ESD and for the
85 * moment it's only implemented for the TClonesArrays. In that case it's
86 * easy to detect whether the object is empty or not.
87 *
88 * \b Note: The function can not match entries of the same type, like e.g.
89 * tracks from the 'Tracks' member.
90 */
91 virtual int Merge(AliESDEvent* pTgt, AliESDEvent* pSrc) const =0;
92
93 /**
f1207f29 94 * Align all ESD to the same number of events.
95 * The function adds empty events to all ESD files if their event number
96 * does not match the specified one.
97 * @param eventno the desired event no
98 * @return neg. error code if failed
99 */
100 virtual int PadESDs(int eventno)=0;
101
102 /**
103 * Set the target directory for the ESD files.
104 */
105 virtual void SetDirectory(const char* directory)=0;
106
107 /**
108 * Get the list of the internally created files.
109 * Returns a blank separated list of the file names.
110 */
111 virtual TString GetFileNames(AliHLTComponentDataType dt=kAliHLTAnyDataType) const = 0;
112
0d62191a 113 /**
114 * Create an AliESDEvent object.
115 * The standard content can optionally be initialized.
116 */
117 virtual AliESDEvent* CreateEsdEvent(bool bCreateStdContent=false) const = 0;
118
119 /**
120 * Add object to ESD event.
121 * Checks the existance of the object under the name 'branchname'
122 * Note: some of the objects have (branch-)names which differ from the object name
123 * However, parameter branchname is never used when adding an object not yet existing.
124 */
125 virtual int AddObject(AliESDEvent* pESD, const TObject* pObject, const char* branchname) const = 0;
126
127 /**
128 * Reset the specified object.
129 * The purpose of this method is to disentangle library dependencies.
130 * The actual implementation is outside the HLT base library in a
131 * child class.
132 */
133 virtual int ResetEsdEvent(AliESDEvent* pESD) const = 0;
134
f1207f29 135 protected:
136 /** constructor */
137 AliHLTEsdManager();
138 /** destructor */
139 virtual ~AliHLTEsdManager();
140
141 private:
142 /** copy constructor prohibited */
143 AliHLTEsdManager(const AliHLTEsdManager&);
144 /** assignment operator prohibited */
145 AliHLTEsdManager& operator=(const AliHLTEsdManager&);
146
147 /** the name of the actual implementation */
148 static const char* fgkImplName; //!
149
150 /** the library of the implementation */
151 static const char* fgkImplLibrary; //!
152
153 ClassDef(AliHLTEsdManager, 0)
154};
155
156#endif