]> git.uio.no Git - u/mrichter/AliRoot.git/blob - HLT/rec/AliHLTEsdManagerImplementation.h
several bugfixes in order to get the HLTGlobalTrigger decision safely into the ESD
[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    * Merge content of source ESD into the target ESD.
60    * Merging is done on the level of objects in the ESD and for the
61    * moment it's only implemented for the TClonesArrays. In that case it's
62    * easy to detect whether the object is empty or not.
63    *
64    * \b Note: The function can not match entries of the same type, like e.g.
65    * tracks from the 'Tracks' member.
66    */
67   int Merge(AliESDEvent* pTgt, AliESDEvent* pSrc) const;
68
69   /**
70    * Align all ESD to the same number of events.
71    * The function adds empty events to all ESD files if their event number
72    * does not match the specified one.
73    * @param eventno     the desired event no
74    * @return neg. error code if failed
75    */
76   int PadESDs(int eventno);
77
78   /**
79    * Set the target directory for the ESD files.
80    */
81   void SetDirectory(const char* directory);
82
83   /**
84    * Get the list of the internally created files.
85    * Returns a blank separated list of the file names.
86    */
87   TString GetFileNames(AliHLTComponentDataType dt=kAliHLTAnyDataType) const;
88
89   /**
90    * Embed an ESD into a TTree object.
91    * The tree object needs to be deleted by the caller.
92    */
93   static TTree* EmbedIntoTree(AliESDEvent* pESD, const char* name="esdTree", const char* title="Tree with HLT ESD objects");
94
95  protected:
96
97  private:
98   /** copy constructor prohibited */
99   AliHLTEsdManagerImplementation(const AliHLTEsdManagerImplementation&);
100   /** assignment operator prohibited */
101   AliHLTEsdManagerImplementation& operator=(const AliHLTEsdManagerImplementation&);
102
103   class AliHLTEsdListEntry : public AliHLTLogging {
104   public:
105     /** constructor */
106     AliHLTEsdListEntry(AliHLTComponentDataType dt);
107     /** destructor */
108     ~AliHLTEsdListEntry();
109
110     /**
111      * Write the ESD to the corresponding file.
112      * The tree is first synchronized with the eventno and additional empty
113      * events might be inserted if there was a gap. Since we are writing
114      * several files in parallel, we have to make sure that those files contain
115      * the same number of events.
116      * @param pESD        ESD to write
117      * @param eventno     optional event no for tree synchronization
118      */
119     int WriteESD(AliESDEvent* pESD, int eventno=-1);
120
121     /**
122      * Set the target directory for the ESD file.
123      */
124     void SetDirectory(const char* directory);
125
126     /**
127      * Delete the ESD file.
128      */
129     void Delete();
130
131     /**
132      * Get name of the ESD file.
133      */
134     const char* GetFileName() const;
135
136     /**
137      * Get the object name prefix generated from the data origin
138      * The prefix is added to the names of the ESD objects when copied to the
139      * master ESD.
140      */
141     const char* GetPrefix();
142
143     bool operator==(AliHLTComponentDataType dt) const;
144
145   private:
146     /** copy constructor prohibited */
147     AliHLTEsdListEntry(const AliHLTEsdListEntry& src);
148     /** assignment operator prohibited */
149     AliHLTEsdListEntry& operator=(const AliHLTEsdListEntry& src);
150
151     /**
152      * Write ESD to temporary file.
153      * The ESD is embedded into a tree and saved to a temporary file.
154      * The file name is retrieved by TSystem::GetTempFileName and returned
155      * on success.
156      * @return file name, empty on failure
157      */
158     TString WriteTempFile(AliESDEvent* pESD) const;
159
160     /** root file name */
161     TString fName; //!transient
162     /** target directory */
163     TString fDirectory; //!transient
164     /** data type of the corresponding block */
165     AliHLTComponentDataType fDt; //!transient
166     /** the root file for this esd */
167     TFile* fpFile; //!transient
168     /** the tree for this esd */
169     TTree* fpTree; //!transient
170     /** the esd to fill into the tree */
171     AliESDEvent* fpEsd; //!transient
172     /** Prefix for generated ESD objects in the master ESD */
173     TString fPrefix; //!transient
174   };
175
176   typedef vector<AliHLTEsdListEntry*> AliHLTEsdPList;
177
178   /**
179    * Find list entry for given data type
180    */
181   AliHLTEsdListEntry* Find(AliHLTComponentDataType dt) const;
182
183   /** the list of the ESDs */
184   AliHLTEsdPList fESDs; //!transient
185
186   /** target directory */
187   TString fDirectory; //!transient
188
189   ClassDef(AliHLTEsdManagerImplementation, 1)
190 };
191
192 #endif