1 /**************************************************************************
2 * This file is property of and copyright by the ALICE HLT Project *
3 * ALICE Experiment at CERN, All rights reserved. *
5 * Primary Authors: Artur Szostak <artursz@iafrica.com> *
6 * for The ALICE HLT Project. *
8 * Permission to use, copy, modify and distribute this software and its *
9 * documentation strictly for non-commercial purposes is hereby granted *
10 * without fee, provided that the above copyright notice appears in all *
11 * copies and that both the copyright notice and this permission notice *
12 * appear in the supporting documentation. The authors make no claims *
13 * about the suitability of this software for any purpose. It is *
14 * provided "as is" without express or implied warranty. *
15 **************************************************************************/
17 /// @file AliHLTReadoutList.cxx
18 /// @author Artur Szostak <artursz@iafrica.com>
20 /// @brief Implementation of the AliHLTReadoutList class.
22 /// The AliHLTReadoutList class is used as an interface to the AliHLTEventDDL
23 /// structure. It makes it easy to manipulate the bits in this structure, which
24 /// define what DDLs should be readout by DAQ.
25 /// Several operators are also overloaded which are meant to be used in the trigger
26 /// menu specification for the AliHLTGlobalTrigger. It allows one to construct
27 /// expressions for the readout lists, which is necessary to be able to evaluate
28 /// or compose the final readout list, given multiple input readout lists received
29 /// from individual components that derive from AliHLTTrigger.
31 #include "AliHLTReadoutList.h"
33 #include "Riostream.h"
35 #include "TObjString.h"
36 #include "TObjArray.h"
39 ClassImp(AliHLTReadoutList)
42 AliHLTReadoutList::AliHLTReadoutList() :
46 // Default constructor.
48 fReadoutList.fCount = gkAliHLTDDLListSize; // Required by ALICE-INT-2007-015
49 memset(fReadoutList.fList, 0x0, sizeof(fReadoutList.fList));
53 AliHLTReadoutList::AliHLTReadoutList(Int_t enabledDetectors) :
57 // Constructor to select which detectors to enable for readout.
58 // See header file for more details.
60 fReadoutList.fCount = gkAliHLTDDLListSize; // Required by ALICE-INT-2007-015
61 memset(fReadoutList.fList, 0x0, sizeof(fReadoutList.fList));
62 Enable(enabledDetectors);
66 AliHLTReadoutList::AliHLTReadoutList(const char* enabledList) :
70 // Constructor to select which detectors and DDLs to enable for readout.
71 // See header file for more details.
73 fReadoutList.fCount = gkAliHLTDDLListSize; // Required by ALICE-INT-2007-015
74 memset(fReadoutList.fList, 0x0, sizeof(fReadoutList.fList));
76 TString str(enabledList);
78 Int_t enabledDetectors = 0;
79 if (str.Contains("ITSSPD")) enabledDetectors |= kITSSPD;
80 if (str.Contains("ITSSDD")) enabledDetectors |= kITSSDD;
81 if (str.Contains("ITSSSD")) enabledDetectors |= kITSSSD;
82 if (str.Contains("TPC")) enabledDetectors |= kTPC;
83 if (str.Contains("TRD")) enabledDetectors |= kTRD;
84 if (str.Contains("TOF")) enabledDetectors |= kTOF;
85 if (str.Contains("HMPID")) enabledDetectors |= kHMPID;
86 if (str.Contains("PHOS")) enabledDetectors |= kPHOS;
87 if (str.Contains("CPV")) enabledDetectors |= kCPV;
88 if (str.Contains("PMD")) enabledDetectors |= kPMD;
89 if (str.Contains("MUONTRK")) enabledDetectors |= kMUONTRK;
90 if (str.Contains("MUONTRG")) enabledDetectors |= kMUONTRG;
91 if (str.Contains("FMD")) enabledDetectors |= kFMD;
92 if (str.Contains("T0")) enabledDetectors |= kT0;
93 if (str.Contains("V0")) enabledDetectors |= kV0;
94 if (str.Contains("ZDC")) enabledDetectors |= kZDC;
95 if (str.Contains("ACORDE")) enabledDetectors |= kACORDE;
96 if (str.Contains("TRG")) enabledDetectors |= kTRG;
97 if (str.Contains("EMCAL")) enabledDetectors |= kEMCAL;
98 if (str.Contains("DAQTEST")) enabledDetectors |= kDAQTEST;
99 if (str.Contains("HLT")) enabledDetectors |= kHLT;
100 if (str.Contains("ALL")) enabledDetectors |= kALLDET;
101 Enable(enabledDetectors);
103 TObjArray* list = str.Tokenize(" ");
105 const TObjString* objstr = NULL;
106 while ((objstr = dynamic_cast<const TObjString*>(next())) != NULL)
108 str = objstr->GetString();
109 if (str.IsDigit()) EnableDDLBit(str.Atoi());
115 AliHLTReadoutList::AliHLTReadoutList(const AliHLTEventDDL& list) :
119 // Constructor to create readout list from AliHLTEventDDL structure.
120 // See header file for more details.
122 memcpy(&fReadoutList, &list, sizeof(fReadoutList));
126 AliHLTReadoutList::AliHLTReadoutList(const AliHLTReadoutList& list) :
130 // Copy constructor performs a deep copy.
132 memcpy(&fReadoutList, &list.fReadoutList, sizeof(fReadoutList));
136 AliHLTReadoutList::~AliHLTReadoutList()
138 // Default destructor.
142 bool AliHLTReadoutList::Empty() const
144 // Returns true if the readout list has no DDLs enabled.
146 for (int i = 0; i < sizeof(fReadoutList.fList) / sizeof(fReadoutList.fList[0]); i++)
148 if (fReadoutList.fList[i] != 0x0) return false;
154 void AliHLTReadoutList::Clear(Option_t* /*option*/)
156 // Resets all the DDL readout bits.
157 memset(fReadoutList.fList, 0x0, sizeof(fReadoutList.fList));
161 bool AliHLTReadoutList::DecodeDDLID(Int_t ddlId, Int_t& wordIndex, Int_t& bitIndex)
163 // Decodes the word index and bit index within that word for the readout list structure.
164 // See header file for more details.
166 // The detector number is bits 15..8 of ddlId and DDL number is bits 7..0.
167 Int_t detNum = ddlId >> 8;
168 Int_t ddlNum = ddlId & 0xFF;
174 else if (detNum == 3)
176 wordIndex = detNum + (ddlNum >> 5);
178 else if (detNum == 4)
180 wordIndex = detNum + 7;
182 else if (detNum == 5)
184 wordIndex = detNum + 7 + (ddlNum >> 5);
186 else if (detNum == 30)
192 wordIndex = detNum + 9;
195 if (wordIndex < 0 or gkAliHLTDDLListSize <= wordIndex) return false;
197 // The bit index within the word indicated by wordIndex.
198 bitIndex = (ddlId & 0xFF) % 32;
203 Bool_t AliHLTReadoutList::GetDDLBit(Int_t ddlId) const
205 // Fetches the bit value for a particular DDL in the readout list.
206 // See header file for more details.
208 Int_t wordIndex, bitIndex;
209 if (! DecodeDDLID(ddlId, wordIndex, bitIndex)) return kFALSE;
210 return ((fReadoutList.fList[wordIndex] >> bitIndex) & 0x1) == 0x1;
214 void AliHLTReadoutList::SetDDLBit(Int_t ddlId, Bool_t state)
216 // Sets the bit value for a particular DDL in the readout list.
217 // See header file for more details.
219 Int_t wordIndex, bitIndex;
220 if (! DecodeDDLID(ddlId, wordIndex, bitIndex)) return;
222 // To set, 'OR' word with bit mask
224 fReadoutList.fList[wordIndex] |= (0x00000001 << bitIndex);
225 // To unset, 'AND' word with bit mask
227 fReadoutList.fList[wordIndex] &= (0xFFFFFFFF ^ (0x00000001 << bitIndex));
231 void AliHLTReadoutList::Enable(Int_t detector)
233 // Enables all DDLs for a particular detector or detectors.
234 // See header file for more details.
236 if ((detector & kITSSPD) != 0) fReadoutList.fList[0] = 0x000FFFFF;
237 if ((detector & kITSSDD) != 0) fReadoutList.fList[1] = 0x00FFFFFF;
238 if ((detector & kITSSSD) != 0) fReadoutList.fList[2] = 0x0000FFFF;
239 if ((detector & kTPC) != 0)
241 fReadoutList.fList[3] = 0xFFFFFFFF;
242 fReadoutList.fList[4] = 0xFFFFFFFF;
243 fReadoutList.fList[5] = 0xFFFFFFFF;
244 fReadoutList.fList[6] = 0xFFFFFFFF;
245 fReadoutList.fList[7] = 0xFFFFFFFF;
246 fReadoutList.fList[8] = 0xFFFFFFFF;
247 fReadoutList.fList[9] = 0x00FFFFFF;
248 fReadoutList.fList[10] = 0x00000000;
250 if ((detector & kTRD) != 0) fReadoutList.fList[11] = 0x0003FFFF;
251 if ((detector & kTOF) != 0)
253 fReadoutList.fList[12] = 0xFFFFFFFF;
254 fReadoutList.fList[13] = 0xFFFFFFFF;
255 fReadoutList.fList[14] = 0x000000FF;
257 if ((detector & kHMPID) != 0) fReadoutList.fList[15] = 0x00003FFF;
258 if ((detector & kPHOS) != 0) fReadoutList.fList[16] = 0x000FFFFF;
259 if ((detector & kCPV) != 0) fReadoutList.fList[17] = 0x000003FF;
260 if ((detector & kPMD) != 0) fReadoutList.fList[18] = 0x0000003F;
261 if ((detector & kMUONTRK) != 0) fReadoutList.fList[19] = 0x000FFFFF;
262 if ((detector & kMUONTRG) != 0) fReadoutList.fList[20] = 0x00000003;
263 if ((detector & kFMD) != 0) fReadoutList.fList[21] = 0x00000007;
264 if ((detector & kT0) != 0) fReadoutList.fList[22] = 0x00000001;
265 if ((detector & kV0) != 0) fReadoutList.fList[23] = 0x00000001;
266 if ((detector & kZDC) != 0) fReadoutList.fList[24] = 0x00000001;
267 if ((detector & kACORDE) != 0) fReadoutList.fList[25] = 0x00000001;
268 if ((detector & kTRG) != 0) fReadoutList.fList[26] = 0x00000001;
269 if ((detector & kEMCAL) != 0) fReadoutList.fList[27] = 0x00FFFFFF;
270 if ((detector & kDAQTEST) != 0) fReadoutList.fList[28] = 0x00000001;
271 if ((detector & kHLT) != 0) fReadoutList.fList[29] = 0x000003FF;
275 void AliHLTReadoutList::Disable(Int_t detector)
277 // Disables all DDLs for a particular detector or detectors.
278 // See header file for more details.
280 if ((detector & kITSSPD) != 0) fReadoutList.fList[0] = 0x00000000;
281 if ((detector & kITSSDD) != 0) fReadoutList.fList[1] = 0x00000000;
282 if ((detector & kITSSSD) != 0) fReadoutList.fList[2] = 0x00000000;
283 if ((detector & kTPC) != 0)
285 fReadoutList.fList[3] = 0x00000000;
286 fReadoutList.fList[4] = 0x00000000;
287 fReadoutList.fList[5] = 0x00000000;
288 fReadoutList.fList[6] = 0x00000000;
289 fReadoutList.fList[7] = 0x00000000;
290 fReadoutList.fList[8] = 0x00000000;
291 fReadoutList.fList[9] = 0x00000000;
292 fReadoutList.fList[10] = 0x00000000;
294 if ((detector & kTRD) != 0) fReadoutList.fList[11] = 0x00000000;
295 if ((detector & kTOF) != 0)
297 fReadoutList.fList[12] = 0x00000000;
298 fReadoutList.fList[13] = 0x00000000;
299 fReadoutList.fList[14] = 0x00000000;
301 if ((detector & kHMPID) != 0) fReadoutList.fList[15] = 0x00000000;
302 if ((detector & kPHOS) != 0) fReadoutList.fList[16] = 0x00000000;
303 if ((detector & kCPV) != 0) fReadoutList.fList[17] = 0x00000000;
304 if ((detector & kPMD) != 0) fReadoutList.fList[18] = 0x00000000;
305 if ((detector & kMUONTRK) != 0) fReadoutList.fList[19] = 0x00000000;
306 if ((detector & kMUONTRG) != 0) fReadoutList.fList[20] = 0x00000000;
307 if ((detector & kFMD) != 0) fReadoutList.fList[21] = 0x00000000;
308 if ((detector & kT0) != 0) fReadoutList.fList[22] = 0x00000000;
309 if ((detector & kV0) != 0) fReadoutList.fList[23] = 0x00000000;
310 if ((detector & kZDC) != 0) fReadoutList.fList[24] = 0x00000000;
311 if ((detector & kACORDE) != 0) fReadoutList.fList[25] = 0x00000000;
312 if ((detector & kTRG) != 0) fReadoutList.fList[26] = 0x00000000;
313 if ((detector & kEMCAL) != 0) fReadoutList.fList[27] = 0x00000000;
314 if ((detector & kDAQTEST) != 0) fReadoutList.fList[28] = 0x00000000;
315 if ((detector & kHLT) != 0) fReadoutList.fList[29] = 0x00000000;
319 bool AliHLTReadoutList::DetectorEnabled(Int_t detector) const
321 // Checks if a particular detector's DDLs are enabled.
322 // See header file for more details.
325 if ((detector & kITSSPD) != 0) result &= fReadoutList.fList[0] == 0x000FFFFF;
326 if ((detector & kITSSDD) != 0) result &= fReadoutList.fList[1] == 0x00FFFFFF;
327 if ((detector & kITSSSD) != 0) result &= fReadoutList.fList[2] == 0x0000FFFF;
328 if ((detector & kTPC) != 0)
330 result &= fReadoutList.fList[3] == 0xFFFFFFFF;
331 result &= fReadoutList.fList[4] == 0xFFFFFFFF;
332 result &= fReadoutList.fList[5] == 0xFFFFFFFF;
333 result &= fReadoutList.fList[6] == 0xFFFFFFFF;
334 result &= fReadoutList.fList[7] == 0xFFFFFFFF;
335 result &= fReadoutList.fList[8] == 0xFFFFFFFF;
336 result &= fReadoutList.fList[9] == 0x00FFFFFF;
338 if ((detector & kTRD) != 0) result &= fReadoutList.fList[11] == 0x0003FFFF;
339 if ((detector & kTOF) != 0)
341 result &= fReadoutList.fList[12] == 0xFFFFFFFF;
342 result &= fReadoutList.fList[13] == 0xFFFFFFFF;
343 result &= fReadoutList.fList[14] == 0x000000FF;
345 if ((detector & kHMPID) != 0) result &= fReadoutList.fList[15] == 0x00003FFF;
346 if ((detector & kPHOS) != 0) result &= fReadoutList.fList[16] == 0x000FFFFF;
347 if ((detector & kCPV) != 0) result &= fReadoutList.fList[17] == 0x000003FF;
348 if ((detector & kPMD) != 0) result &= fReadoutList.fList[18] == 0x0000003F;
349 if ((detector & kMUONTRK) != 0) result &= fReadoutList.fList[19] == 0x000FFFFF;
350 if ((detector & kMUONTRG) != 0) result &= fReadoutList.fList[20] == 0x00000003;
351 if ((detector & kFMD) != 0) result &= fReadoutList.fList[21] == 0x00000007;
352 if ((detector & kT0) != 0) result &= fReadoutList.fList[22] == 0x00000001;
353 if ((detector & kV0) != 0) result &= fReadoutList.fList[23] == 0x00000001;
354 if ((detector & kZDC) != 0) result &= fReadoutList.fList[24] == 0x00000001;
355 if ((detector & kACORDE) != 0) result &= fReadoutList.fList[25] == 0x00000001;
356 if ((detector & kTRG) != 0) result &= fReadoutList.fList[26] == 0x00000001;
357 if ((detector & kEMCAL) != 0) result &= fReadoutList.fList[27] == 0x00FFFFFF;
358 if ((detector & kDAQTEST) != 0) result &= fReadoutList.fList[28] == 0x00000001;
359 if ((detector & kHLT) != 0) result &= fReadoutList.fList[29] == 0x000003FF;
365 void AliHLTReadoutList::Print(Option_t* /*option*/) const
367 // Prints the DDLs that will be readout according to this readout list.
369 cout << "Readout enabled for DDLs:" << endl;
370 for (Int_t i = 0; i < AliDAQ::kNDetectors; i++)
372 Int_t maxddls = AliDAQ::NumberOfDdls(i);
373 cout << AliDAQ::DetectorName(i) << ":";
374 bool nonefound = true;
375 for (Int_t j = 0; j < maxddls; j++)
377 Int_t ddlId = ( ((i == AliDAQ::kNDetectors-1) ? 30 : i) << 8 ) + j;
378 if (GetDDLBit(ddlId))
380 cout << " " << ddlId;
384 if (nonefound) cout << " none";
390 AliHLTReadoutList& AliHLTReadoutList::operator = (const AliHLTReadoutList& list)
392 // Assignment operator performs a deep copy.
394 TObject::operator = (list);
397 memcpy(&fReadoutList, &list.fReadoutList, sizeof(fReadoutList));
403 AliHLTReadoutList& AliHLTReadoutList::operator |= (const AliHLTReadoutList& list)
405 // This operator performs a bitwise inclusive or operation on all DDL bits.
406 // See header file for more details.
408 assert( fReadoutList.fCount == gkAliHLTDDLListSize );
409 for (Int_t i = 0; i < gkAliHLTDDLListSize; i++)
411 fReadoutList.fList[i] |= list.fReadoutList.fList[i];
417 AliHLTReadoutList& AliHLTReadoutList::operator ^= (const AliHLTReadoutList& list)
419 // This operator performs a bitwise exclusive or (xor) operation on all DDL bits.
420 // See header file for more details.
422 assert( fReadoutList.fCount == gkAliHLTDDLListSize );
423 for (Int_t i = 0; i < gkAliHLTDDLListSize; i++)
425 fReadoutList.fList[i] ^= list.fReadoutList.fList[i];
431 AliHLTReadoutList& AliHLTReadoutList::operator &= (const AliHLTReadoutList& list)
433 // This operator performs a bitwise and operation on all DDL bits.
434 // See header file for more details.
436 assert( fReadoutList.fCount == gkAliHLTDDLListSize );
437 for (Int_t i = 0; i < gkAliHLTDDLListSize; i++)
439 fReadoutList.fList[i] &= list.fReadoutList.fList[i];
445 AliHLTReadoutList& AliHLTReadoutList::operator -= (const AliHLTReadoutList& list)
447 // This operator removes all the DDLs specified in list from this readout list.
448 // See header file for more details.
450 assert( fReadoutList.fCount == gkAliHLTDDLListSize );
451 for (Int_t i = 0; i < gkAliHLTDDLListSize; i++)
453 // Effectively apply: this = this & (~ (this & list))
454 // i.e. this = this & (this ^ list)
455 fReadoutList.fList[i] &= fReadoutList.fList[i] ^ list.fReadoutList.fList[i];
461 AliHLTReadoutList AliHLTReadoutList::operator ~ () const
463 // This operator performs a bitwise ones compliment on all DDL bits.
464 // See header file for more details.
466 AliHLTReadoutList readoutlist;
467 readoutlist.fReadoutList.fCount = fReadoutList.fCount;
468 readoutlist.fReadoutList.fList[0] = 0x000FFFFF & (~fReadoutList.fList[0]);
469 readoutlist.fReadoutList.fList[1] = 0x00FFFFFF & (~fReadoutList.fList[1]);
470 readoutlist.fReadoutList.fList[2] = 0x0000FFFF & (~fReadoutList.fList[2]);
471 readoutlist.fReadoutList.fList[3] = 0xFFFFFFFF & (~fReadoutList.fList[3]);
472 readoutlist.fReadoutList.fList[4] = 0xFFFFFFFF & (~fReadoutList.fList[4]);
473 readoutlist.fReadoutList.fList[5] = 0xFFFFFFFF & (~fReadoutList.fList[5]);
474 readoutlist.fReadoutList.fList[6] = 0xFFFFFFFF & (~fReadoutList.fList[6]);
475 readoutlist.fReadoutList.fList[7] = 0xFFFFFFFF & (~fReadoutList.fList[7]);
476 readoutlist.fReadoutList.fList[8] = 0xFFFFFFFF & (~fReadoutList.fList[8]);
477 readoutlist.fReadoutList.fList[9] = 0x00FFFFFF & (~fReadoutList.fList[9]);
478 readoutlist.fReadoutList.fList[10] = 0x00000000 & (~fReadoutList.fList[10]);
479 readoutlist.fReadoutList.fList[11] = 0x0003FFFF & (~fReadoutList.fList[11]);
480 readoutlist.fReadoutList.fList[12] = 0xFFFFFFFF & (~fReadoutList.fList[12]);
481 readoutlist.fReadoutList.fList[13] = 0xFFFFFFFF & (~fReadoutList.fList[13]);
482 readoutlist.fReadoutList.fList[14] = 0x000000FF & (~fReadoutList.fList[14]);
483 readoutlist.fReadoutList.fList[15] = 0x00003FFF & (~fReadoutList.fList[15]);
484 readoutlist.fReadoutList.fList[16] = 0x000FFFFF & (~fReadoutList.fList[16]);
485 readoutlist.fReadoutList.fList[17] = 0x000003FF & (~fReadoutList.fList[17]);
486 readoutlist.fReadoutList.fList[18] = 0x0000003F & (~fReadoutList.fList[18]);
487 readoutlist.fReadoutList.fList[19] = 0x000FFFFF & (~fReadoutList.fList[19]);
488 readoutlist.fReadoutList.fList[20] = 0x00000003 & (~fReadoutList.fList[20]);
489 readoutlist.fReadoutList.fList[21] = 0x00000007 & (~fReadoutList.fList[21]);
490 readoutlist.fReadoutList.fList[22] = 0x00000001 & (~fReadoutList.fList[22]);
491 readoutlist.fReadoutList.fList[23] = 0x00000001 & (~fReadoutList.fList[23]);
492 readoutlist.fReadoutList.fList[24] = 0x00000001 & (~fReadoutList.fList[24]);
493 readoutlist.fReadoutList.fList[25] = 0x00000001 & (~fReadoutList.fList[25]);
494 readoutlist.fReadoutList.fList[26] = 0x00000001 & (~fReadoutList.fList[26]);
495 readoutlist.fReadoutList.fList[27] = 0x00FFFFFF & (~fReadoutList.fList[27]);
496 readoutlist.fReadoutList.fList[28] = 0x00000001 & (~fReadoutList.fList[28]);
497 readoutlist.fReadoutList.fList[29] = 0x000003FF & (~fReadoutList.fList[29]);