]> git.uio.no Git - u/mrichter/AliRoot.git/blame - HLT/BASE/AliHLTReadoutList.cxx
Fixing compilation error.
[u/mrichter/AliRoot.git] / HLT / BASE / AliHLTReadoutList.cxx
CommitLineData
15ede44e 1// $Id$
dce3e5ce 2/**************************************************************************
3 * This file is property of and copyright by the ALICE HLT Project *
4 * ALICE Experiment at CERN, All rights reserved. *
5 * *
6 * Primary Authors: Artur Szostak <artursz@iafrica.com> *
7 * for The ALICE HLT Project. *
8 * *
9 * Permission to use, copy, modify and distribute this software and its *
10 * documentation strictly for non-commercial purposes is hereby granted *
11 * without fee, provided that the above copyright notice appears in all *
12 * copies and that both the copyright notice and this permission notice *
13 * appear in the supporting documentation. The authors make no claims *
14 * about the suitability of this software for any purpose. It is *
15 * provided "as is" without express or implied warranty. *
16 **************************************************************************/
17
18/// @file AliHLTReadoutList.cxx
19/// @author Artur Szostak <artursz@iafrica.com>
20/// @date 19 Nov 2008
21/// @brief Implementation of the AliHLTReadoutList class.
22///
23/// The AliHLTReadoutList class is used as an interface to the AliHLTEventDDL
24/// structure. It makes it easy to manipulate the bits in this structure, which
25/// define what DDLs should be readout by DAQ.
26/// Several operators are also overloaded which are meant to be used in the trigger
27/// menu specification for the AliHLTGlobalTrigger. It allows one to construct
28/// expressions for the readout lists, which is necessary to be able to evaluate
29/// or compose the final readout list, given multiple input readout lists received
30/// from individual components that derive from AliHLTTrigger.
31
32#include "AliHLTReadoutList.h"
52647727 33#include "AliHLTDAQ.h"
dce3e5ce 34#include "Riostream.h"
35#include "TString.h"
36#include "TObjString.h"
37#include "TObjArray.h"
38#include <cassert>
39
40ClassImp(AliHLTReadoutList)
41
42
89413559 43const char* AliHLTReadoutList::DetectorIdToString(EDetectorId id)
44{
45 // Converts a detector ID to a user readable string.
46 switch (id)
47 {
48 case kNoDetector: return "kNoDetector";
49 case kITSSPD: return "kITSSPD";
50 case kITSSDD: return "kITSSDD";
51 case kITSSSD: return "kITSSSD";
52 case kTPC: return "kTPC";
53 case kTRD: return "kTRD";
54 case kTOF: return "kTOF";
55 case kHMPID: return "kHMPID";
56 case kPHOS: return "kPHOS";
57 case kCPV: return "kCPV";
58 case kPMD: return "kPMD";
59 case kMUONTRK: return "kMUONTRK";
60 case kMUONTRG: return "kMUONTRG";
61 case kFMD: return "kFMD";
62 case kT0: return "kT0";
63 case kV0: return "kV0";
64 case kZDC: return "kZDC";
65 case kACORDE: return "kACORDE";
66 case kTRG: return "kTRG";
67 case kEMCAL: return "kEMCAL";
68 case kDAQTEST: return "kDAQTEST";
69 case kHLT: return "kHLT";
70 case kALLDET: return "kALLDET";
71 default: return "UNKNOWN!";
72 }
73}
74
75
dce3e5ce 76AliHLTReadoutList::AliHLTReadoutList() :
1462df14 77 TNamed("AliHLTReadoutList", "Readout list object used for manipulating and storing an AliHLTEventDDL structure."),
dce3e5ce 78 fReadoutList()
79{
80 // Default constructor.
81
82 fReadoutList.fCount = gkAliHLTDDLListSize; // Required by ALICE-INT-2007-015
83 memset(fReadoutList.fList, 0x0, sizeof(fReadoutList.fList));
84}
85
86
87AliHLTReadoutList::AliHLTReadoutList(Int_t enabledDetectors) :
1462df14 88 TNamed("AliHLTReadoutList", "Readout list object used for manipulating and storing an AliHLTEventDDL structure."),
dce3e5ce 89 fReadoutList()
90{
91 // Constructor to select which detectors to enable for readout.
92 // See header file for more details.
93
94 fReadoutList.fCount = gkAliHLTDDLListSize; // Required by ALICE-INT-2007-015
95 memset(fReadoutList.fList, 0x0, sizeof(fReadoutList.fList));
96 Enable(enabledDetectors);
97}
98
99
100AliHLTReadoutList::AliHLTReadoutList(const char* enabledList) :
1462df14 101 TNamed("AliHLTReadoutList", "Readout list object used for manipulating and storing an AliHLTEventDDL structure."),
dce3e5ce 102 fReadoutList()
103{
104 // Constructor to select which detectors and DDLs to enable for readout.
105 // See header file for more details.
106
107 fReadoutList.fCount = gkAliHLTDDLListSize; // Required by ALICE-INT-2007-015
108 memset(fReadoutList.fList, 0x0, sizeof(fReadoutList.fList));
109
110 TString str(enabledList);
111 str.ToUpper();
112 Int_t enabledDetectors = 0;
113 if (str.Contains("ITSSPD")) enabledDetectors |= kITSSPD;
114 if (str.Contains("ITSSDD")) enabledDetectors |= kITSSDD;
115 if (str.Contains("ITSSSD")) enabledDetectors |= kITSSSD;
116 if (str.Contains("TPC")) enabledDetectors |= kTPC;
117 if (str.Contains("TRD")) enabledDetectors |= kTRD;
118 if (str.Contains("TOF")) enabledDetectors |= kTOF;
119 if (str.Contains("HMPID")) enabledDetectors |= kHMPID;
120 if (str.Contains("PHOS")) enabledDetectors |= kPHOS;
121 if (str.Contains("CPV")) enabledDetectors |= kCPV;
122 if (str.Contains("PMD")) enabledDetectors |= kPMD;
123 if (str.Contains("MUONTRK")) enabledDetectors |= kMUONTRK;
124 if (str.Contains("MUONTRG")) enabledDetectors |= kMUONTRG;
125 if (str.Contains("FMD")) enabledDetectors |= kFMD;
126 if (str.Contains("T0")) enabledDetectors |= kT0;
127 if (str.Contains("V0")) enabledDetectors |= kV0;
128 if (str.Contains("ZDC")) enabledDetectors |= kZDC;
129 if (str.Contains("ACORDE")) enabledDetectors |= kACORDE;
130 if (str.Contains("TRG")) enabledDetectors |= kTRG;
131 if (str.Contains("EMCAL")) enabledDetectors |= kEMCAL;
132 if (str.Contains("DAQTEST")) enabledDetectors |= kDAQTEST;
133 if (str.Contains("HLT")) enabledDetectors |= kHLT;
134 if (str.Contains("ALL")) enabledDetectors |= kALLDET;
135 Enable(enabledDetectors);
136
137 TObjArray* list = str.Tokenize(" ");
138 TIter next(list);
139 const TObjString* objstr = NULL;
140 while ((objstr = dynamic_cast<const TObjString*>(next())) != NULL)
141 {
142 str = objstr->GetString();
143 if (str.IsDigit()) EnableDDLBit(str.Atoi());
144 }
145 delete list;
146}
147
148
149AliHLTReadoutList::AliHLTReadoutList(const AliHLTEventDDL& list) :
1462df14 150 TNamed("AliHLTReadoutList", "Readout list object used for manipulating and storing an AliHLTEventDDL structure."),
dce3e5ce 151 fReadoutList()
152{
153 // Constructor to create readout list from AliHLTEventDDL structure.
154 // See header file for more details.
489fb1d7 155 FillStruct(list);
156}
157
158
159AliHLTReadoutList::AliHLTReadoutList(const AliHLTReadoutList& list) :
160 TNamed(list),
161 fReadoutList()
162{
163 // Copy constructor performs a deep copy.
164
165 if (list.fReadoutList.fCount == (unsigned)gkAliHLTDDLListSize)
166 {
167 memcpy(&fReadoutList, &list.fReadoutList, sizeof(fReadoutList));
168 }
169 else
170 {
171 FillStruct(list);
172 }
173}
174
175
176void AliHLTReadoutList::FillStruct(const AliHLTEventDDL& list)
177{
178 // Fills internal DDL bits structure.
179
89413559 180 fReadoutList.fCount = gkAliHLTDDLListSize; // Required by ALICE-INT-2007-015
181 memset(fReadoutList.fList, 0x0, sizeof(fReadoutList.fList));
182 // Handle lists of different sizes. If the size is for a known version
183 // of AliHLTEventDDL then handle appropriately, otherwise just copy only
184 // the overlapping part of the list.
489fb1d7 185 if (list.fCount == (unsigned)gkAliHLTDDLListSizeV0)
89413559 186 {
187 memcpy(&fReadoutList.fList[0], &list.fList[0], sizeof(AliHLTUInt32_t)*28);
188 memcpy(&fReadoutList.fList[29], &list.fList[28], sizeof(AliHLTUInt32_t)*2);
189 }
489fb1d7 190 else if (list.fCount == (unsigned)gkAliHLTDDLListSizeV1)
89413559 191 {
192 memcpy(&fReadoutList.fList, &list.fList, sizeof(AliHLTEventDDL));
193 }
194 else
195 {
196 memcpy(&fReadoutList.fList, &list.fList, (fReadoutList.fCount<list.fCount?fReadoutList.fCount:list.fCount)*sizeof(AliHLTUInt32_t));
197 }
dce3e5ce 198}
199
200
dce3e5ce 201AliHLTReadoutList::~AliHLTReadoutList()
202{
203 // Default destructor.
204}
205
206
8b745301 207bool AliHLTReadoutList::Empty() const
208{
209 // Returns true if the readout list has no DDLs enabled.
210
edddbe3a 211 for (size_t i = 0; i < sizeof(fReadoutList.fList) / sizeof(fReadoutList.fList[0]); i++)
8b745301 212 {
213 if (fReadoutList.fList[i] != 0x0) return false;
214 }
215 return true;
216}
217
218
acc7214e 219void AliHLTReadoutList::Clear(Option_t* /*option*/)
220{
221 // Resets all the DDL readout bits.
222 memset(fReadoutList.fList, 0x0, sizeof(fReadoutList.fList));
489fb1d7 223
224#if 1 // ROOT_SVN_REVISION < 9999 //FIXME: after fixed https://savannah.cern.ch/bugs/?69241
225 // Check if we need to convert to new format and do so.
226 if (fReadoutList.fCount == (unsigned)gkAliHLTDDLListSizeV0)
227 {
228 fReadoutList.fCount = gkAliHLTDDLListSize;
229 }
230#endif
acc7214e 231}
232
233
dce3e5ce 234bool AliHLTReadoutList::DecodeDDLID(Int_t ddlId, Int_t& wordIndex, Int_t& bitIndex)
235{
236 // Decodes the word index and bit index within that word for the readout list structure.
237 // See header file for more details.
238
239 // The detector number is bits 15..8 of ddlId and DDL number is bits 7..0.
240 Int_t detNum = ddlId >> 8;
241 Int_t ddlNum = ddlId & 0xFF;
242
7f8acd80 243 switch (detNum)
dce3e5ce 244 {
7f8acd80 245 case 0: // SPD
246 case 1: // SDD
247 case 2: // SSD
248 if (ddlNum >= 32) return false; // only have 1 32-bit word.
15ede44e 249 // the 3 ITS detectors have one word each
dce3e5ce 250 wordIndex = detNum;
7f8acd80 251 break;
252 case 3: // TPC
15ede44e 253 // the TPC bitfield has in total 8 words
dce3e5ce 254 wordIndex = detNum + (ddlNum >> 5);
7f8acd80 255 break;
256 case 4: // TRD
257 if (ddlNum >= 32) return false; // only have 1 32-bit word.
258 // the TRD bitfield starts at word 11 (3 words ITS + 8 words TPC)
259 wordIndex = 11;
260 break;
261 case 5: // TOF
262 if (ddlNum >= 3*32) return false; // only have 3 32-bit words.
15ede44e 263 // TOF has 72 DDLs, the bitfield is 3 words starting at position 12
7f8acd80 264 wordIndex = 12 + (ddlNum >> 5);
265 break;
266 case 6: // HMPID
267 case 7: // PHOS
268 case 8: // CPV
269 case 9: // PMD
270 case 10: // MUONTRK (MCH)
271 case 11: // MUONTRG (MTR)
272 case 12: // FMD
273 case 13: // T0
274 case 14: // V0
275 case 15: // ZDC
276 case 16: // ACORDE
277 case 17: // TRG
7f8acd80 278 if (ddlNum >= 32) return false; // only have 1 32-bit word.
a9a3028c 279 // all these detectors fit into one word, the offset is due to
15ede44e 280 // TPC and TOF
dce3e5ce 281 wordIndex = detNum + 9;
7f8acd80 282 break;
a9a3028c 283 case 18: // EMCAL
284 if (ddlNum >= 2*32) return false; // only have 2 32-bit words.
285 // 2 words for EMCAL + DCAL
286 wordIndex = detNum + 7;
287 wordIndex = 27 + (ddlNum >> 5);
288 break;
289 case 19: // DAQTEST
290 if (ddlNum >= 32) return false; // only have 1 32-bit word.
291 wordIndex = 29;
292 break;
7f8acd80 293 case 30: // HLT
294 if (ddlNum >= 32) return false; // only have 1 32-bit word.
295 // the HLT bitfield is in the last word
a9a3028c 296 wordIndex = 30;
7f8acd80 297 break;
298 default:
299 return false;
dce3e5ce 300 }
301
a9a3028c 302 if (ddlNum >= AliHLTDAQ::NumberOfDdls(detNum == 30 ? 20 : detNum)) return false;
303
dce3e5ce 304 // The bit index within the word indicated by wordIndex.
7f8acd80 305 bitIndex = ddlNum % 32;
dce3e5ce 306 return true;
307}
308
309
310Bool_t AliHLTReadoutList::GetDDLBit(Int_t ddlId) const
311{
312 // Fetches the bit value for a particular DDL in the readout list.
313 // See header file for more details.
314
315 Int_t wordIndex, bitIndex;
316 if (! DecodeDDLID(ddlId, wordIndex, bitIndex)) return kFALSE;
489fb1d7 317
318#if 1 // ROOT_SVN_REVISION < 9999 //FIXME: after fixed https://savannah.cern.ch/bugs/?69241
319 // Check if we need to convert to new format and do so.
320 if (fReadoutList.fCount == (unsigned)gkAliHLTDDLListSizeV0)
321 {
322 if (wordIndex == 27)
323 {
324 if (bitIndex >= 24) return kFALSE;
325 }
326 else if (wordIndex == 28)
327 {
328 return kFALSE;
329 }
330 else if (wordIndex > 28)
331 {
332 --wordIndex;
333 }
334 }
335#endif
336
dce3e5ce 337 return ((fReadoutList.fList[wordIndex] >> bitIndex) & 0x1) == 0x1;
338}
339
340
341void AliHLTReadoutList::SetDDLBit(Int_t ddlId, Bool_t state)
342{
343 // Sets the bit value for a particular DDL in the readout list.
344 // See header file for more details.
489fb1d7 345
346#if 1 // ROOT_SVN_REVISION < 9999 //FIXME: after fixed https://savannah.cern.ch/bugs/?69241
347 // Check if we need to convert to new format and do so.
348 if (fReadoutList.fCount == (unsigned)gkAliHLTDDLListSizeV0)
349 {
350 AliHLTEventDDL copy = fReadoutList;
351 FillStruct(copy);
352 }
353#endif
354 assert(fReadoutList.fCount == gkAliHLTDDLListSize);
dce3e5ce 355
356 Int_t wordIndex, bitIndex;
357 if (! DecodeDDLID(ddlId, wordIndex, bitIndex)) return;
358
359 // To set, 'OR' word with bit mask
360 if ( state )
361 fReadoutList.fList[wordIndex] |= (0x00000001 << bitIndex);
362 // To unset, 'AND' word with bit mask
363 else
364 fReadoutList.fList[wordIndex] &= (0xFFFFFFFF ^ (0x00000001 << bitIndex));
365}
366
367
368void AliHLTReadoutList::Enable(Int_t detector)
369{
370 // Enables all DDLs for a particular detector or detectors.
371 // See header file for more details.
489fb1d7 372
373#if 1 // ROOT_SVN_REVISION < 9999 //FIXME: after fixed https://savannah.cern.ch/bugs/?69241
374 // Check if we need to convert to new format and do so.
375 if (fReadoutList.fCount == (unsigned)gkAliHLTDDLListSizeV0)
376 {
377 AliHLTEventDDL copy = fReadoutList;
378 FillStruct(copy);
379 }
380#endif
381 assert(fReadoutList.fCount == gkAliHLTDDLListSize);
dce3e5ce 382
383 if ((detector & kITSSPD) != 0) fReadoutList.fList[0] = 0x000FFFFF;
384 if ((detector & kITSSDD) != 0) fReadoutList.fList[1] = 0x00FFFFFF;
385 if ((detector & kITSSSD) != 0) fReadoutList.fList[2] = 0x0000FFFF;
386 if ((detector & kTPC) != 0)
387 {
388 fReadoutList.fList[3] = 0xFFFFFFFF;
389 fReadoutList.fList[4] = 0xFFFFFFFF;
390 fReadoutList.fList[5] = 0xFFFFFFFF;
391 fReadoutList.fList[6] = 0xFFFFFFFF;
392 fReadoutList.fList[7] = 0xFFFFFFFF;
393 fReadoutList.fList[8] = 0xFFFFFFFF;
394 fReadoutList.fList[9] = 0x00FFFFFF;
395 fReadoutList.fList[10] = 0x00000000;
396 }
397 if ((detector & kTRD) != 0) fReadoutList.fList[11] = 0x0003FFFF;
398 if ((detector & kTOF) != 0)
399 {
400 fReadoutList.fList[12] = 0xFFFFFFFF;
401 fReadoutList.fList[13] = 0xFFFFFFFF;
402 fReadoutList.fList[14] = 0x000000FF;
403 }
14da6b98 404 if ((detector & kHMPID) != 0) fReadoutList.fList[15] = 0x000FFFFF;
dce3e5ce 405 if ((detector & kPHOS) != 0) fReadoutList.fList[16] = 0x000FFFFF;
406 if ((detector & kCPV) != 0) fReadoutList.fList[17] = 0x000003FF;
407 if ((detector & kPMD) != 0) fReadoutList.fList[18] = 0x0000003F;
408 if ((detector & kMUONTRK) != 0) fReadoutList.fList[19] = 0x000FFFFF;
409 if ((detector & kMUONTRG) != 0) fReadoutList.fList[20] = 0x00000003;
410 if ((detector & kFMD) != 0) fReadoutList.fList[21] = 0x00000007;
411 if ((detector & kT0) != 0) fReadoutList.fList[22] = 0x00000001;
412 if ((detector & kV0) != 0) fReadoutList.fList[23] = 0x00000001;
413 if ((detector & kZDC) != 0) fReadoutList.fList[24] = 0x00000001;
414 if ((detector & kACORDE) != 0) fReadoutList.fList[25] = 0x00000001;
415 if ((detector & kTRG) != 0) fReadoutList.fList[26] = 0x00000001;
a9a3028c 416 if ((detector & kEMCAL) != 0)
417 {
418 fReadoutList.fList[27] = 0xFFFFFFFF;
419 fReadoutList.fList[28] = 0x00003FFF;
420 }
421 if ((detector & kDAQTEST) != 0) fReadoutList.fList[29] = 0x00000001;
422 if ((detector & kHLT) != 0) fReadoutList.fList[30] = 0x000003FF;
dce3e5ce 423}
424
425
426void AliHLTReadoutList::Disable(Int_t detector)
427{
428 // Disables all DDLs for a particular detector or detectors.
429 // See header file for more details.
489fb1d7 430
431#if 1 // ROOT_SVN_REVISION < 9999 //FIXME: after fixed https://savannah.cern.ch/bugs/?69241
432 // Check if we need to convert to new format and do so.
433 if (fReadoutList.fCount == (unsigned)gkAliHLTDDLListSizeV0)
434 {
435 AliHLTEventDDL copy = fReadoutList;
436 FillStruct(copy);
437 }
438#endif
439 assert(fReadoutList.fCount == gkAliHLTDDLListSize);
dce3e5ce 440
441 if ((detector & kITSSPD) != 0) fReadoutList.fList[0] = 0x00000000;
442 if ((detector & kITSSDD) != 0) fReadoutList.fList[1] = 0x00000000;
443 if ((detector & kITSSSD) != 0) fReadoutList.fList[2] = 0x00000000;
444 if ((detector & kTPC) != 0)
445 {
446 fReadoutList.fList[3] = 0x00000000;
447 fReadoutList.fList[4] = 0x00000000;
448 fReadoutList.fList[5] = 0x00000000;
449 fReadoutList.fList[6] = 0x00000000;
450 fReadoutList.fList[7] = 0x00000000;
451 fReadoutList.fList[8] = 0x00000000;
452 fReadoutList.fList[9] = 0x00000000;
453 fReadoutList.fList[10] = 0x00000000;
454 }
455 if ((detector & kTRD) != 0) fReadoutList.fList[11] = 0x00000000;
456 if ((detector & kTOF) != 0)
457 {
458 fReadoutList.fList[12] = 0x00000000;
459 fReadoutList.fList[13] = 0x00000000;
460 fReadoutList.fList[14] = 0x00000000;
461 }
462 if ((detector & kHMPID) != 0) fReadoutList.fList[15] = 0x00000000;
463 if ((detector & kPHOS) != 0) fReadoutList.fList[16] = 0x00000000;
464 if ((detector & kCPV) != 0) fReadoutList.fList[17] = 0x00000000;
465 if ((detector & kPMD) != 0) fReadoutList.fList[18] = 0x00000000;
466 if ((detector & kMUONTRK) != 0) fReadoutList.fList[19] = 0x00000000;
467 if ((detector & kMUONTRG) != 0) fReadoutList.fList[20] = 0x00000000;
468 if ((detector & kFMD) != 0) fReadoutList.fList[21] = 0x00000000;
469 if ((detector & kT0) != 0) fReadoutList.fList[22] = 0x00000000;
470 if ((detector & kV0) != 0) fReadoutList.fList[23] = 0x00000000;
471 if ((detector & kZDC) != 0) fReadoutList.fList[24] = 0x00000000;
472 if ((detector & kACORDE) != 0) fReadoutList.fList[25] = 0x00000000;
473 if ((detector & kTRG) != 0) fReadoutList.fList[26] = 0x00000000;
a9a3028c 474 if ((detector & kEMCAL) != 0)
475 {
476 fReadoutList.fList[27] = 0x00000000;
477 fReadoutList.fList[28] = 0x00000000;
478 }
479 if ((detector & kDAQTEST) != 0) fReadoutList.fList[29] = 0x00000000;
480 if ((detector & kHLT) != 0) fReadoutList.fList[30] = 0x00000000;
dce3e5ce 481}
482
483
52f67e50 484bool AliHLTReadoutList::DetectorEnabled(Int_t detector) const
485{
486 // Checks if a particular detector's DDLs are enabled.
487 // See header file for more details.
488
489 bool result = true;
490 if ((detector & kITSSPD) != 0) result &= fReadoutList.fList[0] == 0x000FFFFF;
491 if ((detector & kITSSDD) != 0) result &= fReadoutList.fList[1] == 0x00FFFFFF;
492 if ((detector & kITSSSD) != 0) result &= fReadoutList.fList[2] == 0x0000FFFF;
493 if ((detector & kTPC) != 0)
494 {
495 result &= fReadoutList.fList[3] == 0xFFFFFFFF;
496 result &= fReadoutList.fList[4] == 0xFFFFFFFF;
497 result &= fReadoutList.fList[5] == 0xFFFFFFFF;
498 result &= fReadoutList.fList[6] == 0xFFFFFFFF;
499 result &= fReadoutList.fList[7] == 0xFFFFFFFF;
500 result &= fReadoutList.fList[8] == 0xFFFFFFFF;
501 result &= fReadoutList.fList[9] == 0x00FFFFFF;
502 }
503 if ((detector & kTRD) != 0) result &= fReadoutList.fList[11] == 0x0003FFFF;
504 if ((detector & kTOF) != 0)
505 {
506 result &= fReadoutList.fList[12] == 0xFFFFFFFF;
507 result &= fReadoutList.fList[13] == 0xFFFFFFFF;
508 result &= fReadoutList.fList[14] == 0x000000FF;
509 }
14da6b98 510 if ((detector & kHMPID) != 0) result &= fReadoutList.fList[15] == 0x000FFFFF;
52f67e50 511 if ((detector & kPHOS) != 0) result &= fReadoutList.fList[16] == 0x000FFFFF;
512 if ((detector & kCPV) != 0) result &= fReadoutList.fList[17] == 0x000003FF;
513 if ((detector & kPMD) != 0) result &= fReadoutList.fList[18] == 0x0000003F;
514 if ((detector & kMUONTRK) != 0) result &= fReadoutList.fList[19] == 0x000FFFFF;
515 if ((detector & kMUONTRG) != 0) result &= fReadoutList.fList[20] == 0x00000003;
516 if ((detector & kFMD) != 0) result &= fReadoutList.fList[21] == 0x00000007;
517 if ((detector & kT0) != 0) result &= fReadoutList.fList[22] == 0x00000001;
518 if ((detector & kV0) != 0) result &= fReadoutList.fList[23] == 0x00000001;
519 if ((detector & kZDC) != 0) result &= fReadoutList.fList[24] == 0x00000001;
520 if ((detector & kACORDE) != 0) result &= fReadoutList.fList[25] == 0x00000001;
521 if ((detector & kTRG) != 0) result &= fReadoutList.fList[26] == 0x00000001;
489fb1d7 522#if 1 // ROOT_SVN_REVISION < 9999 //FIXME: after fixed https://savannah.cern.ch/bugs/?69241
523 if (fReadoutList.fCount == (unsigned)gkAliHLTDDLListSizeV0)
a9a3028c 524 {
489fb1d7 525 if ((detector & kEMCAL) != 0) result &= fReadoutList.fList[27] == 0x00FFFFFF;
526 if ((detector & kDAQTEST) != 0) result &= fReadoutList.fList[28] == 0x00000001;
527 if ((detector & kHLT) != 0) result &= fReadoutList.fList[29] == 0x000003FF;
528 }
529 else
530#endif
531 {
532 if ((detector & kEMCAL) != 0)
533 {
534 result &= fReadoutList.fList[27] == 0xFFFFFFFF;
535 result &= fReadoutList.fList[28] == 0x00003FFF;
536 }
537 if ((detector & kDAQTEST) != 0) result &= fReadoutList.fList[29] == 0x00000001;
538 if ((detector & kHLT) != 0) result &= fReadoutList.fList[30] == 0x000003FF;
a9a3028c 539 }
52f67e50 540
541 return result;
542}
543
544
89413559 545bool AliHLTReadoutList::DetectorDisabled(Int_t detector) const
546{
547 // Checks if a particular detector's DDLs are disabled.
548 // See header file for more details.
549
550 bool result = true;
551 if ((detector & kITSSPD) != 0) result &= fReadoutList.fList[0] == 0x00000000;
552 if ((detector & kITSSDD) != 0) result &= fReadoutList.fList[1] == 0x00000000;
553 if ((detector & kITSSSD) != 0) result &= fReadoutList.fList[2] == 0x00000000;
554 if ((detector & kTPC) != 0)
555 {
556 result &= fReadoutList.fList[3] == 0x00000000;
557 result &= fReadoutList.fList[4] == 0x00000000;
558 result &= fReadoutList.fList[5] == 0x00000000;
559 result &= fReadoutList.fList[6] == 0x00000000;
560 result &= fReadoutList.fList[7] == 0x00000000;
561 result &= fReadoutList.fList[8] == 0x00000000;
562 result &= fReadoutList.fList[9] == 0x00000000;
563 }
564 if ((detector & kTRD) != 0) result &= fReadoutList.fList[11] == 0x00000000;
565 if ((detector & kTOF) != 0)
566 {
567 result &= fReadoutList.fList[12] == 0x00000000;
568 result &= fReadoutList.fList[13] == 0x00000000;
569 result &= fReadoutList.fList[14] == 0x00000000;
570 }
571 if ((detector & kHMPID) != 0) result &= fReadoutList.fList[15] == 0x00000000;
572 if ((detector & kPHOS) != 0) result &= fReadoutList.fList[16] == 0x00000000;
573 if ((detector & kCPV) != 0) result &= fReadoutList.fList[17] == 0x00000000;
574 if ((detector & kPMD) != 0) result &= fReadoutList.fList[18] == 0x00000000;
575 if ((detector & kMUONTRK) != 0) result &= fReadoutList.fList[19] == 0x00000000;
576 if ((detector & kMUONTRG) != 0) result &= fReadoutList.fList[20] == 0x00000000;
577 if ((detector & kFMD) != 0) result &= fReadoutList.fList[21] == 0x00000000;
578 if ((detector & kT0) != 0) result &= fReadoutList.fList[22] == 0x00000000;
579 if ((detector & kV0) != 0) result &= fReadoutList.fList[23] == 0x00000000;
580 if ((detector & kZDC) != 0) result &= fReadoutList.fList[24] == 0x00000000;
581 if ((detector & kACORDE) != 0) result &= fReadoutList.fList[25] == 0x00000000;
582 if ((detector & kTRG) != 0) result &= fReadoutList.fList[26] == 0x00000000;
489fb1d7 583#if 1 // ROOT_SVN_REVISION < 9999 //FIXME: after fixed https://savannah.cern.ch/bugs/?69241
584 if (fReadoutList.fCount == (unsigned)gkAliHLTDDLListSizeV0)
89413559 585 {
489fb1d7 586 if ((detector & kEMCAL) != 0) result &= fReadoutList.fList[27] == 0x00000000;
587 if ((detector & kDAQTEST) != 0) result &= fReadoutList.fList[28] == 0x00000000;
588 if ((detector & kHLT) != 0) result &= fReadoutList.fList[29] == 0x00000000;
589 }
590 else
591#endif
592 {
593 if ((detector & kEMCAL) != 0)
594 {
595 result &= fReadoutList.fList[27] == 0x00000000;
596 result &= fReadoutList.fList[28] == 0x00000000;
597 }
598 if ((detector & kDAQTEST) != 0) result &= fReadoutList.fList[29] == 0x00000000;
599 if ((detector & kHLT) != 0) result &= fReadoutList.fList[30] == 0x00000000;
89413559 600 }
89413559 601
602 return result;
603}
604
605
606Int_t AliHLTReadoutList::GetFirstWord(EDetectorId detector)
607{
608 // See header file for more details.
609 switch (detector)
610 {
611 case kITSSPD: return 0;
612 case kITSSDD: return 1;
613 case kITSSSD: return 2;
614 case kTPC: return 3;
615 case kTRD: return 11;
616 case kTOF: return 12;
617 case kHMPID: return 15;
618 case kPHOS: return 16;
619 case kCPV: return 17;
620 case kPMD: return 18;
621 case kMUONTRK: return 19;
622 case kMUONTRG: return 20;
623 case kFMD: return 21;
624 case kT0: return 22;
625 case kV0: return 23;
626 case kZDC: return 24;
627 case kACORDE: return 25;
628 case kTRG: return 26;
629 case kEMCAL: return 27;
630 case kDAQTEST: return 29;
631 case kHLT: return 30;
632 default: return -1;
633 }
634}
635
636
637Int_t AliHLTReadoutList::GetWordCount(EDetectorId detector)
638{
639 // See header file for more details.
640 switch (detector)
641 {
642 case kITSSPD: return 1;
643 case kITSSDD: return 1;
644 case kITSSSD: return 1;
645 case kTPC: return 8;
646 case kTRD: return 1;
647 case kTOF: return 3;
648 case kHMPID: return 1;
649 case kPHOS: return 1;
650 case kCPV: return 1;
651 case kPMD: return 1;
652 case kMUONTRK: return 1;
653 case kMUONTRG: return 1;
654 case kFMD: return 1;
655 case kT0: return 1;
656 case kV0: return 1;
657 case kZDC: return 1;
658 case kACORDE: return 1;
659 case kTRG: return 1;
660 case kEMCAL: return 2;
661 case kDAQTEST: return 1;
662 case kHLT: return 1;
663 default: return 0;
664 }
665}
666
667
7c69da51 668AliHLTReadoutList::EDetectorId AliHLTReadoutList::GetDetectorFromWord(Int_t wordindex)
669{
670 // See header file for more details.
671 switch (wordindex)
672 {
673 case 0: return kITSSPD;
674 case 1: return kITSSDD;
675 case 2: return kITSSSD;
676 case 3: return kTPC;
677 case 4: return kTPC;
678 case 5: return kTPC;
679 case 6: return kTPC;
680 case 7: return kTPC;
681 case 8: return kTPC;
682 case 9: return kTPC;
683 case 10: return kTPC;
684 case 11: return kTRD;
685 case 12: return kTOF;
686 case 13: return kTOF;
687 case 14: return kTOF;
688 case 15: return kHMPID;
689 case 16: return kPHOS;
690 case 17: return kCPV;
691 case 18: return kPMD;
692 case 19: return kMUONTRK;
693 case 20: return kMUONTRG;
694 case 21: return kFMD;
695 case 22: return kT0;
696 case 23: return kV0;
697 case 24: return kZDC;
698 case 25: return kACORDE;
699 case 26: return kTRG;
700 case 27: return kEMCAL;
701 case 28: return kEMCAL;
702 case 29: return kDAQTEST;
703 case 30: return kHLT;
704 default: return kNoDetector;
705 }
706}
707
708
89413559 709AliHLTReadoutList::EDetectorId AliHLTReadoutList::GetFirstUsedDetector(EDetectorId startAfter) const
710{
711 // See header file for more details.
489fb1d7 712
89413559 713 if (startAfter < kITSSPD and fReadoutList.fList[0] != 0x00000000) return kITSSPD;
714 if (startAfter < kITSSDD and fReadoutList.fList[1] != 0x00000000) return kITSSDD;
715 if (startAfter < kITSSSD and fReadoutList.fList[2] != 0x00000000) return kITSSSD;
716 if (startAfter < kTPC and fReadoutList.fList[3] != 0x00000000) return kTPC;
717 if (startAfter < kTPC and fReadoutList.fList[4] != 0x00000000) return kTPC;
718 if (startAfter < kTPC and fReadoutList.fList[5] != 0x00000000) return kTPC;
719 if (startAfter < kTPC and fReadoutList.fList[6] != 0x00000000) return kTPC;
720 if (startAfter < kTPC and fReadoutList.fList[7] != 0x00000000) return kTPC;
721 if (startAfter < kTPC and fReadoutList.fList[8] != 0x00000000) return kTPC;
722 if (startAfter < kTPC and fReadoutList.fList[9] != 0x00000000) return kTPC;
723 if (startAfter < kTPC and fReadoutList.fList[10] != 0x00000000) return kTPC;
724 if (startAfter < kTRD and fReadoutList.fList[11] != 0x00000000) return kTRD;
725 if (startAfter < kTOF and fReadoutList.fList[12] != 0x00000000) return kTOF;
726 if (startAfter < kTOF and fReadoutList.fList[13] != 0x00000000) return kTOF;
727 if (startAfter < kTOF and fReadoutList.fList[14] != 0x00000000) return kTOF;
728 if (startAfter < kHMPID and fReadoutList.fList[15] != 0x00000000) return kHMPID;
729 if (startAfter < kPHOS and fReadoutList.fList[16] != 0x00000000) return kPHOS;
730 if (startAfter < kCPV and fReadoutList.fList[17] != 0x00000000) return kCPV;
731 if (startAfter < kPMD and fReadoutList.fList[18] != 0x00000000) return kPMD;
732 if (startAfter < kMUONTRK and fReadoutList.fList[19] != 0x00000000) return kMUONTRK;
733 if (startAfter < kMUONTRG and fReadoutList.fList[20] != 0x00000000) return kMUONTRG;
734 if (startAfter < kFMD and fReadoutList.fList[21] != 0x00000000) return kFMD;
735 if (startAfter < kT0 and fReadoutList.fList[22] != 0x00000000) return kT0;
736 if (startAfter < kV0 and fReadoutList.fList[23] != 0x00000000) return kV0;
737 if (startAfter < kZDC and fReadoutList.fList[24] != 0x00000000) return kZDC;
738 if (startAfter < kACORDE and fReadoutList.fList[25] != 0x00000000) return kACORDE;
739 if (startAfter < kTRG and fReadoutList.fList[26] != 0x00000000) return kTRG;
740 if (startAfter < kEMCAL and fReadoutList.fList[27] != 0x00000000) return kEMCAL;
489fb1d7 741#if 1 // ROOT_SVN_REVISION < 9999 //FIXME: after fixed https://savannah.cern.ch/bugs/?69241
742 // Check if we need to convert to new format and do so.
743 if (fReadoutList.fCount == (unsigned)gkAliHLTDDLListSizeV0)
744 {
745 if (startAfter < kDAQTEST and fReadoutList.fList[28] != 0x00000000) return kDAQTEST;
746 if (startAfter < kHLT and fReadoutList.fList[29] != 0x00000000) return kHLT;
747 }
748 else
749#endif
750 {
751 if (startAfter < kEMCAL and fReadoutList.fList[28] != 0x00000000) return kEMCAL;
752 if (startAfter < kDAQTEST and fReadoutList.fList[29] != 0x00000000) return kDAQTEST;
753 if (startAfter < kHLT and fReadoutList.fList[30] != 0x00000000) return kHLT;
754 }
89413559 755 return kNoDetector;
756}
757
758
dce3e5ce 759void AliHLTReadoutList::Print(Option_t* /*option*/) const
760{
761 // Prints the DDLs that will be readout according to this readout list.
762
763 cout << "Readout enabled for DDLs:" << endl;
52647727 764 for (Int_t i = 0; i < AliHLTDAQ::NumberOfDetectors(); i++)
dce3e5ce 765 {
52647727 766 Int_t maxddls = AliHLTDAQ::NumberOfDdls(i);
767 cout << AliHLTDAQ::DetectorName(i) << ":";
dce3e5ce 768 bool nonefound = true;
769 for (Int_t j = 0; j < maxddls; j++)
770 {
52647727 771 Int_t ddlId = ( ((i == AliHLTDAQ::NumberOfDetectors()-1) ? 30 : i) << 8 ) + j;
dce3e5ce 772 if (GetDDLBit(ddlId))
773 {
774 cout << " " << ddlId;
775 nonefound = false;
776 }
777 }
778 if (nonefound) cout << " none";
779 cout << endl;
780 }
781}
782
783
784AliHLTReadoutList& AliHLTReadoutList::operator = (const AliHLTReadoutList& list)
785{
786 // Assignment operator performs a deep copy.
787
788 TObject::operator = (list);
789 if (&list != this)
790 {
489fb1d7 791 if (list.fReadoutList.fCount == (unsigned)gkAliHLTDDLListSize)
792 {
793 memcpy(&fReadoutList, &list.fReadoutList, sizeof(fReadoutList));
794 }
795 else
796 {
797 FillStruct(list);
798 }
dce3e5ce 799 }
800 return *this;
801}
802
803
804AliHLTReadoutList& AliHLTReadoutList::operator |= (const AliHLTReadoutList& list)
805{
806 // This operator performs a bitwise inclusive or operation on all DDL bits.
807 // See header file for more details.
e5339167 808 this->OrEq(list);
809 return *this;
810}
811
812AliHLTReadoutList& AliHLTReadoutList::OrEq(const AliHLTReadoutList& list)
813{
814 // a bitwise inclusive or operation on all DDL bits.
815 // See header file for more details.
dce3e5ce 816
15ede44e 817 assert( fReadoutList.fCount == (unsigned)gkAliHLTDDLListSize );
7cd66daa 818 assert( fReadoutList.fCount == list.fReadoutList.fCount );
dce3e5ce 819 for (Int_t i = 0; i < gkAliHLTDDLListSize; i++)
820 {
821 fReadoutList.fList[i] |= list.fReadoutList.fList[i];
822 }
823 return *this;
824}
825
826
827AliHLTReadoutList& AliHLTReadoutList::operator ^= (const AliHLTReadoutList& list)
828{
829 // This operator performs a bitwise exclusive or (xor) operation on all DDL bits.
830 // See header file for more details.
e5339167 831
832 this->XorEq(list);
833 return *this;
834}
835
836AliHLTReadoutList& AliHLTReadoutList::XorEq(const AliHLTReadoutList& list)
837{
838 // bitwise exclusive or (xor) operation on all DDL bits.
839 // See header file for more details.
dce3e5ce 840
15ede44e 841 assert( fReadoutList.fCount == (unsigned)gkAliHLTDDLListSize );
7cd66daa 842 assert( fReadoutList.fCount == list.fReadoutList.fCount );
dce3e5ce 843 for (Int_t i = 0; i < gkAliHLTDDLListSize; i++)
844 {
845 fReadoutList.fList[i] ^= list.fReadoutList.fList[i];
846 }
847 return *this;
848}
849
850
851AliHLTReadoutList& AliHLTReadoutList::operator &= (const AliHLTReadoutList& list)
852{
853 // This operator performs a bitwise and operation on all DDL bits.
854 // See header file for more details.
e5339167 855
856 this->AndEq(list);
857 return *this;
858}
859
860AliHLTReadoutList& AliHLTReadoutList::AndEq(const AliHLTReadoutList& list)
861{
862 // bitwise and operation on all DDL bits.
863 // See header file for more details.
864
15ede44e 865 assert( fReadoutList.fCount == (unsigned)gkAliHLTDDLListSize );
7cd66daa 866 assert( fReadoutList.fCount == list.fReadoutList.fCount );
dce3e5ce 867 for (Int_t i = 0; i < gkAliHLTDDLListSize; i++)
868 {
869 fReadoutList.fList[i] &= list.fReadoutList.fList[i];
870 }
871 return *this;
872}
873
dce3e5ce 874AliHLTReadoutList& AliHLTReadoutList::operator -= (const AliHLTReadoutList& list)
875{
876 // This operator removes all the DDLs specified in list from this readout list.
877 // See header file for more details.
878
15ede44e 879 assert( fReadoutList.fCount == (unsigned)gkAliHLTDDLListSize );
7cd66daa 880 assert( fReadoutList.fCount == list.fReadoutList.fCount );
dce3e5ce 881 for (Int_t i = 0; i < gkAliHLTDDLListSize; i++)
882 {
883 // Effectively apply: this = this & (~ (this & list))
884 // i.e. this = this & (this ^ list)
885 fReadoutList.fList[i] &= fReadoutList.fList[i] ^ list.fReadoutList.fList[i];
886 }
887 return *this;
888}
889
890
891AliHLTReadoutList AliHLTReadoutList::operator ~ () const
892{
893 // This operator performs a bitwise ones compliment on all DDL bits.
894 // See header file for more details.
895
896 AliHLTReadoutList readoutlist;
489fb1d7 897 readoutlist.fReadoutList.fCount = gkAliHLTDDLListSize;
dce3e5ce 898 readoutlist.fReadoutList.fList[0] = 0x000FFFFF & (~fReadoutList.fList[0]);
899 readoutlist.fReadoutList.fList[1] = 0x00FFFFFF & (~fReadoutList.fList[1]);
900 readoutlist.fReadoutList.fList[2] = 0x0000FFFF & (~fReadoutList.fList[2]);
901 readoutlist.fReadoutList.fList[3] = 0xFFFFFFFF & (~fReadoutList.fList[3]);
902 readoutlist.fReadoutList.fList[4] = 0xFFFFFFFF & (~fReadoutList.fList[4]);
903 readoutlist.fReadoutList.fList[5] = 0xFFFFFFFF & (~fReadoutList.fList[5]);
904 readoutlist.fReadoutList.fList[6] = 0xFFFFFFFF & (~fReadoutList.fList[6]);
905 readoutlist.fReadoutList.fList[7] = 0xFFFFFFFF & (~fReadoutList.fList[7]);
906 readoutlist.fReadoutList.fList[8] = 0xFFFFFFFF & (~fReadoutList.fList[8]);
907 readoutlist.fReadoutList.fList[9] = 0x00FFFFFF & (~fReadoutList.fList[9]);
908 readoutlist.fReadoutList.fList[10] = 0x00000000 & (~fReadoutList.fList[10]);
909 readoutlist.fReadoutList.fList[11] = 0x0003FFFF & (~fReadoutList.fList[11]);
910 readoutlist.fReadoutList.fList[12] = 0xFFFFFFFF & (~fReadoutList.fList[12]);
911 readoutlist.fReadoutList.fList[13] = 0xFFFFFFFF & (~fReadoutList.fList[13]);
912 readoutlist.fReadoutList.fList[14] = 0x000000FF & (~fReadoutList.fList[14]);
14da6b98 913 readoutlist.fReadoutList.fList[15] = 0x000FFFFF & (~fReadoutList.fList[15]);
dce3e5ce 914 readoutlist.fReadoutList.fList[16] = 0x000FFFFF & (~fReadoutList.fList[16]);
915 readoutlist.fReadoutList.fList[17] = 0x000003FF & (~fReadoutList.fList[17]);
916 readoutlist.fReadoutList.fList[18] = 0x0000003F & (~fReadoutList.fList[18]);
917 readoutlist.fReadoutList.fList[19] = 0x000FFFFF & (~fReadoutList.fList[19]);
918 readoutlist.fReadoutList.fList[20] = 0x00000003 & (~fReadoutList.fList[20]);
919 readoutlist.fReadoutList.fList[21] = 0x00000007 & (~fReadoutList.fList[21]);
920 readoutlist.fReadoutList.fList[22] = 0x00000001 & (~fReadoutList.fList[22]);
921 readoutlist.fReadoutList.fList[23] = 0x00000001 & (~fReadoutList.fList[23]);
922 readoutlist.fReadoutList.fList[24] = 0x00000001 & (~fReadoutList.fList[24]);
923 readoutlist.fReadoutList.fList[25] = 0x00000001 & (~fReadoutList.fList[25]);
924 readoutlist.fReadoutList.fList[26] = 0x00000001 & (~fReadoutList.fList[26]);
489fb1d7 925#if 1 // ROOT_SVN_REVISION < 9999 //FIXME: after fixed https://savannah.cern.ch/bugs/?69241
926 // Check if we need to convert to new format and do so.
927 if (fReadoutList.fCount == (unsigned)gkAliHLTDDLListSizeV0)
928 {
929 readoutlist.fReadoutList.fList[27] = 0x00FFFFFF & (~fReadoutList.fList[27]);
930 readoutlist.fReadoutList.fList[28] = 0x00000000;
931 readoutlist.fReadoutList.fList[29] = 0x00000001 & (~fReadoutList.fList[28]);
932 readoutlist.fReadoutList.fList[30] = 0x000003FF & (~fReadoutList.fList[29]);
933 }
934 else
935#endif
936 {
937 readoutlist.fReadoutList.fList[27] = 0xFFFFFFFF & (~fReadoutList.fList[27]);
938 readoutlist.fReadoutList.fList[28] = 0x00003FFF & (~fReadoutList.fList[28]);
939 readoutlist.fReadoutList.fList[29] = 0x00000001 & (~fReadoutList.fList[29]);
940 readoutlist.fReadoutList.fList[30] = 0x000003FF & (~fReadoutList.fList[30]);
941 }
dce3e5ce 942 return readoutlist;
943}
944
489fb1d7 945#if ROOT_VERSION_CODE < ROOT_VERSION(5,26,0)
946void AliHLTReadoutList::Streamer(TBuffer &R__b)
947{
948 // Stream an object of class AliHLTReadoutList.
949
950 if (R__b.IsReading()) {
951 R__b.ReadClassBuffer(AliHLTReadoutList::Class(),this);
952 // Convert old structure to new version if necessary.
953 if (fReadoutList.fCount == (unsigned)gkAliHLTDDLListSizeV0)
954 {
955 fReadoutList.fList[30] = fReadoutList.fList[29];
956 fReadoutList.fList[29] = fReadoutList.fList[28];
957 fReadoutList.fList[28] = 0x0;
958 fReadoutList.fCount = gkAliHLTDDLListSizeV1;
959 }
960 } else {
961 R__b.WriteClassBuffer(AliHLTReadoutList::Class(),this);
962 }
963}
964#endif // ROOT version check.