]> git.uio.no Git - u/mrichter/AliRoot.git/blob - HLT/rec/AliHLTEsdManagerImplementation.h
- singleton functionality added for component and configuration handler
[u/mrichter/AliRoot.git] / HLT / rec / AliHLTEsdManagerImplementation.h
1 //-*- Mode: C++ -*-
2 // $Id$
3
4 #ifndef ALIHLTESDMANAGERIMPLEMENTATION_H
5 #define ALIHLTESDMANAGERIMPLEMENTATION_H
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
10 /** @file   AliHLTEsdManagerImplementation.h
11     @author Matthias Richter
12     @date   
13     @brief  Implementation of the AliHLTEsdManager
14 */
15
16 #include "AliHLTEsdManager.h"
17 #include "TString.h"
18 #include <vector>
19
20 class AliESDEvent;
21 class TTree;
22 class TFile;
23
24 /**
25  * @class AliHLTEsdManagerImplementation
26  * Implementation of the AliHLTEsdManager.
27  *
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.
32  *
33  * @ingroup alihlt_aliroot_reconstruction
34  */
35 class AliHLTEsdManagerImplementation : public AliHLTEsdManager {
36  public:
37   /** constructor */
38   AliHLTEsdManagerImplementation();
39   /** destructor */
40   virtual ~AliHLTEsdManagerImplementation();
41
42   /**
43    * Convert data buffer to ESD.
44    * The buffer is supposed to describe a streamed AliESDEvent object.
45    * If no target object is specified, the ESD is written to a file AliHLTdetESDs.root,
46    * where 'det' is derived from the data type origin. Each time the function is invoked
47    * a new event is created. Dummy events are added if the previous events did not contain
48    *
49    * @param pBuffer  [in] the data buffer
50    * @param size     [in] data buffer size
51    * @param dt       [in] data type of the block
52    * @param tgtesd   [out] optional target
53    * @param eventno  [in] optional event no
54    */
55   int WriteESD(const AliHLTUInt8_t* pBuffer, AliHLTUInt32_t size, AliHLTComponentDataType dt,
56                AliESDEvent* tgtesd=NULL, int eventno=-1);
57
58   /**
59    * Align all ESD to the same number of events.
60    * The function adds empty events to all ESD files if their event number
61    * does not match the specified one.
62    * @param eventno     the desired event no
63    * @return neg. error code if failed
64    */
65   int PadESDs(int eventno);
66
67   /**
68    * Set the target directory for the ESD files.
69    */
70   void SetDirectory(const char* directory);
71
72   /**
73    * Get the list of the internally created files.
74    * Returns a blank separated list of the file names.
75    */
76   TString GetFileNames(AliHLTComponentDataType dt=kAliHLTAnyDataType) const;
77
78   /**
79    * Embed an ESD into a TTree object.
80    * The tree object needs to be deleted by the caller.
81    */
82   static TTree* EmbedIntoTree(AliESDEvent* pESD, const char* name="esdTree", const char* title="Tree with HLT ESD objects");
83
84  protected:
85
86  private:
87   /** copy constructor prohibited */
88   AliHLTEsdManagerImplementation(const AliHLTEsdManagerImplementation&);
89   /** assignment operator prohibited */
90   AliHLTEsdManagerImplementation& operator=(const AliHLTEsdManagerImplementation&);
91
92   class AliHLTEsdListEntry : public AliHLTLogging {
93   public:
94     /** constructor */
95     AliHLTEsdListEntry(AliHLTComponentDataType dt);
96     /** destructor */
97     ~AliHLTEsdListEntry();
98
99     /**
100      * Write the ESD to the corresponding file.
101      * The tree is first synchronized with the eventno and additional empty
102      * events might be inserted if there was a gap. Since we are writing
103      * several files in parallel, we have to make sure that those files contain
104      * the same number of events.
105      * @param pESD        ESD to write
106      * @param eventno     optional event no for tree synchronization
107      */
108     int WriteESD(AliESDEvent* pESD, int eventno=-1);
109
110     /**
111      * Set the target directory for the ESD file.
112      */
113     void SetDirectory(const char* directory);
114
115     /**
116      * Delete the ESD file.
117      */
118     void Delete();
119
120     /**
121      * Get name of the ESD file.
122      */
123     const char* GetFileName() const;
124
125     bool operator==(AliHLTComponentDataType dt) const;
126
127   private:
128     /** copy constructor prohibited */
129     AliHLTEsdListEntry(const AliHLTEsdListEntry& src);
130     /** assignment operator prohibited */
131     AliHLTEsdListEntry& operator=(const AliHLTEsdListEntry& src);
132
133     /**
134      * Write ESD to temporary file.
135      * The ESD is embedded into a tree and saved to a temporary file.
136      * The file name is retrieved by TSystem::GetTempFileName and returned
137      * on success.
138      * @return file name, empty on failure
139      */
140     TString WriteTempFile(AliESDEvent* pESD) const;
141
142     /** root file name */
143     TString fName; //!transient
144     /** target directory */
145     TString fDirectory; //!transient
146     /** data type of the corresponding block */
147     AliHLTComponentDataType fDt; //!transient
148     /** the root file for this esd */
149     TFile* fpFile; //!transient
150     /** the tree for this esd */
151     TTree* fpTree; //!transient
152     /** the esd to fill into the tree */
153     AliESDEvent* fpEsd; //!transient
154   };
155
156   typedef vector<AliHLTEsdListEntry*> AliHLTEsdPList;
157
158   /**
159    * Find list entry for given data type
160    */
161   AliHLTEsdListEntry* Find(AliHLTComponentDataType dt) const;
162
163   /** the list of the ESDs */
164   AliHLTEsdPList fESDs; //!transient
165
166   /** target directory */
167   TString fDirectory; //!transient
168
169   ClassDef(AliHLTEsdManagerImplementation, 1)
170 };
171
172 #endif