]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - MUON/AliMUONContourMaker.cxx
next50 trigger mask in AliHLTGlobalEsdConverterComponent
[u/mrichter/AliRoot.git] / MUON / AliMUONContourMaker.cxx
index f992d9b8431291437688cb44918d7e8113dd2c95..3442155d777eb39f5e987611e60ea2cfcaa4eae9 100644 (file)
 #include "TArrayD.h"
 #include "TMath.h"
 #include <cassert>
+#include "TArrayI.h"
 
 /// \cond CLASSIMP
 ClassImp(AliMUONContourMaker)
 /// \endcond
 
-namespace
-{
-  void PrintSegments(const TObjArray& array)
-  {
-    TIter next(&array);
-    AliMUONSegment* s;
-    Int_t i(0);
-    while ( ( s = static_cast<AliMUONSegment*>(next()) ) )
-    {
-      cout << Form("i=%d %s",i,s->AsString()) << endl;
-      ++i;
-    }
-  }
-}
-
 //_____________________________________________________________________________
 AliMUONContourMaker::AliMUONContourMaker() 
 {
@@ -83,7 +69,7 @@ AliMUONContourMaker::CreateContour(const TObjArray& polygons, const char* name)
   /// and get back the intermediate verticals and horizontal segments
   /// both arrays are arrays of AliMUONSegment objects.
   
-  AliCodeTimerAuto("");
+  AliCodeTimerAuto("",0);
   
   if ( polygons.IsEmpty() ) return 0x0; // protection against user error...
   
@@ -104,7 +90,7 @@ AliMUONContourMaker::CreateContour(const TObjArray& polygons, const char* name)
   
   if ( polygons.GetLast() == 0 ) 
   {
-    AliCodeTimerAuto("Trivial case");
+    AliCodeTimerAuto("Trivial case",1);
     contour = new AliMUONContour(name);
     pol = static_cast<AliMUONPolygon*>(polygons.First());
     contour->Add(*pol);
@@ -124,10 +110,8 @@ AliMUONContourMaker::CreateContour(const TObjArray& polygons, const char* name)
   
   if ( polygonVerticalEdges.GetLast()+1 < 2 ) 
   {
-    AliError(Form("Got too few edges here for createContour %s",name));
     polygons.Print();
-    TObject* o(0x0);
-    o->Print();
+    AliFatal(Form("Got too few edges here for createContour %s",name));
   }
   
   // Find the vertical edges of the merged contour. This is the meat of the algorithm...
@@ -154,7 +138,7 @@ AliMUONContourMaker::FinalizeContour(const TObjArray& verticals,
   /// For a list of vertical and horizontal edges, we build the final
   /// contour object.
   
-  AliCodeTimerAuto("");
+  AliCodeTimerAuto("",0);
   
   TObjArray all; // array of AliMUONSegment
   TObjArray inorder; // array of AliMUONSegment
@@ -167,6 +151,9 @@ AliMUONContourMaker::FinalizeContour(const TObjArray& verticals,
     all.Add(verticals.UncheckedAt(i));
     all.Add(horizontals.UncheckedAt(i));
   }
+
+  TArrayI alreadyAdded(all.GetLast()+1);
+  alreadyAdded.Reset();
   
   Int_t i(0);
   
@@ -186,6 +173,7 @@ AliMUONContourMaker::FinalizeContour(const TObjArray& verticals,
     
     AliMUONSegment* si = static_cast<AliMUONSegment*>(all.UncheckedAt(i));
     inorder.Add(si);
+    alreadyAdded[i] = 1;
     const AliMUONSegment* all0 = static_cast<const AliMUONSegment*>(all.First());
     if ( i != 0 && AliMUONSegment::AreEqual(si->EndX(),all0->StartX()) && AliMUONSegment::AreEqual(si->EndY(),all0->StartY()) )
     {
@@ -211,13 +199,15 @@ AliMUONContourMaker::FinalizeContour(const TObjArray& verticals,
       {
         i = 0;
         inorder.Clear();
+        alreadyAdded.Set(all.GetLast()+1);
+        alreadyAdded.Reset();
       }
       continue;
     }
     
     for ( Int_t j = 0; j <= all.GetLast(); ++j) 
     {
-      if ( j != i ) 
+      if ( j != i && alreadyAdded[j] == 0 
       {        
         const AliMUONSegment* sj = static_cast<const AliMUONSegment*>(all.UncheckedAt(j));
         if ( AliMUONSegment::AreEqual(si->EndX(),sj->StartX()) && AliMUONSegment::AreEqual(si->EndY(),sj->StartY()))
@@ -241,7 +231,7 @@ AliMUONContourMaker::GetVerticalEdges(const TObjArray& polygons, TObjArray& poly
   /// From an array of polygons, extract the list of vertical edges.
   /// Output array polygonVerticalEdges should be empty before calling.
   
-  AliCodeTimerAuto("");
+  AliCodeTimerAuto("",0);
   
   for ( Int_t i = 0; i <= polygons.GetLast(); ++i ) 
   {
@@ -265,7 +255,7 @@ AliMUONContourMaker::GetYPositions(const TObjArray& polygonVerticalEdges,
   /// Fill the array yPositions with the different y positions found in 
   /// polygonVerticalEdges
   
-  AliCodeTimerAuto("");
+  AliCodeTimerAuto("",0);
   
   Double_t* y = new Double_t[polygonVerticalEdges.GetSize()*2];
   Int_t n(0);
@@ -309,7 +299,7 @@ AliMUONContourMaker::MergeContour(const TObjArray& contours, const char* name) c
 {
   /// Merge all the polygons of all contours into a single contour
   
-  AliCodeTimerAuto("");
+  AliCodeTimerAuto("",0);
   
   TObjArray polygons;
   polygons.SetOwner(kTRUE);
@@ -343,7 +333,7 @@ AliMUONContourMaker::SortPoints(const TObjArray& polygonVerticalEdges,
   /// then on abcissa, and put them in output vector sortedPoints.
   /// Output array sortedPoints should be empty before calling this method.
   
-  AliCodeTimerAuto("");
+  AliCodeTimerAuto("",0);
   
   for ( Int_t i = 0; i <= polygonVerticalEdges.GetLast(); ++i )
   {
@@ -364,7 +354,7 @@ AliMUONContourMaker::Sweep(const TObjArray& polygonVerticalEdges,
 {
   /// This is the meat of the algorithm of the contour merging...
   
-  AliCodeTimerAuto("");
+  AliCodeTimerAuto("",0);
   
   TArrayD yPositions;
   GetYPositions(polygonVerticalEdges,yPositions);
@@ -434,7 +424,7 @@ AliMUONContourMaker::VerticalToHorizontal(const TObjArray& polygonVerticalEdges,
   /// Deduce the set of horizontal edges from the vertical edges
   /// Output array horizontalEdges should be empty before calling this method
   
-  AliCodeTimerAuto("");
+  AliCodeTimerAuto("",0);
   
   TObjArray points; // array of AliMUONPointWithRef
   points.SetOwner(kTRUE);