This commit was generated by cvs2svn to compensate for changes in r11742,
[u/mrichter/AliRoot.git] / HLT / MUON / src / AliRoot / TriggerSource.hpp
CommitLineData
8356cc1d 1////////////////////////////////////////////////////////////////////////////////
2//
3// Author: Artur Szostak
4// Email: artur@alice.phy.uct.ac.za | artursz@iafrica.com
5//
6////////////////////////////////////////////////////////////////////////////////
7
8#ifndef dHLT_ALIROOT_TRIGGER_SOURCE_HPP
9#define dHLT_ALIROOT_TRIGGER_SOURCE_HPP
10
11#include "TROOT.h"
12#include "TObject.h"
13#include "TString.h"
14#include "TClonesArray.h"
15#include "AliRoot/TriggerRecord.hpp"
16
17class AliMUON;
18class AliMUONLocalTrigger;
19class AliMUONDataInterface;
20
21
22namespace AliMUONHLT
23{
24
25
26class TriggerSource : public TObject
27{
28public:
29
30 enum AreaType
31 {
32 FromWholePlane,
33 FromLeftHalfPlane,
34 FromRightHalfPlane
35 };
36
37 enum SourceType
38 {
39 FromHits,
40 FromLocalTriggers
41 };
42
43
44 TriggerSource();
45
46 /* Creates a new trigger source object by filling data from the data interface.
47 */
48 TriggerSource(AliMUONDataInterface* data);
49
50 virtual ~TriggerSource();
51
52 /* Get and set methods to specify how the FillFrom methods should fill the
53 internal data structures.
54 */
55 void AreaToUse(const AreaType value) { fAreaToUse = value; };
56 AreaType AreaToUse() const { return fAreaToUse; };
57 void DataToUse(const SourceType value) { fDataToUse = value; };
58 SourceType DataToUse() const { return fDataToUse; };
59 void MaxBlockSize(const UInt_t value) { fMaxBlockSize = value; };
60 UInt_t MaxBlockSize() const { return fMaxBlockSize; };
61 void UseLookupTable(const Bool_t value) { fUseLookupTable = value; };
62 Bool_t UseLookupTable() const { return fUseLookupTable; };
63
64 /* Fills the internal data structures from the specified data interface
65 for all the events found in AliMUONDataInterface.
66 */
67 void FillFrom(AliMUONDataInterface* data);
68
69 /* Fills the internal data structures from the specified data interface
70 for the given event.
71 */
72 void FillFrom(AliMUONDataInterface* data, const Int_t event);
73
74 /* Fills the internal data structures from the specified data interface
75 for the given event and trigger number.
76 If 'newblock' is set to true then the new trigger record is added to
77 a new block. Otherwise the point is added to the current block.
78 Note: This method ignores the fAreaToUse and fMaxBlockSize flags.
79 This is very usefull for custom trigger source filling.
80 For the case of adding data from AliMUONHit objects the 'trigger'
81 parameter becomes the track number in TreeH and not the index of the
82 AliMUONLocalTrigger object.
83 */
84 void FillFrom(
85 AliMUONDataInterface* data,
86 const Int_t event, const Int_t trigger, const Bool_t newblock = kFALSE
87 );
88
89 /* Clears all the internal arrays.
90 */
91 void Clear();
92
93 // Get methods.
94 TString FileName() const { return fFilename; };
95 TString FolderName() const { return fFoldername; };
96
97 /* Returns the number of events stored.
98 */
99 Int_t NumberOfEvents() const { return fEventList.GetEntriesFast(); };
100
101 /* Fetches the specified event number stored in this TriggerSource.
102 Sets the current block and trigger to the first block and trigger record in
103 the event. If there are no blocks or trigger records then these pointers are
104 set to NULL. kTRUE is returned if the event was found, kFALSE otherwise.
105 */
106 Bool_t GetEvent(const Int_t eventnumber) const;
107
108 /* Fetches the first event stored in this TriggerSource.
109 Sets the current block and trigger record to the first block and trigger
110 in the event. If there are no blocks or trigger records then these pointers
111 are set to NULL. kTRUE is returned if the event was found, kFALSE otherwise.
112 */
113 Bool_t GetFirstEvent() const;
114
115 /* Returns kTRUE if there are more events to iterate over.
116 */
117 Bool_t MoreEvents() const;
118
119 /* Fetches the next event stored following the currently selected one.
120 kTRUE is returned if the event was found, kFALSE otherwise.
121 The internal pointers are reset if we reached the last event.
122 */
123 Bool_t GetNextEvent() const;
124
125 /* Returns the corresponding AliRoot event number for the current event.
126 -1 is returned if no event is selected.
127 */
128 Int_t CurrentEvent() const;
129
130 /* Returns the number of trigger record blocks in the current event.
131 -1 is returned if no event is selected.
132 */
133 Int_t NumberOfBlocks() const;
134
135 /* Fetches the index'th block in the current event.
136 Sets the current trigger record to the first trigger in the block.
137 If there are no trigger records then this pointer is set to NULL.
138 kTRUE is returned if the block was found, kFALSE otherwise.
139 */
140 Bool_t GetBlock(const Int_t index) const;
141
142 /* Fetches the first block in the current event.
143 Sets the current trigger record to the first trigger in the block.
144 If there are no trigger records then this pointer is set to NULL.
145 kTRUE is returned if the block was found, kFALSE otherwise.
146 */
147 Bool_t GetFirstBlock() const;
148
149 /* Returns kTRUE if there are more blocks to be traversed.
150 */
151 Bool_t MoreBlocks() const;
152
153 /* Fetches the next block in the current event.
154 kTRUE is returned if the block was found, kFALSE otherwise.
155 */
156 Bool_t GetNextBlock() const;
157
158 /* Returns the currently selected block number.
159 -1 is returned if no blocks are selected.
160 */
161 Int_t CurrentBlock() const { return fBlockIndex; };
162
163 /* Returns the number of trigger records in the current block.
164 -1 is returned if no block is selected.
165 */
166 Int_t NumberOfTriggers() const;
167
168 /* Fetches the trigger record with the specified trigger number from
169 the current block.
170 NULL is returned if the record was not found.
171 */
172 const TriggerRecord* GetTrigger(const Int_t triggernumber) const;
173
174 /* Fetches the first trigger record in the current block.
175 NULL is returned if the record was not found.
176 */
177 const TriggerRecord* GetFirstTrigger() const;
178
179 /* Returns kTRUE if there are more triggers to iterate over.
180 */
181 Bool_t MoreTriggers() const;
182
183 /* Fetches the next trigger record in the current block.
184 NULL is returned if the record was not found.
185 */
186 const TriggerRecord* GetNextTrigger() const;
187
188 /* Returns the current trigger record.
189 NULL is returned if the record was not found.
190 */
191 const TriggerRecord* GetTrigger() const { return fCurrentTrigger; };
192
193 /* Returns the trigger record number for the currently selected trigger record.
194 This number corresponds to the index'th AliMUONLocalTrigger object for the
195 current event.
196 -1 is returned if no trigger record is selected.
197 */
198 Int_t CurrentTrigger() const;
199
200
201private:
202
203 /* Adds a new EventData block to the fEventList and updates the fCurrentEvent,
204 fCurrentBlock and fCurrentTrigger pointers.
205 */
206 void AddEvent(const Int_t eventnumber);
207
208 /* Adds a new block to the current event and updates fCurrentBlock and fCurrentTrigger.
209 */
210 void AddBlock();
211
212 /* Adds a new trigger record to the current event and block.
213 The fCurrentTrigger is updated appropriately.
214 */
215 void AddTrigger(const TriggerRecord& data);
216
217 /* Checks if the file and folder names correspond to this TriggerSource'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, AliMUON* module, const Int_t event);
229
230 /* Adds the specified trigger record from the given data interface.
231 The data interface should be initialised correctly, that is the event
232 should already be selected before calling this method.
233 */
234 void AddTriggerFrom(AliMUONDataInterface* data, AliMUON* module, const Int_t trigger);
235
236 /* Checks to see if the specified trigger record is in the chamber region
237 we want to fill from.
238 kTRUE is returned if (x, y) is in the region, and kFALSE otherwise.
239 */
240 Bool_t InFillRegion(const TriggerRecord& data);
241
242 /* Fills the trigger data from the AliMUONLocalTrigger object.
243 if the fUseLookupTable is set to true then we use the L0 lookup table to
244 fill the Pt value otherwise we use the PtCal method in AliMUONTriggerCircuit.
245 Note the fTriggerNumber parameter is not filled in to 'record'.
246 */
247 void FillTriggerFromLocalTrigger(
248 AliMUONLocalTrigger* trigger, AliMUON* module, TriggerRecord& record
249 );
250
251 /* Fills the TriggerRecord structure from AliMUONHit objects.
252 The hits on the last 4 chambers are used (i.e. chambers 11 to 14).
253 kTRUE is returned if the structure was filled successfully.
254 */
255 Bool_t FillTriggerFromHits(AliMUONDataInterface* data, const Int_t track, TriggerRecord& record);
256
257 /* Fetches the AliMUON module from the AliRun global object. AliRun will be loaded
258 by the runloader if it has not yet been loaded. In such a case the AliRun object
259 will also we unloaded when we are done with it.
260 kTRUE is returned if no error occured and kFALSE otherwise.
261 Note that if fDataToUse is set to FromHits then gAlice is not loaded and 'module'
262 will be left untouched. The method will still return kTRUE however since this is
263 not an error. We do not need the AliMUON module when filling from hits.
264 */
265 Bool_t FetchAliMUON(AliMUON*& module);
266
267 /* After one is finished with the AliMUON object returned by GetAliMUON, one
268 should call this method.
269 If the gAlice object was loaded by GetAliMUON then it will be unloaded at
270 this point, otherwise nothing is done.
271 */
272 void FinishedWithAliMUON();
273
274 /* Sets all the current pointers to NULL and indices to -1.
275 */
276 void ResetAllPointers() const;
277
278 /* Sets the block and trigger pointers to NULL and indices to -1.
279 */
280 void ResetBlockPointers() const;
281
282 /* Sets just the current trigger record pointer to NULL and index to -1.
283 */
284 void ResetTriggerPointers() const;
285
286
287public: // Unfortunately ROOT requires the following to be public.
288
289 class EventData : public TObject
290 {
291 public:
292 EventData();
293 EventData(const Int_t eventnumber);
294 virtual ~EventData();
295
296 Int_t fEventNumber; // Event number in AliMUONDataInterface from which the triggers were taken.
297 TClonesArray fBlocks; // The list of blocks of trigger records.
298
299 ClassDef(EventData, 1); // Data per event.
300 };
301
302private:
303
304 AreaType fAreaToUse; //! The part of the chamber to fill from.
305 SourceType fDataToUse; //! The type of raw AliRoot data to fill from.
306 UInt_t fMaxBlockSize; //! The maximum block size to create in the fill methods.
307 Bool_t fUseLookupTable; //! Set to true if the L0 lookup table should be used for finding Pt.
308
309 TString fFilename; // The file from which the trigger data was taken.
310 TString fFoldername; // The folder name from which trigger data was taken.
311
312 mutable Int_t fEventIndex; //! The index number of the currently selected event.
313 mutable EventData* fCurrentEvent; //! Pointer to the currently selected event.
314 mutable Int_t fBlockIndex; //! The index number of the currently selected block.
315 mutable TClonesArray* fCurrentBlock; //! Pointer to the currently selected block.
316 mutable Int_t fTriggerIndex; //! The index number of the currently selected trigger record.
317 mutable TriggerRecord* fCurrentTrigger; //! Pointer to the currently selected trigger record.
318
319 TClonesArray fEventList; // List of trigger records per event.
320
321 Bool_t fHadToLoadgAlice; //! Flag indicating if this object had to load the AliRun object.
322
323 ClassDef(TriggerSource, 1); // The source of trigger records for dHLT.
324};
325
326
327}; // AliMUONHLT
328
329#endif // dHLT_ALIROOT_TRIGGER_SOURCE_HPP