]> git.uio.no Git - u/mrichter/AliRoot.git/blob - HLT/trigger/AliHLTReadoutList.h
Adding trigger domain and trigger decision classes. AliHLTTrigger now produces an...
[u/mrichter/AliRoot.git] / HLT / trigger / AliHLTReadoutList.h
1 #ifndef ALIHLTREADOUTLIST_H
2 #define ALIHLTREADOUTLIST_H
3 /* This file is property of and copyright by the ALICE HLT Project        *
4  * ALICE Experiment at CERN, All rights reserved.                         *
5  * See cxx source for full Copyright notice                               */
6
7 /// @file   AliHLTReadoutList.h
8 /// @author Artur Szostak <artursz@iafrica.com>
9 /// @date   19 Nov 2008
10 /// @brief  Declaration of the AliHLTReadoutList class used to handle AliHLTEventDDL structures.
11
12 #include "TObject.h"
13 #include "AliHLTDataTypes.h"
14
15 /**
16  * \class AliHLTReadoutList
17  * This class is used as an interface or wrapper to the AliHLTEventDDL structure.
18  * It makes it easy to manipulate the bits in this structure, which define what DDLs
19  * should be readout by DAQ.
20  * Several operators are also overloaded which are meant to be used in the trigger
21  * menu specification for the AliHLTGlobalTrigger. It allows one to construct
22  * expressions for the readout lists, which is necessary to be able to evaluate
23  * or compose the final readout list, given multiple input readout lists received
24  * from individual components that derive from AliHLTTrigger.
25  * The operators implemented are:
26  *  |  applies a bitwise or on the DDL bits.
27  *  &  applies a bitwise and on the DDL bits.
28  *  ^  applies a bitwise xor on the DDL bits.
29  *  ~  applies a bitwise not on the DDL bits.
30  *  +  synonym for the '|' operator.
31  *  -  unsets the bits in readout list A that are set in readout list B.
32  *      This effectively applies A & (A ^ B).
33  */
34 class AliHLTReadoutList : public TObject
35 {
36  public:
37   
38   /**
39    * Identifiers for different detectors used by methods in AliHLTReadoutList.
40    */
41   enum EDetectorId
42   {
43     kITSSPD = 0x1 << 0,    /// ID for SPD detector
44     kITSSDD = 0x1 << 1,    /// ID for SDD detector
45     kITSSSD = 0x1 << 2,    /// ID for SSD detector
46     kTPC = 0x1 << 3,       /// ID for TPC detector
47     kTRD = 0x1 << 4,       /// ID for TRD detector
48     kTOF = 0x1 << 5,       /// ID for TOF detector
49     kHMPID = 0x1 << 6,     /// ID for HMPID detector
50     kPHOS = 0x1 << 7,      /// ID for PHOS detector
51     kCPV = 0x1 << 8,       /// ID for CPV detector
52     kPMD = 0x1 << 9,       /// ID for PMD detector
53     kMUONTRK = 0x1 << 10,  /// ID for MUON tracking chambers
54     kMUONTRG = 0x1 << 11,  /// ID for MUON trigger detector
55     kFMD = 0x1 << 12,      /// ID for FMD detector
56     kT0 = 0x1 << 13,       /// ID for T0 detector
57     kV0 = 0x1 << 14,       /// ID for V0 detector
58     kZDC = 0x1 << 15,      /// ID for ZDC detector
59     kACORDE = 0x1 << 16,   /// ID for ACORDE detector
60     kTRG = 0x1 << 17,      /// ID for TRG detector
61     kEMCAL = 0x1 << 18,    /// ID for EMCAL detector
62     kDAQTEST = 0x1 << 19,  /// ID for DAQ_TEST detector
63     kHLT = 0x1 << 30,      /// ID for HLT detector
64     // kALLDET sets readout for all detectors except DAQ_TEST
65     kALLDET = (kITSSPD | kITSSDD | kITSSSD | kTPC | kTRD | kTOF | kHMPID | kPHOS
66                | kCPV | kPMD | kMUONTRK | kMUONTRG | kFMD | kT0 | kV0 | kZDC
67                | kACORDE | kTRG | kEMCAL | kHLT)
68   };
69   
70   /**
71    * Default constructor.
72    */
73   AliHLTReadoutList();
74   
75   /**
76    *  Constructor to select which detectors to enable for readout.
77    * \param enabledDetectors  Detector bit field. Can be any values for
78    *     EDetectorId or'ed together.
79    */
80   AliHLTReadoutList(Int_t enabledDetectors);
81   
82   /**
83    * Constructor to select which detectors and DDLs to enable for readout.
84    * \param enabledList The string format is a space separated list where
85    *     each item is either a detector acronym name or DDL number.
86    * Invalid sub-strings are simply ignored. The special ALL string is
87    * equivalent to kALLDET for AliHLTReadoutList(Int_t enabledDetectors).
88    */
89   AliHLTReadoutList(const char* enabledList);
90   
91   /**
92    * Constructor to create readout list from AliHLTEventDDL structure.
93    * \param list  The AliHLTEventDDL structure from which to create this object.
94    */
95   AliHLTReadoutList(const AliHLTEventDDL& list);
96   
97   /**
98    * The copy constructor performs a deep copy.
99    * \param list  The readout list to copy from.
100    */
101   AliHLTReadoutList(const AliHLTReadoutList& list);
102   
103   /**
104    * Default destructor.
105    */
106   virtual ~AliHLTReadoutList();
107   
108   /**
109    * Enables a specific DDL bit in the readout list.
110    * \param ddlId  The ID number of the DDL to enable.
111    */
112   void EnableDDLBit(Int_t ddlId)
113   {
114     SetDDLBit(ddlId, kTRUE);
115   }
116   
117   /**
118    * Disables a specific DDL bit in the readout list.
119    * \param ddlId  The ID number of the DDL to disable.
120    */
121   void DisableDDLBit(Int_t ddlId)
122   {
123     SetDDLBit(ddlId, kFALSE);
124   }
125   
126   /**
127    * Fetches the bit value for a particular DDL in the readout list.
128    * \param ddlId  The ID number of the DDL to fetch.
129    * \return the bit value for the specified DDL.
130    */
131   Bool_t GetDDLBit(Int_t ddlId) const;
132   
133   /**
134    * Sets the bit value for a particular DDL in the readout list.
135    * \param ddlId  The ID number of the DDL to set.
136    * \param state  The value to set the bit to.
137    */
138   void SetDDLBit(Int_t ddlId, Bool_t state);
139   
140   /**
141    * Checks if a particular DDL is enabled for readout.
142    * \param ddlId  The ID number of the DDL to check.
143    * \return the if the DDL is enabled for readout.
144    */
145   bool IsDDLEnabled(Int_t ddlId) const
146   {
147     return GetDDLBit(ddlId) == kTRUE;
148   }
149   
150   /**
151    * Checks if a particular DDL is disabled for readout.
152    * \param ddlId  The ID number of the DDL to check.
153    * \return the if the DDL is disabled for readout.
154    */
155   bool IsDDLDisabled(Int_t ddlId) const
156   {
157     return GetDDLBit(ddlId) == kFALSE;
158   }
159   
160   /**
161    * Enables all DDLs for a particular detector or detectors.
162    * \param detector  A bitmap of detectors to enable. Should be any values from
163    *    EDetectorId that can be or'ed together for multiple detector selection.
164    */
165   void Enable(Int_t detector);
166   
167   /**
168    * Disables all DDLs for a particular detector or detectors.
169    * \param detector  A bitmap of detectors to disable. Should be any values from
170    *    EDetectorId that can be or'ed together for multiple detector selection.
171    */
172   void Disable(Int_t detector);
173   
174   /**
175    * Inherited from TObject. Prints the DDLs that will be readout according to
176    * this readout list.
177    * \param option  This is not used by this method.
178    */
179   virtual void Print(Option_t* option = "") const;
180   
181   /**
182    * This typecast operator converts the readout list to the AliHLTEventDDL
183    * structure format.
184    * \return  Copy of the AliHLTEventDDL raw structure.
185    */
186   operator AliHLTEventDDL () const { return fReadoutList; }
187   
188   /**
189    * This typecast operator converts the readout list to the AliHLTEventDDL
190    * structure format.
191    * \return  Reference to the AliHLTEventDDL raw structure.
192    */
193   operator AliHLTEventDDL& () { return fReadoutList; }
194   
195   /**
196    * Assignment operator performs a deep copy.
197    * \param list  The readout list to copy from.
198    * \return  A reference to this object.
199    */
200   AliHLTReadoutList& operator = (const AliHLTReadoutList& list);
201   
202   /**
203    * This operator performs a bitwise inclusive or operation on all DDL bits
204    * between this readout and <i>list</i>.
205    * \param list  The right hand side readout list to operate on.
206    * \return  A reference to this object.
207    */
208   AliHLTReadoutList& operator |= (const AliHLTReadoutList& list);
209   
210   /**
211    * This operator performs a bitwise exclusive or (xor) operation on all DDL
212    * bits between this readout and <i>list</i>.
213    * \param list  The right hand side readout list to operate on.
214    * \return  A reference to this object.
215    */
216   AliHLTReadoutList& operator ^= (const AliHLTReadoutList& list);
217   
218   /**
219    * This operator performs a bitwise and operation on all DDL bits between
220    * this readout and <i>list</i>.
221    * \param list  The right hand side readout list to operate on.
222    * \return  A reference to this object.
223    */
224   AliHLTReadoutList& operator &= (const AliHLTReadoutList& list);
225   
226   /**
227    * This operator performs the same operation as '|='.
228    * \param list  The right hand side readout list to operate on.
229    * \return  A reference to this object.
230    */
231   AliHLTReadoutList& operator += (const AliHLTReadoutList& list)
232   {
233     return operator |= (list);
234   }
235   
236   /**
237    * This operator performs the effective operation of "this and (this xor list)".
238    * It removes all the DDLs specified in list from this readout list.
239    * \param list  The right hand side readout list to operate on.
240    * \return  A reference to this object.
241    */
242   AliHLTReadoutList& operator -= (const AliHLTReadoutList& list);
243   
244   /**
245    * This operator performs a bitwise ones compliment on all DDL bits of this
246    * readout list.
247    * \return  The result of the unary operator.
248    */
249   AliHLTReadoutList operator ~ () const;
250   
251   /**
252    * This operator performs a bitwise inclusive or operation on all DDL bits
253    * between this readout and <i>list</i>.
254    * \param list  The right hand side readout list to operate on.
255    * \return  The result of the binary operator.
256    */
257   AliHLTReadoutList operator | (const AliHLTReadoutList& list) const
258   {
259     AliHLTReadoutList result = *this;
260     return result.operator |= (list);
261   }
262   
263   /**
264    * This operator performs a bitwise exclusive or (xor) operation on all DDL
265    * bits between this readout and <i>list</i>.
266    * \param list  The right hand side readout list to operate on.
267    * \return  The result of the binary operator.
268    */
269   AliHLTReadoutList operator ^ (const AliHLTReadoutList& list) const
270   {
271     AliHLTReadoutList result = *this;
272     return result.operator ^= (list);
273   }
274   
275   /**
276    * This operator performs a bitwise and operation on all DDL bits between
277    * this readout and <i>list</i>.
278    * \param list  The right hand side readout list to operate on.
279    * \return  The result of the binary operator.
280    */
281   AliHLTReadoutList operator & (const AliHLTReadoutList& list) const
282   {
283     AliHLTReadoutList result = *this;
284     return result.operator &= (list);
285   }
286   
287   /**
288    * This operator performs the same operation as '|'.
289    * \param list  The right hand side readout list to operate on.
290    * \return  The result of the binary operator.
291    */
292   AliHLTReadoutList operator + (const AliHLTReadoutList& list) const
293   {
294     AliHLTReadoutList result = *this;
295     return result.operator += (list);
296   }
297   
298   /**
299    * This operator performs the effective operation of "this and (this xor list)".
300    * It removes all the DDLs specified in list from this readout list.
301    * \param list  The right hand side readout list to operate on.
302    * \return  The result of the binary operator.
303    */
304   AliHLTReadoutList operator - (const AliHLTReadoutList& list) const
305   {
306     AliHLTReadoutList result = *this;
307     return result.operator -= (list);
308   }
309   
310  private:
311   
312   /**
313    * Decodes the word index and bit index within that word for the readout list structure.
314    * \param ddlId <i>[in]</i>  The ID number of the DDL to decode.
315    * \param wordIndex <i>[out]</i>  the word index of the word to modify or check
316    *    within fReadoutList.fList
317    * \param bitIndex <i>[out]</i>   the bit index of the bit to modify or check
318    *    within the word pointed to by <i>wordIndex</i>.
319    * \return  true if the ddlId was decoded and false if it was invalid.
320    * \note We do not check extensively if the ddlId is invalid. Just simple checks
321    *    are performed to see that we do not overflow the buffer fReadoutList.fList.
322    */
323   static bool DecodeDDLID(Int_t ddlId, Int_t& wordIndex, Int_t& bitIndex);
324   
325   AliHLTEventDDL fReadoutList; /// The DDL readout list structure.
326   
327   ClassDef(AliHLTReadoutList, 1) // Readout list object used for manipulating and storing an AliHLTEventDDL structure.
328
329 };
330
331 #endif // ALIHLTREADOUTLIST_H
332