41 #include "Riostream.h" 74 if ( polygons.IsEmpty() )
return 0x0;
77 TIter next(&polygons);
79 while ( ( pol = static_cast<AliMUONPolygon*>(next()) ) )
83 AliError(Form(
"Got a clockwise oriented polygon in CreateContour(%s). That's not OK !",name));
91 if ( polygons.GetLast() == 0 )
102 polygonVerticalEdges.SetOwner(kTRUE);
109 polygonVerticalEdges.Sort();
111 if ( polygonVerticalEdges.GetLast()+1 < 2 )
114 AliFatal(Form(
"Got too few edges here for createContour %s",name));
119 contourVerticalEdges.SetOwner(kTRUE);
120 Sweep(polygonVerticalEdges,contourVerticalEdges);
123 horizontals.SetOwner(kTRUE);
128 if ( contour && name ) contour->SetName(name);
146 all.SetOwner(kFALSE);
147 inorder.SetOwner(kFALSE);
149 for ( Int_t i = 0; i <= verticals.GetLast(); ++i )
151 all.Add(verticals.UncheckedAt(i));
152 all.Add(horizontals.UncheckedAt(i));
155 TArrayI alreadyAdded(all.GetLast()+1);
156 alreadyAdded.Reset();
164 while ( !all.IsEmpty() )
170 AliError(
"Total 1000 reached !!!!");
185 for ( Int_t j = 0; j <= inorder.GetLast(); ++j )
196 contour->
Add(polygon);
198 if ( ! all.IsEmpty() )
202 alreadyAdded.Set(all.GetLast()+1);
203 alreadyAdded.Reset();
208 for ( Int_t j = 0; j <= all.GetLast(); ++j)
210 if ( j != i && alreadyAdded[j] == 0 )
236 for ( Int_t i = 0; i <= polygons.GetLast(); ++i )
253 TArrayD& yPositions)
const 260 Double_t* y =
new Double_t[polygonVerticalEdges.GetSize()*2];
263 for ( Int_t i = 0; i < polygonVerticalEdges.GetLast(); ++i )
270 Int_t* ix =
new Int_t[n+1];
272 TMath::Sort(n,y,ix,kFALSE);
279 for ( Int_t i = 0; i < n; ++i )
283 yPositions[u] = y[ix[i]];
305 polygons.SetOwner(kTRUE);
307 TIter next(&contours);
309 while ( ( contour = static_cast<AliMUONContour*>(next()) ) )
312 TIter nextPol(contourPolygons);
314 while ( ( pol = static_cast<AliMUONPolygon*>(nextPol()) ) )
320 if ( polygons.IsEmpty() )
return 0x0;
338 for ( Int_t i = 0; i <= polygonVerticalEdges.GetLast(); ++i )
364 for ( Int_t i = 0; i <= polygonVerticalEdges.GetLast(); ++i )
383 if ( i < polygonVerticalEdges.GetLast() )
391 ( i == polygonVerticalEdges.GetLast() ) )
395 double x = edge->
StartX();
397 for ( Int_t j = 0; j <= stack.GetLast(); ++j )
412 contourVerticalEdges.Add(s);
430 points.SetOwner(kTRUE);
434 for ( Int_t k = 0; k < (points.GetLast()+1)/2; ++k )
Double_t EndX() const
Return the x-coordinate of our ending point.
Double_t Y(Int_t i) const
Return the y-coordinate of the i-th vertex.
const TObjArray & Stack() const
Get the stack.
static Bool_t AreEqual(double a, double b)
A TVector2 with an integer ref, and a specific Compare.
virtual ~AliMUONContourMaker()
AliMUONContour * MergeContour(const TObjArray &contours, const char *name=0x0) const
void AssertOrientation(Bool_t autoCorrect=kFALSE)
void Set(Double_t xstart, Double_t ystart, Double_t xend, Double_t yend)
Bool_t IsCounterClockwiseOriented() const
Whether this polygon is oriented counter clockwise.
Double_t StartY() const
Return the y-coordinate of our starting point.
Implementation of a segment tree.
Double_t StartX() const
Return the x-coordinate of our starting point.
Int_t NumberOfVertices() const
Get the number of vertices of this polygon.
Double_t X(Int_t i) const
Return the x-coordinate of the i-th vertex.
void Sweep(const TObjArray &polygonVerticalEdges, TObjArray &contourVerticalEdges) const
Bool_t IsLeftEdge() const
Whether we are a left edge.
double Bottom() const
Return our bottom y.
void Add(const AliMUONPolygon &polygon)
Double_t X() const
Return x value.
A basic line segment, used for contour making algorithm(s)
#define AliCodeTimerAuto(message, counter)
void GetYPositions(const TObjArray &polygonVerticalEdges, TArrayD &yPositions) const
const TObjArray * Polygons() const
Get the list of polygons we have.
void Contribution(double b, double e)
void DeleteInterval(double d, double e)
void ResetStack()
Reset the stack.
void VerticalToHorizontal(const TObjArray &verticalEdges, TObjArray &horizontalEdges) const
#define StdoutToAliError(whatever)
#define AliFatal(message)
void SortPoints(const TObjArray &polygonVerticalEdges, TObjArray &sortedPoints) const
Creator/merger of AliMUONContour objects.
void GetVerticalEdges(const TObjArray &polygons, TObjArray &polygonVerticalEdges) const
Double_t EndY() const
Return the y-coordinate of our ending point.
Int_t Ref() const
Return the index of the original point in some array.
AliMUONContour * CreateContour(const TObjArray &polygons, const char *name=0x0) const
Bool_t IsAPoint() const
Whether we're just a point.
#define AliError(message)
void InsertInterval(double b, double e)
Double_t Y() const
Return y value.
AliMUONContour * FinalizeContour(const TObjArray &verticals, const TObjArray &horizontals) const