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 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)
72 * Default constructor.
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.
81 AliHLTReadoutList(Int_t enabledDetectors);
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).
90 AliHLTReadoutList(const char* enabledList);
93 * Constructor to create readout list from AliHLTEventDDL structure.
94 * \param list The AliHLTEventDDL structure from which to create this object.
96 AliHLTReadoutList(const AliHLTEventDDL& list);
99 * The copy constructor performs a deep copy.
100 * \param list The readout list to copy from.
102 AliHLTReadoutList(const AliHLTReadoutList& list);
105 * Default destructor.
107 virtual ~AliHLTReadoutList();
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.
116 * Disables all bits in the readout list.
117 * \param option This parameter is ignored.
118 * The method is inherited from TObject.
120 virtual void Clear(Option_t* option = "");
123 * Enables a specific DDL bit in the readout list.
124 * \param ddlId The ID number of the DDL to enable.
126 void EnableDDLBit(Int_t ddlId)
128 SetDDLBit(ddlId, kTRUE);
132 * Disables a specific DDL bit in the readout list.
133 * \param ddlId The ID number of the DDL to disable.
135 void DisableDDLBit(Int_t ddlId)
137 SetDDLBit(ddlId, kFALSE);
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.
145 Bool_t GetDDLBit(Int_t ddlId) const;
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.
152 void SetDDLBit(Int_t ddlId, Bool_t state);
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.
159 bool IsDDLEnabled(Int_t ddlId) const
161 return GetDDLBit(ddlId) == kTRUE;
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.
169 bool IsDDLDisabled(Int_t ddlId) const
171 return GetDDLBit(ddlId) == kFALSE;
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.
179 void Enable(Int_t detector);
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.
186 void Disable(Int_t detector);
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.
194 bool DetectorEnabled(Int_t ddlId) const;
197 * Inherited from TObject. Prints the DDLs that will be readout according to
199 * \param option This is not used by this method.
201 virtual void Print(Option_t* option = "") const;
204 * This typecast operator converts the readout list to the AliHLTEventDDL
206 * \return Copy of the AliHLTEventDDL raw structure.
208 operator AliHLTEventDDL () const { return fReadoutList; }
211 * This typecast operator converts the readout list to the AliHLTEventDDL
213 * \return Reference to the AliHLTEventDDL raw structure.
215 operator AliHLTEventDDL& () { return fReadoutList; }
218 * Access method to the binary buffer.
219 * \return pointer to the binary buffer.
221 AliHLTEventDDL* Buffer() { return &fReadoutList; }
224 * Access method to the binary buffer.
225 * \return const pointer to the binary buffer.
227 const AliHLTEventDDL* Buffer() const { return &fReadoutList; }
230 * Access to the size of the binary buffer.
231 * \return size of the binary buffer
233 unsigned BufferSize() const { return sizeof(fReadoutList); }
236 * Assignment operator performs a deep copy.
237 * \param list The readout list to copy from.
238 * \return A reference to this object.
240 AliHLTReadoutList& operator = (const AliHLTReadoutList& list);
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.
248 AliHLTReadoutList& operator |= (const AliHLTReadoutList& list);
250 /// same as operator |=
251 AliHLTReadoutList& OrEq(const AliHLTReadoutList& list);
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.
259 AliHLTReadoutList& operator ^= (const AliHLTReadoutList& list);
261 /// same as operator ^=
262 AliHLTReadoutList& XorEq(const AliHLTReadoutList& list);
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.
270 AliHLTReadoutList& operator &= (const AliHLTReadoutList& list);
272 /// same as operator &=
273 AliHLTReadoutList& AndEq(const AliHLTReadoutList& list);
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.
281 AliHLTReadoutList& operator -= (const AliHLTReadoutList& list);
284 * This operator performs a bitwise ones compliment on all DDL bits of this
286 * \return The result of the unary operator.
288 AliHLTReadoutList operator ~ () const;
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.
296 AliHLTReadoutList operator | (const AliHLTReadoutList& list) const
298 AliHLTReadoutList result = *this;
299 return result.operator |= (list);
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.
308 AliHLTReadoutList operator ^ (const AliHLTReadoutList& list) const
310 AliHLTReadoutList result = *this;
311 return result.operator ^= (list);
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.
320 AliHLTReadoutList operator & (const AliHLTReadoutList& list) const
322 AliHLTReadoutList result = *this;
323 return result.operator &= (list);
327 * This operator performs the effective operation of "this and (this xor list)".
328 * i.e. the set difference.
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.
333 AliHLTReadoutList operator - (const AliHLTReadoutList& list) const
335 AliHLTReadoutList result = *this;
336 return result.operator -= (list);
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.
352 static bool DecodeDDLID(Int_t ddlId, Int_t& wordIndex, Int_t& bitIndex);
354 AliHLTEventDDL fReadoutList; /// The DDL readout list structure.
356 ClassDef(AliHLTReadoutList, 2) // Readout list object used for manipulating and storing an AliHLTEventDDL structure.
360 #endif // ALIHLTREADOUTLIST_H