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