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 */
9 /// @file AliHLTReadoutList.h
10 /// @author Artur Szostak <artursz@iafrica.com>
12 /// @brief Declaration of the AliHLTReadoutList class used to handle AliHLTEventDDL structures.
15 #include "AliHLTDataTypes.h"
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).
35 class AliHLTReadoutList : public TNamed
40 * Identifiers for different detectors used by methods in AliHLTReadoutList.
44 kNoDetector = 0, /// No detector value
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 kAD = 0x1 << 21, /// ID for AD detector
66 kHLT = 0x1 << 30, /// ID for HLT detector
67 // kALLDET sets readout for all detectors except DAQ_TEST
68 kALLDET = (kITSSPD | kITSSDD | kITSSSD | kTPC | kTRD | kTOF | kHMPID | kPHOS
69 | kCPV | kPMD | kMUONTRK | kMUONTRG | kFMD | kT0 | kV0 | kZDC
70 | kACORDE | kTRG | kEMCAL | kAD | kHLT)
73 /// Converts a detector ID to a user readable string.
74 static const char* DetectorIdToString(EDetectorId id);
77 * Default constructor.
82 * Constructor to select which detectors to enable for readout.
83 * \param enabledDetectors Detector bit field. Can be any values for
84 * EDetectorId or'ed together.
86 AliHLTReadoutList(Int_t enabledDetectors);
89 * Constructor to select which detectors and DDLs to enable for readout.
90 * \param enabledList The string format is a space separated list where
91 * each item is either a detector acronym name or DDL number.
92 * Invalid sub-strings are simply ignored. The special ALL string is
93 * equivalent to kALLDET for AliHLTReadoutList(Int_t enabledDetectors).
95 AliHLTReadoutList(const char* enabledList);
98 * Constructor to create readout list from AliHLTEventDDL structure.
99 * \param list The AliHLTEventDDL structure from which to create this object.
101 AliHLTReadoutList(const AliHLTEventDDL& list);
104 * The copy constructor performs a deep copy.
105 * \param list The readout list to copy from.
107 AliHLTReadoutList(const AliHLTReadoutList& list);
110 * Default destructor.
112 virtual ~AliHLTReadoutList();
115 * Checks if the readout list is empty, i.e. all DDLs are disabled.
116 * \returns true if the readout list is empty and false otherwise.
121 * Disables all bits in the readout list.
122 * \param option This parameter is ignored.
123 * The method is inherited from TObject.
125 virtual void Clear(Option_t* option = "");
128 * Enables a specific DDL bit in the readout list.
129 * \param ddlId The ID number of the DDL to enable.
131 void EnableDDLBit(Int_t ddlId)
133 SetDDLBit(ddlId, kTRUE);
137 * Disables a specific DDL bit in the readout list.
138 * \param ddlId The ID number of the DDL to disable.
140 void DisableDDLBit(Int_t ddlId)
142 SetDDLBit(ddlId, kFALSE);
146 * Fetches the bit value for a particular DDL in the readout list.
147 * \param ddlId The ID number of the DDL to fetch.
148 * \return the bit value for the specified DDL.
150 Bool_t GetDDLBit(Int_t ddlId) const;
153 * Sets the bit value for a particular DDL in the readout list.
154 * \param ddlId The ID number of the DDL to set.
155 * \param state The value to set the bit to.
157 void SetDDLBit(Int_t ddlId, Bool_t state);
160 * Checks if a particular DDL is enabled for readout.
161 * \param ddlId The ID number of the DDL to check.
162 * \return the if the DDL is enabled for readout.
164 bool IsDDLEnabled(Int_t ddlId) const
166 return GetDDLBit(ddlId) == kTRUE;
170 * Checks if a particular DDL is disabled for readout.
171 * \param ddlId The ID number of the DDL to check.
172 * \return the if the DDL is disabled for readout.
174 bool IsDDLDisabled(Int_t ddlId) const
176 return GetDDLBit(ddlId) == kFALSE;
180 * Enables all DDLs for a particular detector or detectors.
181 * \param detector A bitmap of detectors to enable. Should be any values from
182 * EDetectorId that can be or'ed together for multiple detector selection.
184 void Enable(Int_t detector);
187 * Disables all DDLs for a particular detector or detectors.
188 * \param detector A bitmap of detectors to disable. Should be any values from
189 * EDetectorId that can be or'ed together for multiple detector selection.
191 void Disable(Int_t detector);
194 * Checks if a particular detector's DDLs are all enabled for readout.
195 * \param detector A bitmap of detectors to check. Should be any values from
196 * EDetectorId that can be or'ed together for multiple detector selection.
197 * \return true if all DDLs for the specified detectors are enabled for readout.
199 bool DetectorEnabled(Int_t detector) const;
202 * Checks if a particular detector's DDLs are all disabled for readout.
203 * \param detector A bitmap of detectors to check. Should be any values from
204 * EDetectorId that can be or'ed together for multiple detector selection.
205 * \return true if all DDLs for the specified detectors are disabled for readout.
206 * \note If both DetectorEnabled(x) and DetectorDisabled(x) return false then
207 * it means that only part of the detectors DDLs are enabled.
209 bool DetectorDisabled(Int_t detector) const;
212 * Returns the first word of DDL bits for a given detector in the internal structure.
213 * \param detector The detector code for which to return the starting word.
214 * \returns the first word of DDL bits for the detector or -1 if an invalid code is given.
216 static Int_t GetFirstWord(EDetectorId detector);
219 * Returns the first word of DDL bits for a given detector in the internal structure.
220 * \param detector The detector code for which to return the starting word.
221 * \returns the first word of DDL bits for the detector or -1 if an invalid code is given.
223 static Int_t GetWordCount(EDetectorId detector);
226 * Returns the corresponding detector ID code for the given word index into the
227 * internal data structure.
228 * \param wordindex The position of the word from the start of the DDL readout bit list.
229 * \returns the code of the corresponding detector or kNoDetector if invalid.
231 static EDetectorId GetDetectorFromWord(Int_t wordindex);
234 * Returns the first detector with non-zero DDL bits.
235 * \param startAfter The detector code after which to start looking from.
236 * If kTOF is used for example then only detectors after kTOF will be checked,
237 * not including kTOF, in the order of precedence indicated by EDetectorId.
238 * \returns the code of the first used detector.
240 EDetectorId GetFirstUsedDetector(EDetectorId startAfter = kNoDetector) const;
243 * Inherited from TObject. Prints the DDLs that will be readout according to
245 * \param option This is not used by this method.
247 virtual void Print(Option_t* option = "") const;
250 * This typecast operator converts the readout list to the AliHLTEventDDL
252 * \return Constant reference to the AliHLTEventDDL raw structure.
254 operator const AliHLTEventDDL& () const { return fReadoutList; }
257 * This typecast operator converts the readout list to the AliHLTEventDDL
259 * \return Reference to the AliHLTEventDDL raw structure.
261 operator AliHLTEventDDL& () { return fReadoutList; }
264 * Access method to the binary buffer.
265 * \return pointer to the binary buffer.
267 AliHLTEventDDL* Buffer() { return &fReadoutList; }
270 * Access method to the binary buffer.
271 * \return const pointer to the binary buffer.
273 const AliHLTEventDDL* Buffer() const { return &fReadoutList; }
276 * Access to the size of the binary buffer.
277 * \return size of the binary buffer
279 unsigned BufferSize() const { return sizeof(fReadoutList); }
282 * Assignment operator performs a deep copy.
283 * \param list The readout list to copy from.
284 * \return A reference to this object.
286 AliHLTReadoutList& operator = (const AliHLTReadoutList& list);
289 * This operator performs a bitwise inclusive or operation on all DDL bits
290 * between this readout and <i>list</i>.
291 * \param list The right hand side readout list to operate on.
292 * \return A reference to this object.
294 AliHLTReadoutList& operator |= (const AliHLTReadoutList& list);
296 /// same as operator |=
297 AliHLTReadoutList& OrEq(const AliHLTReadoutList& list);
300 * This operator performs a bitwise exclusive or (xor) operation on all DDL
301 * bits between this readout and <i>list</i>.
302 * \param list The right hand side readout list to operate on.
303 * \return A reference to this object.
305 AliHLTReadoutList& operator ^= (const AliHLTReadoutList& list);
307 /// same as operator ^=
308 AliHLTReadoutList& XorEq(const AliHLTReadoutList& list);
311 * This operator performs a bitwise and operation on all DDL bits between
312 * this readout and <i>list</i>.
313 * \param list The right hand side readout list to operate on.
314 * \return A reference to this object.
316 AliHLTReadoutList& operator &= (const AliHLTReadoutList& list);
318 /// same as operator &=
319 AliHLTReadoutList& AndEq(const AliHLTReadoutList& list);
322 * This operator performs the effective operation of "this and (this xor list)".
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 A reference to this object.
327 AliHLTReadoutList& operator -= (const AliHLTReadoutList& list);
330 * This operator performs a bitwise ones compliment on all DDL bits of this
332 * \return The result of the unary operator.
334 AliHLTReadoutList operator ~ () const;
337 * This operator performs a bitwise inclusive or operation on all DDL bits
338 * between this readout and <i>list</i>.
339 * \param list The right hand side readout list to operate on.
340 * \return The result of the binary operator.
342 AliHLTReadoutList operator | (const AliHLTReadoutList& list) const
344 AliHLTReadoutList result = *this;
345 return result.operator |= (list);
349 * This operator performs a bitwise exclusive or (xor) operation on all DDL
350 * bits between this readout and <i>list</i>.
351 * \param list The right hand side readout list to operate on.
352 * \return The result of the binary operator.
354 AliHLTReadoutList operator ^ (const AliHLTReadoutList& list) const
356 AliHLTReadoutList result = *this;
357 return result.operator ^= (list);
361 * This operator performs a bitwise and operation on all DDL bits between
362 * this readout and <i>list</i>.
363 * \param list The right hand side readout list to operate on.
364 * \return The result of the binary operator.
366 AliHLTReadoutList operator & (const AliHLTReadoutList& list) const
368 AliHLTReadoutList result = *this;
369 return result.operator &= (list);
373 * This operator performs the effective operation of "this and (this xor list)".
374 * i.e. the set difference.
375 * It removes all the DDLs specified in list from this readout list.
376 * \param list The right hand side readout list to operate on.
377 * \return The result of the binary operator.
379 AliHLTReadoutList operator - (const AliHLTReadoutList& list) const
381 AliHLTReadoutList result = *this;
382 return result.operator -= (list);
386 * Decodes the word index and bit index within that word for the readout list structure.
387 * \param [in] ddlId The ID number of the DDL to decode.
388 * \param [out] wordIndex the word index of the word to modify or check within fReadoutList.fList
389 * \param [out] bitIndex the bit index of the bit to modify or check
390 * within the word pointed to by <i>wordIndex</i>.
391 * \return true if the ddlId was decoded and false if it was invalid.
392 * \note We do not check extensively if the ddlId is invalid. Just simple checks
393 * are performed to see that we do not overflow the buffer fReadoutList.fList.
395 static bool DecodeDDLID(Int_t ddlId, Int_t& wordIndex, Int_t& bitIndex);
401 * This method fills the internal bit field structure taking care of converting
402 * from the old format to the new one.
403 * \param list The raw DDL readout list bits.
405 void FillStruct(const AliHLTEventDDL& list);
407 AliHLTEventDDL fReadoutList; /// The DDL readout list structure.
409 ClassDef(AliHLTReadoutList, 4) // Readout list object used for manipulating and storing an AliHLTEventDDL structure.
413 #endif // ALIHLTREADOUTLIST_H