1 ////////////////////////////////////////////////////////////////////////////////
3 // Author: Artur Szostak
4 // Email: artur@alice.phy.uct.ac.za | artursz@iafrica.com
6 ////////////////////////////////////////////////////////////////////////////////
8 #ifndef dHLT_ALIROOT_CLUSTER_SOURCE_HPP
9 #define dHLT_ALIROOT_CLUSTER_SOURCE_HPP
14 #include "TClonesArray.h"
15 #include "AliRoot/Point.hpp"
17 class AliMUONDataInterface;
23 class ClusterSource : public TObject
41 ClusterSource(AliMUONDataInterface* data);
43 virtual ~ClusterSource();
45 /* Get and set methods to specify how the FillFrom methods should fill the
46 internal data structures.
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; };
55 /* Fills the internal data structures from the specified data interface
56 for all the events found in AliMUONDataInterface.
58 void FillFrom(AliMUONDataInterface* data);
60 /* Fills the internal data structures from the specified data interface
63 void FillFrom(AliMUONDataInterface* data, Int_t event);
65 /* Fills the internal data structures from the specified data interface
66 for the given event and chamber.
68 void FillFrom(AliMUONDataInterface* data, Int_t event, Int_t chamber);
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
81 AliMUONDataInterface* data,
82 Int_t event, Int_t chamber, Int_t cluster,
83 Bool_t newblock = kFALSE
86 /* Clears all the internal arrays.
91 TString FileName() const { return fFilename; };
92 TString FolderName() const { return fFoldername; };
94 /* Returns the number of events stored.
96 Int_t NumberOfEvents() const { return fEventList.GetEntriesFast(); };
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
102 kTRUE is returned if the event was found, kFALSE otherwise.
104 Bool_t GetEvent(Int_t eventnumber) const;
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
110 kTRUE is returned if the event was found, kFALSE otherwise.
112 Bool_t GetFirstEvent() const;
114 /* Returns kTRUE if there are more events to interate over.
116 Bool_t MoreEvents() const;
118 /* Fetches the next event stored following the currently selected one.
119 kTRUE is returned if the event was found, kFALSE otherwise.
121 Bool_t GetNextEvent() const;
123 /* Returns the corresponding AliRoot event number for the current event.
124 -1 is returned if no event is selected.
126 Int_t CurrentEvent() const;
128 /* Returns the number of cluster blocks in the current event.
129 -1 is returned if no event is selected.
131 Int_t NumberOfBlocks() const;
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.
138 Bool_t GetBlock(Int_t index) const;
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.
145 Bool_t GetFirstBlock() const;
147 /* Returns kTRUE if there are more blocks to interate over.
149 Bool_t MoreBlocks() const;
151 /* Fetches the next block in the current event.
152 kTRUE is returned if the block was found, kFALSE otherwise.
154 Bool_t GetNextBlock() const;
156 /* Returns the current block intex number.
157 -1 is returned if no block is selected.
159 Int_t CurrentBlock() const { return fBlockIndex; };
161 /* Returns the chamber number of the current block.
162 -1 is returned if no block is selected.
164 Int_t Chamber() const;
166 /* Returns the number of cluster points in the current block.
167 -1 is returned if no block is selected.
169 Int_t NumberOfClusters() const;
171 /* Fetches the index'th cluster point in the current block.
172 kTRUE is returned if the point was found, kFALSE otherwise.
174 const Point* GetCluster(Int_t index) const;
176 /* Fetches the first cluster point in the current block.
177 NULL is returned if the point was not found.
179 const Point* GetFirstCluster() const;
181 /* Returns kTRUE if there are more cluster points to interate over.
183 Bool_t MoreClusters() const;
185 /* Fetches the next cluster point in the current block.
186 NULL is returned if the point was not found.
188 const Point* GetNextCluster() const;
190 /* Returns the x and y coordinate of the current cluster point.
191 kFALSE is returned if there is no cluster point selected.
193 Bool_t FetchCluster(Float_t& x, Float_t& y) const;
195 /* Returns the current cluster point.
196 NULL is returned if no cluster point is selected.
198 const Point* GetCluster() const { return fCurrentCluster; };
202 /* Adds a new EventData block to the fEventList and updates the fCurrentEvent,
203 fCurrentBlock and fCurrentCluster pointers.
205 void AddEvent(Int_t eventnumber);
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.
210 void AddBlock(Int_t chamber);
212 /* Adds a new cluster point to the current event and block.
213 The fCurrentCluster is updated appropriately.
215 void AddPoint(Float_t x, Float_t y);
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.
222 Bool_t FileAndFolderOk(AliMUONDataInterface* data);
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
228 void AddEventFrom(AliMUONDataInterface* data, Int_t event);
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.
234 void AddChamberFrom(AliMUONDataInterface* data, Int_t chamber);
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.
240 void AddClusterFrom(AliMUONDataInterface* data, Int_t chamber, Int_t cluster);
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.
246 Bool_t InFillRegion(Float_t x, Float_t y);
248 /* Sets all the current pointers to NULL and indices to -1.
250 void ResetAllPointers() const;
252 /* Sets the block and trigger pointers to NULL and indices to -1.
254 void ResetBlockPointers() const;
256 /* Sets just the current cluster point pointer to NULL and index to -1.
258 void ResetClusterPointers() const;
261 public: // Unfortunately ROOT requires the following to be public.
263 class BlockData : public TObject
267 BlockData(Int_t chamber);
268 virtual ~BlockData();
270 Int_t fChamber; // The chamber number this block of clusters came from.
271 TClonesArray fClusters; // The cluster points in this block.
273 ClassDef(BlockData, 1); // Data per block.
276 class EventData : public TObject
280 EventData(Int_t eventnumber);
281 virtual ~EventData();
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.
286 ClassDef(EventData, 1); // Data per event.
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.
296 TString fFilename; // The file from which the cluster data was taken.
297 TString fFoldername; // The folder name from which cluster data was taken.
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.
306 TClonesArray fEventList; // List of clusters per event.
308 ClassDef(ClusterSource, 1) // The source of cluster point blocks for dHLT.
314 #endif // dHLT_ALIROOT_CLUSTER_SOURCE_HPP