]> git.uio.no Git - u/mrichter/AliRoot.git/commitdiff
Adding fixes for backward compatibility of AliHLTReadoutList.
authoraszostak <aszostak@f7af4fe6-9843-0410-8265-dc069ae4e863>
Wed, 30 Jun 2010 00:47:07 +0000 (00:47 +0000)
committeraszostak <aszostak@f7af4fe6-9843-0410-8265-dc069ae4e863>
Wed, 30 Jun 2010 00:47:07 +0000 (00:47 +0000)
HLT/BASE/AliHLTReadoutList.cxx
HLT/BASE/AliHLTReadoutList.h
HLT/BASE/HLTbaseLinkDef.h
HLT/BASE/test/testAliHLTEventDDLBackwardCompatibility.C

index ddd30da26a774af9e4184a51bf6fcf1a845c20fb..bbd255b844965b1d98850f3dcf540856ea6b5afb 100644 (file)
@@ -152,17 +152,42 @@ AliHLTReadoutList::AliHLTReadoutList(const AliHLTEventDDL& list) :
 {
   // Constructor to create readout list from AliHLTEventDDL structure.
   // See header file for more details.
+  FillStruct(list);
+}
+
+
+AliHLTReadoutList::AliHLTReadoutList(const AliHLTReadoutList& list) :
+       TNamed(list),
+       fReadoutList()
+{
+  // Copy constructor performs a deep copy.
+  
+  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 == gkAliHLTDDLListSizeV0)
+  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 == gkAliHLTDDLListSizeV1)
+  else if (list.fCount == (unsigned)gkAliHLTDDLListSizeV1)
   {
     memcpy(&fReadoutList.fList, &list.fList, sizeof(AliHLTEventDDL));
   }
@@ -173,16 +198,6 @@ AliHLTReadoutList::AliHLTReadoutList(const AliHLTEventDDL& list) :
 }
 
 
-AliHLTReadoutList::AliHLTReadoutList(const AliHLTReadoutList& list) :
-       TNamed(list),
-       fReadoutList()
-{
-  // Copy constructor performs a deep copy.
-  
-  memcpy(&fReadoutList, &list.fReadoutList, sizeof(fReadoutList));
-}
-
-
 AliHLTReadoutList::~AliHLTReadoutList()
 {
   // Default destructor.
@@ -205,6 +220,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
 }
 
 
@@ -291,6 +314,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;
 }
 
@@ -299,6 +342,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;
@@ -316,6 +369,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;
@@ -364,6 +427,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;
@@ -446,13 +519,24 @@ 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)
+#if 1 // ROOT_SVN_REVISION < 9999  //FIXME: after fixed https://savannah.cern.ch/bugs/?69241
+  if (fReadoutList.fCount == (unsigned)gkAliHLTDDLListSizeV0)
   {
-    result &= fReadoutList.fList[27] == 0xFFFFFFFF;
-    result &= fReadoutList.fList[28] == 0x00003FFF;
+    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] == 0x000003FF;
   }
-  if ((detector & kDAQTEST) != 0) result &= fReadoutList.fList[29] == 0x00000001;
-  if ((detector & kHLT) != 0) result &= fReadoutList.fList[30] == 0x000003FF;
   
   return result;
 }
@@ -496,13 +580,24 @@ bool AliHLTReadoutList::DetectorDisabled(Int_t detector) const
   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 ((detector & kEMCAL) != 0)
+#if 1 // ROOT_SVN_REVISION < 9999  //FIXME: after fixed https://savannah.cern.ch/bugs/?69241
+  if (fReadoutList.fCount == (unsigned)gkAliHLTDDLListSizeV0)
   {
-    result &= fReadoutList.fList[27] == 0x00000000;
-    result &= fReadoutList.fList[28] == 0x00000000;
+    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;
   }
-  if ((detector & kDAQTEST) != 0) result &= fReadoutList.fList[29] == 0x00000000;
-  if ((detector & kHLT) != 0) result &= fReadoutList.fList[30] == 0x00000000;
   
   return result;
 }
@@ -614,6 +709,7 @@ AliHLTReadoutList::EDetectorId AliHLTReadoutList::GetDetectorFromWord(Int_t word
 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;
@@ -642,9 +738,20 @@ AliHLTReadoutList::EDetectorId AliHLTReadoutList::GetFirstUsedDetector(EDetector
   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 (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;
+#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;
 }
 
@@ -681,7 +788,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;
 }
@@ -701,6 +815,7 @@ AliHLTReadoutList& AliHLTReadoutList::OrEq(const AliHLTReadoutList& list)
   // See header file for more details.
   
   assert( fReadoutList.fCount == (unsigned)gkAliHLTDDLListSize );
+  assert( fReadoutList.fCount == list.fCount );
   for (Int_t i = 0; i < gkAliHLTDDLListSize; i++)
   {
     fReadoutList.fList[i] |= list.fReadoutList.fList[i];
@@ -724,6 +839,7 @@ AliHLTReadoutList& AliHLTReadoutList::XorEq(const AliHLTReadoutList& list)
   // See header file for more details.
   
   assert( fReadoutList.fCount == (unsigned)gkAliHLTDDLListSize );
+  assert( fReadoutList.fCount == list.fCount );
   for (Int_t i = 0; i < gkAliHLTDDLListSize; i++)
   {
     fReadoutList.fList[i] ^= list.fReadoutList.fList[i];
@@ -747,6 +863,7 @@ AliHLTReadoutList& AliHLTReadoutList::AndEq(const AliHLTReadoutList& list)
   // See header file for more details.
 
   assert( fReadoutList.fCount == (unsigned)gkAliHLTDDLListSize );
+  assert( fReadoutList.fCount == list.fCount );
   for (Int_t i = 0; i < gkAliHLTDDLListSize; i++)
   {
     fReadoutList.fList[i] &= list.fReadoutList.fList[i];
@@ -760,6 +877,7 @@ AliHLTReadoutList& AliHLTReadoutList::operator -= (const AliHLTReadoutList& list
   // See header file for more details.
   
   assert( fReadoutList.fCount == (unsigned)gkAliHLTDDLListSize );
+  assert( fReadoutList.fCount == list.fCount );
   for (Int_t i = 0; i < gkAliHLTDDLListSize; i++)
   {
     // Effectively apply: this = this & (~ (this & list))
@@ -776,7 +894,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]);
@@ -804,10 +922,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] = 0xFFFFFFFF & (~fReadoutList.fList[27]);
-  readoutlist.fReadoutList.fList[28] = 0x00003FFF & (~fReadoutList.fList[28]);
-  readoutlist.fReadoutList.fList[29] = 0x00000001 & (~fReadoutList.fList[29]);
-  readoutlist.fReadoutList.fList[30] = 0x000003FF & (~fReadoutList.fList[30]);
+#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] = 0x000003FF & (~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.
index 9415a34cc0047f65402f8e225612fbca8d9bc1a5..eb674103ecd49f5c0347e37aaf7e33933201c729 100644 (file)
@@ -248,9 +248,9 @@ class AliHLTReadoutList : public TNamed
   /**
    * This typecast operator converts the readout list to the AliHLTEventDDL
    * structure format.
-   * \return  Copy of the AliHLTEventDDL raw structure.
+   * \return  Constant reference to the AliHLTEventDDL raw structure.
    */
-  operator AliHLTEventDDL () const { return fReadoutList; }
+  operator const AliHLTEventDDL& () const { return fReadoutList; }
   
   /**
    * This typecast operator converts the readout list to the AliHLTEventDDL
@@ -381,8 +381,6 @@ class AliHLTReadoutList : public TNamed
     return result.operator -= (list);
   }
   
- private:
-  
   /**
    * Decodes the word index and bit index within that word for the readout list structure.
    * \param ddlId <i>[in]</i>  The ID number of the DDL to decode.
@@ -396,6 +394,15 @@ class AliHLTReadoutList : public TNamed
    */
   static bool DecodeDDLID(Int_t ddlId, Int_t& wordIndex, Int_t& bitIndex);
   
+ private:
+  
+  /**
+   * This method fills the internal bit field structure taking care of converting
+   * from the old format to the new one.
+   * \param list  The raw DDL readout list bits.
+   */
+  void FillStruct(const AliHLTEventDDL& list);
+  
   AliHLTEventDDL fReadoutList; /// The DDL readout list structure.
   
   ClassDef(AliHLTReadoutList, 3) // Readout list object used for manipulating and storing an AliHLTEventDDL structure.
index 6a34ba1782fd150323f34f533f1ff79d9343add8..1c0c00fd3fa032c72e2f7dd4790a876493bac099 100644 (file)
 #pragma link C++ class AliHLTBlockDataCollection+;
 #pragma link C++ class AliHLTTriggerDecision+;
 #pragma link C++ class AliHLTGlobalTriggerDecision-;  // '-' option since the class uses a custom streamer.
+
+#include "RVersion.h"
+#if ROOT_VERSION_CODE < 334336 //ROOT_VERSION(5,26,0)
+
+#pragma link C++ class AliHLTReadoutList-;  // '-' option since the class uses a custom streamer.
+
+#else // ROOT version check
+
 #pragma link C++ class AliHLTReadoutList+;
+
+// Do nothing special with schema evolution for new versions of the readout list.
+#pragma read sourceClass="AliHLTReadoutList" version="[3-]" targetClass="AliHLTReadoutList"
+
+// For old versions we need to convert the format of the readout list into the new one.
+#pragma read sourceClass="AliHLTReadoutList" version="[1-2]" targetClass="AliHLTReadoutList"\
+  source="AliHLTEventDDL fReadoutList" target="fReadoutList"\
+  code="{\
+    fReadoutList.fCount = gkAliHLTDDLListSize;\
+    for (int i = 0; i < 28; ++i) fReadoutList.fList[i] = onfile.fReadoutList.fList[i];\
+    fReadoutList.fList[28] = 0x0;\
+    for (int i = 29; i < gkAliHLTDDLListSize; ++i) fReadoutList.fList[i] = onfile.fReadoutList.fList[i-1];\
+  }"
+
+#endif // ROOT version check
+
 #pragma link C++ class AliHLTTriggerDomain+;
 #pragma link C++ class AliHLTDomainEntry+;
 #pragma link C++ class AliHLTTriggerMenu+;
index 538b9cf9be5165b64b6a385b3a0894b283dd5c06..9b7900567baa3d99a819275296c7782971b73a8d 100644 (file)
@@ -347,6 +347,9 @@ bool CheckReadingOldFormat(const char* filename = "oldAliHLTReadoutListFormat.ro
                                << endl;
                        return false;
                }
+#if 1 // ROOT_SVN_REVISION < 9999  //FIXME: after fixed https://savannah.cern.ch/bugs/?69241
+               r->SetDDLBit(9999999, kTRUE);  // Triggers a reformating of the internal structure to the new version.
+#endif
                if (memcmp(r->Buffer(), rl[i]->Buffer(), r->BufferSize()) != 0)
                {
                        cerr << "ERROR: readoutlist" << i+1