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