]> git.uio.no Git - u/mrichter/AliRoot.git/blame - HLT/BASE/AliHLTReadoutList.h
introducing functions in addition some of the operator functions since the operator...
[u/mrichter/AliRoot.git] / HLT / BASE / AliHLTReadoutList.h
CommitLineData
c580e182 1//-*- Mode: C++ -*-
15ede44e 2// $Id$
dce3e5ce 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
1462df14 14#include "TNamed.h"
dce3e5ce 15#include "AliHLTDataTypes.h"
16
1b9a175e 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.
1b9a175e 32 * - unsets the bits in readout list A that are set in readout list B.
33 * This effectively applies A & (A ^ B).
34 */
1462df14 35class AliHLTReadoutList : public TNamed
dce3e5ce 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
8b745301 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
acc7214e 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
dce3e5ce 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
52f67e50 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
dce3e5ce 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; }
15ede44e 216
217 /**
218 * Access method to the binary buffer.
219 * \return pointer to the binary buffer.
220 */
221 AliHLTEventDDL* Buffer() { return &fReadoutList; }
222
223 /**
224 * Access to the size of the binary buffer.
225 * \return size of the binary buffer
226 */
227 unsigned BufferSize() { return sizeof(fReadoutList); }
dce3e5ce 228
229 /**
230 * Assignment operator performs a deep copy.
231 * \param list The readout list to copy from.
232 * \return A reference to this object.
233 */
234 AliHLTReadoutList& operator = (const AliHLTReadoutList& list);
235
236 /**
237 * This operator performs a bitwise inclusive or operation on all DDL bits
238 * between this readout and <i>list</i>.
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);
e5339167 243
244 /// same as operator |=
245 AliHLTReadoutList& OrEq(const AliHLTReadoutList& list);
dce3e5ce 246
247 /**
248 * This operator performs a bitwise exclusive or (xor) operation on all DDL
249 * bits between this readout and <i>list</i>.
250 * \param list The right hand side readout list to operate on.
251 * \return A reference to this object.
252 */
253 AliHLTReadoutList& operator ^= (const AliHLTReadoutList& list);
e5339167 254
255 /// same as operator ^=
256 AliHLTReadoutList& XorEq(const AliHLTReadoutList& list);
dce3e5ce 257
258 /**
259 * This operator performs a bitwise and operation on all DDL bits between
260 * this readout and <i>list</i>.
261 * \param list The right hand side readout list to operate on.
262 * \return A reference to this object.
263 */
264 AliHLTReadoutList& operator &= (const AliHLTReadoutList& list);
e5339167 265
266 /// same as operator &=
267 AliHLTReadoutList& AndEq(const AliHLTReadoutList& list);
dce3e5ce 268
dce3e5ce 269 /**
270 * This operator performs the effective operation of "this and (this xor list)".
271 * It removes all the DDLs specified in list from this readout list.
272 * \param list The right hand side readout list to operate on.
273 * \return A reference to this object.
274 */
275 AliHLTReadoutList& operator -= (const AliHLTReadoutList& list);
276
277 /**
278 * This operator performs a bitwise ones compliment on all DDL bits of this
279 * readout list.
280 * \return The result of the unary operator.
281 */
282 AliHLTReadoutList operator ~ () const;
283
284 /**
285 * This operator performs a bitwise inclusive or operation on all DDL bits
286 * between this readout and <i>list</i>.
287 * \param list The right hand side readout list to operate on.
288 * \return The result of the binary operator.
289 */
290 AliHLTReadoutList operator | (const AliHLTReadoutList& list) const
291 {
292 AliHLTReadoutList result = *this;
293 return result.operator |= (list);
294 }
295
296 /**
297 * This operator performs a bitwise exclusive or (xor) operation on all DDL
298 * bits between this readout and <i>list</i>.
299 * \param list The right hand side readout list to operate on.
300 * \return The result of the binary operator.
301 */
302 AliHLTReadoutList operator ^ (const AliHLTReadoutList& list) const
303 {
304 AliHLTReadoutList result = *this;
305 return result.operator ^= (list);
306 }
307
308 /**
309 * This operator performs a bitwise and operation on all DDL bits between
310 * this readout and <i>list</i>.
311 * \param list The right hand side readout list to operate on.
312 * \return The result of the binary operator.
313 */
314 AliHLTReadoutList operator & (const AliHLTReadoutList& list) const
315 {
316 AliHLTReadoutList result = *this;
317 return result.operator &= (list);
318 }
319
dce3e5ce 320 /**
321 * This operator performs the effective operation of "this and (this xor list)".
0910cc2f 322 * i.e. the set difference.
dce3e5ce 323 * It removes all the DDLs specified in list from this readout list.
324 * \param list The right hand side readout list to operate on.
325 * \return The result of the binary operator.
326 */
327 AliHLTReadoutList operator - (const AliHLTReadoutList& list) const
328 {
329 AliHLTReadoutList result = *this;
330 return result.operator -= (list);
331 }
332
333 private:
334
335 /**
336 * Decodes the word index and bit index within that word for the readout list structure.
337 * \param ddlId <i>[in]</i> The ID number of the DDL to decode.
338 * \param wordIndex <i>[out]</i> the word index of the word to modify or check
339 * within fReadoutList.fList
340 * \param bitIndex <i>[out]</i> the bit index of the bit to modify or check
341 * within the word pointed to by <i>wordIndex</i>.
342 * \return true if the ddlId was decoded and false if it was invalid.
343 * \note We do not check extensively if the ddlId is invalid. Just simple checks
344 * are performed to see that we do not overflow the buffer fReadoutList.fList.
345 */
346 static bool DecodeDDLID(Int_t ddlId, Int_t& wordIndex, Int_t& bitIndex);
347
348 AliHLTEventDDL fReadoutList; /// The DDL readout list structure.
349
1462df14 350 ClassDef(AliHLTReadoutList, 2) // Readout list object used for manipulating and storing an AliHLTEventDDL structure.
dce3e5ce 351
352};
353
354#endif // ALIHLTREADOUTLIST_H
355