activating individual HLT simulations from digits and raw data
[u/mrichter/AliRoot.git] / HLT / rec / AliHLTEsdManagerImplementation.h
CommitLineData
c5123824 1//-*- Mode: C++ -*-
2// $Id$
3
f1207f29 4#ifndef ALIHLTESDMANAGERIMPLEMENTATION_H
5#define ALIHLTESDMANAGERIMPLEMENTATION_H
c5123824 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
04df9166 10/// @file AliHLTEsdManagerImplementation.h
11/// @author Matthias Richter
12/// @date
13/// @brief Implementation of the AliHLTEsdManager
14/// This is an implementation of the abstract interface AliHLTEsdManager
c5123824 15
f1207f29 16#include "AliHLTEsdManager.h"
f5ea7ce2 17#include "AliESDEvent.h"
90c37647 18#include "TString.h"
c5123824 19#include <vector>
20
c5123824 21class TTree;
22class TFile;
23
24/**
f1207f29 25 * @class AliHLTEsdManagerImplementation
26 * Implementation of the AliHLTEsdManager.
83cb7e1d 27 *
f1207f29 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
31 * usage.
83cb7e1d 32 *
9d4cf2ab 33 * @ingroup alihlt_aliroot_reconstruction
c5123824 34 */
f1207f29 35class AliHLTEsdManagerImplementation : public AliHLTEsdManager {
c5123824 36 public:
37 /** constructor */
f1207f29 38 AliHLTEsdManagerImplementation();
c5123824 39 /** destructor */
f1207f29 40 virtual ~AliHLTEsdManagerImplementation();
c5123824 41
42 /**
794de106 43 * Inherited from base class, see AliHLTEsdManager::SetOption() for
44 * documentation.
45 */
46 virtual int SetOption(const char* option);
47
48 /**
c5123824 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
54 *
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
60 */
61 int WriteESD(const AliHLTUInt8_t* pBuffer, AliHLTUInt32_t size, AliHLTComponentDataType dt,
62 AliESDEvent* tgtesd=NULL, int eventno=-1);
63
90c37647 64 /**
57584811 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.
69 *
70 * \b Note: The function can not match entries of the same type, like e.g.
71 * tracks from the 'Tracks' member.
72 */
73 int Merge(AliESDEvent* pTgt, AliESDEvent* pSrc) const;
74
75 /**
90c37647 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
81 */
82 int PadESDs(int eventno);
83
84 /**
85 * Set the target directory for the ESD files.
86 */
87 void SetDirectory(const char* directory);
88
89 /**
90 * Get the list of the internally created files.
91 * Returns a blank separated list of the file names.
92 */
93 TString GetFileNames(AliHLTComponentDataType dt=kAliHLTAnyDataType) const;
94
95 /**
96 * Embed an ESD into a TTree object.
97 * The tree object needs to be deleted by the caller.
98 */
99 static TTree* EmbedIntoTree(AliESDEvent* pESD, const char* name="esdTree", const char* title="Tree with HLT ESD objects");
100
f5ea7ce2 101 class AliHLTESDEventHelper : public AliESDEvent {
102 public:
103 static bool IsStdContent(const char* key);
104 };
105
5b687e5d 106 int CheckClassConditions() const;
107
0d62191a 108 AliESDEvent* CreateEsdEvent(bool bCreateStdContent=false) const;
109
110 int AddObject(AliESDEvent* pESD, const TObject* pObject, const char* branchname) const;
111
112 int ResetEsdEvent(AliESDEvent* pESD) const;
113
c5123824 114 protected:
115
116 private:
117 /** copy constructor prohibited */
f1207f29 118 AliHLTEsdManagerImplementation(const AliHLTEsdManagerImplementation&);
c5123824 119 /** assignment operator prohibited */
f1207f29 120 AliHLTEsdManagerImplementation& operator=(const AliHLTEsdManagerImplementation&);
c5123824 121
122 class AliHLTEsdListEntry : public AliHLTLogging {
123 public:
124 /** constructor */
125 AliHLTEsdListEntry(AliHLTComponentDataType dt);
c5123824 126 /** destructor */
127 ~AliHLTEsdListEntry();
128
129 /**
130 * Write the ESD to the corresponding file.
131 * The tree is first synchronized with the eventno and additional empty
132 * events might be inserted if there was a gap. Since we are writing
133 * several files in parallel, we have to make sure that those files contain
134 * the same number of events.
135 * @param pESD ESD to write
136 * @param eventno optional event no for tree synchronization
137 */
138 int WriteESD(AliESDEvent* pESD, int eventno=-1);
139
90c37647 140 /**
141 * Set the target directory for the ESD file.
142 */
143 void SetDirectory(const char* directory);
144
145 /**
a7100c59 146 * Set the tree name
147 */
148 void SetTreeName(const char* treename) {fTreeName=treename;}
149
150 /**
90c37647 151 * Get name of the ESD file.
152 */
153 const char* GetFileName() const;
154
f527516f 155 /**
156 * Get the object name prefix generated from the data origin
157 * The prefix is added to the names of the ESD objects when copied to the
158 * master ESD.
159 */
160 const char* GetPrefix();
161
c5123824 162 bool operator==(AliHLTComponentDataType dt) const;
163
164 private:
62ff1e23 165 /** copy constructor prohibited */
166 AliHLTEsdListEntry(const AliHLTEsdListEntry& src);
167 /** assignment operator prohibited */
168 AliHLTEsdListEntry& operator=(const AliHLTEsdListEntry& src);
c5123824 169
170 /** root file name */
171 TString fName; //!transient
90c37647 172 /** target directory */
173 TString fDirectory; //!transient
c5123824 174 /** data type of the corresponding block */
175 AliHLTComponentDataType fDt; //!transient
83cb7e1d 176 /** the root file for this esd */
177 TFile* fpFile; //!transient
178 /** the tree for this esd */
179 TTree* fpTree; //!transient
180 /** the esd to fill into the tree */
181 AliESDEvent* fpEsd; //!transient
f527516f 182 /** Prefix for generated ESD objects in the master ESD */
183 TString fPrefix; //!transient
a7100c59 184 /** name of the tree to be created */
185 TString fTreeName; //!transient
c5123824 186 };
187
62ff1e23 188 typedef vector<AliHLTEsdListEntry*> AliHLTEsdPList;
c5123824 189
190 /**
191 * Find list entry for given data type
192 */
193 AliHLTEsdListEntry* Find(AliHLTComponentDataType dt) const;
194
195 /** the list of the ESDs */
62ff1e23 196 AliHLTEsdPList fESDs; //!transient
c5123824 197
90c37647 198 /** target directory */
199 TString fDirectory; //!transient
a7100c59 200 /** target directory */
201 TString fTreeName; //!transient
794de106 202 /** write local files */
203 bool fWriteLocal; //!transient
90c37647 204
a7100c59 205 ClassDef(AliHLTEsdManagerImplementation, 3)
c5123824 206};
90c37647 207
c5123824 208#endif