1 ////////////////////////////////////////////////////////////////////////////////
3 // Author: Artur Szostak
4 // Email: artur@alice.phy.uct.ac.za | artursz@iafrica.com
6 ////////////////////////////////////////////////////////////////////////////////
8 /* AliHLTMUONTriggerSource is used to extract L0 trigger information for
9 the muon spectrometer from a simulated event stored in .root files by AliRoot.
10 It is used by the AliHLTMUONMicrodHLT class as a input data set for the
14 #ifndef ALIHLTMUONTRIGGERSOURCE_H
15 #define ALIHLTMUONTRIGGERSOURCE_H
20 #include "TClonesArray.h"
21 #include "AliRoot/TriggerRecord.hpp"
24 class AliMUONLocalTrigger;
25 class AliMUONDataInterface;
28 class AliHLTMUONTriggerSource : public TObject
30 public: // Unfortunately ROOT requires the following to be public.
32 class AliEventData : public TObject
36 AliEventData(Int_t eventnumber);
37 virtual ~AliEventData();
39 Int_t& EventNumber() { return fEventNumber; }
40 TClonesArray& Blocks() { return fBlocks; }
44 Int_t fEventNumber; // Event number in AliMUONDataInterface from which the triggers were taken.
45 TClonesArray fBlocks; // The list of blocks of trigger records.
47 ClassDef(AliEventData, 1) // Data per event.
67 AliHLTMUONTriggerSource();
69 /* Creates a new trigger source object by filling data from the data interface.
71 AliHLTMUONTriggerSource(AliMUONDataInterface* data);
73 virtual ~AliHLTMUONTriggerSource();
75 /* Get and set methods to specify how the FillFrom methods should fill the
76 internal data structures.
78 void AreaToUse(AreaType value) { fAreaToUse = value; };
79 AreaType AreaToUse() const { return fAreaToUse; };
80 void DataToUse(SourceType value) { fDataToUse = value; };
81 SourceType DataToUse() const { return fDataToUse; };
82 void MaxBlockSize(UInt_t value) { fMaxBlockSize = value; };
83 UInt_t MaxBlockSize() const { return fMaxBlockSize; };
84 void UseLookupTable(Bool_t value) { fUseLookupTable = value; };
85 Bool_t UseLookupTable() const { return fUseLookupTable; };
87 /* Fills the internal data structures from the specified data interface
88 for all the events found in AliMUONDataInterface.
90 void FillFrom(AliMUONDataInterface* data);
92 /* Fills the internal data structures from the specified data interface
95 void FillFrom(AliMUONDataInterface* data, Int_t event);
97 /* Fills the internal data structures from the specified data interface
98 for the given event and trigger number.
99 If 'newblock' is set to true then the new trigger record is added to
100 a new block. Otherwise the point is added to the current block.
101 Note: This method ignores the fAreaToUse and fMaxBlockSize flags.
102 This is very usefull for custom trigger source filling.
103 For the case of adding data from AliMUONHit objects the 'trigger'
104 parameter becomes the track number in TreeH and not the index of the
105 AliMUONLocalTrigger object.
108 AliMUONDataInterface* data,
109 Int_t event, Int_t trigger, Bool_t newblock = kFALSE
112 /* Clears all the internal arrays.
114 virtual void Clear(Option_t* option = "");
117 TString FileName() const { return fFilename; };
118 TString FolderName() const { return fFoldername; };
120 /* Returns the number of events stored.
122 Int_t NumberOfEvents() const { return fEventList.GetEntriesFast(); };
124 /* Fetches the specified event number stored in this AliHLTMUONTriggerSource.
125 Sets the current block and trigger to the first block and trigger record in
126 the event. If there are no blocks or trigger records then these pointers are
127 set to NULL. kTRUE is returned if the event was found, kFALSE otherwise.
129 Bool_t GetEvent(Int_t eventnumber) const;
131 /* Fetches the first event stored in this AliHLTMUONTriggerSource.
132 Sets the current block and trigger record to the first block and trigger
133 in the event. If there are no blocks or trigger records then these pointers
134 are set to NULL. kTRUE is returned if the event was found, kFALSE otherwise.
136 Bool_t GetFirstEvent() const;
138 /* Returns kTRUE if there are more events to iterate over.
140 Bool_t MoreEvents() const;
142 /* Fetches the next event stored following the currently selected one.
143 kTRUE is returned if the event was found, kFALSE otherwise.
144 The internal pointers are reset if we reached the last event.
146 Bool_t GetNextEvent() const;
148 /* Returns the corresponding AliRoot event number for the current event.
149 -1 is returned if no event is selected.
151 Int_t CurrentEvent() const;
153 /* Returns the number of trigger record blocks in the current event.
154 -1 is returned if no event is selected.
156 Int_t NumberOfBlocks() const;
158 /* Fetches the index'th block in the current event.
159 Sets the current trigger record to the first trigger in the block.
160 If there are no trigger records then this pointer is set to NULL.
161 kTRUE is returned if the block was found, kFALSE otherwise.
163 Bool_t GetBlock(Int_t index) const;
165 /* Fetches the first block in the current event.
166 Sets the current trigger record to the first trigger in the block.
167 If there are no trigger records then this pointer is set to NULL.
168 kTRUE is returned if the block was found, kFALSE otherwise.
170 Bool_t GetFirstBlock() const;
172 /* Returns kTRUE if there are more blocks to be traversed.
174 Bool_t MoreBlocks() const;
176 /* Fetches the next block in the current event.
177 kTRUE is returned if the block was found, kFALSE otherwise.
179 Bool_t GetNextBlock() const;
181 /* Returns the currently selected block number.
182 -1 is returned if no blocks are selected.
184 Int_t CurrentBlock() const { return fBlockIndex; };
186 /* Returns the number of trigger records in the current block.
187 -1 is returned if no block is selected.
189 Int_t NumberOfTriggers() const;
191 /* Fetches the trigger record with the specified trigger number from
193 NULL is returned if the record was not found.
195 const AliHLTMUONTriggerRecord* GetTrigger(Int_t triggernumber) const;
197 /* Fetches the first trigger record in the current block.
198 NULL is returned if the record was not found.
200 const AliHLTMUONTriggerRecord* GetFirstTrigger() const;
202 /* Returns kTRUE if there are more triggers to iterate over.
204 Bool_t MoreTriggers() const;
206 /* Fetches the next trigger record in the current block.
207 NULL is returned if the record was not found.
209 const AliHLTMUONTriggerRecord* GetNextTrigger() const;
211 /* Returns the current trigger record.
212 NULL is returned if the record was not found.
214 const AliHLTMUONTriggerRecord* GetTrigger() const { return fCurrentTrigger; };
216 /* Returns the trigger record number for the currently selected trigger record.
217 This number corresponds to the index'th AliMUONLocalTrigger object for the
219 -1 is returned if no trigger record is selected.
221 Int_t CurrentTrigger() const;
226 /* Adds a new AliEventData block to the fEventList and updates the fCurrentEvent,
227 fCurrentBlock and fCurrentTrigger pointers.
229 void AddEvent(Int_t eventnumber);
231 /* Adds a new block to the current event and updates fCurrentBlock and fCurrentTrigger.
235 /* Adds a new trigger record to the current event and block.
236 The fCurrentTrigger is updated appropriately.
238 void AddTrigger(const AliHLTMUONTriggerRecord& data);
240 /* Checks if the file and folder names correspond to this AliHLTMUONTriggerSource's
241 file and folder names. kTRUE is returned if they do.
242 If the file and folder names are empty then they are assigned the names
243 as found in the data interface and kTRUE is returned.
245 Bool_t FileAndFolderOk(AliMUONDataInterface* data);
247 /* Adds the whole event from the data interface to the internal data structures.
248 It is assumed that FileAndFolderOk(data) returns true just before calling
251 void AddEventFrom(AliMUONDataInterface* data, AliMUON* module, Int_t event);
253 /* Adds the specified trigger record from the given data interface.
254 The data interface should be initialised correctly, that is the event
255 should already be selected before calling this method.
257 void AddTriggerFrom(AliMUONDataInterface* data, AliMUON* module, Int_t trigger);
259 /* Checks to see if the specified trigger record is in the chamber region
260 we want to fill from.
261 kTRUE is returned if (x, y) is in the region, and kFALSE otherwise.
263 Bool_t InFillRegion(const AliHLTMUONTriggerRecord& data) const;
265 /* Fills the trigger data from the AliMUONLocalTrigger object.
266 if the fUseLookupTable is set to true then we use the L0 lookup table to
267 fill the Pt value otherwise we use the PtCal method in AliMUONTriggerCircuit.
268 Note the fTriggerNumber parameter is not filled in to 'record'.
270 void FillTriggerFromLocalTrigger(
271 AliMUONLocalTrigger* trigger, AliMUON* module, AliHLTMUONTriggerRecord& record
274 /* Fills the TriggerRecord structure from AliMUONHit objects.
275 The hits on the last 4 chambers are used (i.e. chambers 11 to 14).
276 kTRUE is returned if the structure was filled successfully.
278 Bool_t FillTriggerFromHits(AliMUONDataInterface* data, Int_t track, AliHLTMUONTriggerRecord& record);
280 /* Fetches the AliMUON module from the AliRun global object. AliRun will be loaded
281 by the runloader if it has not yet been loaded. In such a case the AliRun object
282 will also we unloaded when we are done with it.
283 kTRUE is returned if no error occured and kFALSE otherwise.
284 Note that if fDataToUse is set to kFromHits then gAlice is not loaded and 'module'
285 will be left untouched. The method will still return kTRUE however since this is
286 not an error. We do not need the AliMUON module when filling from hits.
288 Bool_t FetchAliMUON(AliMUON*& module);
290 /* After one is finished with the AliMUON object returned by GetAliMUON, one
291 should call this method.
292 If the gAlice object was loaded by GetAliMUON then it will be unloaded at
293 this point, otherwise nothing is done.
295 void FinishedWithAliMUON();
297 /* Sets all the current pointers to NULL and indices to -1.
299 void ResetAllPointers() const;
301 /* Sets the block and trigger pointers to NULL and indices to -1.
303 void ResetBlockPointers() const;
305 /* Sets just the current trigger record pointer to NULL and index to -1.
307 void ResetTriggerPointers() const;
310 // Do not allow copying of this object.
311 AliHLTMUONTriggerSource(const AliHLTMUONTriggerSource& /*object*/)
313 fAreaToUse(kFromWholePlane), fDataToUse(kFromLocalTriggers),
314 fMaxBlockSize(0xFFFFFFFF), fUseLookupTable(kTRUE),
315 fFilename(""), fFoldername(""),
316 fEventIndex(-1), fCurrentEvent(NULL),
317 fBlockIndex(-1), fCurrentBlock(NULL),
318 fTriggerIndex(-1), fCurrentTrigger(NULL),
319 fEventList(AliHLTMUONTriggerSource::AliEventData::Class()),
320 fHadToLoadgAlice(kFALSE)
323 AliHLTMUONTriggerSource& operator = (const AliHLTMUONTriggerSource& /*object*/) { return *this; }
326 AreaType fAreaToUse; //! The part of the chamber to fill from.
327 SourceType fDataToUse; //! The type of raw AliRoot data to fill from.
328 UInt_t fMaxBlockSize; //! The maximum block size to create in the fill methods.
329 Bool_t fUseLookupTable; //! Set to true if the L0 lookup table should be used for finding Pt.
331 TString fFilename; // The file from which the trigger data was taken.
332 TString fFoldername; // The folder name from which trigger data was taken.
334 mutable Int_t fEventIndex; //! The index number of the currently selected event.
335 mutable AliEventData* fCurrentEvent; //! Pointer to the currently selected event.
336 mutable Int_t fBlockIndex; //! The index number of the currently selected block.
337 mutable TClonesArray* fCurrentBlock; //! Pointer to the currently selected block.
338 mutable Int_t fTriggerIndex; //! The index number of the currently selected trigger record.
339 mutable AliHLTMUONTriggerRecord* fCurrentTrigger; //! Pointer to the currently selected trigger record.
341 TClonesArray fEventList; // List of trigger records per event.
343 Bool_t fHadToLoadgAlice; //! Flag indicating if this object had to load the AliRun object.
345 ClassDef(AliHLTMUONTriggerSource, 1) // The source of trigger records for dHLT.
349 #endif // ALIHLTMUONTRIGGERSOURCE_H