]> git.uio.no Git - u/mrichter/AliRoot.git/blame_incremental - MUON/mapping/AliMpGraphContext.cxx
gAlice->Particle(lab) removed. TParticle obj. accessed via AliMC
[u/mrichter/AliRoot.git] / MUON / mapping / AliMpGraphContext.cxx
... / ...
CommitLineData
1// $Id$
2// Category: graphics
3//
4// Class AliMpGraphContext
5// -----------------------
6// Class describing a the correspondance between a given area
7// in pad, and a zone of real (cm) position
8//
9// Author: David GUEZ, IPN Orsay
10
11#include "AliMpGraphContext.h"
12
13ClassImp(AliMpGraphContext)
14
15AliMpGraphContext *AliMpGraphContext::fgInstance = 0;
16GraphContextVector AliMpGraphContext::fgStack;
17
18// private constructor
19AliMpGraphContext::AliMpGraphContext():
20 TObject(),
21 fPadPosition(TVector2(0.5,0.5)),
22 fPadDimensions(TVector2(0.49,0.49)),
23 fRealPosition(TVector2(0.,0.)),
24 fRealDimensions(TVector2(1,1))
25{
26 fColor = 20;
27 // default constructor (private)
28}
29AliMpGraphContext *AliMpGraphContext::Instance()
30{
31 // return or create a unique instance of this class
32 if (fgInstance) return fgInstance;
33 fgInstance = new AliMpGraphContext;
34 return fgInstance;
35}
36
37TVector2 AliMpGraphContext::RealToPad(const TVector2 &position) const
38{
39 // transform a real position into its equivalent position in the pad
40 Double_t x=position.X();
41 Double_t y=position.Y();
42 x-= (fRealPosition.X()-fRealDimensions.X());
43 x/=fRealDimensions.X();
44 x*=fPadDimensions.X();
45 x+= (fPadPosition.X()-fPadDimensions.X() );
46
47 y-= (fRealPosition.Y()-fRealDimensions.Y());
48 y/=fRealDimensions.Y();
49 y*=fPadDimensions.Y();
50 y+= (fPadPosition.Y()-fPadDimensions.Y() );
51
52 return TVector2(x,y);
53}
54
55
56
57void AliMpGraphContext::RealToPad(const TVector2 &position,
58 const TVector2 &dimensions,
59 TVector2 &padPosition,
60 TVector2 &padDimensions) const
61{
62 // transform the real area (position,dimensions) to
63 // its equivalent pad area
64 padPosition = RealToPad(position);
65 padDimensions =
66 TVector2(dimensions.X()*fPadDimensions.X()/fRealDimensions.X(),
67 dimensions.Y()*fPadDimensions.Y()/fRealDimensions.Y());
68
69}
70void AliMpGraphContext::SetPadPosForReal(const TVector2 &position,
71 const TVector2 &dimensions)
72{
73 // Set the pad area from the actual one
74 // corresponding to the given real area.
75 RealToPad(position,dimensions,fPadPosition,fPadDimensions);
76}
77void AliMpGraphContext::Push() const
78{
79 // Store the current configuration
80 AliMpGraphContext *save = new AliMpGraphContext(*this);
81 fgStack.push_back(save);
82}
83void AliMpGraphContext::Pop()
84{
85 // restore the last saved configuration
86 if (!fgStack.empty()){
87 AliMpGraphContext *obj = fgStack.back();
88 *this = *obj;
89 fgStack.pop_back();
90 delete obj;
91 }
92}