]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - HLT/BASE/AliHLTReadoutList.cxx
ALIROOT-5433 Transition to CDHv3 in HLT
[u/mrichter/AliRoot.git] / HLT / BASE / AliHLTReadoutList.cxx
index 08545c1e8661b9a84fe253f2981c58e49c36ecf0..31110373432ae5e2311205af7fba8511c8406cab 100644 (file)
 ClassImp(AliHLTReadoutList)
 
 
+const char* AliHLTReadoutList::DetectorIdToString(EDetectorId id)
+{
+  // Converts a detector ID to a user readable string.
+  switch (id)
+  {
+  case kNoDetector: return "kNoDetector";
+  case kITSSPD:  return "kITSSPD";
+  case kITSSDD:  return "kITSSDD";
+  case kITSSSD:  return "kITSSSD";
+  case kTPC:     return "kTPC";
+  case kTRD:     return "kTRD";
+  case kTOF:     return "kTOF";
+  case kHMPID:   return "kHMPID";
+  case kPHOS:    return "kPHOS";
+  case kCPV:     return "kCPV";
+  case kPMD:     return "kPMD";
+  case kMUONTRK: return "kMUONTRK";
+  case kMUONTRG: return "kMUONTRG";
+  case kFMD:     return "kFMD";
+  case kT0:      return "kT0";
+  case kV0:      return "kV0";
+  case kZDC:     return "kZDC";
+  case kACORDE:  return "kACORDE";
+  case kTRG:     return "kTRG";
+  case kEMCAL:   return "kEMCAL";
+  case kDAQTEST: return "kDAQTEST";
+  case kHLT:     return "kHLT";
+  case kALLDET:  return "kALLDET";
+  default:       return "UNKNOWN!";
+  }
+}
+
+
 AliHLTReadoutList::AliHLTReadoutList() :
         TNamed("AliHLTReadoutList", "Readout list object used for manipulating and storing an AliHLTEventDDL structure."),
        fReadoutList()
@@ -77,30 +110,6 @@ AliHLTReadoutList::AliHLTReadoutList(const char* enabledList) :
   TString str(enabledList);
   str.ToUpper();
   Int_t enabledDetectors = 0;
-  if (str.Contains("ITSSPD")) enabledDetectors |= kITSSPD;
-  if (str.Contains("ITSSDD")) enabledDetectors |= kITSSDD;
-  if (str.Contains("ITSSSD")) enabledDetectors |= kITSSSD;
-  if (str.Contains("TPC")) enabledDetectors |= kTPC;
-  if (str.Contains("TRD")) enabledDetectors |= kTRD;
-  if (str.Contains("TOF")) enabledDetectors |= kTOF;
-  if (str.Contains("HMPID")) enabledDetectors |= kHMPID;
-  if (str.Contains("PHOS")) enabledDetectors |= kPHOS;
-  if (str.Contains("CPV")) enabledDetectors |= kCPV;
-  if (str.Contains("PMD")) enabledDetectors |= kPMD;
-  if (str.Contains("MUONTRK")) enabledDetectors |= kMUONTRK;
-  if (str.Contains("MUONTRG")) enabledDetectors |= kMUONTRG;
-  if (str.Contains("FMD")) enabledDetectors |= kFMD;
-  if (str.Contains("T0")) enabledDetectors |= kT0;
-  if (str.Contains("V0")) enabledDetectors |= kV0;
-  if (str.Contains("ZDC")) enabledDetectors |= kZDC;
-  if (str.Contains("ACORDE")) enabledDetectors |= kACORDE;
-  if (str.Contains("TRG")) enabledDetectors |= kTRG;
-  if (str.Contains("EMCAL")) enabledDetectors |= kEMCAL;
-  if (str.Contains("DAQTEST")) enabledDetectors |= kDAQTEST;
-  if (str.Contains("HLT")) enabledDetectors |= kHLT;
-  if (str.Contains("ALL")) enabledDetectors |= kALLDET;
-  Enable(enabledDetectors);
-  
   TObjArray* list = str.Tokenize(" ");
   TIter next(list);
   const TObjString* objstr = NULL;
@@ -108,8 +117,31 @@ AliHLTReadoutList::AliHLTReadoutList(const char* enabledList) :
   {
     str = objstr->GetString();
     if (str.IsDigit()) EnableDDLBit(str.Atoi());
+    if (str == "ITSSPD") enabledDetectors |= kITSSPD;
+    if (str == "ITSSDD") enabledDetectors |= kITSSDD;
+    if (str == "ITSSSD") enabledDetectors |= kITSSSD;
+    if (str == "TPC") enabledDetectors |= kTPC;
+    if (str == "TRD") enabledDetectors |= kTRD;
+    if (str == "TOF") enabledDetectors |= kTOF;
+    if (str == "HMPID") enabledDetectors |= kHMPID;
+    if (str == "PHOS") enabledDetectors |= kPHOS;
+    if (str == "CPV") enabledDetectors |= kCPV;
+    if (str == "PMD") enabledDetectors |= kPMD;
+    if (str == "MUONTRK") enabledDetectors |= kMUONTRK;
+    if (str == "MUONTRG") enabledDetectors |= kMUONTRG;
+    if (str == "FMD") enabledDetectors |= kFMD;
+    if (str == "T0") enabledDetectors |= kT0;
+    if (str == "V0") enabledDetectors |= kV0;
+    if (str == "ZDC") enabledDetectors |= kZDC;
+    if (str == "ACORDE") enabledDetectors |= kACORDE;
+    if (str == "TRG") enabledDetectors |= kTRG;
+    if (str == "EMCAL") enabledDetectors |= kEMCAL;
+    if (str == "DAQTEST") enabledDetectors |= kDAQTEST;
+    if (str == "HLT") enabledDetectors |= kHLT;
+    if (str == "ALL") enabledDetectors |= kALLDET;
   }
   delete list;
+  Enable(enabledDetectors);
 }
 
 
@@ -119,10 +151,7 @@ AliHLTReadoutList::AliHLTReadoutList(const AliHLTEventDDL& list) :
 {
   // Constructor to create readout list from AliHLTEventDDL structure.
   // See header file for more details.
-  memset(&fReadoutList, 0, sizeof(fReadoutList));
-  // handle lists of different sizes, copy only the overlapping part of the list
-  fReadoutList.fCount=sizeof(fReadoutList.fList)/sizeof(AliHLTUInt32_t);
-  memcpy(&fReadoutList.fList, &list.fList, (fReadoutList.fCount<list.fCount?fReadoutList.fCount:list.fCount)*sizeof(AliHLTUInt32_t));
+  FillStruct(list);
 }
 
 
@@ -132,7 +161,39 @@ AliHLTReadoutList::AliHLTReadoutList(const AliHLTReadoutList& list) :
 {
   // Copy constructor performs a deep copy.
   
-  memcpy(&fReadoutList, &list.fReadoutList, sizeof(fReadoutList));
+  if (list.fReadoutList.fCount == (unsigned)gkAliHLTDDLListSize)
+  {
+    memcpy(&fReadoutList, &list.fReadoutList, sizeof(fReadoutList));
+  }
+  else
+  {
+    FillStruct(list);
+  }
+}
+
+
+void AliHLTReadoutList::FillStruct(const AliHLTEventDDL& list)
+{
+  // Fills internal DDL bits structure.
+
+  fReadoutList.fCount = gkAliHLTDDLListSize;  // Required by ALICE-INT-2007-015
+  memset(fReadoutList.fList, 0x0, sizeof(fReadoutList.fList));
+  // Handle lists of different sizes. If the size is for a known version
+  // of AliHLTEventDDL then handle appropriately, otherwise just copy only
+  // the overlapping part of the list.
+  if (list.fCount == (unsigned)gkAliHLTDDLListSizeV0)
+  {
+    memcpy(&fReadoutList.fList[0], &list.fList[0], sizeof(AliHLTUInt32_t)*28);
+    memcpy(&fReadoutList.fList[29], &list.fList[28], sizeof(AliHLTUInt32_t)*2);
+  }
+  else if (list.fCount == (unsigned)gkAliHLTDDLListSizeV1)
+  {
+    memcpy(&fReadoutList, &list, sizeof(AliHLTEventDDL));
+  }
+  else
+  {
+    memcpy(&fReadoutList.fList, &list.fList, (fReadoutList.fCount<list.fCount?fReadoutList.fCount:list.fCount)*sizeof(AliHLTUInt32_t));
+  }
 }
 
 
@@ -158,6 +219,14 @@ void AliHLTReadoutList::Clear(Option_t* /*option*/)
 {
   // Resets all the DDL readout bits.
   memset(fReadoutList.fList, 0x0, sizeof(fReadoutList.fList));
+
+#if 1 // ROOT_SVN_REVISION < 9999  //FIXME: after fixed https://savannah.cern.ch/bugs/?69241
+  // Check if we need to convert to new format and do so.
+  if (fReadoutList.fCount == (unsigned)gkAliHLTDDLListSizeV0)
+  {
+    fReadoutList.fCount = gkAliHLTDDLListSize;
+  }
+#endif
 }
 
 
@@ -170,42 +239,69 @@ bool AliHLTReadoutList::DecodeDDLID(Int_t ddlId, Int_t& wordIndex, Int_t& bitInd
   Int_t detNum = ddlId >> 8;
   Int_t ddlNum = ddlId & 0xFF;
   
-  if (detNum < 3)
+  switch (detNum)
   {
+  case 0: // SPD
+  case 1: // SDD
+  case 2: // SSD
+    if (ddlNum >= 32) return false; // only have 1 32-bit word.
     // the 3 ITS detectors have one word each
     wordIndex = detNum;
-  }
-  else if (detNum == 3)
-  {
+    break;
+  case 3: // TPC
     // the TPC bitfield has in total 8 words
     wordIndex = detNum + (ddlNum >> 5);
-  }
-  else if (detNum == 4)
-  {
-    // the TRD bitfield starts at position 11 (3 ITS + 8 TPC)
-    wordIndex = detNum + 7;
-  }
-  else if (detNum == 5)
-  {
+    break;
+  case 4: // TRD
+    if (ddlNum >= 32) return false; // only have 1 32-bit word.
+    // the TRD bitfield starts at word 11 (3 words ITS + 8 words TPC)
+    wordIndex = 11;
+    break;
+  case 5: // TOF
+    if (ddlNum >= 3*32) return false; // only have 3 32-bit words.
     // TOF has 72 DDLs, the bitfield is 3 words starting at position 12
-    wordIndex = detNum + 7 + (ddlNum >> 5);
-  }
-  else if (detNum == 30)
-  {
-    // the HLT bitfield is in the last word 
-    wordIndex = 29;
-  }
-  else
-  {
-    // all other detectors fit into one word, the offset is due to
+    wordIndex = 12 + (ddlNum >> 5);
+    break;
+  case 6: // HMPID
+  case 7: // PHOS
+  case 8: // CPV
+  case 9: // PMD
+  case 10: // MUONTRK (MCH)
+  case 11: // MUONTRG (MTR)
+  case 12: // FMD
+  case 13: // T0
+  case 14: // V0
+  case 15: // ZDC
+  case 16: // ACORDE
+  case 17: // TRG
+    if (ddlNum >= 32) return false; // only have 1 32-bit word.
+    // all these detectors fit into one word, the offset is due to
     // TPC and TOF
     wordIndex = detNum + 9;
+    break;
+  case 18: // EMCAL
+    if (ddlNum >= 2*32) return false; // only have 2 32-bit words.
+    // 2 words for EMCAL + DCAL
+    wordIndex = detNum + 7;
+    wordIndex = 27 + (ddlNum >> 5);
+    break;
+  case 19: // DAQTEST
+    if (ddlNum >= 32) return false; // only have 1 32-bit word.
+    wordIndex = 29;
+    break;
+  case 30: // HLT
+    if (ddlNum >= 32) return false; // only have 1 32-bit word.
+    // the HLT bitfield is in the last word
+    wordIndex = 30;
+    break;
+  default:
+    return false;
   }
   
-  if (wordIndex < 0 or gkAliHLTDDLListSize <= wordIndex) return false;
+  if (ddlNum >= AliHLTDAQ::NumberOfDdls(detNum == 30 ? 20 : detNum)) return false;
   
   // The bit index within the word indicated by wordIndex.
-  bitIndex = (ddlId & 0xFF) % 32;
+  bitIndex = ddlNum % 32;
   return true;
 }
 
@@ -217,6 +313,26 @@ Bool_t AliHLTReadoutList::GetDDLBit(Int_t ddlId) const
   
   Int_t wordIndex, bitIndex;
   if (! DecodeDDLID(ddlId, wordIndex, bitIndex)) return kFALSE;
+
+#if 1 // ROOT_SVN_REVISION < 9999  //FIXME: after fixed https://savannah.cern.ch/bugs/?69241
+  // Check if we need to convert to new format and do so.
+  if (fReadoutList.fCount == (unsigned)gkAliHLTDDLListSizeV0)
+  {
+    if (wordIndex == 27)
+    {
+      if (bitIndex >= 24) return kFALSE;
+    }
+    else if (wordIndex == 28)
+    {
+      return kFALSE;
+    }
+    else if (wordIndex > 28)
+    {
+      --wordIndex;
+    }
+  }
+#endif
+
   return ((fReadoutList.fList[wordIndex] >> bitIndex) & 0x1) == 0x1;
 }
 
@@ -225,6 +341,16 @@ void AliHLTReadoutList::SetDDLBit(Int_t ddlId, Bool_t state)
 {
   // Sets the bit value for a particular DDL in the readout list.
   // See header file for more details.
+
+#if 1 // ROOT_SVN_REVISION < 9999  //FIXME: after fixed https://savannah.cern.ch/bugs/?69241
+  // Check if we need to convert to new format and do so.
+  if (fReadoutList.fCount == (unsigned)gkAliHLTDDLListSizeV0)
+  {
+    AliHLTEventDDL copy = fReadoutList;
+    FillStruct(copy);
+  }
+#endif
+  assert(fReadoutList.fCount == gkAliHLTDDLListSize);
   
   Int_t wordIndex, bitIndex;
   if (! DecodeDDLID(ddlId, wordIndex, bitIndex)) return;
@@ -242,6 +368,16 @@ void AliHLTReadoutList::Enable(Int_t detector)
 {
   // Enables all DDLs for a particular detector or detectors.
   // See header file for more details.
+
+#if 1 // ROOT_SVN_REVISION < 9999  //FIXME: after fixed https://savannah.cern.ch/bugs/?69241
+  // Check if we need to convert to new format and do so.
+  if (fReadoutList.fCount == (unsigned)gkAliHLTDDLListSizeV0)
+  {
+    AliHLTEventDDL copy = fReadoutList;
+    FillStruct(copy);
+  }
+#endif
+  assert(fReadoutList.fCount == gkAliHLTDDLListSize);
   
   if ((detector & kITSSPD) != 0) fReadoutList.fList[0] = 0x000FFFFF;
   if ((detector & kITSSDD) != 0) fReadoutList.fList[1] = 0x00FFFFFF;
@@ -264,7 +400,7 @@ void AliHLTReadoutList::Enable(Int_t detector)
     fReadoutList.fList[13] = 0xFFFFFFFF;
     fReadoutList.fList[14] = 0x000000FF;
   }
-  if ((detector & kHMPID) != 0) fReadoutList.fList[15] = 0x00003FFF;
+  if ((detector & kHMPID) != 0) fReadoutList.fList[15] = 0x000FFFFF;
   if ((detector & kPHOS) != 0) fReadoutList.fList[16] = 0x000FFFFF;
   if ((detector & kCPV) != 0) fReadoutList.fList[17] = 0x000003FF;
   if ((detector & kPMD) != 0) fReadoutList.fList[18] = 0x0000003F;
@@ -276,9 +412,13 @@ void AliHLTReadoutList::Enable(Int_t detector)
   if ((detector & kZDC) != 0) fReadoutList.fList[24] = 0x00000001;
   if ((detector & kACORDE) != 0) fReadoutList.fList[25] = 0x00000001;
   if ((detector & kTRG) != 0) fReadoutList.fList[26] = 0x00000001;
-  if ((detector & kEMCAL) != 0) fReadoutList.fList[27] = 0x00FFFFFF;
-  if ((detector & kDAQTEST) != 0) fReadoutList.fList[28] = 0x00000001;
-  if ((detector & kHLT) != 0) fReadoutList.fList[29] = 0x000003FF;
+  if ((detector & kEMCAL) != 0)
+  {
+    fReadoutList.fList[27] = 0xFFFFFFFF;
+    fReadoutList.fList[28] = 0x00003FFF;
+  }
+  if ((detector & kDAQTEST) != 0) fReadoutList.fList[29] = 0x00000001;
+  if ((detector & kHLT) != 0) fReadoutList.fList[30] = 0x0FFFFFFF;
 }
 
 
@@ -286,6 +426,16 @@ void AliHLTReadoutList::Disable(Int_t detector)
 {
   // Disables all DDLs for a particular detector or detectors.
   // See header file for more details.
+
+#if 1 // ROOT_SVN_REVISION < 9999  //FIXME: after fixed https://savannah.cern.ch/bugs/?69241
+  // Check if we need to convert to new format and do so.
+  if (fReadoutList.fCount == (unsigned)gkAliHLTDDLListSizeV0)
+  {
+    AliHLTEventDDL copy = fReadoutList;
+    FillStruct(copy);
+  }
+#endif
+  assert(fReadoutList.fCount == gkAliHLTDDLListSize);
   
   if ((detector & kITSSPD) != 0) fReadoutList.fList[0] = 0x00000000;
   if ((detector & kITSSDD) != 0) fReadoutList.fList[1] = 0x00000000;
@@ -320,9 +470,13 @@ void AliHLTReadoutList::Disable(Int_t detector)
   if ((detector & kZDC) != 0) fReadoutList.fList[24] = 0x00000000;
   if ((detector & kACORDE) != 0) fReadoutList.fList[25] = 0x00000000;
   if ((detector & kTRG) != 0) fReadoutList.fList[26] = 0x00000000;
-  if ((detector & kEMCAL) != 0) fReadoutList.fList[27] = 0x00000000;
-  if ((detector & kDAQTEST) != 0) fReadoutList.fList[28] = 0x00000000;
-  if ((detector & kHLT) != 0) fReadoutList.fList[29] = 0x00000000;
+  if ((detector & kEMCAL) != 0)
+  {
+    fReadoutList.fList[27] = 0x00000000;
+    fReadoutList.fList[28] = 0x00000000;
+  }
+  if ((detector & kDAQTEST) != 0) fReadoutList.fList[29] = 0x00000000;
+  if ((detector & kHLT) != 0) fReadoutList.fList[30] = 0x00000000;
 }
 
 
@@ -352,7 +506,7 @@ bool AliHLTReadoutList::DetectorEnabled(Int_t detector) const
     result &= fReadoutList.fList[13] == 0xFFFFFFFF;
     result &= fReadoutList.fList[14] == 0x000000FF;
   }
-  if ((detector & kHMPID) != 0) result &= fReadoutList.fList[15] == 0x00003FFF;
+  if ((detector & kHMPID) != 0) result &= fReadoutList.fList[15] == 0x000FFFFF;
   if ((detector & kPHOS) != 0) result &= fReadoutList.fList[16] == 0x000FFFFF;
   if ((detector & kCPV) != 0) result &= fReadoutList.fList[17] == 0x000003FF;
   if ((detector & kPMD) != 0) result &= fReadoutList.fList[18] == 0x0000003F;
@@ -364,14 +518,243 @@ bool AliHLTReadoutList::DetectorEnabled(Int_t detector) const
   if ((detector & kZDC) != 0) result &= fReadoutList.fList[24] == 0x00000001;
   if ((detector & kACORDE) != 0) result &= fReadoutList.fList[25] == 0x00000001;
   if ((detector & kTRG) != 0) result &= fReadoutList.fList[26] == 0x00000001;
-  if ((detector & kEMCAL) != 0) result &= fReadoutList.fList[27] == 0x00FFFFFF;
-  if ((detector & kDAQTEST) != 0) result &= fReadoutList.fList[28] == 0x00000001;
-  if ((detector & kHLT) != 0) result &= fReadoutList.fList[29] == 0x000003FF;
+#if 1 // ROOT_SVN_REVISION < 9999  //FIXME: after fixed https://savannah.cern.ch/bugs/?69241
+  if (fReadoutList.fCount == (unsigned)gkAliHLTDDLListSizeV0)
+  {
+    if ((detector & kEMCAL) != 0) result &= fReadoutList.fList[27] == 0x00FFFFFF;
+    if ((detector & kDAQTEST) != 0) result &= fReadoutList.fList[28] == 0x00000001;
+    if ((detector & kHLT) != 0) result &= fReadoutList.fList[29] == 0x000003FF;
+  }
+  else
+#endif
+  {
+    if ((detector & kEMCAL) != 0)
+    {
+      result &= fReadoutList.fList[27] == 0xFFFFFFFF;
+      result &= fReadoutList.fList[28] == 0x00003FFF;
+    }
+    if ((detector & kDAQTEST) != 0) result &= fReadoutList.fList[29] == 0x00000001;
+    if ((detector & kHLT) != 0) result &= fReadoutList.fList[30] == 0x0FFFFFFF;
+  }
+  
+  return result;
+}
+
+
+bool AliHLTReadoutList::DetectorDisabled(Int_t detector) const
+{
+  // Checks if a particular detector's DDLs are disabled.
+  // See header file for more details.
+  
+  bool result = true;
+  if ((detector & kITSSPD) != 0) result &= fReadoutList.fList[0] == 0x00000000;
+  if ((detector & kITSSDD) != 0) result &= fReadoutList.fList[1] == 0x00000000;
+  if ((detector & kITSSSD) != 0) result &= fReadoutList.fList[2] == 0x00000000;
+  if ((detector & kTPC) != 0)
+  {
+    result &= fReadoutList.fList[3] == 0x00000000;
+    result &= fReadoutList.fList[4] == 0x00000000;
+    result &= fReadoutList.fList[5] == 0x00000000;
+    result &= fReadoutList.fList[6] == 0x00000000;
+    result &= fReadoutList.fList[7] == 0x00000000;
+    result &= fReadoutList.fList[8] == 0x00000000;
+    result &= fReadoutList.fList[9] == 0x00000000;
+  }
+  if ((detector & kTRD) != 0) result &= fReadoutList.fList[11] == 0x00000000;
+  if ((detector & kTOF) != 0)
+  {
+    result &= fReadoutList.fList[12] == 0x00000000;
+    result &= fReadoutList.fList[13] == 0x00000000;
+    result &= fReadoutList.fList[14] == 0x00000000;
+  }
+  if ((detector & kHMPID) != 0) result &= fReadoutList.fList[15] == 0x00000000;
+  if ((detector & kPHOS) != 0) result &= fReadoutList.fList[16] == 0x00000000;
+  if ((detector & kCPV) != 0) result &= fReadoutList.fList[17] == 0x00000000;
+  if ((detector & kPMD) != 0) result &= fReadoutList.fList[18] == 0x00000000;
+  if ((detector & kMUONTRK) != 0) result &= fReadoutList.fList[19] == 0x00000000;
+  if ((detector & kMUONTRG) != 0) result &= fReadoutList.fList[20] == 0x00000000;
+  if ((detector & kFMD) != 0) result &= fReadoutList.fList[21] == 0x00000000;
+  if ((detector & kT0) != 0) result &= fReadoutList.fList[22] == 0x00000000;
+  if ((detector & kV0) != 0) result &= fReadoutList.fList[23] == 0x00000000;
+  if ((detector & kZDC) != 0) result &= fReadoutList.fList[24] == 0x00000000;
+  if ((detector & kACORDE) != 0) result &= fReadoutList.fList[25] == 0x00000000;
+  if ((detector & kTRG) != 0) result &= fReadoutList.fList[26] == 0x00000000;
+#if 1 // ROOT_SVN_REVISION < 9999  //FIXME: after fixed https://savannah.cern.ch/bugs/?69241
+  if (fReadoutList.fCount == (unsigned)gkAliHLTDDLListSizeV0)
+  {
+    if ((detector & kEMCAL) != 0) result &= fReadoutList.fList[27] == 0x00000000;
+    if ((detector & kDAQTEST) != 0) result &= fReadoutList.fList[28] == 0x00000000;
+    if ((detector & kHLT) != 0) result &= fReadoutList.fList[29] == 0x00000000;
+  }
+  else
+#endif
+  {
+    if ((detector & kEMCAL) != 0)
+    {
+      result &= fReadoutList.fList[27] == 0x00000000;
+      result &= fReadoutList.fList[28] == 0x00000000;
+    }
+    if ((detector & kDAQTEST) != 0) result &= fReadoutList.fList[29] == 0x00000000;
+    if ((detector & kHLT) != 0) result &= fReadoutList.fList[30] == 0x00000000;
+  }
   
   return result;
 }
 
 
+Int_t AliHLTReadoutList::GetFirstWord(EDetectorId detector)
+{
+  // See header file for more details.
+  switch (detector)
+  {
+  case kITSSPD:  return 0;
+  case kITSSDD:  return 1;
+  case kITSSSD:  return 2;
+  case kTPC:     return 3;
+  case kTRD:     return 11;
+  case kTOF:     return 12;
+  case kHMPID:   return 15;
+  case kPHOS:    return 16;
+  case kCPV:     return 17;
+  case kPMD:     return 18;
+  case kMUONTRK: return 19;
+  case kMUONTRG: return 20;
+  case kFMD:     return 21;
+  case kT0:      return 22;
+  case kV0:      return 23;
+  case kZDC:     return 24;
+  case kACORDE:  return 25;
+  case kTRG:     return 26;
+  case kEMCAL:   return 27;
+  case kDAQTEST: return 29;
+  case kHLT:     return 30;
+  default:       return -1;
+  }
+}
+
+
+Int_t AliHLTReadoutList::GetWordCount(EDetectorId detector)
+{
+  // See header file for more details.
+  switch (detector)
+  {
+  case kITSSPD:  return 1;
+  case kITSSDD:  return 1;
+  case kITSSSD:  return 1;
+  case kTPC:     return 8;
+  case kTRD:     return 1;
+  case kTOF:     return 3;
+  case kHMPID:   return 1;
+  case kPHOS:    return 1;
+  case kCPV:     return 1;
+  case kPMD:     return 1;
+  case kMUONTRK: return 1;
+  case kMUONTRG: return 1;
+  case kFMD:     return 1;
+  case kT0:      return 1;
+  case kV0:      return 1;
+  case kZDC:     return 1;
+  case kACORDE:  return 1;
+  case kTRG:     return 1;
+  case kEMCAL:   return 2;
+  case kDAQTEST: return 1;
+  case kHLT:     return 1;
+  default:       return 0;
+  }
+}
+
+
+AliHLTReadoutList::EDetectorId AliHLTReadoutList::GetDetectorFromWord(Int_t wordindex)
+{
+  // See header file for more details.
+  switch (wordindex)
+  {
+  case 0: return kITSSPD;
+  case 1: return kITSSDD;
+  case 2: return kITSSSD;
+  case 3: return kTPC;
+  case 4: return kTPC;
+  case 5: return kTPC;
+  case 6: return kTPC;
+  case 7: return kTPC;
+  case 8: return kTPC;
+  case 9: return kTPC;
+  case 10: return kTPC;
+  case 11: return kTRD;
+  case 12: return kTOF;
+  case 13: return kTOF;
+  case 14: return kTOF;
+  case 15: return kHMPID;
+  case 16: return kPHOS;
+  case 17: return kCPV;
+  case 18: return kPMD;
+  case 19: return kMUONTRK;
+  case 20: return kMUONTRG;
+  case 21: return kFMD;
+  case 22: return kT0;
+  case 23: return kV0;
+  case 24: return kZDC;
+  case 25: return kACORDE;
+  case 26: return kTRG;
+  case 27: return kEMCAL;
+  case 28: return kEMCAL;
+  case 29: return kDAQTEST;
+  case 30: return kHLT;
+  default: return kNoDetector;
+  }
+}
+
+
+AliHLTReadoutList::EDetectorId AliHLTReadoutList::GetFirstUsedDetector(EDetectorId startAfter) const
+{
+  // See header file for more details.
+
+  if (startAfter < kITSSPD and fReadoutList.fList[0] != 0x00000000) return kITSSPD;
+  if (startAfter < kITSSDD and fReadoutList.fList[1] != 0x00000000) return kITSSDD;
+  if (startAfter < kITSSSD and fReadoutList.fList[2] != 0x00000000) return kITSSSD;
+  if (startAfter < kTPC and fReadoutList.fList[3] != 0x00000000) return kTPC;
+  if (startAfter < kTPC and fReadoutList.fList[4] != 0x00000000) return kTPC;
+  if (startAfter < kTPC and fReadoutList.fList[5] != 0x00000000) return kTPC;
+  if (startAfter < kTPC and fReadoutList.fList[6] != 0x00000000) return kTPC;
+  if (startAfter < kTPC and fReadoutList.fList[7] != 0x00000000) return kTPC;
+  if (startAfter < kTPC and fReadoutList.fList[8] != 0x00000000) return kTPC;
+  if (startAfter < kTPC and fReadoutList.fList[9] != 0x00000000) return kTPC;
+  if (startAfter < kTPC and fReadoutList.fList[10] != 0x00000000) return kTPC;
+  if (startAfter < kTRD and fReadoutList.fList[11] != 0x00000000) return kTRD;
+  if (startAfter < kTOF and fReadoutList.fList[12] != 0x00000000) return kTOF;
+  if (startAfter < kTOF and fReadoutList.fList[13] != 0x00000000) return kTOF;
+  if (startAfter < kTOF and fReadoutList.fList[14] != 0x00000000) return kTOF;
+  if (startAfter < kHMPID and fReadoutList.fList[15] != 0x00000000) return kHMPID;
+  if (startAfter < kPHOS and fReadoutList.fList[16] != 0x00000000) return kPHOS;
+  if (startAfter < kCPV and fReadoutList.fList[17] != 0x00000000) return kCPV;
+  if (startAfter < kPMD and fReadoutList.fList[18] != 0x00000000) return kPMD;
+  if (startAfter < kMUONTRK and fReadoutList.fList[19] != 0x00000000) return kMUONTRK;
+  if (startAfter < kMUONTRG and fReadoutList.fList[20] != 0x00000000) return kMUONTRG;
+  if (startAfter < kFMD and fReadoutList.fList[21] != 0x00000000) return kFMD;
+  if (startAfter < kT0 and fReadoutList.fList[22] != 0x00000000) return kT0;
+  if (startAfter < kV0 and fReadoutList.fList[23] != 0x00000000) return kV0;
+  if (startAfter < kZDC and fReadoutList.fList[24] != 0x00000000) return kZDC;
+  if (startAfter < kACORDE and fReadoutList.fList[25] != 0x00000000) return kACORDE;
+  if (startAfter < kTRG and fReadoutList.fList[26] != 0x00000000) return kTRG;
+  if (startAfter < kEMCAL and fReadoutList.fList[27] != 0x00000000) return kEMCAL;
+#if 1 // ROOT_SVN_REVISION < 9999  //FIXME: after fixed https://savannah.cern.ch/bugs/?69241
+  // Check if we need to convert to new format and do so.
+  if (fReadoutList.fCount == (unsigned)gkAliHLTDDLListSizeV0)
+  {
+    if (startAfter < kDAQTEST and fReadoutList.fList[28] != 0x00000000) return kDAQTEST;
+    if (startAfter < kHLT and fReadoutList.fList[29] != 0x00000000) return kHLT;
+  }
+  else
+#endif
+  {
+    if (startAfter < kEMCAL and fReadoutList.fList[28] != 0x00000000) return kEMCAL;
+    if (startAfter < kDAQTEST and fReadoutList.fList[29] != 0x00000000) return kDAQTEST;
+    if (startAfter < kHLT and fReadoutList.fList[30] != 0x00000000) return kHLT;
+  }
+  return kNoDetector;
+}
+
+
 void AliHLTReadoutList::Print(Option_t* /*option*/) const
 {
   // Prints the DDLs that will be readout according to this readout list.
@@ -404,7 +787,14 @@ AliHLTReadoutList& AliHLTReadoutList::operator = (const AliHLTReadoutList& list)
   TObject::operator = (list);
   if (&list != this)
   {
-    memcpy(&fReadoutList, &list.fReadoutList, sizeof(fReadoutList));
+    if (list.fReadoutList.fCount == (unsigned)gkAliHLTDDLListSize)
+    {
+      memcpy(&fReadoutList, &list.fReadoutList, sizeof(fReadoutList));
+    }
+    else
+    {
+      FillStruct(list);
+    }
   }
   return *this;
 }
@@ -414,8 +804,17 @@ AliHLTReadoutList& AliHLTReadoutList::operator |= (const AliHLTReadoutList& list
 {
   // This operator performs a bitwise inclusive or operation on all DDL bits.
   // See header file for more details.
+  this->OrEq(list);
+  return *this;
+}
+
+AliHLTReadoutList& AliHLTReadoutList::OrEq(const AliHLTReadoutList& list)
+{
+  // a bitwise inclusive or operation on all DDL bits.
+  // See header file for more details.
   
   assert( fReadoutList.fCount == (unsigned)gkAliHLTDDLListSize );
+  assert( fReadoutList.fCount == list.fReadoutList.fCount );
   for (Int_t i = 0; i < gkAliHLTDDLListSize; i++)
   {
     fReadoutList.fList[i] |= list.fReadoutList.fList[i];
@@ -428,8 +827,18 @@ AliHLTReadoutList& AliHLTReadoutList::operator ^= (const AliHLTReadoutList& list
 {
   // This operator performs a bitwise exclusive or (xor) operation on all DDL bits.
   // See header file for more details.
+
+  this->XorEq(list);
+  return *this;
+}
+
+AliHLTReadoutList& AliHLTReadoutList::XorEq(const AliHLTReadoutList& list)
+{
+  // bitwise exclusive or (xor) operation on all DDL bits.
+  // See header file for more details.
   
   assert( fReadoutList.fCount == (unsigned)gkAliHLTDDLListSize );
+  assert( fReadoutList.fCount == list.fReadoutList.fCount );
   for (Int_t i = 0; i < gkAliHLTDDLListSize; i++)
   {
     fReadoutList.fList[i] ^= list.fReadoutList.fList[i];
@@ -442,8 +851,18 @@ AliHLTReadoutList& AliHLTReadoutList::operator &= (const AliHLTReadoutList& list
 {
   // This operator performs a bitwise and operation on all DDL bits.
   // See header file for more details.
-  
+
+  this->AndEq(list);
+  return *this;
+}
+
+AliHLTReadoutList& AliHLTReadoutList::AndEq(const AliHLTReadoutList& list)
+{
+  // bitwise and operation on all DDL bits.
+  // See header file for more details.
+
   assert( fReadoutList.fCount == (unsigned)gkAliHLTDDLListSize );
+  assert( fReadoutList.fCount == list.fReadoutList.fCount );
   for (Int_t i = 0; i < gkAliHLTDDLListSize; i++)
   {
     fReadoutList.fList[i] &= list.fReadoutList.fList[i];
@@ -451,13 +870,13 @@ AliHLTReadoutList& AliHLTReadoutList::operator &= (const AliHLTReadoutList& list
   return *this;
 }
 
-
 AliHLTReadoutList& AliHLTReadoutList::operator -= (const AliHLTReadoutList& list)
 {
   // This operator removes all the DDLs specified in list from this readout list.
   // See header file for more details.
   
   assert( fReadoutList.fCount == (unsigned)gkAliHLTDDLListSize );
+  assert( fReadoutList.fCount == list.fReadoutList.fCount );
   for (Int_t i = 0; i < gkAliHLTDDLListSize; i++)
   {
     // Effectively apply: this = this & (~ (this & list))
@@ -474,7 +893,7 @@ AliHLTReadoutList AliHLTReadoutList::operator ~ () const
   // See header file for more details.
   
   AliHLTReadoutList readoutlist;
-  readoutlist.fReadoutList.fCount = fReadoutList.fCount;
+  readoutlist.fReadoutList.fCount = gkAliHLTDDLListSize;
   readoutlist.fReadoutList.fList[0] = 0x000FFFFF & (~fReadoutList.fList[0]);
   readoutlist.fReadoutList.fList[1] = 0x00FFFFFF & (~fReadoutList.fList[1]);
   readoutlist.fReadoutList.fList[2] = 0x0000FFFF & (~fReadoutList.fList[2]);
@@ -485,12 +904,12 @@ AliHLTReadoutList AliHLTReadoutList::operator ~ () const
   readoutlist.fReadoutList.fList[7] = 0xFFFFFFFF & (~fReadoutList.fList[7]);
   readoutlist.fReadoutList.fList[8] = 0xFFFFFFFF & (~fReadoutList.fList[8]);
   readoutlist.fReadoutList.fList[9] = 0x00FFFFFF & (~fReadoutList.fList[9]);
-  readoutlist.fReadoutList.fList[10] = 0x00000000 & (~fReadoutList.fList[10]);
+  readoutlist.fReadoutList.fList[10] = 0x00000000;// & (~fReadoutList.fList[10]); // Commented out the end part to suppress coverty warning.
   readoutlist.fReadoutList.fList[11] = 0x0003FFFF & (~fReadoutList.fList[11]);
   readoutlist.fReadoutList.fList[12] = 0xFFFFFFFF & (~fReadoutList.fList[12]);
   readoutlist.fReadoutList.fList[13] = 0xFFFFFFFF & (~fReadoutList.fList[13]);
   readoutlist.fReadoutList.fList[14] = 0x000000FF & (~fReadoutList.fList[14]);
-  readoutlist.fReadoutList.fList[15] = 0x00003FFF & (~fReadoutList.fList[15]);
+  readoutlist.fReadoutList.fList[15] = 0x000FFFFF & (~fReadoutList.fList[15]);
   readoutlist.fReadoutList.fList[16] = 0x000FFFFF & (~fReadoutList.fList[16]);
   readoutlist.fReadoutList.fList[17] = 0x000003FF & (~fReadoutList.fList[17]);
   readoutlist.fReadoutList.fList[18] = 0x0000003F & (~fReadoutList.fList[18]);
@@ -502,9 +921,43 @@ AliHLTReadoutList AliHLTReadoutList::operator ~ () const
   readoutlist.fReadoutList.fList[24] = 0x00000001 & (~fReadoutList.fList[24]);
   readoutlist.fReadoutList.fList[25] = 0x00000001 & (~fReadoutList.fList[25]);
   readoutlist.fReadoutList.fList[26] = 0x00000001 & (~fReadoutList.fList[26]);
-  readoutlist.fReadoutList.fList[27] = 0x00FFFFFF & (~fReadoutList.fList[27]);
-  readoutlist.fReadoutList.fList[28] = 0x00000001 & (~fReadoutList.fList[28]);
-  readoutlist.fReadoutList.fList[29] = 0x000003FF & (~fReadoutList.fList[29]);
+#if 1 // ROOT_SVN_REVISION < 9999  //FIXME: after fixed https://savannah.cern.ch/bugs/?69241
+  // Check if we need to convert to new format and do so.
+  if (fReadoutList.fCount == (unsigned)gkAliHLTDDLListSizeV0)
+  {
+    readoutlist.fReadoutList.fList[27] = 0x00FFFFFF & (~fReadoutList.fList[27]);
+    readoutlist.fReadoutList.fList[28] = 0x00000000;
+    readoutlist.fReadoutList.fList[29] = 0x00000001 & (~fReadoutList.fList[28]);
+    readoutlist.fReadoutList.fList[30] = 0x000003FF & (~fReadoutList.fList[29]);
+  }
+  else
+#endif
+  {
+    readoutlist.fReadoutList.fList[27] = 0xFFFFFFFF & (~fReadoutList.fList[27]);
+    readoutlist.fReadoutList.fList[28] = 0x00003FFF & (~fReadoutList.fList[28]);
+    readoutlist.fReadoutList.fList[29] = 0x00000001 & (~fReadoutList.fList[29]);
+    readoutlist.fReadoutList.fList[30] = 0x0FFFFFFF & (~fReadoutList.fList[30]);
+  }
   return readoutlist;
 }
 
+#if ROOT_VERSION_CODE < ROOT_VERSION(5,26,0)
+void AliHLTReadoutList::Streamer(TBuffer &R__b)
+{
+   // Stream an object of class AliHLTReadoutList.
+
+   if (R__b.IsReading()) {
+      R__b.ReadClassBuffer(AliHLTReadoutList::Class(),this);
+      // Convert old structure to new version if necessary.
+      if (fReadoutList.fCount == (unsigned)gkAliHLTDDLListSizeV0)
+      {
+        fReadoutList.fList[30] = fReadoutList.fList[29];
+        fReadoutList.fList[29] = fReadoutList.fList[28];
+        fReadoutList.fList[28] = 0x0;
+        fReadoutList.fCount = gkAliHLTDDLListSizeV1;
+      }
+   } else {
+      R__b.WriteClassBuffer(AliHLTReadoutList::Class(),this);
+   }
+}
+#endif // ROOT version check.