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