]> git.uio.no Git - u/mrichter/AliRoot.git/blob - HLT/TPCLib/AliHLTTPCEsdWriterComponent.h
ee58b938c932dbde4b3c2b3a892a44da64bf89bc
[u/mrichter/AliRoot.git] / HLT / TPCLib / AliHLTTPCEsdWriterComponent.h
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                                                                           */
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
21 #include "AliHLTRootFileWriterComponent.h"
22 #include "AliHLTProcessor.h"
23
24 // forward declarations
25 class TTree;
26 class AliESDEvent;
27 class AliHLTTPCTrackArray;
28
29 /**
30  * @class AliHLTTPCEsdWriterComponent
31  * Translation of internal TPC track data to the ESD format.
32  * This class translates incoming track segments structures from the TPC
33  * conformal mapping tracker (datatype TRAKSEGS/TPC) or tracks in global 
34  * coordinates from the AliHLTTPCGlobalMergerComponent (TRACKS/TPC) into
35  * the ESD format.
36  *
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
39  * type ::kAliHLTDataTypeESDTree and origin TPC.
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>
48  * <!-- NOTE: ignore the \li. <i> and </i>: it's just doxygen formatting -->
49  * \li -datafile     <i> filename   </i> <br>
50  *      file name base
51  * \li -directory    <i> directory  </i> <br>
52  *      target directory
53  *
54  * Arguments TPCEsdConverter: <br>
55  * <!-- NOTE: ignore the \li. <i> and </i>: it's just doxygen formatting -->
56  * \li -notree
57  *      write ESD directly to output (::kAliHLTDataTypeESDObject)
58  * \li -tree
59  *      write ESD directly to TTree and to output (::kAliHLTDataTypeESDTree),
60  *      this is the default behavior.
61  *
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  *
77  * @see AliHLTFileWriter and AliHLTRootFileWriterComponent for more parameters
78  *
79  * @ingroup alihlt_tpc_components
80  */
81 class AliHLTTPCEsdWriterComponent : public AliHLTLogging
82 {
83  public:
84   /** standard constructor */
85   AliHLTTPCEsdWriterComponent();
86   /** destructor */
87   ~AliHLTTPCEsdWriterComponent();
88
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 */
99   virtual ~AliWriter();
100
101   /**
102    * The id of the component.
103    * @return component id (string)
104    */
105   const char* GetComponentID() {return "TPCEsdWriter";};
106
107   void GetInputDataTypes(AliHLTComponentDataTypeList& list);
108
109   /**
110    * Spawn function.
111    * @return new class instance
112    */
113   AliHLTComponent* Spawn() {return new AliHLTTPCEsdWriterComponent::AliWriter;}
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    */
124   int DumpEvent( const AliHLTComponentEventData& evtData,
125                  const AliHLTComponentBlockData* blocks, 
126                  AliHLTComponentTriggerData& trigData );
127
128   using AliHLTRootFileWriterComponent::DumpEvent;
129
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);
139  private:
140   /** copy constructor prohibited */
141   AliWriter(const AliWriter&);
142   /** assignment operator prohibited */
143   AliWriter& operator=(const AliWriter&);
144
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
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 */
180     virtual ~AliConverter();
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
211     /** write object to TTree or directly */
212     int fWriteTree; //!transient
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
222    * @param pMinSlice [OUT] receives the minimum slice no
223    * @param pMaxSlice [OUT] receives the maximum slice no
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
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    */
235   int Tracks2ESD(AliHLTTPCTrackArray* pTracks, AliESDEvent* pESD);
236
237  private:
238   /** copy constructor prohibited */
239   AliHLTTPCEsdWriterComponent(const AliHLTTPCEsdWriterComponent&);
240   /** assignment operator prohibited */
241   AliHLTTPCEsdWriterComponent& operator=(const AliHLTTPCEsdWriterComponent&);
242
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)
261 };
262 #endif