AliRoot Core  v5-06-15 (45dab64)
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
AliMpIteratorPainter.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 
18 #include "AliMpIteratorPainter.h"
19 
20 #include "AliMpVPadIterator.h"
21 #include "AliMpPad.h"
22 #include "AliMpGraphContext.h"
23 
24 #include "AliLog.h"
25 
26 #include "TObjArray.h"
27 #include "TVirtualX.h"
28 #include "TVirtualPad.h"
29 #include "TVector2.h"
30 #include "TMath.h"
31 
32 //-----------------------------------------------------------------------------
39 //-----------------------------------------------------------------------------
40 
44 
45 //_____________________________________________________________________________
47 : AliMpVPainter(), fPads(new TObjArray), fPosition(), fDimensions()
48 {
50 
51  //if (!it) throw;
52  if (!it) {
53  AliFatal("Iterator must not be null.");
54  return;
55  }
56 
57  Double_t xmin(1E9), xmax(-1E9);
58  Double_t ymin(1E9), ymax(-1E9);
59 
60  fPads->SetOwner(kTRUE);
61  it->First();
62  while ( !it->IsDone() )
63  {
64  AliMpPad pad = it->CurrentItem();
65  fPads->AddLast(new AliMpPad(pad));
66  TVector2 lowerLeft(TVector2(pad.GetPositionX(),pad.GetPositionY())-
67  TVector2(pad.GetDimensionX(),pad.GetDimensionY()));
68  TVector2 upperRight(TVector2(pad.GetPositionX(),pad.GetPositionY())+
69  TVector2(pad.GetDimensionX(),pad.GetDimensionY()));
70  xmin = TMath::Min(lowerLeft.X(),xmin);
71  ymin = TMath::Min(lowerLeft.Y(),ymin);
72  xmax = TMath::Max(upperRight.X(),xmax);
73  ymax = TMath::Max(upperRight.Y(),ymax);
74  it->Next();
75  }
76  fPosition = TVector2((xmin+xmax)/2.0,(ymin+ymax)/2.0);
77  fDimensions = TVector2((xmax-xmin)/2.0,(ymax-ymin)/2.0);
78 }
79 
80 //_____________________________________________________________________________
82 {
84  delete fPads;
85 }
86 
87 //_____________________________________________________________________________
88 void
89 AliMpIteratorPainter::Draw(Option_t* option)
90 {
93  gr->Push();
96  AppendPad(option);
97  gr->Pop();
98 }
99 
100 //_____________________________________________________________________________
101 void
103 {
105 
107  gr->Push();
109  gPad->Range(0.,0.,1.,1.);
110 
111  TIter next(fPads);
112  AliMpPad* pad;
113 
114  while ( ( pad = static_cast<AliMpPad*>(next()) ) )
115  {
116  TVector2 padPadPos;
117  TVector2 padPadDim;
118 
119  gr->RealToPad(TVector2(pad->GetPositionX(),
120  pad->GetPositionY()),
121  TVector2(pad->GetDimensionX(),
122  pad->GetDimensionY()),
123  padPadPos, padPadDim);
124 
125  TVector2 bl = padPadPos - padPadDim;
126  TVector2 ur = padPadPos + padPadDim;
127 
128  Int_t manuId = pad->GetManuId();
129 
130  Style_t sty = gVirtualX->GetFillStyle();
131 
132  gVirtualX->SetFillStyle(1);
133  if (manuId % 5 == 0)
134  gVirtualX->SetFillColor(0);
135  if (manuId % 5 == 1)
136  gVirtualX->SetFillColor(38);
137  if (manuId % 5 == 2)
138  gVirtualX->SetFillColor(33);
139  if (manuId % 5 == 3)
140  gVirtualX->SetFillColor(16);
141  if (manuId % 5 == 4)
142  gVirtualX->SetFillColor(44);
143 
144  gPad->PaintBox(bl.X(),bl.Y(),ur.X(),ur.Y());
145  gVirtualX->SetFillStyle(0);
146  gPad->PaintBox(bl.X(),bl.Y(),ur.X(),ur.Y());
147  gVirtualX->SetFillStyle(sty);
148 
149  Float_t textSize = gVirtualX->GetTextSize();
150  gVirtualX->SetTextSize(10);
151  gVirtualX->SetTextAlign(22);
152  gPad->PaintText((bl.X()+ur.X())/2.0,(bl.Y()+ur.Y())/2.0,
153  Form("%d",pad->GetManuChannel()));
154 
155  gVirtualX->SetTextSize(textSize);
156 
157  }
158 }
159 
160 
TVector2 GetPosition() const
Return the owned object's position.
void Paint(Option_t *option)
Paint the associated object.
Painter for a group of pads defined by an iterator.
#define TObjArray
void Draw(Option_t *option)
Int_t GetManuId() const
Definition: AliMpPad.cxx:256
static AliMpGraphContext * Instance()
void SetPadPosForReal(const TVector2 &position, const TVector2 &dimensions)
ClassImp(TPCGenInfo)
Definition: AliTPCCmpNG.C:254
Int_t GetManuChannel() const
Definition: AliMpPad.cxx:264
TGraph * gr
Definition: CalibTime.C:25
An interface for an iterator over pads.
Double_t GetPositionY() const
Return the pad x position (in cm)
Definition: AliMpPad.h:81
Abstract base class for drawing objects into canvas.
Definition: AliMpVPainter.h:21
TVector2 GetDimensions() const
Return the owned object's dimensions.
Double_t GetDimensionY() const
Return the y pad dimension - half length (in cm)
Definition: AliMpPad.h:86
TVector2 RealToPad(const TVector2 &position) const
Class which encapsuate all information about a pad.
Definition: AliMpPad.h:22
Double_t GetPositionX() const
Return the pad x position (in cm)
Definition: AliMpPad.h:79
TObjArray * fPads
! pads of the iterator
Class describing the correspondance between a given area in pad, and a zone of real (cm) position...
Double_t GetDimensionX() const
Return the x pad dimension - half length (in cm)
Definition: AliMpPad.h:84
void InitGraphContext()