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 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)
72 /// Converts a detector ID to a user readable string.
73 static const char* DetectorIdToString(EDetectorId id);
76 * Default constructor.
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.
85 AliHLTReadoutList(Int_t enabledDetectors);
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).
94 AliHLTReadoutList(const char* enabledList);
97 * Constructor to create readout list from AliHLTEventDDL structure.
98 * \param list The AliHLTEventDDL structure from which to create this object.
100 AliHLTReadoutList(const AliHLTEventDDL& list);
103 * The copy constructor performs a deep copy.
104 * \param list The readout list to copy from.
106 AliHLTReadoutList(const AliHLTReadoutList& list);
109 * Default destructor.
111 virtual ~AliHLTReadoutList();
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.
120 * Disables all bits in the readout list.
121 * \param option This parameter is ignored.
122 * The method is inherited from TObject.
124 virtual void Clear(Option_t* option = "");
127 * Enables a specific DDL bit in the readout list.
128 * \param ddlId The ID number of the DDL to enable.
130 void EnableDDLBit(Int_t ddlId)
132 SetDDLBit(ddlId, kTRUE);
136 * Disables a specific DDL bit in the readout list.
137 * \param ddlId The ID number of the DDL to disable.
139 void DisableDDLBit(Int_t ddlId)
141 SetDDLBit(ddlId, kFALSE);
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.
149 Bool_t GetDDLBit(Int_t ddlId) const;
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.
156 void SetDDLBit(Int_t ddlId, Bool_t state);
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.
163 bool IsDDLEnabled(Int_t ddlId) const
165 return GetDDLBit(ddlId) == kTRUE;
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.
173 bool IsDDLDisabled(Int_t ddlId) const
175 return GetDDLBit(ddlId) == kFALSE;
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.
183 void Enable(Int_t detector);
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.
190 void Disable(Int_t detector);
193 * Checks if a particular detector's DDLs are all enabled for readout.
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.
198 bool DetectorEnabled(Int_t detector) const;
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.
208 bool DetectorDisabled(Int_t detector) const;
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.
215 static Int_t GetFirstWord(EDetectorId detector);
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.
222 static Int_t GetWordCount(EDetectorId detector);
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.
230 static EDetectorId GetDetectorFromWord(Int_t wordindex);
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.
239 EDetectorId GetFirstUsedDetector(EDetectorId startAfter = kNoDetector) const;
242 * Inherited from TObject. Prints the DDLs that will be readout according to
244 * \param option This is not used by this method.
246 virtual void Print(Option_t* option = "") const;
249 * This typecast operator converts the readout list to the AliHLTEventDDL
251 * \return Constant reference to the AliHLTEventDDL raw structure.
253 operator const AliHLTEventDDL& () const { return fReadoutList; }
256 * This typecast operator converts the readout list to the AliHLTEventDDL
258 * \return Reference to the AliHLTEventDDL raw structure.
260 operator AliHLTEventDDL& () { return fReadoutList; }
263 * Access method to the binary buffer.
264 * \return pointer to the binary buffer.
266 AliHLTEventDDL* Buffer() { return &fReadoutList; }
269 * Access method to the binary buffer.
270 * \return const pointer to the binary buffer.
272 const AliHLTEventDDL* Buffer() const { return &fReadoutList; }
275 * Access to the size of the binary buffer.
276 * \return size of the binary buffer
278 unsigned BufferSize() const { return sizeof(fReadoutList); }
281 * Assignment operator performs a deep copy.
282 * \param list The readout list to copy from.
283 * \return A reference to this object.
285 AliHLTReadoutList& operator = (const AliHLTReadoutList& list);
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.
293 AliHLTReadoutList& operator |= (const AliHLTReadoutList& list);
295 /// same as operator |=
296 AliHLTReadoutList& OrEq(const AliHLTReadoutList& list);
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.
304 AliHLTReadoutList& operator ^= (const AliHLTReadoutList& list);
306 /// same as operator ^=
307 AliHLTReadoutList& XorEq(const AliHLTReadoutList& list);
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.
315 AliHLTReadoutList& operator &= (const AliHLTReadoutList& list);
317 /// same as operator &=
318 AliHLTReadoutList& AndEq(const AliHLTReadoutList& list);
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.
326 AliHLTReadoutList& operator -= (const AliHLTReadoutList& list);
329 * This operator performs a bitwise ones compliment on all DDL bits of this
331 * \return The result of the unary operator.
333 AliHLTReadoutList operator ~ () const;
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.
341 AliHLTReadoutList operator | (const AliHLTReadoutList& list) const
343 AliHLTReadoutList result = *this;
344 return result.operator |= (list);
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.
353 AliHLTReadoutList operator ^ (const AliHLTReadoutList& list) const
355 AliHLTReadoutList result = *this;
356 return result.operator ^= (list);
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.
365 AliHLTReadoutList operator & (const AliHLTReadoutList& list) const
367 AliHLTReadoutList result = *this;
368 return result.operator &= (list);
372 * This operator performs the effective operation of "this and (this xor list)".
373 * i.e. the set difference.
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.
378 AliHLTReadoutList operator - (const AliHLTReadoutList& list) const
380 AliHLTReadoutList result = *this;
381 return result.operator -= (list);
385 * Decodes the word index and bit index within that word for the readout list structure.
386 * \param [in] ddlId The ID number of the DDL to decode.
387 * \param [out] wordIndex the word index of the word to modify or check within fReadoutList.fList
388 * \param [out] bitIndex the bit index of the bit to modify or check
389 * within the word pointed to by <i>wordIndex</i>.
390 * \return true if the ddlId was decoded and false if it was invalid.
391 * \note We do not check extensively if the ddlId is invalid. Just simple checks
392 * are performed to see that we do not overflow the buffer fReadoutList.fList.
394 static bool DecodeDDLID(Int_t ddlId, Int_t& wordIndex, Int_t& bitIndex);
399 * This method fills the internal bit field structure taking care of converting
400 * from the old format to the new one.
401 * \param list The raw DDL readout list bits.
403 void FillStruct(const AliHLTEventDDL& list);
405 AliHLTEventDDL fReadoutList; /// The DDL readout list structure.
407 ClassDef(AliHLTReadoutList, 3) // Readout list object used for manipulating and storing an AliHLTEventDDL structure.
411 #endif // ALIHLTREADOUTLIST_H