]> git.uio.no Git - u/mrichter/AliRoot.git/blob - HLT/MUON/src/AliRoot/ClusterSource.hpp
Removing warnings on alphacxx6
[u/mrichter/AliRoot.git] / HLT / MUON / src / AliRoot / ClusterSource.hpp
1 ////////////////////////////////////////////////////////////////////////////////
2 //
3 // Author: Artur Szostak
4 // Email:  artur@alice.phy.uct.ac.za | artursz@iafrica.com
5 //
6 ////////////////////////////////////////////////////////////////////////////////
7
8 #ifndef dHLT_ALIROOT_CLUSTER_SOURCE_HPP
9 #define dHLT_ALIROOT_CLUSTER_SOURCE_HPP
10
11 #include "TROOT.h"
12 #include "TObject.h"
13 #include "TString.h"
14 #include "TClonesArray.h"
15 #include "AliRoot/Point.hpp"
16
17 class AliMUONDataInterface;
18
19 namespace AliMUONHLT
20 {
21
22
23 class ClusterSource : public TObject
24 {
25 public:
26
27         enum AreaType
28         {
29                 FromWholePlane,
30                 FromLeftHalfPlane,
31                 FromRightHalfPlane
32         };
33         
34         enum SourceType
35         {
36                 FromHits,
37                 FromRawClusters
38         };
39
40         ClusterSource();
41         ClusterSource(AliMUONDataInterface* data);
42         
43         virtual ~ClusterSource();
44         
45         /* Get and set methods to specify how the FillFrom methods should fill the
46            internal data structures.
47          */
48         void AreaToUse(AreaType value) { fAreaToUse = value; };
49         AreaType AreaToUse() const { return fAreaToUse; };
50         void DataToUse(SourceType value) { fDataToUse = value; };
51         SourceType DataToUse() const { return fDataToUse; };
52         void MaxBlockSize(UInt_t value) { fMaxBlockSize = value; };
53         UInt_t MaxBlockSize() const { return fMaxBlockSize; };
54
55         /* Fills the internal data structures from the specified data interface
56            for all the events found in AliMUONDataInterface.
57          */
58         void FillFrom(AliMUONDataInterface* data);
59         
60         /* Fills the internal data structures from the specified data interface
61            for the given event.
62          */
63         void FillFrom(AliMUONDataInterface* data, Int_t event);
64         
65         /* Fills the internal data structures from the specified data interface
66            for the given event and chamber.
67          */
68         void FillFrom(AliMUONDataInterface* data, Int_t event, Int_t chamber);
69         
70         /* Fills the internal data structures from the specified data interface
71            for the given event, chamber and cluster number.
72            If 'newblock' is set to true then the new cluster point is added to 
73            a new block. Otherwise the point is added to the current block.
74            Note: This method ignores the fAreaToUse and fMaxBlockSize flags.
75            This is very usefull for custom cluster source filling.
76            For the case of adding data from AliMUONHit objects the 'cluster' parameter
77            becomes the track number in TreeH and not the index of the AliMUONRawCluster
78            object.
79          */
80         void FillFrom(
81                         AliMUONDataInterface* data, 
82                         Int_t event, Int_t chamber, Int_t cluster,
83                         Bool_t newblock = kFALSE
84                 );
85         
86         /* Clears all the internal arrays.
87          */
88         void Clear();
89         
90         // Get methods.
91         TString FileName()   const { return fFilename; };
92         TString FolderName() const { return fFoldername; };
93         
94         /* Returns the number of events stored.
95          */
96         Int_t NumberOfEvents() const { return fEventList.GetEntriesFast(); };
97         
98         /* Fetches the specified event number stored in this ClusterSource.
99            Sets the current block and cluster point to the first block and cluster
100            point respectively. If there are no blocks or clusters then these pointers
101            are set to NULL.
102            kTRUE is returned if the event was found, kFALSE otherwise.
103          */
104         Bool_t GetEvent(Int_t eventnumber) const;
105         
106         /* Fetches the first event stored in this ClusterSource.
107            Sets the current block and cluster point to the first block and cluster
108            point respectively. If there are no blocks or clusters then these pointers
109            are set to NULL.
110            kTRUE is returned if the event was found, kFALSE otherwise.
111          */
112         Bool_t GetFirstEvent() const;
113         
114         /* Returns kTRUE if there are more events to interate over.
115          */
116         Bool_t MoreEvents() const;
117         
118         /* Fetches the next event stored following the currently selected one.
119            kTRUE is returned if the event was found, kFALSE otherwise.
120          */
121         Bool_t GetNextEvent() const;
122         
123         /* Returns the corresponding AliRoot event number for the current event.
124            -1 is returned if no event is selected.
125          */
126         Int_t CurrentEvent() const;
127         
128         /* Returns the number of cluster blocks in the current event.
129            -1 is returned if no event is selected.
130          */
131         Int_t NumberOfBlocks() const;
132         
133         /* Fetches the index'th block in the current event.
134            Sets the current cluster point to the first cluster point in the block.
135            If there are no cluster points then this pointer is set to NULL.
136            kTRUE is returned if the block was found, kFALSE otherwise.
137          */
138         Bool_t GetBlock(Int_t index) const;
139         
140         /* Fetches the first block in the current event.
141            Sets the current cluster point to the first cluster point in the block.
142            If there are no cluster points then this pointer is set to NULL.
143            kTRUE is returned if the block was found, kFALSE otherwise.
144          */
145         Bool_t GetFirstBlock() const;
146         
147         /* Returns kTRUE if there are more blocks to interate over.
148          */
149         Bool_t MoreBlocks() const;
150         
151         /* Fetches the next block in the current event.
152            kTRUE is returned if the block was found, kFALSE otherwise.
153          */
154         Bool_t GetNextBlock() const;
155         
156         /* Returns the current block intex number.
157            -1 is returned if no block is selected.
158          */
159         Int_t CurrentBlock() const { return fBlockIndex; };
160         
161         /* Returns the chamber number of the current block.
162            -1 is returned if no block is selected.
163          */
164         Int_t Chamber() const;
165         
166         /* Returns the number of cluster points in the current block.
167            -1 is returned if no block is selected.
168          */
169         Int_t NumberOfClusters() const;
170         
171         /* Fetches the index'th cluster point in the current block.
172            kTRUE is returned if the point was found, kFALSE otherwise.
173          */
174         const Point* GetCluster(Int_t index) const;
175         
176         /* Fetches the first cluster point in the current block.
177            NULL is returned if the point was not found.
178          */
179         const Point* GetFirstCluster() const;
180         
181         /* Returns kTRUE if there are more cluster points to interate over.
182          */
183         Bool_t MoreClusters() const;
184         
185         /* Fetches the next cluster point in the current block.
186            NULL is returned if the point was not found.
187          */
188         const Point* GetNextCluster() const;
189         
190         /* Returns the x and y coordinate of the current cluster point.
191            kFALSE is returned if there is no cluster point selected.
192          */
193         Bool_t FetchCluster(Float_t& x, Float_t& y) const;
194         
195         /* Returns the current cluster point.
196            NULL is returned if no cluster point is selected.
197          */
198         const Point* GetCluster() const { return fCurrentCluster; };
199
200 private:
201
202         /* Adds a new EventData block to the fEventList and updates the fCurrentEvent,
203            fCurrentBlock and fCurrentCluster pointers.
204          */ 
205         void AddEvent(Int_t eventnumber);
206         
207         /* Adds a new block to the current event and updates fCurrentBlock and fCurrentCluster.
208            The chamber number is assigned to the blocks fChamber value.
209          */
210         void AddBlock(Int_t chamber);
211         
212         /* Adds a new cluster point to the current event and block.
213            The fCurrentCluster is updated appropriately.
214          */
215         void AddPoint(Float_t x, Float_t y);
216         
217         /* Checks if the file and folder names correspond to this ClusterSource's 
218            file and folder names. kTRUE is returned if they do.
219            If the file and folder names are empty then they are assigned the names
220            as found in the data interface and kTRUE is returned.
221          */
222         Bool_t FileAndFolderOk(AliMUONDataInterface* data);
223         
224         /* Adds the whole event from the data interface to the internal data structures.
225            It is assumed that FileAndFolderOk(data) returns true just before calling
226            this method.
227          */
228         void AddEventFrom(AliMUONDataInterface* data, Int_t event);
229         
230         /* Adds all cluster points found on the given chamber from the specified data
231            interface. The data interface should be initialised correctly, that is the
232            event should already be selected before calling this method.
233          */
234         void AddChamberFrom(AliMUONDataInterface* data, Int_t chamber);
235         
236         /* Adds the cluster point from the specified data interface.
237            The data interface should be initialised correctly, that is the event
238            should already be selected before calling this method.
239          */
240         void AddClusterFrom(AliMUONDataInterface* data, Int_t chamber, Int_t cluster);
241         
242         /* Checks to see if the x and y coordinate of the cluster point are in the
243            chamber region we want to fill from.
244            kTRUE is returned if (x, y) is in the region, and kFALSE otherwise.
245          */
246         Bool_t InFillRegion(Float_t x, Float_t y);
247
248         /* Sets all the current pointers to NULL and indices to -1.
249          */
250         void ResetAllPointers() const;
251         
252         /* Sets the block and trigger pointers to NULL and indices to -1.
253          */
254         void ResetBlockPointers() const;
255         
256         /* Sets just the current cluster point pointer to NULL and index to -1.
257          */
258         void ResetClusterPointers() const;
259         
260
261 public:  // Unfortunately ROOT requires the following to be public.
262         
263         class BlockData : public TObject
264         {
265         public:
266                 BlockData();
267                 BlockData(Int_t chamber);
268                 virtual ~BlockData();
269
270                 Int_t fChamber;  // The chamber number this block of clusters came from.
271                 TClonesArray fClusters;  // The cluster points in this block.
272                 
273                 ClassDef(BlockData, 1);  // Data per block.
274         };
275         
276         class EventData : public TObject
277         {
278         public:
279                 EventData();
280                 EventData(Int_t eventnumber);
281                 virtual ~EventData();
282
283                 Int_t fEventNumber;  // Event number in AliMUONDataInterface from which the clusters were taken.
284                 TClonesArray fBlocks;  // The list of cluster blocks for this event.
285                 
286                 ClassDef(EventData, 1);  // Data per event.
287         };
288
289
290 private:
291
292         AreaType fAreaToUse;    //! The part of the chamber to fill from.
293         SourceType fDataToUse;  //! The type of raw AliRoot data to fill from.
294         UInt_t fMaxBlockSize;   //! The maximum block size to create in the fill methods.
295
296         TString fFilename;    // The file from which the cluster data was taken.
297         TString fFoldername;  // The folder name from which cluster data was taken.
298         
299         mutable Int_t fEventIndex;             //! The index number of the currently selected event.
300         mutable EventData* fCurrentEvent;      //! Pointer to the currently selected event.
301         mutable Int_t fBlockIndex;             //! The index number of the currently selected block.
302         mutable BlockData* fCurrentBlock;      //! Pointer to the currently selected block.
303         mutable Int_t fClusterIndex;           //! The index number of the currently selected cluster point.
304         mutable Point* fCurrentCluster;        //! Pointer to the currently selected cluster point.
305
306         TClonesArray fEventList;  // List of clusters per event.
307
308         ClassDef(ClusterSource, 1)  // The source of cluster point blocks for dHLT.
309 };
310
311
312 } // AliMUONHLT
313
314 #endif // dHLT_ALIROOT_CLUSTER_SOURCE_HPP