StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
TVolumePosition.h
1 // @(#)root/table:$Id$
2 // Author: Valery Fine(fine@bnl.gov) 25/12/98
3 
4 /*************************************************************************
5  * Copyright (C) 1995-2000, Rene Brun and Fons Rademakers. *
6  * All rights reserved. *
7  * *
8  * For the licensing terms see $ROOTSYS/LICENSE. *
9  * For the list of contributors see $ROOTSYS/README/CREDITS. *
10  *************************************************************************/
11 
13 // //
14 // TVolumePosition //
15 // //
16 // Description of parameters to position a 3-D geometry object //
17 // //
19 
20 #ifndef ROOT_TVolumePosition
21 #define ROOT_TVolumePosition
22 
23 #include "TVolume.h"
24 
25 class TBrowser;
26 class TRotMatrix;
27 
28 class TVolumePosition : public TObject {
29 protected:
30  Double_t fX[3]; //X offset with respect to parent object
31  TRotMatrix *fMatrix; //Pointer to rotation matrix
32  TVolume *fNode; //Refs pointer to the node defined
33  UInt_t fId; // Unique ID of this position
34 
35 protected:
36  void DeleteOwnMatrix();
37 
38 public:
39  enum EPositionBits {
40  kIsOwn = BIT(23) // if the TVolumePoistion doesn't own the TRotMatrix object
41  };
42  TVolumePosition(TVolume *node=0,Double_t x=0, Double_t y=0, Double_t z=0, TRotMatrix *matrix=0);
43  TVolumePosition(TVolume *node,Double_t x, Double_t y, Double_t z, const char *matrixname);
44  TVolumePosition(const TVolumePosition* oldPosition, const TVolumePosition* curPosition);
46  virtual ~TVolumePosition();
47  virtual void Browse(TBrowser *b);
48  virtual Float_t *Errmx2Local (const Float_t *masterError, Float_t *localError ) const;
49  virtual Double_t *Errmx2Local (const Double_t *masterError, Double_t *localError) const;
50  virtual Float_t *Errmx2Master(const Float_t *localError, Float_t *masterError ) const;
51  virtual Double_t *Errmx2Master(const Double_t *localError, Double_t *masterError) const;
52  virtual Double_t *Cormx2Local (const Double_t *masterCorr, Double_t *localCorr ) const;
53  virtual Float_t *Cormx2Local (const Float_t *masterCorr, Float_t *localCorr ) const;
54  virtual Double_t *Cormx2Master(const Double_t *localCorr, Double_t *masterCorr ) const;
55  virtual Float_t *Cormx2Master(const Float_t *localCorr, Float_t *masterCorr ) const;
56  virtual Double_t *Master2Local(const Double_t *master, Double_t *local,Int_t nPoints=1) const;
57  virtual Float_t *Master2Local(const Float_t *master, Float_t *local,Int_t nPoints=1) const;
58 
59  virtual Int_t DistancetoPrimitive(Int_t px, Int_t py);
60  virtual TDataSet *DefineSet();
61  virtual void Draw(Option_t *depth="3"); // *MENU*
62  virtual void ExecuteEvent(Int_t event, Int_t px, Int_t py);
63  virtual TVolume *GetNode() const {return fNode;}
64  virtual char *GetObjectInfo(Int_t px, Int_t py) const;
65  const Option_t *GetOption() const { return GetNode()?GetNode()->GetOption():0;}
66  virtual const Char_t *GetName() const;
67  const TRotMatrix *GetMatrix() const;
68  TRotMatrix *GetMatrix();
69 
70  Int_t GetVisibility() const {return GetNode()?GetNode()->GetVisibility():0;}
71  virtual Double_t GetX(Int_t indx=0) const {return fX[indx];}
72  virtual const Double_t *GetXYZ() const {return fX;}
73  virtual Double_t GetY() const {return fX[1];}
74  virtual Double_t GetZ() const {return fX[2];}
75  virtual UInt_t GetId() const {return fId;}
76  Bool_t IsMatrixOwner() const;
77  Bool_t SetMatrixOwner(Bool_t ownerShips=kTRUE);
78  Bool_t IsFolder() const {return GetNode()?kTRUE:kFALSE;}
79  virtual Bool_t Is3D() const {return kTRUE;}
80  virtual Double_t *Local2Master(const Double_t *local, Double_t *master,Int_t nPoints=1) const;
81  virtual Float_t *Local2Master(const Float_t *local, Float_t *master,Int_t nPoints=1) const;
82  virtual TVolumePosition &Mult(const TVolumePosition &position);
83  virtual void Paint(Option_t *option="");
84  virtual void Print(Option_t *option="") const;
85  virtual void UpdatePosition(Option_t *option="");
86  virtual TVolumePosition *Reset(TVolume *node=0,Double_t x=0, Double_t y=0, Double_t z=0, TRotMatrix *matrix=0);
87  virtual void SavePrimitive(std::ostream &out, Option_t *option = "");
88  virtual void SetLineAttributes(); // *MENU*
89  virtual void SetMatrix(TRotMatrix *matrix=0);
90  virtual void SetNode(TVolume *node){ fNode = node;}
91  virtual void SetPosition( Double_t x=0, Double_t y=0, Double_t z=0) {fX[0]=x; fX[1]=y; fX[2]=z;}
92  virtual void SetVisibility(Int_t vis=1); // *MENU*
93  virtual void SetX(Double_t x){ fX[0] = x;}
94  virtual void SetY(Double_t y){ fX[1] = y;}
95  virtual void SetZ(Double_t z){ fX[2] = z;}
96  virtual void SetXYZ(Double_t *xyz = 0);
97  virtual void SetId(UInt_t id){fId = id;}
98  TVolumePosition &operator=(const TVolumePosition &rhs);
99  ClassDef(TVolumePosition,2) //Description of parameters to position a 3-D geometry object
100 };
101 
102 //______________________________________________________________________________
103 inline TDataSet *TVolumePosition::DefineSet(){ return GetNode(); }
104 //______________________________________________________________________________
105 inline void TVolumePosition::DeleteOwnMatrix()
106 {
107  if (IsMatrixOwner()) {
108  TRotMatrix *erasing = fMatrix;
109  fMatrix = 0;
110  delete erasing;
111  }
112 }
113 //______________________________________________________________________________
114 inline TRotMatrix *TVolumePosition::GetMatrix()
115 { return fMatrix; }
116 //______________________________________________________________________________
117 inline const TRotMatrix *TVolumePosition::GetMatrix() const
118 { return fMatrix; }
119 //______________________________________________________________________________
120 inline Bool_t TVolumePosition::SetMatrixOwner(Bool_t ownerShips)
121 {
122  Bool_t currentOwner = IsMatrixOwner();
123  SetBit(kIsOwn,ownerShips);
124  return currentOwner;
125 }
126 //______________________________________________________________________________
127 inline Bool_t TVolumePosition::IsMatrixOwner() const
128 {
129  // Check whether this object owns the TRotMatrix (to be deleted for example)
130  // Note: This method is to be caleed from dtor.
131  // It is dangerous to make it virtual
132  return TestBit(kIsOwn);
133 }
134 //______________________________________________________________________________
135 inline TVolumePosition &TVolumePosition::operator=(const TVolumePosition &rhs) {
136  if (this != &rhs) {
137  for (int i = 0; i < 3; i++) fX[i] = rhs.fX[i];
138  fMatrix = rhs.fMatrix;
139  fNode = rhs.fNode;
140  fId = rhs.fId;
141  }
142  return *this;
143 }
144 //______________________________________________________________________________
145 std::ostream& operator<<(std::ostream& s,const TVolumePosition &target);
146 #endif
virtual void Browse(TBrowser *b)
to be documented
virtual void Draw(Option_t *depth="3")
Draw Referenced node with current parameters.
virtual Double_t * Cormx2Master(const Double_t *localCorr, Double_t *masterCorr) const
to be documented
virtual Float_t * Errmx2Master(const Float_t *localError, Float_t *masterError) const
to be documented
virtual Int_t DistancetoPrimitive(Int_t px, Int_t py)
virtual void SetXYZ(Double_t *xyz=0)
to be documented
virtual void SavePrimitive(std::ostream &out, Option_t *option="")
to be documented
virtual Double_t * Local2Master(const Double_t *local, Double_t *master, Int_t nPoints=1) const
virtual ~TVolumePosition()
to be documented
virtual void SetVisibility(Int_t vis=1)
to be documented
virtual Double_t * Cormx2Local(const Double_t *masterCorr, Double_t *localCorr) const
to be documented
virtual char * GetObjectInfo(Int_t px, Int_t py) const
to be documented
virtual void SetLineAttributes()
to be documented
virtual void SetMatrix(TRotMatrix *matrix=0)
to be documented
TVolumePosition(TVolume *node=0, Double_t x=0, Double_t y=0, Double_t z=0, TRotMatrix *matrix=0)
virtual void UpdatePosition(Option_t *option="")
to be documented
virtual void ExecuteEvent(Int_t event, Int_t px, Int_t py)
virtual TVolumePosition * Reset(TVolume *node=0, Double_t x=0, Double_t y=0, Double_t z=0, TRotMatrix *matrix=0)
virtual Double_t * Master2Local(const Double_t *master, Double_t *local, Int_t nPoints=1) const
virtual Float_t * Errmx2Local(const Float_t *masterError, Float_t *localError) const
to be documented
virtual void Print(Option_t *option="") const
to be documented
virtual void Paint(Option_t *option="")
Paint Referenced node with current parameters.
virtual const Char_t * GetName() const
return VolumePosition name