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