//-----------------------------------------------------------------------------
#include "AliMpArea.h"
+
+#include "AliLog.h"
#include "AliMpConstants.h"
#include <Riostream.h>
return TVector2(RightBorder(), UpBorder());
}
+//_____________________________________________________________________________
+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
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