Line data Source code
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 :
20 : class 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 : */
48 : class 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 : /**
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 : /**
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 [in] pBuffer the data buffer
74 : * @param [in] size data buffer size
75 : * @param [in] dt data type of the block
76 : * @param [out] tgtesd optional target
77 : * @param [in] eventno 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 : /**
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 : /**
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 :
113 : /**
114 : * Create an AliESDEvent object.
115 : * The standard content can optionally be initialized.
116 : */
117 : virtual TObject* CreateEsdEvent(bool bCreateStdContent=false) const = 0;
118 :
119 : /**
120 : * Delete instance of AliESDEvent
121 : */
122 : virtual int DestroyEsdEvent(TObject* pESDInstance) const=0;
123 :
124 : /**
125 : * Add object to ESD event.
126 : * Checks the existance of the object under the name 'branchname'
127 : * Note: some of the objects have (branch-)names which differ from the object name
128 : * However, parameter branchname is never used when adding an object not yet existing.
129 : */
130 : virtual int AddObject(TObject* pESDInstance, const TObject* pObject, const char* branchname) const = 0;
131 :
132 : /**
133 : * Reset the specified object.
134 : * The purpose of this method is to disentangle library dependencies.
135 : * The actual implementation is outside the HLT base library in a
136 : * child class.
137 : */
138 : virtual int ResetEsdEvent(TObject* pESDInstance) const = 0;
139 :
140 : protected:
141 : /** constructor */
142 : AliHLTEsdManager();
143 : /** destructor */
144 : virtual ~AliHLTEsdManager();
145 :
146 : private:
147 : /** copy constructor prohibited */
148 : AliHLTEsdManager(const AliHLTEsdManager&);
149 : /** assignment operator prohibited */
150 : AliHLTEsdManager& operator=(const AliHLTEsdManager&);
151 :
152 : /** the name of the actual implementation */
153 : static const char* fgkImplName; //!
154 :
155 : /** the library of the implementation */
156 : static const char* fgkImplLibrary; //!
157 :
158 126 : ClassDef(AliHLTEsdManager, 0)
159 : };
160 :
161 : #endif
|