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