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