1 #ifndef ALIMUONPAINTERCONTOURMAKER_H
2 #define ALIMUONPAINTERCONTOURMAKER_H
4 /* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
5 * See cxx source for full Copyright notice */
10 /// \class AliMUONPainterContourMaker
11 /// \brief Utility class to build painter contours
13 // Author Laurent Aphecetche, Subatech
16 # include "TVector2.h"
23 #ifndef ALIMUONVPAINTER_H
24 # include "AliMUONVPainter.h"
28 class AliMpMotifPosition;
29 class AliMUONAttPainter;
30 class AliMUONPainterContour;
31 class AliMUONPainterPadStore;
38 class AliMUONPainterContourMaker : public TObject
41 AliMUONPainterContourMaker(AliMpExMap* globalTransformations=0x0);
42 virtual ~AliMUONPainterContourMaker();
44 void Add(AliMUONPainterContour* contour);
46 AliMUONPainterContour* FindLocalManuContour(Int_t detElemId, Int_t manuId) const;
48 AliMUONPainterContour* GetContour(const char* name) const;
50 AliMUONPainterContour* GenerateManuContour(const char* name,
53 AliMUONAttPainter viewType) const;
55 Bool_t HasContour(const char* name) const;
57 AliMUONPainterContour* MergeContours(const TObjArray& contours,
58 const char* contourName) const;
62 void Print(Option_t* opt="") const;
67 /// \brief Store information about one pad's neighbours.
68 /// \author Laurent Aphecetche, Subatech
69 class AliMUONNeighbour : public TObject
74 : fID(-1), fPosition(), fDimensions(),
75 fLeft(kFALSE), fRight(kFALSE),
76 fTop(kFALSE), fBottom(kFALSE) {}
79 AliMUONNeighbour(Int_t absID,
80 const TVector2& position,
81 const TVector2& dimensions,
82 Bool_t hasLeftNeighbour, Bool_t hasRightNeighbour,
83 Bool_t hasTopNeighbour, Bool_t hasBottomNeighbour)
84 : fID(absID), fPosition(position), fDimensions(dimensions),
85 fLeft(hasLeftNeighbour), fRight(hasRightNeighbour),
86 fTop(hasTopNeighbour), fBottom(hasBottomNeighbour) {}
89 virtual ~AliMUONNeighbour() {}
92 virtual Bool_t IsSortable() const { return kTRUE; }
94 virtual Int_t Compare(const TObject* object) const;
97 Int_t ID() const { return fID; }
99 /// Whether we have a neighbour on our left
100 Bool_t HasLeftNeighbour() const { return fLeft; }
101 /// Whether we have a neighbour on our right
102 Bool_t HasRightNeighbour() const { return fRight; }
103 /// Whether we have a neighbour above
104 Bool_t HasTopNeighbour() const { return fTop; }
105 /// Whether we have a neighbour below
106 Bool_t HasBottomNeighbour() const { return fBottom; }
109 TVector2 Position() const { return fPosition; }
110 /// Our (half-)dimensions
111 TVector2 Dimensions() const { return fDimensions; }
113 /// Lower left corner
114 TVector2 LowerLeft() const { return fPosition - fDimensions; }
115 /// Upper right corner
116 TVector2 UpperRight() const { return fPosition + fDimensions; }
118 void Print(Option_t* opt="") const;
121 void SetPosition(Double_t x, Double_t y) { fPosition.Set(x,y); }
124 Int_t fID; ///< id of the pad
125 TVector2 fPosition; ///< position
126 TVector2 fDimensions; ///< (half)dimension
127 Bool_t fLeft; ///< do we have a neighbour on our left ?
128 Bool_t fRight; ///< do we have a neighbour on our right ?
129 Bool_t fTop; ///< do we have a neighbour on top of us ?
130 Bool_t fBottom; ///< do we have a neighbour below us ?
132 ClassDef(AliMUONNeighbour,1) // Neighbour internal class
139 void AddSegments(TObjArray& segments, const AliMUONPainterContour& contour) const;
141 void AddSegment(TObjArray& segments, Double_t x1, Double_t y1,
142 Double_t x2, Double_t y2, Int_t padID) const;
144 TLine* AddToLine(TPolyLine& line, TObjArray& segments, Int_t i) const;
146 AliMpMotifPosition* FindMotifPosition(Int_t detElemId, Int_t manuId) const;
148 Int_t FindPoint(const TPolyLine& lines, Double_t x, Double_t y) const;
150 Int_t FindPoint(Double_t x, Double_t y, TObjArray& segments) const;
152 TLine* InsertSegment(TPolyLine& lines, TLine& l) const;
154 using TObject::IsEqual;
156 Bool_t IsEqual(Double_t x, Double_t y) const;
158 Int_t Overlap(const TLine& line1, const TLine& line2) const;
160 Bool_t IsLineClosed(const TPolyLine& line) const;
162 AliMUONPainterContour* ConvertEdgePadsToContour(TObjArray& edgePads, const char* name) const;
164 AliMUONPainterContour* ConvertSegmentsToContour(TObjArray& segments, const char* name) const;
166 void Local2Global(Int_t detElemId, Double_t xl, Double_t yl, Double_t zl,
167 Double_t& xg, Double_t& yg, Double_t& zg) const;
169 TString NameIt(const AliMpMotifPosition& motifPosition) const;
171 TPolyLine* Simplify(const TPolyLine& lines) const;
173 Double_t Slope(const TLine& line) const;
175 Bool_t IsPoint(const TLine& line) const;
177 void PrintLine(const TLine& line, const char* msg="") const;
179 void PrintSegments(const TObjArray& segments) const;
181 Bool_t SameDirection(const TLine& line1, const TLine& line2) const;
183 void Swap(TLine& line) const;
185 TLine Shift(const TLine& line, Double_t x, Double_t y) const;
187 Int_t IsInside(const TLine& line1, const TLine& line2,
188 Bool_t useEndPoints=kFALSE) const;
190 Bool_t IsInside(const TObjArray& segments, const TLine& line) const;
192 Int_t IsInLine(const TLine& line, Double_t x, Double_t y,
193 Bool_t strict=kTRUE) const;
195 Bool_t IsEqual(const TLine& line1, const TLine& line2) const;
197 Bool_t SanityCheck(const TObjArray& contours, const TObjArray& segments, Bool_t check=kTRUE) const;
199 TString LineAsString(const TLine& line, Bool_t slope=kTRUE) const;
201 Int_t IsInRange(Double_t x, Double_t a, Double_t b,
202 Bool_t strict=kTRUE) const;
204 Bool_t HasLine(const TObjArray& segments, const TLine& line) const;
206 void CleanSegments(TObjArray& segments, const TArrayI& toBeRemoved) const;
208 Int_t SplitSegments(TObjArray& segments) const;
210 Int_t RemoveInsideSegments(const TObjArray& contours, TObjArray& segments) const;
212 Bool_t IsHorizontal(const TLine& line) const;
214 Bool_t IsVertical(const TLine& line) const;
216 Int_t CountPoint(const TObjArray& segments, Double_t x, Double_t y) const;
218 Bool_t ShouldBeRemoved(const TObjArray& contours, Double_t x, Double_t y) const;
222 AliMUONPainterContourMaker(const AliMUONPainterContourMaker& rhs);
224 AliMUONPainterContourMaker& operator=(const AliMUONPainterContourMaker& rhs);
226 AliMpExMap* fGlobalTransformations; ///< store of global transformations for DEs
227 TMap* fLocalManuContours; ///< store for local contours of all manus
228 TMap* fContours; ///< store for all our contours
230 ClassDef(AliMUONPainterContourMaker,1) // Painter contour builder