]>
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 | { | |
89413559 | 44 | kNoDetector = 0, /// No detector value |
dce3e5ce | 45 | kITSSPD = 0x1 << 0, /// ID for SPD detector |
46 | kITSSDD = 0x1 << 1, /// ID for SDD detector | |
47 | kITSSSD = 0x1 << 2, /// ID for SSD detector | |
48 | kTPC = 0x1 << 3, /// ID for TPC detector | |
49 | kTRD = 0x1 << 4, /// ID for TRD detector | |
50 | kTOF = 0x1 << 5, /// ID for TOF detector | |
51 | kHMPID = 0x1 << 6, /// ID for HMPID detector | |
52 | kPHOS = 0x1 << 7, /// ID for PHOS detector | |
53 | kCPV = 0x1 << 8, /// ID for CPV detector | |
54 | kPMD = 0x1 << 9, /// ID for PMD detector | |
55 | kMUONTRK = 0x1 << 10, /// ID for MUON tracking chambers | |
56 | kMUONTRG = 0x1 << 11, /// ID for MUON trigger detector | |
57 | kFMD = 0x1 << 12, /// ID for FMD detector | |
58 | kT0 = 0x1 << 13, /// ID for T0 detector | |
59 | kV0 = 0x1 << 14, /// ID for V0 detector | |
60 | kZDC = 0x1 << 15, /// ID for ZDC detector | |
61 | kACORDE = 0x1 << 16, /// ID for ACORDE detector | |
62 | kTRG = 0x1 << 17, /// ID for TRG detector | |
63 | kEMCAL = 0x1 << 18, /// ID for EMCAL detector | |
64 | kDAQTEST = 0x1 << 19, /// ID for DAQ_TEST detector | |
65 | kHLT = 0x1 << 30, /// ID for HLT detector | |
66 | // kALLDET sets readout for all detectors except DAQ_TEST | |
67 | kALLDET = (kITSSPD | kITSSDD | kITSSSD | kTPC | kTRD | kTOF | kHMPID | kPHOS | |
68 | | kCPV | kPMD | kMUONTRK | kMUONTRG | kFMD | kT0 | kV0 | kZDC | |
69 | | kACORDE | kTRG | kEMCAL | kHLT) | |
70 | }; | |
71 | ||
89413559 | 72 | /// Converts a detector ID to a user readable string. |
73 | static const char* DetectorIdToString(EDetectorId id); | |
74 | ||
dce3e5ce | 75 | /** |
76 | * Default constructor. | |
77 | */ | |
78 | AliHLTReadoutList(); | |
79 | ||
80 | /** | |
81 | * Constructor to select which detectors to enable for readout. | |
82 | * \param enabledDetectors Detector bit field. Can be any values for | |
83 | * EDetectorId or'ed together. | |
84 | */ | |
85 | AliHLTReadoutList(Int_t enabledDetectors); | |
86 | ||
87 | /** | |
88 | * Constructor to select which detectors and DDLs to enable for readout. | |
89 | * \param enabledList The string format is a space separated list where | |
90 | * each item is either a detector acronym name or DDL number. | |
91 | * Invalid sub-strings are simply ignored. The special ALL string is | |
92 | * equivalent to kALLDET for AliHLTReadoutList(Int_t enabledDetectors). | |
93 | */ | |
94 | AliHLTReadoutList(const char* enabledList); | |
95 | ||
96 | /** | |
97 | * Constructor to create readout list from AliHLTEventDDL structure. | |
98 | * \param list The AliHLTEventDDL structure from which to create this object. | |
99 | */ | |
100 | AliHLTReadoutList(const AliHLTEventDDL& list); | |
101 | ||
102 | /** | |
103 | * The copy constructor performs a deep copy. | |
104 | * \param list The readout list to copy from. | |
105 | */ | |
106 | AliHLTReadoutList(const AliHLTReadoutList& list); | |
107 | ||
108 | /** | |
109 | * Default destructor. | |
110 | */ | |
111 | virtual ~AliHLTReadoutList(); | |
112 | ||
8b745301 | 113 | /** |
114 | * Checks if the readout list is empty, i.e. all DDLs are disabled. | |
115 | * \returns true if the readout list is empty and false otherwise. | |
116 | */ | |
117 | bool Empty() const; | |
118 | ||
acc7214e | 119 | /** |
120 | * Disables all bits in the readout list. | |
121 | * \param option This parameter is ignored. | |
122 | * The method is inherited from TObject. | |
123 | */ | |
124 | virtual void Clear(Option_t* option = ""); | |
125 | ||
dce3e5ce | 126 | /** |
127 | * Enables a specific DDL bit in the readout list. | |
128 | * \param ddlId The ID number of the DDL to enable. | |
129 | */ | |
130 | void EnableDDLBit(Int_t ddlId) | |
131 | { | |
132 | SetDDLBit(ddlId, kTRUE); | |
133 | } | |
134 | ||
135 | /** | |
136 | * Disables a specific DDL bit in the readout list. | |
137 | * \param ddlId The ID number of the DDL to disable. | |
138 | */ | |
139 | void DisableDDLBit(Int_t ddlId) | |
140 | { | |
141 | SetDDLBit(ddlId, kFALSE); | |
142 | } | |
143 | ||
144 | /** | |
145 | * Fetches the bit value for a particular DDL in the readout list. | |
146 | * \param ddlId The ID number of the DDL to fetch. | |
147 | * \return the bit value for the specified DDL. | |
148 | */ | |
149 | Bool_t GetDDLBit(Int_t ddlId) const; | |
150 | ||
151 | /** | |
152 | * Sets the bit value for a particular DDL in the readout list. | |
153 | * \param ddlId The ID number of the DDL to set. | |
154 | * \param state The value to set the bit to. | |
155 | */ | |
156 | void SetDDLBit(Int_t ddlId, Bool_t state); | |
157 | ||
158 | /** | |
159 | * Checks if a particular DDL is enabled for readout. | |
160 | * \param ddlId The ID number of the DDL to check. | |
161 | * \return the if the DDL is enabled for readout. | |
162 | */ | |
163 | bool IsDDLEnabled(Int_t ddlId) const | |
164 | { | |
165 | return GetDDLBit(ddlId) == kTRUE; | |
166 | } | |
167 | ||
168 | /** | |
169 | * Checks if a particular DDL is disabled for readout. | |
170 | * \param ddlId The ID number of the DDL to check. | |
171 | * \return the if the DDL is disabled for readout. | |
172 | */ | |
173 | bool IsDDLDisabled(Int_t ddlId) const | |
174 | { | |
175 | return GetDDLBit(ddlId) == kFALSE; | |
176 | } | |
177 | ||
178 | /** | |
179 | * Enables all DDLs for a particular detector or detectors. | |
180 | * \param detector A bitmap of detectors to enable. Should be any values from | |
181 | * EDetectorId that can be or'ed together for multiple detector selection. | |
182 | */ | |
183 | void Enable(Int_t detector); | |
184 | ||
185 | /** | |
186 | * Disables all DDLs for a particular detector or detectors. | |
187 | * \param detector A bitmap of detectors to disable. Should be any values from | |
188 | * EDetectorId that can be or'ed together for multiple detector selection. | |
189 | */ | |
190 | void Disable(Int_t detector); | |
191 | ||
52f67e50 | 192 | /** |
89413559 | 193 | * Checks if a particular detector's DDLs are all enabled for readout. |
52f67e50 | 194 | * \param detector A bitmap of detectors to check. Should be any values from |
195 | * EDetectorId that can be or'ed together for multiple detector selection. | |
196 | * \return true if all DDLs for the specified detectors are enabled for readout. | |
197 | */ | |
89413559 | 198 | bool DetectorEnabled(Int_t detector) const; |
199 | ||
200 | /** | |
201 | * Checks if a particular detector's DDLs are all disabled for readout. | |
202 | * \param detector A bitmap of detectors to check. Should be any values from | |
203 | * EDetectorId that can be or'ed together for multiple detector selection. | |
204 | * \return true if all DDLs for the specified detectors are disabled for readout. | |
205 | * \note If both DetectorEnabled(x) and DetectorDisabled(x) return false then | |
206 | * it means that only part of the detectors DDLs are enabled. | |
207 | */ | |
208 | bool DetectorDisabled(Int_t detector) const; | |
209 | ||
210 | /** | |
211 | * Returns the first word of DDL bits for a given detector in the internal structure. | |
212 | * \param detector The detector code for which to return the starting word. | |
213 | * \returns the first word of DDL bits for the detector or -1 if an invalid code is given. | |
214 | */ | |
215 | static Int_t GetFirstWord(EDetectorId detector); | |
216 | ||
217 | /** | |
218 | * Returns the first word of DDL bits for a given detector in the internal structure. | |
219 | * \param detector The detector code for which to return the starting word. | |
220 | * \returns the first word of DDL bits for the detector or -1 if an invalid code is given. | |
221 | */ | |
222 | static Int_t GetWordCount(EDetectorId detector); | |
223 | ||
7c69da51 | 224 | /** |
225 | * Returns the corresponding detector ID code for the given word index into the | |
226 | * internal data structure. | |
227 | * \param wordindex The position of the word from the start of the DDL readout bit list. | |
228 | * \returns the code of the corresponding detector or kNoDetector if invalid. | |
229 | */ | |
230 | static EDetectorId GetDetectorFromWord(Int_t wordindex); | |
231 | ||
89413559 | 232 | /** |
233 | * Returns the first detector with non-zero DDL bits. | |
234 | * \param startAfter The detector code after which to start looking from. | |
235 | * If kTOF is used for example then only detectors after kTOF will be checked, | |
236 | * not including kTOF, in the order of precedence indicated by EDetectorId. | |
237 | * \returns the code of the first used detector. | |
238 | */ | |
239 | EDetectorId GetFirstUsedDetector(EDetectorId startAfter = kNoDetector) const; | |
52f67e50 | 240 | |
dce3e5ce | 241 | /** |
242 | * Inherited from TObject. Prints the DDLs that will be readout according to | |
243 | * this readout list. | |
244 | * \param option This is not used by this method. | |
245 | */ | |
246 | virtual void Print(Option_t* option = "") const; | |
247 | ||
248 | /** | |
249 | * This typecast operator converts the readout list to the AliHLTEventDDL | |
250 | * structure format. | |
251 | * \return Copy of the AliHLTEventDDL raw structure. | |
252 | */ | |
253 | operator AliHLTEventDDL () const { return fReadoutList; } | |
254 | ||
255 | /** | |
256 | * This typecast operator converts the readout list to the AliHLTEventDDL | |
257 | * structure format. | |
258 | * \return Reference to the AliHLTEventDDL raw structure. | |
259 | */ | |
260 | operator AliHLTEventDDL& () { return fReadoutList; } | |
15ede44e | 261 | |
262 | /** | |
263 | * Access method to the binary buffer. | |
264 | * \return pointer to the binary buffer. | |
265 | */ | |
266 | AliHLTEventDDL* Buffer() { return &fReadoutList; } | |
267 | ||
78f642dc | 268 | /** |
269 | * Access method to the binary buffer. | |
270 | * \return const pointer to the binary buffer. | |
271 | */ | |
272 | const AliHLTEventDDL* Buffer() const { return &fReadoutList; } | |
273 | ||
15ede44e | 274 | /** |
275 | * Access to the size of the binary buffer. | |
276 | * \return size of the binary buffer | |
277 | */ | |
78f642dc | 278 | unsigned BufferSize() const { return sizeof(fReadoutList); } |
dce3e5ce | 279 | |
280 | /** | |
281 | * Assignment operator performs a deep copy. | |
282 | * \param list The readout list to copy from. | |
283 | * \return A reference to this object. | |
284 | */ | |
285 | AliHLTReadoutList& operator = (const AliHLTReadoutList& list); | |
286 | ||
287 | /** | |
288 | * This operator performs a bitwise inclusive or operation on all DDL bits | |
289 | * between this readout and <i>list</i>. | |
290 | * \param list The right hand side readout list to operate on. | |
291 | * \return A reference to this object. | |
292 | */ | |
293 | AliHLTReadoutList& operator |= (const AliHLTReadoutList& list); | |
e5339167 | 294 | |
295 | /// same as operator |= | |
296 | AliHLTReadoutList& OrEq(const AliHLTReadoutList& list); | |
dce3e5ce | 297 | |
298 | /** | |
299 | * This operator performs a bitwise exclusive or (xor) operation on all DDL | |
300 | * bits between this readout and <i>list</i>. | |
301 | * \param list The right hand side readout list to operate on. | |
302 | * \return A reference to this object. | |
303 | */ | |
304 | AliHLTReadoutList& operator ^= (const AliHLTReadoutList& list); | |
e5339167 | 305 | |
306 | /// same as operator ^= | |
307 | AliHLTReadoutList& XorEq(const AliHLTReadoutList& list); | |
dce3e5ce | 308 | |
309 | /** | |
310 | * This operator performs a bitwise and operation on all DDL bits between | |
311 | * this readout and <i>list</i>. | |
312 | * \param list The right hand side readout list to operate on. | |
313 | * \return A reference to this object. | |
314 | */ | |
315 | AliHLTReadoutList& operator &= (const AliHLTReadoutList& list); | |
e5339167 | 316 | |
317 | /// same as operator &= | |
318 | AliHLTReadoutList& AndEq(const AliHLTReadoutList& list); | |
dce3e5ce | 319 | |
dce3e5ce | 320 | /** |
321 | * This operator performs the effective operation of "this and (this xor list)". | |
322 | * It removes all the DDLs specified in list from this readout list. | |
323 | * \param list The right hand side readout list to operate on. | |
324 | * \return A reference to this object. | |
325 | */ | |
326 | AliHLTReadoutList& operator -= (const AliHLTReadoutList& list); | |
327 | ||
328 | /** | |
329 | * This operator performs a bitwise ones compliment on all DDL bits of this | |
330 | * readout list. | |
331 | * \return The result of the unary operator. | |
332 | */ | |
333 | AliHLTReadoutList operator ~ () const; | |
334 | ||
335 | /** | |
336 | * This operator performs a bitwise inclusive or operation on all DDL bits | |
337 | * between this readout and <i>list</i>. | |
338 | * \param list The right hand side readout list to operate on. | |
339 | * \return The result of the binary operator. | |
340 | */ | |
341 | AliHLTReadoutList operator | (const AliHLTReadoutList& list) const | |
342 | { | |
343 | AliHLTReadoutList result = *this; | |
344 | return result.operator |= (list); | |
345 | } | |
346 | ||
347 | /** | |
348 | * This operator performs a bitwise exclusive or (xor) operation on all DDL | |
349 | * bits between this readout and <i>list</i>. | |
350 | * \param list The right hand side readout list to operate on. | |
351 | * \return The result of the binary operator. | |
352 | */ | |
353 | AliHLTReadoutList operator ^ (const AliHLTReadoutList& list) const | |
354 | { | |
355 | AliHLTReadoutList result = *this; | |
356 | return result.operator ^= (list); | |
357 | } | |
358 | ||
359 | /** | |
360 | * This operator performs a bitwise and operation on all DDL bits between | |
361 | * this readout and <i>list</i>. | |
362 | * \param list The right hand side readout list to operate on. | |
363 | * \return The result of the binary operator. | |
364 | */ | |
365 | AliHLTReadoutList operator & (const AliHLTReadoutList& list) const | |
366 | { | |
367 | AliHLTReadoutList result = *this; | |
368 | return result.operator &= (list); | |
369 | } | |
370 | ||
dce3e5ce | 371 | /** |
372 | * This operator performs the effective operation of "this and (this xor list)". | |
0910cc2f | 373 | * i.e. the set difference. |
dce3e5ce | 374 | * It removes all the DDLs specified in list from this readout list. |
375 | * \param list The right hand side readout list to operate on. | |
376 | * \return The result of the binary operator. | |
377 | */ | |
378 | AliHLTReadoutList operator - (const AliHLTReadoutList& list) const | |
379 | { | |
380 | AliHLTReadoutList result = *this; | |
381 | return result.operator -= (list); | |
382 | } | |
383 | ||
384 | private: | |
385 | ||
386 | /** | |
387 | * Decodes the word index and bit index within that word for the readout list structure. | |
388 | * \param ddlId <i>[in]</i> The ID number of the DDL to decode. | |
389 | * \param wordIndex <i>[out]</i> the word index of the word to modify or check | |
390 | * within fReadoutList.fList | |
391 | * \param bitIndex <i>[out]</i> the bit index of the bit to modify or check | |
392 | * within the word pointed to by <i>wordIndex</i>. | |
393 | * \return true if the ddlId was decoded and false if it was invalid. | |
394 | * \note We do not check extensively if the ddlId is invalid. Just simple checks | |
395 | * are performed to see that we do not overflow the buffer fReadoutList.fList. | |
396 | */ | |
397 | static bool DecodeDDLID(Int_t ddlId, Int_t& wordIndex, Int_t& bitIndex); | |
398 | ||
399 | AliHLTEventDDL fReadoutList; /// The DDL readout list structure. | |
400 | ||
a9a3028c | 401 | ClassDef(AliHLTReadoutList, 3) // Readout list object used for manipulating and storing an AliHLTEventDDL structure. |
dce3e5ce | 402 | |
403 | }; | |
404 | ||
405 | #endif // ALIHLTREADOUTLIST_H | |
406 |