AliRoot Core  v5-06-15 (45dab64)
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
AliMpSectorPainter.cxx
Go to the documentation of this file.
1 /**************************************************************************
2  * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
3  * *
4  * Author: The ALICE Off-line Project. *
5  * Contributors are mentioned in the code where appropriate. *
6  * *
7  * Permission to use, copy, modify and distribute this software and its *
8  * documentation strictly for non-commercial purposes is hereby granted *
9  * without fee, provided that the above copyright notice appears in all *
10  * copies and that both the copyright notice and this permission notice *
11  * appear in the supporting documentation. The authors make no claims *
12  * about the suitability of this software for any purpose. It is *
13  * provided "as is" without express or implied warranty. *
14  **************************************************************************/
15 
16 // $Id$
17 // $MpId: AliMpSectorPainter.cxx,v 1.8 2006/05/24 13:58:32 ivana Exp $
18 
19 //-----------------------------------------------------------------------------
20 // Class AliMpSectorPainter
21 // ------------------------
22 // Class for drawing a sector into canvas
23 // Included in AliRoot: 2003/05/02
24 // Authors: David Guez, IPN Orsay
25 //-----------------------------------------------------------------------------
26 
27 #include "AliMpSectorPainter.h"
28 #include "AliMpGraphContext.h"
29 #include "AliMpSector.h"
30 #include "AliMpZone.h"
31 #include "AliMpSubZone.h"
32 #include "AliMpRow.h"
33 #include "AliMpVRowSegment.h"
34 
35 #include <TVirtualX.h>
36 #include <TPad.h>
37 
41 
42 //_______________________________________________________________________
44  :AliMpVPainter(),
45  fSector(0)
46 {
48 }
49 //_______________________________________________________________________
51  :AliMpVPainter(),
52  fSector(sector)
53 {
55 
56 }
57 
58 //_______________________________________________________________________
60 {
62 }
63 
64 //_______________________________________________________________________
66 {
68 
69  fSector->Dump();
70 }
71 
72 //_______________________________________________________________________
74 {
76 
77  if (fSector->GetNofRows()<1) return TVector2(0.,0.);
78  AliMpRow* row = fSector->GetRow(0);
79 
80  // bl = bottom left position;
81  TVector2 bl = TVector2(row->GetPositionX(), row->GetPositionY())-
82  TVector2(row->GetDimensionX(), row->GetDimensionY());
83  // ur = upper right position
84  TVector2 ur = TVector2(row->GetPositionX(), row->GetPositionY())+
85  TVector2(row->GetDimensionX(), row->GetDimensionY());;
86 
87  for (Int_t irow=1;irow<fSector->GetNofRows();++irow){
88  row = fSector->GetRow(irow);
89  // update the bottom-left corner
90  if (bl.X()>row->GetPositionX()-row->GetDimensionX())
91  bl.Set(row->GetPositionX()-row->GetPositionX(),bl.Y());
92  if (bl.Y()>row->GetPositionY()-row->GetDimensionY())
93  bl.Set(bl.X(),row->GetPositionY()-row->GetDimensionY());
94  // update the upper-right corner
95  if (ur.X()<row->GetPositionX()+row->GetDimensionX())
96  ur.Set(row->GetPositionX()+row->GetDimensionX(),ur.Y());
97  if (ur.Y()<row->GetPositionY()+row->GetDimensionY())
98  ur.Set(ur.X(),row->GetPositionY()+row->GetDimensionY());
99  }
100  return (ur+bl)/2.;
101 }
102 
103 //_______________________________________________________________________
105 {
107 
108  if (fSector->GetNofRows()<1) return TVector2(0.,0.);
109  AliMpRow* row = fSector->GetRow(0);
110 
111 
112  // bl = bottom left position
113  TVector2 bl = TVector2(row->GetPositionX(), row->GetPositionY())-
114  TVector2(row->GetDimensionX(), row->GetDimensionY());
115  // ur = upper right position
116  TVector2 ur = TVector2(row->GetPositionX(), row->GetPositionY())+
117  TVector2(row->GetDimensionX(), row->GetDimensionY());
118 
119  for (Int_t irow=1;irow<fSector->GetNofRows();++irow){
120  row = fSector->GetRow(irow);
121  // update the bottom-left corner
122  if (bl.X()>row->GetPositionX()-row->GetDimensionX())
123  bl.Set(row->GetPositionX()-row->GetDimensionX(),bl.Y());
124  if (bl.Y()>row->GetPositionY()-row->GetDimensionY())
125  bl.Set(bl.X(),row->GetPositionY()-row->GetDimensionY());
126  // update the upper-right corner
127  if (ur.X()<row->GetPositionX()+row->GetDimensionX())
128  ur.Set(row->GetPositionX()+row->GetDimensionX(),ur.Y());
129  if (ur.Y()<row->GetPositionY()+row->GetDimensionY())
130  ur.Set(ur.X(),row->GetPositionY()+row->GetDimensionY());
131  }
132  return (ur-bl)/2.;
133 
134 }
135 //_______________________________________________________________________
136 void AliMpSectorPainter::Draw(Option_t *option)
137 {
146 
148  if (!fSector) return;
149  gr->Push();
151 
152  switch (option[0]){
153  case 'Z':
154  {
155  for (Int_t iZone=1;iZone<=fSector->GetNofZones();++iZone){
156  AliMpZone *zone = fSector->GetZone(iZone);
157  gr->Push();
158 
159  Double_t blx= 9999, bly= 9999;
160  Double_t urx= -9999, ury= -9999;
161 
162  for (Int_t iSubZone=0;iSubZone<zone->GetNofSubZones();++iSubZone){
163  AliMpSubZone *subZone = zone->GetSubZone(iSubZone);
164  for (Int_t iRowSeg=0;iRowSeg<subZone->GetNofRowSegments();++iRowSeg){
165  AliMpVRowSegment *rowSegment = subZone->GetRowSegment(iRowSeg);
166 
167  TVector2 bl = TVector2(rowSegment->GetPositionX(),
168  rowSegment->GetPositionY()) -
169  TVector2(rowSegment->GetDimensionX(),
170  rowSegment->GetDimensionY());
171  TVector2 ur = TVector2(rowSegment->GetPositionX(),
172  rowSegment->GetPositionY())+
173  TVector2(rowSegment->GetDimensionX(),
174  rowSegment->GetDimensionY());
175 
176  if (bl.X()<blx) blx=bl.X();
177  if (bl.Y()<bly) bly=bl.Y();
178  if (ur.X()>urx) urx=ur.X();
179  if (ur.Y()>ury) ury=ur.Y();
180  }
181  }
182  TVector2 position ( (urx+blx)/2.,(ury+bly)/2. );
183  TVector2 dimensions( (urx-blx)/2.,(ury-bly)/2. );
184 
185  gr->SetPadPosForReal(position,dimensions);
186  gr->SetColor(iZone+3);
187  DrawObject(zone,option+1);
188 
189  gr->Pop();
190  }
191  }
192  break;
193  case 'R':
194  {
195  for (Int_t iRow=0;iRow<fSector->GetNofRows();++iRow){
196  AliMpRow *row = fSector->GetRow(iRow);
197  gr->Push();
198  gr->SetPadPosForReal(TVector2(row->GetPositionX(), row->GetPositionY()),
199  TVector2(row->GetDimensionX(), row->GetDimensionY()));
200  DrawObject(row,option+1);
201  gr->Pop();
202  }
203  }
204  break;
205  default: AppendPad(option);
206  }
207  gr->Pop();
208 }
209 
210 //_______________________________________________________________________
211 void AliMpSectorPainter::Paint(Option_t* /*option*/)
212 {
214 
216  if (!fSector) return;
217  if (fSector->GetNofRows()<1) return;
218  Int_t col=gVirtualX->GetFillColor();
219  gr->Push();
221  gPad->Range(0.,0.,1.,1.);
222 
223 
224  Double_t lx1=0.;
225  Double_t lx2=0.;
226  Int_t iRow;
227  for (iRow=0;iRow<fSector->GetNofRows();++iRow){
228  AliMpRow *row = fSector->GetRow(iRow);
229  TVector2 pos,dim;
230  gr->RealToPad(TVector2(row->GetPositionX(), row->GetPositionY()),
231  TVector2(row->GetDimensionX(), row->GetDimensionY()),pos,dim);
232  gPad->PaintBox(pos.X()-dim.X(),pos.Y()-dim.Y(),
233  pos.X()+dim.X(),pos.Y()+dim.Y());
234  gPad->PaintLine(pos.X()-dim.X(),pos.Y()-dim.Y(),
235  pos.X()-dim.X(),pos.Y()+dim.Y());
236  gPad->PaintLine(pos.X()+dim.X(),pos.Y()-dim.Y(),
237  pos.X()+dim.X(),pos.Y()+dim.Y());
238 
239  if (iRow>0){
240  gPad->PaintLine(pos.X()-dim.X(),pos.Y()-dim.Y(),lx1,pos.Y()-dim.Y());
241  gPad->PaintLine(pos.X()+dim.X(),pos.Y()-dim.Y(),lx2,pos.Y()-dim.Y());
242  }
243  lx1=pos.X()-dim.X();
244  lx2=pos.X()+dim.X();
245  }
246 
247  // now we draw the lower and upper horizontal lines
248 
249  AliMpRow *row = fSector->GetRow(0);
250  TVector2 pos,dim;
251  gr->RealToPad(TVector2(row->GetPositionX(), row->GetPositionY()),
252  TVector2(row->GetDimensionX(), row->GetDimensionY()),pos,dim);
253  gPad->PaintLine(pos.X()-dim.X(),pos.Y()-dim.Y(),
254  pos.X()+dim.X(),pos.Y()-dim.Y());
255 
256  row = fSector->GetRow(fSector->GetNofRows()-1);
257  gr->RealToPad(TVector2(row->GetPositionX(), row->GetPositionY()),
258  TVector2(row->GetDimensionX(), row->GetDimensionY()),pos,dim);
259  gPad->PaintLine(pos.X()-dim.X(),pos.Y()+dim.Y(),
260  pos.X()+dim.X(),pos.Y()+dim.Y());
261 
262  gr->Pop();
263  gVirtualX->SetFillColor(col);
264 }
265 
Int_t GetNofRows() const
virtual void Paint(Option_t *)
Paint the associated object.
Double_t GetPositionX() const
Definition: AliMpRow.cxx:338
virtual Double_t GetDimensionX() const =0
Return the x dimension of the row segment centre.
Double_t GetPositionY() const
Definition: AliMpRow.cxx:347
Int_t GetNofRowSegments() const
static AliMpGraphContext * Instance()
void SetPadPosForReal(const TVector2 &position, const TVector2 &dimensions)
virtual TVector2 GetDimensions() const
Return the owned object's dimensions.
void SetColor(Int_t color)
Set color to use.
A region of pads of the same dimensions composed of subzones.
Definition: AliMpZone.h:25
Double_t GetDimensionY() const
Definition: AliMpRow.cxx:364
Int_t GetNofSubZones() const
Definition: AliMpZone.cxx:103
ClassImp(TPCGenInfo)
Definition: AliTPCCmpNG.C:254
An interface for a row segment.
Double_t GetDimensionX() const
Definition: AliMpRow.cxx:355
virtual Double_t GetPositionX() const =0
Return the x position of the row segment centre.
virtual Double_t GetPositionY() const =0
Return the y position of the row segment centre.
TGraph * gr
Definition: CalibTime.C:25
virtual void Draw(Option_t *option)
Abstract base class for drawing objects into canvas.
Definition: AliMpVPainter.h:21
virtual TVector2 GetPosition() const
Return the owned object's position.
Int_t GetNofZones() const
Class for drawing a sector into canvas.
A row composed of the row segments.
Definition: AliMpRow.h:26
A sector (quadrant) of the MUON chamber of stations 1 and 2.
Definition: AliMpSector.h:34
AliMpSector * fSector
the sector to draw
virtual Double_t GetDimensionY() const =0
Return the y dimension of the row segment centre.
AliMpVPainter * DrawObject(TObject *object, Option_t *option="")
Not implemented.
TVector2 RealToPad(const TVector2 &position) const
AliMpSubZone * GetSubZone(Int_t i) const
Definition: AliMpZone.cxx:111
AliMpRow * GetRow(Int_t i) const
Class describing the correspondance between a given area in pad, and a zone of real (cm) position...
AliMpZone * GetZone(Int_t i) const
AliMpVRowSegment * GetRowSegment(Int_t i) const
void InitGraphContext()
virtual void DumpObject()
A region in zone composed of the row segments with the same motif type.
Definition: AliMpSubZone.h:23