1 ////////////////////////////////////////////////////////////////////////////////
3 // Author: Artur Szostak
4 // Email: artur@alice.phy.uct.ac.za | artursz@iafrica.com
6 ////////////////////////////////////////////////////////////////////////////////
8 #ifndef ALIHLTMUONTRIGGERSOURCE_H
9 #define ALIHLTMUONTRIGGERSOURCE_H
14 #include "TClonesArray.h"
15 #include "AliRoot/TriggerRecord.hpp"
18 class AliMUONLocalTrigger;
19 class AliMUONDataInterface;
22 class AliHLTMUONTriggerSource : public TObject
40 AliHLTMUONTriggerSource();
42 /* Creates a new trigger source object by filling data from the data interface.
44 AliHLTMUONTriggerSource(AliMUONDataInterface* data);
46 virtual ~AliHLTMUONTriggerSource();
48 /* Get and set methods to specify how the FillFrom methods should fill the
49 internal data structures.
51 void AreaToUse(AreaType value) { fAreaToUse = value; };
52 AreaType AreaToUse() const { return fAreaToUse; };
53 void DataToUse(SourceType value) { fDataToUse = value; };
54 SourceType DataToUse() const { return fDataToUse; };
55 void MaxBlockSize(UInt_t value) { fMaxBlockSize = value; };
56 UInt_t MaxBlockSize() const { return fMaxBlockSize; };
57 void UseLookupTable(Bool_t value) { fUseLookupTable = value; };
58 Bool_t UseLookupTable() const { return fUseLookupTable; };
60 /* Fills the internal data structures from the specified data interface
61 for all the events found in AliMUONDataInterface.
63 void FillFrom(AliMUONDataInterface* data);
65 /* Fills the internal data structures from the specified data interface
68 void FillFrom(AliMUONDataInterface* data, Int_t event);
70 /* Fills the internal data structures from the specified data interface
71 for the given event and trigger number.
72 If 'newblock' is set to true then the new trigger record 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 trigger source filling.
76 For the case of adding data from AliMUONHit objects the 'trigger'
77 parameter becomes the track number in TreeH and not the index of the
78 AliMUONLocalTrigger object.
81 AliMUONDataInterface* data,
82 Int_t event, Int_t trigger, Bool_t newblock = kFALSE
85 /* Clears all the internal arrays.
87 virtual void Clear(Option_t* option = "");
90 TString FileName() const { return fFilename; };
91 TString FolderName() const { return fFoldername; };
93 /* Returns the number of events stored.
95 Int_t NumberOfEvents() const { return fEventList.GetEntriesFast(); };
97 /* Fetches the specified event number stored in this AliHLTMUONTriggerSource.
98 Sets the current block and trigger to the first block and trigger record in
99 the event. If there are no blocks or trigger records then these pointers are
100 set to NULL. kTRUE is returned if the event was found, kFALSE otherwise.
102 Bool_t GetEvent(Int_t eventnumber) const;
104 /* Fetches the first event stored in this AliHLTMUONTriggerSource.
105 Sets the current block and trigger record to the first block and trigger
106 in the event. If there are no blocks or trigger records then these pointers
107 are set to NULL. kTRUE is returned if the event was found, kFALSE otherwise.
109 Bool_t GetFirstEvent() const;
111 /* Returns kTRUE if there are more events to iterate over.
113 Bool_t MoreEvents() const;
115 /* Fetches the next event stored following the currently selected one.
116 kTRUE is returned if the event was found, kFALSE otherwise.
117 The internal pointers are reset if we reached the last event.
119 Bool_t GetNextEvent() const;
121 /* Returns the corresponding AliRoot event number for the current event.
122 -1 is returned if no event is selected.
124 Int_t CurrentEvent() const;
126 /* Returns the number of trigger record blocks in the current event.
127 -1 is returned if no event is selected.
129 Int_t NumberOfBlocks() const;
131 /* Fetches the index'th block in the current event.
132 Sets the current trigger record to the first trigger in the block.
133 If there are no trigger records then this pointer is set to NULL.
134 kTRUE is returned if the block was found, kFALSE otherwise.
136 Bool_t GetBlock(Int_t index) const;
138 /* Fetches the first block in the current event.
139 Sets the current trigger record to the first trigger in the block.
140 If there are no trigger records then this pointer is set to NULL.
141 kTRUE is returned if the block was found, kFALSE otherwise.
143 Bool_t GetFirstBlock() const;
145 /* Returns kTRUE if there are more blocks to be traversed.
147 Bool_t MoreBlocks() const;
149 /* Fetches the next block in the current event.
150 kTRUE is returned if the block was found, kFALSE otherwise.
152 Bool_t GetNextBlock() const;
154 /* Returns the currently selected block number.
155 -1 is returned if no blocks are selected.
157 Int_t CurrentBlock() const { return fBlockIndex; };
159 /* Returns the number of trigger records in the current block.
160 -1 is returned if no block is selected.
162 Int_t NumberOfTriggers() const;
164 /* Fetches the trigger record with the specified trigger number from
166 NULL is returned if the record was not found.
168 const AliHLTMUONTriggerRecord* GetTrigger(Int_t triggernumber) const;
170 /* Fetches the first trigger record in the current block.
171 NULL is returned if the record was not found.
173 const AliHLTMUONTriggerRecord* GetFirstTrigger() const;
175 /* Returns kTRUE if there are more triggers to iterate over.
177 Bool_t MoreTriggers() const;
179 /* Fetches the next trigger record in the current block.
180 NULL is returned if the record was not found.
182 const AliHLTMUONTriggerRecord* GetNextTrigger() const;
184 /* Returns the current trigger record.
185 NULL is returned if the record was not found.
187 const AliHLTMUONTriggerRecord* GetTrigger() const { return fCurrentTrigger; };
189 /* Returns the trigger record number for the currently selected trigger record.
190 This number corresponds to the index'th AliMUONLocalTrigger object for the
192 -1 is returned if no trigger record is selected.
194 Int_t CurrentTrigger() const;
199 /* Adds a new EventData block to the fEventList and updates the fCurrentEvent,
200 fCurrentBlock and fCurrentTrigger pointers.
202 void AddEvent(Int_t eventnumber);
204 /* Adds a new block to the current event and updates fCurrentBlock and fCurrentTrigger.
208 /* Adds a new trigger record to the current event and block.
209 The fCurrentTrigger is updated appropriately.
211 void AddTrigger(const AliHLTMUONTriggerRecord& data);
213 /* Checks if the file and folder names correspond to this AliHLTMUONTriggerSource's
214 file and folder names. kTRUE is returned if they do.
215 If the file and folder names are empty then they are assigned the names
216 as found in the data interface and kTRUE is returned.
218 Bool_t FileAndFolderOk(AliMUONDataInterface* data);
220 /* Adds the whole event from the data interface to the internal data structures.
221 It is assumed that FileAndFolderOk(data) returns true just before calling
224 void AddEventFrom(AliMUONDataInterface* data, AliMUON* module, Int_t event);
226 /* Adds the specified trigger record from the given data interface.
227 The data interface should be initialised correctly, that is the event
228 should already be selected before calling this method.
230 void AddTriggerFrom(AliMUONDataInterface* data, AliMUON* module, Int_t trigger);
232 /* Checks to see if the specified trigger record is in the chamber region
233 we want to fill from.
234 kTRUE is returned if (x, y) is in the region, and kFALSE otherwise.
236 Bool_t InFillRegion(const AliHLTMUONTriggerRecord& data);
238 /* Fills the trigger data from the AliMUONLocalTrigger object.
239 if the fUseLookupTable is set to true then we use the L0 lookup table to
240 fill the Pt value otherwise we use the PtCal method in AliMUONTriggerCircuit.
241 Note the fTriggerNumber parameter is not filled in to 'record'.
243 void FillTriggerFromLocalTrigger(
244 AliMUONLocalTrigger* trigger, AliMUON* module, AliHLTMUONTriggerRecord& record
247 /* Fills the TriggerRecord structure from AliMUONHit objects.
248 The hits on the last 4 chambers are used (i.e. chambers 11 to 14).
249 kTRUE is returned if the structure was filled successfully.
251 Bool_t FillTriggerFromHits(AliMUONDataInterface* data, Int_t track, AliHLTMUONTriggerRecord& record);
253 /* Fetches the AliMUON module from the AliRun global object. AliRun will be loaded
254 by the runloader if it has not yet been loaded. In such a case the AliRun object
255 will also we unloaded when we are done with it.
256 kTRUE is returned if no error occured and kFALSE otherwise.
257 Note that if fDataToUse is set to FromHits then gAlice is not loaded and 'module'
258 will be left untouched. The method will still return kTRUE however since this is
259 not an error. We do not need the AliMUON module when filling from hits.
261 Bool_t FetchAliMUON(AliMUON*& module);
263 /* After one is finished with the AliMUON object returned by GetAliMUON, one
264 should call this method.
265 If the gAlice object was loaded by GetAliMUON then it will be unloaded at
266 this point, otherwise nothing is done.
268 void FinishedWithAliMUON();
270 /* Sets all the current pointers to NULL and indices to -1.
272 void ResetAllPointers() const;
274 /* Sets the block and trigger pointers to NULL and indices to -1.
276 void ResetBlockPointers() const;
278 /* Sets just the current trigger record pointer to NULL and index to -1.
280 void ResetTriggerPointers() const;
283 public: // Unfortunately ROOT requires the following to be public.
285 class EventData : public TObject
289 EventData(Int_t eventnumber);
290 virtual ~EventData();
292 Int_t fEventNumber; // Event number in AliMUONDataInterface from which the triggers were taken.
293 TClonesArray fBlocks; // The list of blocks of trigger records.
295 ClassDef(EventData, 1) // Data per event.
300 AreaType fAreaToUse; //! The part of the chamber to fill from.
301 SourceType fDataToUse; //! The type of raw AliRoot data to fill from.
302 UInt_t fMaxBlockSize; //! The maximum block size to create in the fill methods.
303 Bool_t fUseLookupTable; //! Set to true if the L0 lookup table should be used for finding Pt.
305 TString fFilename; // The file from which the trigger data was taken.
306 TString fFoldername; // The folder name from which trigger data was taken.
308 mutable Int_t fEventIndex; //! The index number of the currently selected event.
309 mutable EventData* fCurrentEvent; //! Pointer to the currently selected event.
310 mutable Int_t fBlockIndex; //! The index number of the currently selected block.
311 mutable TClonesArray* fCurrentBlock; //! Pointer to the currently selected block.
312 mutable Int_t fTriggerIndex; //! The index number of the currently selected trigger record.
313 mutable AliHLTMUONTriggerRecord* fCurrentTrigger; //! Pointer to the currently selected trigger record.
315 TClonesArray fEventList; // List of trigger records per event.
317 Bool_t fHadToLoadgAlice; //! Flag indicating if this object had to load the AliRun object.
319 ClassDef(AliHLTMUONTriggerSource, 1) // The source of trigger records for dHLT.
323 #endif // ALIHLTMUONTRIGGERSOURCE_H