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::DecodeDDLID(Int_t ddlId, Int_t& wordIndex, Int_t& bitIndex)
144 // Decodes the word index and bit index within that word for the readout list structure.
145 // See header file for more details.
147 // The detector number is bits 15..8 of ddlId and DDL number is bits 7..0.
148 Int_t detNum = ddlId >> 8;
149 Int_t ddlNum = ddlId & 0xFF;
155 else if (detNum == 3)
157 wordIndex = detNum + (ddlNum >> 5);
159 else if (detNum == 4)
161 wordIndex = detNum + 7;
163 else if (detNum == 5)
165 wordIndex = detNum + 7 + (ddlNum >> 5);
167 else if (detNum == 30)
173 wordIndex = detNum + 9;
176 if (wordIndex < 0 or gkAliHLTDDLListSize <= wordIndex) return false;
178 // The bit index within the word indicated by wordIndex.
179 bitIndex = (ddlId & 0xFF) % 32;
184 Bool_t AliHLTReadoutList::GetDDLBit(Int_t ddlId) const
186 // Fetches the bit value for a particular DDL in the readout list.
187 // See header file for more details.
189 Int_t wordIndex, bitIndex;
190 if (! DecodeDDLID(ddlId, wordIndex, bitIndex)) return kFALSE;
191 return ((fReadoutList.fList[wordIndex] >> bitIndex) & 0x1) == 0x1;
195 void AliHLTReadoutList::SetDDLBit(Int_t ddlId, Bool_t state)
197 // Sets the bit value for a particular DDL in the readout list.
198 // See header file for more details.
200 Int_t wordIndex, bitIndex;
201 if (! DecodeDDLID(ddlId, wordIndex, bitIndex)) return;
203 // To set, 'OR' word with bit mask
205 fReadoutList.fList[wordIndex] |= (0x00000001 << bitIndex);
206 // To unset, 'AND' word with bit mask
208 fReadoutList.fList[wordIndex] &= (0xFFFFFFFF ^ (0x00000001 << bitIndex));
212 void AliHLTReadoutList::Enable(Int_t detector)
214 // Enables all DDLs for a particular detector or detectors.
215 // See header file for more details.
217 if ((detector & kITSSPD) != 0) fReadoutList.fList[0] = 0x000FFFFF;
218 if ((detector & kITSSDD) != 0) fReadoutList.fList[1] = 0x00FFFFFF;
219 if ((detector & kITSSSD) != 0) fReadoutList.fList[2] = 0x0000FFFF;
220 if ((detector & kTPC) != 0)
222 fReadoutList.fList[3] = 0xFFFFFFFF;
223 fReadoutList.fList[4] = 0xFFFFFFFF;
224 fReadoutList.fList[5] = 0xFFFFFFFF;
225 fReadoutList.fList[6] = 0xFFFFFFFF;
226 fReadoutList.fList[7] = 0xFFFFFFFF;
227 fReadoutList.fList[8] = 0xFFFFFFFF;
228 fReadoutList.fList[9] = 0x00FFFFFF;
229 fReadoutList.fList[10] = 0x00000000;
231 if ((detector & kTRD) != 0) fReadoutList.fList[11] = 0x0003FFFF;
232 if ((detector & kTOF) != 0)
234 fReadoutList.fList[12] = 0xFFFFFFFF;
235 fReadoutList.fList[13] = 0xFFFFFFFF;
236 fReadoutList.fList[14] = 0x000000FF;
238 if ((detector & kHMPID) != 0) fReadoutList.fList[15] = 0x00003FFF;
239 if ((detector & kPHOS) != 0) fReadoutList.fList[16] = 0x000FFFFF;
240 if ((detector & kCPV) != 0) fReadoutList.fList[17] = 0x000003FF;
241 if ((detector & kPMD) != 0) fReadoutList.fList[18] = 0x0000003F;
242 if ((detector & kMUONTRK) != 0) fReadoutList.fList[19] = 0x000FFFFF;
243 if ((detector & kMUONTRG) != 0) fReadoutList.fList[20] = 0x00000003;
244 if ((detector & kFMD) != 0) fReadoutList.fList[21] = 0x00000007;
245 if ((detector & kT0) != 0) fReadoutList.fList[22] = 0x00000001;
246 if ((detector & kV0) != 0) fReadoutList.fList[23] = 0x00000001;
247 if ((detector & kZDC) != 0) fReadoutList.fList[24] = 0x00000001;
248 if ((detector & kACORDE) != 0) fReadoutList.fList[25] = 0x00000001;
249 if ((detector & kTRG) != 0) fReadoutList.fList[26] = 0x00000001;
250 if ((detector & kEMCAL) != 0) fReadoutList.fList[27] = 0x00FFFFFF;
251 if ((detector & kDAQTEST) != 0) fReadoutList.fList[28] = 0x00000001;
252 if ((detector & kHLT) != 0) fReadoutList.fList[29] = 0x000003FF;
256 void AliHLTReadoutList::Disable(Int_t detector)
258 // Disables all DDLs for a particular detector or detectors.
259 // See header file for more details.
261 if ((detector & kITSSPD) != 0) fReadoutList.fList[0] = 0x00000000;
262 if ((detector & kITSSDD) != 0) fReadoutList.fList[1] = 0x00000000;
263 if ((detector & kITSSSD) != 0) fReadoutList.fList[2] = 0x00000000;
264 if ((detector & kTPC) != 0)
266 fReadoutList.fList[3] = 0x00000000;
267 fReadoutList.fList[4] = 0x00000000;
268 fReadoutList.fList[5] = 0x00000000;
269 fReadoutList.fList[6] = 0x00000000;
270 fReadoutList.fList[7] = 0x00000000;
271 fReadoutList.fList[8] = 0x00000000;
272 fReadoutList.fList[9] = 0x00000000;
273 fReadoutList.fList[10] = 0x00000000;
275 if ((detector & kTRD) != 0) fReadoutList.fList[11] = 0x00000000;
276 if ((detector & kTOF) != 0)
278 fReadoutList.fList[12] = 0x00000000;
279 fReadoutList.fList[13] = 0x00000000;
280 fReadoutList.fList[14] = 0x00000000;
282 if ((detector & kHMPID) != 0) fReadoutList.fList[15] = 0x00000000;
283 if ((detector & kPHOS) != 0) fReadoutList.fList[16] = 0x00000000;
284 if ((detector & kCPV) != 0) fReadoutList.fList[17] = 0x00000000;
285 if ((detector & kPMD) != 0) fReadoutList.fList[18] = 0x00000000;
286 if ((detector & kMUONTRK) != 0) fReadoutList.fList[19] = 0x00000000;
287 if ((detector & kMUONTRG) != 0) fReadoutList.fList[20] = 0x00000000;
288 if ((detector & kFMD) != 0) fReadoutList.fList[21] = 0x00000000;
289 if ((detector & kT0) != 0) fReadoutList.fList[22] = 0x00000000;
290 if ((detector & kV0) != 0) fReadoutList.fList[23] = 0x00000000;
291 if ((detector & kZDC) != 0) fReadoutList.fList[24] = 0x00000000;
292 if ((detector & kACORDE) != 0) fReadoutList.fList[25] = 0x00000000;
293 if ((detector & kTRG) != 0) fReadoutList.fList[26] = 0x00000000;
294 if ((detector & kEMCAL) != 0) fReadoutList.fList[27] = 0x00000000;
295 if ((detector & kDAQTEST) != 0) fReadoutList.fList[28] = 0x00000000;
296 if ((detector & kHLT) != 0) fReadoutList.fList[29] = 0x00000000;
300 void AliHLTReadoutList::Print(Option_t* /*option*/) const
302 // Prints the DDLs that will be readout according to this readout list.
304 cout << "Readout enabled for DDLs:" << endl;
305 for (Int_t i = 0; i < AliDAQ::kNDetectors; i++)
307 Int_t maxddls = AliDAQ::NumberOfDdls(i);
308 cout << AliDAQ::DetectorName(i) << ":";
309 bool nonefound = true;
310 for (Int_t j = 0; j < maxddls; j++)
312 Int_t ddlId = ( ((i == AliDAQ::kNDetectors-1) ? 30 : i) << 8 ) + j;
313 if (GetDDLBit(ddlId))
315 cout << " " << ddlId;
319 if (nonefound) cout << " none";
325 AliHLTReadoutList& AliHLTReadoutList::operator = (const AliHLTReadoutList& list)
327 // Assignment operator performs a deep copy.
329 TObject::operator = (list);
332 memcpy(&fReadoutList, &list.fReadoutList, sizeof(fReadoutList));
338 AliHLTReadoutList& AliHLTReadoutList::operator |= (const AliHLTReadoutList& list)
340 // This operator performs a bitwise inclusive or operation on all DDL bits.
341 // See header file for more details.
343 assert( fReadoutList.fCount == gkAliHLTDDLListSize );
344 for (Int_t i = 0; i < gkAliHLTDDLListSize; i++)
346 fReadoutList.fList[i] |= list.fReadoutList.fList[i];
352 AliHLTReadoutList& AliHLTReadoutList::operator ^= (const AliHLTReadoutList& list)
354 // This operator performs a bitwise exclusive or (xor) operation on all DDL bits.
355 // See header file for more details.
357 assert( fReadoutList.fCount == gkAliHLTDDLListSize );
358 for (Int_t i = 0; i < gkAliHLTDDLListSize; i++)
360 fReadoutList.fList[i] ^= list.fReadoutList.fList[i];
366 AliHLTReadoutList& AliHLTReadoutList::operator &= (const AliHLTReadoutList& list)
368 // This operator performs a bitwise and operation on all DDL bits.
369 // See header file for more details.
371 assert( fReadoutList.fCount == gkAliHLTDDLListSize );
372 for (Int_t i = 0; i < gkAliHLTDDLListSize; i++)
374 fReadoutList.fList[i] &= list.fReadoutList.fList[i];
380 AliHLTReadoutList& AliHLTReadoutList::operator -= (const AliHLTReadoutList& list)
382 // This operator removes all the DDLs specified in list from this readout list.
383 // See header file for more details.
385 assert( fReadoutList.fCount == gkAliHLTDDLListSize );
386 for (Int_t i = 0; i < gkAliHLTDDLListSize; i++)
388 // Effectively apply: this = this & (~ (this & list))
389 // i.e. this = this & (this ^ list)
390 fReadoutList.fList[i] &= fReadoutList.fList[i] ^ list.fReadoutList.fList[i];
396 AliHLTReadoutList AliHLTReadoutList::operator ~ () const
398 // This operator performs a bitwise ones compliment on all DDL bits.
399 // See header file for more details.
401 AliHLTReadoutList readoutlist;
402 readoutlist.fReadoutList.fCount = fReadoutList.fCount;
403 readoutlist.fReadoutList.fList[0] = 0x000FFFFF & (~fReadoutList.fList[0]);
404 readoutlist.fReadoutList.fList[1] = 0x00FFFFFF & (~fReadoutList.fList[1]);
405 readoutlist.fReadoutList.fList[2] = 0x0000FFFF & (~fReadoutList.fList[2]);
406 readoutlist.fReadoutList.fList[3] = 0xFFFFFFFF & (~fReadoutList.fList[3]);
407 readoutlist.fReadoutList.fList[4] = 0xFFFFFFFF & (~fReadoutList.fList[4]);
408 readoutlist.fReadoutList.fList[5] = 0xFFFFFFFF & (~fReadoutList.fList[5]);
409 readoutlist.fReadoutList.fList[6] = 0xFFFFFFFF & (~fReadoutList.fList[6]);
410 readoutlist.fReadoutList.fList[7] = 0xFFFFFFFF & (~fReadoutList.fList[7]);
411 readoutlist.fReadoutList.fList[8] = 0xFFFFFFFF & (~fReadoutList.fList[8]);
412 readoutlist.fReadoutList.fList[9] = 0x00FFFFFF & (~fReadoutList.fList[9]);
413 readoutlist.fReadoutList.fList[10] = 0x00000000 & (~fReadoutList.fList[10]);
414 readoutlist.fReadoutList.fList[11] = 0x0003FFFF & (~fReadoutList.fList[11]);
415 readoutlist.fReadoutList.fList[12] = 0xFFFFFFFF & (~fReadoutList.fList[12]);
416 readoutlist.fReadoutList.fList[13] = 0xFFFFFFFF & (~fReadoutList.fList[13]);
417 readoutlist.fReadoutList.fList[14] = 0x000000FF & (~fReadoutList.fList[14]);
418 readoutlist.fReadoutList.fList[15] = 0x00003FFF & (~fReadoutList.fList[15]);
419 readoutlist.fReadoutList.fList[16] = 0x000FFFFF & (~fReadoutList.fList[16]);
420 readoutlist.fReadoutList.fList[17] = 0x000003FF & (~fReadoutList.fList[17]);
421 readoutlist.fReadoutList.fList[18] = 0x0000003F & (~fReadoutList.fList[18]);
422 readoutlist.fReadoutList.fList[19] = 0x000FFFFF & (~fReadoutList.fList[19]);
423 readoutlist.fReadoutList.fList[20] = 0x00000003 & (~fReadoutList.fList[20]);
424 readoutlist.fReadoutList.fList[21] = 0x00000007 & (~fReadoutList.fList[21]);
425 readoutlist.fReadoutList.fList[22] = 0x00000001 & (~fReadoutList.fList[22]);
426 readoutlist.fReadoutList.fList[23] = 0x00000001 & (~fReadoutList.fList[23]);
427 readoutlist.fReadoutList.fList[24] = 0x00000001 & (~fReadoutList.fList[24]);
428 readoutlist.fReadoutList.fList[25] = 0x00000001 & (~fReadoutList.fList[25]);
429 readoutlist.fReadoutList.fList[26] = 0x00000001 & (~fReadoutList.fList[26]);
430 readoutlist.fReadoutList.fList[27] = 0x00FFFFFF & (~fReadoutList.fList[27]);
431 readoutlist.fReadoutList.fList[28] = 0x00000001 & (~fReadoutList.fList[28]);
432 readoutlist.fReadoutList.fList[29] = 0x000003FF & (~fReadoutList.fList[29]);