]> git.uio.no Git - u/mrichter/AliRoot.git/commitdiff
Fixing problem with backward compatibility for old trigger decision objects recorded...
authoraszostak <aszostak@f7af4fe6-9843-0410-8265-dc069ae4e863>
Wed, 18 Nov 2009 11:20:53 +0000 (11:20 +0000)
committeraszostak <aszostak@f7af4fe6-9843-0410-8265-dc069ae4e863>
Wed, 18 Nov 2009 11:20:53 +0000 (11:20 +0000)
HLT/BASE/AliHLTTriggerDecision.cxx
HLT/BASE/AliHLTTriggerDecision.h

index 9af4ba37d2e2fa5c894d5e2e2637fe509f712f4d..917fae4090ac3b3bf5bac433622a18fb94508807 100644 (file)
@@ -38,6 +38,24 @@ AliHLTTriggerDecision::AliHLTTriggerDecision() :
 }
 
 
+AliHLTTriggerDecision::AliHLTTriggerDecision(const AliHLTTriggerDecision& obj) :
+  TObject(obj),
+  fName(obj.fName),
+  fDescription(obj.fDescription),
+  fTriggerDomain(obj.fTriggerDomain)
+{
+  // Copy constructor performs a deep copy.
+  
+  // The following is a backward compatibility fix to be able to read trigger
+  // decisions recorded before the fix in AliRoot trunk rev. 35998 correctly.
+  if (obj.TestBits(15) == 15)
+  {
+    ResetBit(15);  // We can clear 'this' objects bit because we performed a deep copy.
+    SetBit(BIT(15));
+  }
+}
+
+
 AliHLTTriggerDecision::AliHLTTriggerDecision(bool result, const char* name) :
   TObject(),
   fName(name),
@@ -72,6 +90,34 @@ AliHLTTriggerDecision::~AliHLTTriggerDecision()
 }
 
 
+bool AliHLTTriggerDecision::Result() const
+{
+  // Returns the result of the trigger decision.
+  
+  // The following is a backward compatibility fix to be able to read trigger
+  // decisions recorded before the fix in AliRoot trunk rev. 35998 correctly.
+  if (TestBits(15) == 15) return true;
+  
+  return TestBit(BIT(15)) == 1;
+}
+
+
+void AliHLTTriggerDecision::Result(bool value)
+{
+  // Sets the result of the trigger decision.
+  SetBit(BIT(15), value);
+  
+  // The following is a backward compatibility fix to be able to read trigger
+  // decisions recorded before the fix in AliRoot trunk rev. 35998 correctly.
+  // It looks like bit 1 and 2 of fBits are not used in the case of the
+  // AliHLTTriggerDecision class, so reset those to prevent "TestBits(15) == 15"
+  // from succeeding in the "Result() const" method above.
+  // We do not touch the other two bits because they could affect memory handling
+  // and cleanup.
+  if (TestBits(15) == 15) ResetBit(6);
+}
+
+
 void AliHLTTriggerDecision::ReadoutList(const AliHLTReadoutList& value)
 {
   // Replaces the readout list in the trigger domain with the new value.
@@ -121,3 +167,25 @@ Option_t *AliHLTTriggerDecision::GetOption() const
   if (Result()) return "1";
   return "0";
 }
+
+
+AliHLTTriggerDecision& AliHLTTriggerDecision::operator = (const AliHLTTriggerDecision& obj)
+{
+  // Assignment operator performs a deep copy.
+  
+  if (this == &obj) return *this;
+  
+  TObject::operator = (obj);
+  // The following is a backward compatibility fix to be able to read trigger
+  // decisions recorded before the fix in AliRoot trunk rev. 35998 correctly.
+  if (obj.TestBits(15) == 15)
+  {
+    ResetBit(15);  // We can clear 'this' objects bit because we performed a deep copy.
+    SetBit(BIT(15));
+  }
+  
+  fName = obj.fName;
+  fDescription = obj.fDescription;
+  fTriggerDomain = obj.fTriggerDomain;
+  return *this;
+}
index cb35a64e50c336ff31c1cf739c3e2ca04cae0219..d763f91cd8dfd15bdbb79dff5ee18a0c1c4edcb2 100644 (file)
@@ -31,6 +31,11 @@ class AliHLTTriggerDecision : public TObject
    */
   AliHLTTriggerDecision();
   
+  /**
+   * Copy constructor performs a deep copy.
+   */
+  AliHLTTriggerDecision(const AliHLTTriggerDecision& obj);
+  
   /**
    * Constructor specifying the result and trigger name.
    * \param result  The result of the trigger decision.
@@ -100,7 +105,7 @@ class AliHLTTriggerDecision : public TObject
    * The decision is stored in bit 15 of the fBits field.
    * \returns true if the event was triggered and should be readout.
    */
-  bool Result() const { return TestBit(BIT(15)) == 1; }
+  bool Result() const;
   
   /**
    * Sets the result of the trigger decision.
@@ -108,7 +113,7 @@ class AliHLTTriggerDecision : public TObject
    * \param value  The value to set; true if the event triggered and should be
    *     readout and false otherwise.
    */
-  void Result(bool value) { SetBit(BIT(15), value); }
+  void Result(bool value);
   
   /**
    * Returns the name of the trigger decision.
@@ -155,13 +160,18 @@ class AliHLTTriggerDecision : public TObject
    */
   void TriggerDomain(const AliHLTTriggerDomain& value) { fTriggerDomain = value; }
   
+  /**
+   * Assignment operator performs a deep copy.
+   */
+  AliHLTTriggerDecision& operator = (const AliHLTTriggerDecision& obj);
+  
  private:
   
   TString fName; /// The name of the trigger decision. Should be the name of the trigger component that generated it.
   TString fDescription; /// Optional descriptive text giving the reason for the trigger.
   AliHLTTriggerDomain fTriggerDomain;  /// The trigger domain associated with this trigger. i.e. the HLT data blocks to read out.
   
-  ClassDef(AliHLTTriggerDecision, 1) // HLT trigger decision object storing information about the readout list, trigger domain and result.
+  ClassDef(AliHLTTriggerDecision, 2) // HLT trigger decision object storing information about the readout list, trigger domain and result.
 };
 
 #endif // ALIHLTTRIGGERDECISION_H