]> git.uio.no Git - u/mrichter/AliRoot.git/blob - MUON/AliMUONPainterContourMaker.h
Raw2SDigits() restored and improved.
[u/mrichter/AliRoot.git] / MUON / AliMUONPainterContourMaker.h
1 #ifndef ALIMUONPAINTERCONTOURMAKER_H
2 #define ALIMUONPAINTERCONTOURMAKER_H
3
4 /* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
5 * See cxx source for full Copyright notice                               */
6
7 // $Id$
8
9 /// \ingroup graphics
10 /// \class AliMUONPainterContourMaker
11 /// \brief Utility class to build painter contours
12 /// 
13 // Author Laurent Aphecetche, Subatech
14
15 #ifndef ROOT_TVector2
16 #  include "TVector2.h"
17 #endif
18
19 #ifndef ROOT_TObject
20 #  include "TObject.h"
21 #endif
22
23 #ifndef ALIMUONVPAINTER_H
24 #  include "AliMUONVPainter.h"
25 #endif
26
27 class AliMpExMap;
28 class AliMpMotifPosition;
29 class AliMUONAttPainter;
30 class AliMUONPainterContour;
31 class AliMUONPainterPadStore;
32 class TArrayI;
33 class TMap;
34 #include <TLine.h>
35 class TPolyLine;
36 class TObjArray;
37
38 class AliMUONPainterContourMaker : public TObject
39 {
40 public:
41   AliMUONPainterContourMaker(AliMpExMap* globalTransformations=0x0);
42   virtual ~AliMUONPainterContourMaker();
43   
44   void Add(AliMUONPainterContour* contour);
45   
46   AliMUONPainterContour* FindLocalManuContour(Int_t detElemId, Int_t manuId) const;
47   
48   AliMUONPainterContour* GetContour(const char* name) const;
49
50   AliMUONPainterContour* GenerateManuContour(const char* name,
51                                              Int_t detElemId,
52                                              Int_t manuId,
53                                              AliMUONAttPainter viewType) const;
54
55   Bool_t HasContour(const char* name) const;
56
57   AliMUONPainterContour* MergeContours(const TObjArray& contours,
58                                        const char* contourName) const;
59   
60   Int_t Size() const;
61   
62   void Print(Option_t* opt="") const;
63   
64 public:
65     
66   /// \ingroup graphics
67   /// \brief Store information about one pad's neighbours.
68   /// \author Laurent Aphecetche, Subatech
69   class AliMUONNeighbour : public TObject
70   {
71 public:
72     /// default ctor
73     AliMUONNeighbour()
74     : fID(-1), fPosition(), fDimensions(), 
75     fLeft(kFALSE), fRight(kFALSE), 
76     fTop(kFALSE), fBottom(kFALSE) {}
77     
78     /// normal ctor
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) {}
87
88     /// dtor
89     virtual ~AliMUONNeighbour() {}
90     
91     /// we are sortable
92     virtual Bool_t IsSortable() const { return kTRUE; }
93     
94     virtual Int_t Compare(const TObject* object) const;
95     
96     /// our id
97     Int_t ID() const { return fID; }
98     
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; }
107     
108     /// Our position
109     TVector2 Position() const { return fPosition; }
110     /// Our (half-)dimensions
111     TVector2 Dimensions() const { return fDimensions; }
112     
113     /// Lower left corner
114     TVector2 LowerLeft() const { return fPosition - fDimensions; }
115     /// Upper right corner
116     TVector2 UpperRight() const { return fPosition + fDimensions; }
117     
118     void Print(Option_t* opt="") const;
119     
120     /// Set our position
121     void SetPosition(Double_t x, Double_t y) { fPosition.Set(x,y); }
122     
123 private:
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 ?
131     
132     ClassDef(AliMUONNeighbour,1) // Neighbour internal class
133   };
134     
135
136 public:
137     
138
139   void AddSegments(TObjArray& segments, const AliMUONPainterContour& contour) const;
140
141   void AddSegment(TObjArray& segments, Double_t x1, Double_t y1,
142                     Double_t x2, Double_t y2, Int_t padID) const;
143   
144   TLine* AddToLine(TPolyLine& line, TObjArray& segments, Int_t i) const;
145
146   AliMpMotifPosition* FindMotifPosition(Int_t detElemId, Int_t manuId) const;
147   
148   Int_t FindPoint(const TPolyLine& lines, Double_t x, Double_t y) const;
149   
150   Int_t FindPoint(Double_t x, Double_t y, TObjArray& segments) const;
151
152   TLine* InsertSegment(TPolyLine& lines, TLine& l) const;
153
154   using TObject::IsEqual;
155   
156   Bool_t IsEqual(Double_t x, Double_t y) const;
157
158   Int_t Overlap(const TLine& line1, const TLine& line2) const;
159
160   Bool_t IsLineClosed(const TPolyLine& line) const;
161   
162   AliMUONPainterContour* ConvertEdgePadsToContour(TObjArray& edgePads, const char* name) const;
163   
164   AliMUONPainterContour* ConvertSegmentsToContour(TObjArray& segments, const char* name) const;
165   
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;
168     
169   TString NameIt(const AliMpMotifPosition& motifPosition) const;
170
171   TPolyLine* Simplify(const TPolyLine& lines) const;
172
173   Double_t Slope(const TLine& line) const;
174
175   Bool_t IsPoint(const TLine& line) const;
176
177   void PrintLine(const TLine& line, const char* msg="") const;
178
179   void PrintSegments(const TObjArray& segments) const;
180     
181   Bool_t SameDirection(const TLine& line1, const TLine& line2) const;
182
183   void Swap(TLine& line) const;
184   
185   TLine Shift(const TLine& line, Double_t x, Double_t y) const;
186
187   Int_t IsInside(const TLine& line1, const TLine& line2,
188                  Bool_t useEndPoints=kFALSE) const;
189     
190   Bool_t IsInside(const TObjArray& segments, const TLine& line) const;
191     
192   Int_t IsInLine(const TLine& line, Double_t x, Double_t y, 
193                  Bool_t strict=kTRUE) const;
194   
195   Bool_t IsEqual(const TLine& line1, const TLine& line2) const;
196     
197   Bool_t SanityCheck(const TObjArray& contours, const TObjArray& segments, Bool_t check=kTRUE) const;
198   
199   TString LineAsString(const TLine& line, Bool_t slope=kTRUE) const;
200   
201   Int_t IsInRange(Double_t x, Double_t a, Double_t b, 
202                   Bool_t strict=kTRUE) const;
203   
204   Bool_t HasLine(const TObjArray& segments, const TLine& line) const;
205     
206   void CleanSegments(TObjArray& segments, const TArrayI& toBeRemoved) const;
207     
208   Int_t SplitSegments(TObjArray& segments) const;
209
210   Int_t RemoveInsideSegments(const TObjArray& contours, TObjArray& segments) const;
211       
212   Bool_t IsHorizontal(const TLine& line) const;
213
214   Bool_t IsVertical(const TLine& line) const;
215     
216   Int_t CountPoint(const TObjArray& segments, Double_t x, Double_t y) const;
217     
218   Bool_t ShouldBeRemoved(const TObjArray& contours, Double_t x, Double_t y) const;
219     
220 private:
221   /// not implemented
222   AliMUONPainterContourMaker(const AliMUONPainterContourMaker& rhs);
223   /// not implemented
224   AliMUONPainterContourMaker& operator=(const AliMUONPainterContourMaker& rhs);
225
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
229   
230   ClassDef(AliMUONPainterContourMaker,1) // Painter contour builder
231 };
232
233 #endif
234