Adding a couple of methods used by combined tracking (Laurent)
authorivana <ivana@f7af4fe6-9843-0410-8265-dc069ae4e863>
Tue, 27 Nov 2007 17:21:18 +0000 (17:21 +0000)
committerivana <ivana@f7af4fe6-9843-0410-8265-dc069ae4e863>
Tue, 27 Nov 2007 17:21:18 +0000 (17:21 +0000)
MUON/mapping/AliMpArea.cxx
MUON/mapping/AliMpArea.h

index 0529420..66e8734 100755 (executable)
@@ -26,6 +26,8 @@
 //-----------------------------------------------------------------------------
 
 #include "AliMpArea.h"
+
+#include "AliLog.h"
 #include "AliMpConstants.h"
 
 #include <Riostream.h>
@@ -172,6 +174,64 @@ TVector2 AliMpArea::RightUpCorner() const
 }  
 
 //_____________________________________________________________________________
+Bool_t AliMpArea::Contains(const AliMpArea& area) const
+{
+/// Whether area is contained within this
+  
+//  return
+//    ( area.LeftBorder() > LeftBorder() - AliMpConstants::LengthTolerance() &&
+//      area.RightBorder() < RightBorder() +  AliMpConstants::LengthTolerance() &&
+//      area.DownBorder() > DownBorder() - AliMpConstants::LengthTolerance() &&
+//      area.UpBorder() < UpBorder() + AliMpConstants::LengthTolerance() );
+
+  if ( area.LeftBorder() < LeftBorder() ||
+       area.RightBorder() > RightBorder() ||
+       area.DownBorder() < DownBorder() ||
+       area.UpBorder() > UpBorder() ) 
+  {
+    return kFALSE;
+  }
+  else
+  {
+    return kTRUE;
+  }
+}
+
+//_____________________________________________________________________________
+AliMpArea AliMpArea::Intersect(const AliMpArea& area) const
+{ 
+/// Return the common part of area and this
+
+  Double_t xmin = TMath::Max(area.LeftBorder(),LeftBorder());
+  Double_t xmax = TMath::Min(area.RightBorder(),RightBorder());
+  Double_t ymin = TMath::Max(area.DownBorder(),DownBorder());
+  Double_t ymax = TMath::Min(area.UpBorder(),UpBorder());
+
+  return AliMpArea( TVector2( (xmin+xmax)/2.0, (ymin+ymax)/2.0 ),
+                    TVector2( (xmax-xmin)/2.0, (ymax-ymin)/2.0 ) );
+}
+
+//_____________________________________________________________________________
+Bool_t AliMpArea::Overlap(const AliMpArea& area) const
+{
+/// Return true if this overlaps with given area
+
+  if ( LeftBorder() > area.RightBorder() - AliMpConstants::LengthTolerance() ||
+       RightBorder() < area.LeftBorder() + AliMpConstants::LengthTolerance() )
+  {
+    return kFALSE;
+  }
+
+  if ( DownBorder() > area.UpBorder() - AliMpConstants::LengthTolerance() ||
+       UpBorder() < area.DownBorder() + AliMpConstants::LengthTolerance() )
+  {
+    return kFALSE;
+  }
+  return kTRUE;
+  
+}
+
+//_____________________________________________________________________________
 void
 AliMpArea::Print(Option_t*) const
 {
index 83c5b8e..273cdd6 100755 (executable)
@@ -38,12 +38,17 @@ class AliMpArea : public TObject
   TVector2 RightDownCorner() const;
   TVector2 RightUpCorner() const;
 
+  AliMpArea Intersect(const AliMpArea& area) const;
+  Bool_t    Overlap(const AliMpArea& area) const;
+  Bool_t    Contains(const AliMpArea& area) const;
+  
+  void Print(Option_t* opt="") const;
+
   // get methods
   TVector2  Position() const;
   TVector2  Dimensions() const;    
   Bool_t    IsValid() const;
   
-  void Print(Option_t* opt="") const;
   
  private:
   // data members