- workaround for copying and merging of ESDs: The HLTOUT contains ESDs for every...
[u/mrichter/AliRoot.git] / HLT / TPCLib / AliHLTTPCEsdWriterComponent.h
CommitLineData
3cde846d 1// @(#) $Id$
2
3#ifndef ALIHLTTPCESDWRITERCOMPONENT_H
4#define ALIHLTTPCESDWRITERCOMPONENT_H
5/* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
6 * See cxx source for full Copyright notice */
7
8/** @file AliHLTTPCEsdWriterComponent.h
9 @author Matthias Richter
10 @date
11 @brief Writer component to store tracks of the HLT TPC conformal
12 mapping tracker in the AliESD format
13
14 */
f32b83e1 15// see below for class documentation
16// or
17// refer to README to build package
18// or
19// visit http://web.ift.uib.no/~kjeks/doc/alice-hlt
20
3cde846d 21#include "AliHLTRootFileWriterComponent.h"
37513ae4 22#include "AliHLTProcessor.h"
3cde846d 23
24// forward declarations
25class TTree;
af885e0f 26class AliESDEvent;
3cde846d 27class AliHLTTPCTrackArray;
28
29/**
4fdaad1e 30 * @class AliHLTTPCEsdWriterComponent
2efb85be 31 * Translation of internal TPC track data to the ESD format.
4fdaad1e 32 * This class translates incoming track segments structures from the TPC
de554e07 33 * conformal mapping tracker (datatype TRAKSEGS/TPC) or tracks in global
34 * coordinates from the AliHLTTPCGlobalMergerComponent (TRACKS/TPC) into
37513ae4 35 * the ESD format.
de554e07 36 *
37513ae4 37 * The \em TPCEsdWriter writes it to a ROOT file, the \em TPCEsdConverter
38 * to a TTree and sends the whole object to the output stream with data
2efb85be 39 * type ::kAliHLTDataTypeESDTree and origin TPC.
37513ae4 40 *
41 * In case of TRAKSEGS, the component can only process data block containing
42 * data of one slice, but it can read an unlimeted number of data blocks.
43 *
44 * componentid: \b TPCEsdWriter <br>
45 * componentid: \b TPCEsdConverter <br>
46 * componentlibrary: \b libAliHLTTPC.so <br>
47 * Arguments TPCEsdWriter: <br>
4fdaad1e 48 * <!-- NOTE: ignore the \li. <i> and </i>: it's just doxygen formating -->
49 * \li -datafile <i> filename </i> <br>
50 * file name base
51 * \li -directory <i> directory </i> <br>
52 * target directory
53 *
37513ae4 54 * Arguments TPCEsdConverter: <br>
55 * <!-- NOTE: ignore the \li. <i> and </i>: it's just doxygen formating -->
a978c0d5 56 * \li -notree
2efb85be 57 * write ESD directly to output (::kAliHLTDataTypeESDObject)
a978c0d5 58 * \li -tree
2efb85be 59 * write ESD directly to TTree and to output (::kAliHLTDataTypeESDTree),
a978c0d5 60 * this is the default behavior.
37513ae4 61 *
6014e33a 62 * <pre>
63 * Example usage (HLT configuration file):
64 * \<Proc ID="EsdWriter" type="prc">
65 * \<Cmd>AliRootWrapperSubscriber -eventmodulo 1
66 * -componentid TPCEsdWriter
67 * -componentlibrary libAliHLTTPC.so
68 * -componentargs "-datafile AliESDs.root"
69 * \</Cmd>
70 *
71 * \<Parent>TR0-SC\</Parent>
72 * \<Node>master\</Node>
73 * \<Shm blocksize="1k" blockcount="1" type="sysv"/>
74 * \</Proc>
75 * </pre>
76 *
4fdaad1e 77 * @see AliHLTFileWriter and AliHLTRootFileWriterComponent for more parameters
2efb85be 78 *
79 * @ingroup alihlt_tpc_components
3cde846d 80 */
37513ae4 81class AliHLTTPCEsdWriterComponent : public AliHLTLogging
3cde846d 82{
83 public:
84 /** standard constructor */
85 AliHLTTPCEsdWriterComponent();
86 /** destructor */
87 ~AliHLTTPCEsdWriterComponent();
88
37513ae4 89 /**
90 * class AliHLTTPCEsdWriterComponent::AliWriter
91 * The writer component of the AliHLTTPCEsdWriterComponent.
92 */
93 class AliWriter : public AliHLTRootFileWriterComponent
94 {
95 public:
96 /** standard constructor */
97 AliWriter();
98 /** destructor */
f32b83e1 99 virtual ~AliWriter();
37513ae4 100
3cde846d 101 /**
102 * The id of the component.
103 * @return component id (string)
104 */
105 const char* GetComponentID() {return "TPCEsdWriter";};
106
37513ae4 107 void GetInputDataTypes(AliHLTComponentDataTypeList& list);
108
3cde846d 109 /**
110 * Spawn function.
111 * @return new class instance
112 */
37513ae4 113 AliHLTComponent* Spawn() {return new AliHLTTPCEsdWriterComponent::AliWriter;}
3cde846d 114
115 protected:
116 /**
117 * Data processing method for the component.
118 * The function can be overloaded by specific ROOT file writer
119 * components.
120 * @param evtData event data structure
121 * @param blocks input data block descriptors
122 * @param trigData trigger data structure
123 */
f32b83e1 124 int DumpEvent( const AliHLTComponentEventData& evtData,
125 const AliHLTComponentBlockData* blocks,
126 AliHLTComponentTriggerData& trigData );
3cde846d 127
5d2abf3b 128 using AliHLTRootFileWriterComponent::DumpEvent;
129
3cde846d 130 /**
131 * Scan one argument and adjacent parameters.
132 * @param argc size of the argument array
133 * @param argv agument array for component initialization
134 * @return number of processed members of the argv <br>
135 * -EINVAL unknown argument <br>
136 * -EPROTO parameter for argument missing <br>
137 */
138 int ScanArgument(int argc, const char** argv);
3cde846d 139 private:
8f8bf0af 140 /** copy constructor prohibited */
37513ae4 141 AliWriter(const AliWriter&);
8f8bf0af 142 /** assignment operator prohibited */
37513ae4 143 AliWriter& operator=(const AliWriter&);
7e99beb3 144
3cde846d 145 /**
146 * Init the writer.
147 * The DoInit function is not available for this child class. InitWriter is the
148 * corresponding function for classes derived from AliHLTFileWriter.
149 */
150 int InitWriter();
151
152 /**
153 * Init the writer.
154 * The DoDeinit function is not available for this child class. CloseWriter is the
155 * corresponding function for classes derived from AliHLTFileWriter.
156 */
157 int CloseWriter();
158
37513ae4 159 /** the ESD tree */
160 TTree* fTree; //! transient value
161
162 /** the ESD */
163 AliESDEvent* fESD; //! transient value
164
165 /** pointer to the basic ESD conversion methods */
166 AliHLTTPCEsdWriterComponent* fBase; //! transient value
167 };
168
169 /**
170 * class AliHLTTPCEsdWriterComponent::AliConverter
171 * The converter component of the AliHLTTPCEsdWriterComponent.
172 *
173 */
174 class AliConverter : public AliHLTProcessor
175 {
176 public:
177 /** standard constructor */
178 AliConverter();
179 /** destructor */
f32b83e1 180 virtual ~AliConverter();
37513ae4 181
182 // interface methods of base class
183 const char* GetComponentID() {return "TPCEsdConverter";};
184 void GetInputDataTypes(AliHLTComponentDataTypeList& list);
185 AliHLTComponentDataType GetOutputDataType();
186 void GetOutputDataSize(unsigned long& constBase, double& inputMultiplier);
187 AliHLTComponent* Spawn() {return new AliHLTTPCEsdWriterComponent::AliConverter;}
188
189 protected:
190 // interface methods of base class
191 int DoInit(int argc, const char** argv);
192 int DoDeinit();
193 int DoEvent(const AliHLTComponentEventData& evtData,
194 const AliHLTComponentBlockData* blocks,
195 AliHLTComponentTriggerData& trigData,
196 AliHLTUInt8_t* outputPtr,
197 AliHLTUInt32_t& size,
198 AliHLTComponentBlockDataList& outputBlocks );
199
200 using AliHLTProcessor::DoEvent;
201
202 private:
203 /** copy constructor prohibited */
204 AliConverter(const AliConverter&);
205 /** assignment operator prohibited */
206 AliConverter& operator=(const AliConverter&);
207
208 /** pointer to the basic ESD conversion methods */
209 AliHLTTPCEsdWriterComponent* fBase; //! transient value
210
a978c0d5 211 /** write object to TTree or directly */
212 int fWriteTree; //!transient
37513ae4 213 };
214
215 protected:
216 /**
217 * Process the input data blocks.
218 * @param pTree tree to be filled
219 * @param pESD ESD to be filled
220 * @param blocks data block descriptor array
221 * @param nBlocks size of the array
e962f438 222 * @param pMinSlice [OUT] receives the minimum slice no
223 * @param pMaxSlice [OUT] receives the maximum slice no
37513ae4 224 * @return neg. error code if failed
225 */
226 int ProcessBlocks(TTree* pTree, AliESDEvent* pESD, const AliHLTComponentBlockData* blocks,
227 int nBlocks, int* pMinSlice=NULL, int* pMaxSlice=NULL);
228
3cde846d 229 /**
230 * Covert tracks to AliTPCtracks (AliKalmanTracks) and add them to ESD.
231 * @param pTracks array of tracks
232 * @param pESD pointer to ESD
233 * @return neg. error code if failed
234 */
af885e0f 235 int Tracks2ESD(AliHLTTPCTrackArray* pTracks, AliESDEvent* pESD);
3cde846d 236
37513ae4 237 private:
238 /** copy constructor prohibited */
239 AliHLTTPCEsdWriterComponent(const AliHLTTPCEsdWriterComponent&);
240 /** assignment operator prohibited */
241 AliHLTTPCEsdWriterComponent& operator=(const AliHLTTPCEsdWriterComponent&);
3cde846d 242
90c37647 243 /**
244 * (Re)Configure from the CDB
245 * Loads the following objects:
246 * - HLT/ConfigHLT/SolenoidBz
247 */
248 int Reconfigure(const char* cdbEntry, const char* chainId);
249
250 /**
251 * Configure the component.
252 * Parse a string for the configuration arguments and set the component
253 * properties.
254 */
255 int Configure(const char* arguments);
256
257 /** solenoid b field */
258 Double_t fSolenoidBz; //! transient
259
260 ClassDef(AliHLTTPCEsdWriterComponent, 2)
3cde846d 261};
262#endif