]> git.uio.no Git - u/mrichter/AliRoot.git/commitdiff
Fixing up streaming of global decision using new ROOT I/O schema rules. Should now...
authoraszostak <aszostak@f7af4fe6-9843-0410-8265-dc069ae4e863>
Wed, 27 Oct 2010 11:23:12 +0000 (11:23 +0000)
committeraszostak <aszostak@f7af4fe6-9843-0410-8265-dc069ae4e863>
Wed, 27 Oct 2010 11:23:12 +0000 (11:23 +0000)
HLT/BASE/AliHLTGlobalTriggerDecision.cxx
HLT/BASE/AliHLTGlobalTriggerDecision.h
HLT/BASE/HLTbaseLinkDef.h

index 8d88b2c0cb8d8e717caa1c1631bec45f6cce3d8c..de3011bb96022384038c149b1a691a84953f076c 100644 (file)
@@ -336,6 +336,44 @@ void AliHLTGlobalTriggerDecision::DeleteInputObjects()
 }
 
 
+void AliHLTGlobalTriggerDecision::MarkInputObjectsAsOwned()
+{
+  // Marks all input objects as owned.
+
+  // We must mark all the objects that were read into fInputObjects as owned.
+  // Otherwise we will have a memory leak in DeleteInputObjects.
+  bool loggedWarning = false;
+  for (Int_t i = 0; i < fInputObjects.GetEntriesFast(); ++i)
+  {
+    TObject* obj = fInputObjects.UncheckedAt(i);
+    // We must check if the object pointer is NULL. This could happen because the
+    // class dictionary has not been loaded, so the ReadClassBuffer streamer just
+    // silently skips the object but fills the fInputObjects array with a NULL pointer.
+    if (obj == NULL)
+    {
+      fInputObjects.RemoveAt(i);
+      if (not loggedWarning)
+      {
+        AliHLTLogging log;
+        log.LoggingVarargs(kHLTLogWarning, this->ClassName(), FUNCTIONNAME(), __FILE__, __LINE__,
+          "The global trigger decision contains NULL pointers in the input object array."
+          " This is probably due to the fact that some class dictionaries have not been loaded."
+          " Will just remove the NULL pointer and continue."
+        );
+        loggedWarning = true;  // Prevent multiple warnings, one is enough.
+      }
+    }
+    else
+    {
+      obj->SetBit(kCanDelete);
+    }
+  }
+  // Compress the input object array to prevent any seg-faults due to access of
+  // NULL pointers if the objects were not loaded due to missing dictionaries.
+  fInputObjects.Compress();
+}
+
+#if ROOT_VERSION_CODE < ROOT_VERSION(5,26,0)
 void AliHLTGlobalTriggerDecision::Streamer(TBuffer &b)
 {
    // Stream an object of class AliHLTGlobalTriggerDecision.
@@ -343,38 +381,11 @@ void AliHLTGlobalTriggerDecision::Streamer(TBuffer &b)
    if (b.IsReading())
    {
      b.ReadClassBuffer(AliHLTGlobalTriggerDecision::Class(), this);
-     // We must mark all the objects that were read into fInputObjects as owned.
-     // Otherwise we will have a memory leak in DeleteInputObjects.
-     bool loggedWarning = false;
-     for (Int_t i = 0; i < fInputObjects.GetEntriesFast(); ++i)
-     {
-       TObject* obj = fInputObjects.UncheckedAt(i);
-       // We must check if the object pointer is NULL. This could happen because the
-       // class dictionary has not been loaded, so the ReadClassBuffer streamer just
-       // silently skips the object but fills the fInputObjects array with a NULL pointer.
-       if (obj == NULL)
-       {
-         fInputObjects.RemoveAt(i);
-         if (not loggedWarning)
-         {
-           AliHLTLogging log;
-           log.LoggingVarargs(kHLTLogWarning, this->ClassName(), FUNCTIONNAME(), __FILE__, __LINE__,
-             "The global trigger decision contains NULL pointers in the input object array."
-             " This is probably due to the fact that some class dictionaries have not been loaded."
-             " Will just remove the NULL pointer and continue."
-           );
-           loggedWarning = true;  // Prevent multiple warnings, one is enough.
-         }
-       }
-       else
-       {
-         obj->SetBit(kCanDelete);
-       }
-     }
-     fInputObjects.Compress();
+     MarkInputObjectsAsOwned();
    }
    else
    {
      b.WriteClassBuffer(AliHLTGlobalTriggerDecision::Class(), this);
    }
 }
+#endif // ROOT version check.
index 512de8b8b30087ae70af7acff42d53bf72105134..8a8e7ebc145021be5d2481461871b938c621f42f 100644 (file)
@@ -227,6 +227,12 @@ class AliHLTGlobalTriggerDecision : public AliHLTTriggerDecision
    */
   void DeleteInputObjects();
   
+  /**
+   * This method is called in the streamer to mark the entries in fInputObjects as
+   * owned and deletable.
+   */
+  void MarkInputObjectsAsOwned();
+  
   TClonesArray fContributingTriggers;  /// The list of contributing trigger decisions from all AliHLTTrigger components that were considered.
   TObjArray fInputObjects;  /// The list of other input objects.
   TArrayL64 fCounters;  /// Event trigger counters. One counter for each trigger class in the global trigger.
index ad68886b7d96ea60d8b2663fc8f72a7e74f82e82..e84ad6bfce918ccd851bf9bd557723ed37a98276 100644 (file)
 #pragma link C++ class AliHLTEventStatistics+;
 #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 AliHLTGlobalTriggerDecision-;  // '-' option since the class uses a custom streamer.
 #pragma link C++ class AliHLTReadoutList-;  // '-' option since the class uses a custom streamer.
 
 #else // ROOT version check
 
+#pragma link C++ class AliHLTGlobalTriggerDecision+;
+
+// Scheme rule to mark all objects in the trigger decision loaded from file as
+// deletable. Meaning the new object owns all the input objects.
+#pragma read sourceClass="AliHLTGlobalTriggerDecision" version="[1-]" targetClass="AliHLTGlobalTriggerDecision"\
+  source="" target="" code="{ newObj->MarkInputObjectsAsOwned(); }"
+
 #pragma link C++ class AliHLTReadoutList+;
 
 // Do nothing special with schema evolution for new versions of the readout list.