source: trunk/MagicSoft/Mars/mgeom/MGeomPix.h@ 9271

Last change on this file since 9271 was 9259, checked in by tbretz, 16 years ago
*** empty log message ***
File size: 3.4 KB
Line 
1#ifndef MARS_MGeomPix
2#define MARS_MGeomPix
3
4#ifndef MARS_MParContainer
5#include "MParContainer.h"
6#endif
7
8class MGeomCam;
9class TVector2;
10class TOrdCollection;
11
12
13class MGeomPix : public MParContainer
14{
15public:
16 static const Float_t gsTan60; // tan(60/kRad2Deg);
17 static const Float_t gsTan30; // tan(30/kRad2Deg);
18
19 enum {
20 kRightTop,
21 kRight,
22 kRightBottom,
23 kLeftBottom,
24 kLeft,
25 kLeftTop
26 };
27
28private:
29 enum {
30 kIsInOutermostRing = 0,
31 kIsInOuterRing = 1,
32 };
33
34 Float_t fX; // [mm] the x coordinate of the center
35 Float_t fY; // [mm] the y coordinate of the center
36 Float_t fD; // [mm] the d coordinate of the pixel (dist between two parallel sides)
37 Float_t fA; // [mm^2] Area of the pixel
38
39 Byte_t fNumNeighbors; // number of valid neighbors
40 Short_t fNeighbors[6]; // the IDs of the pixel next to it (we are assuming an hexagonal geometry)
41
42 UInt_t fSector; // Number of sector the pixels corresponds to
43 UInt_t fAidx; // Area index of the pixel
44
45 Byte_t fUserBits;
46
47public:
48 MGeomPix(Float_t x=0, Float_t y=0, Float_t d=1, UInt_t s=0, UInt_t aidx=0);
49
50 void Copy(TObject &obj) const
51 {
52 MGeomPix &pix = (MGeomPix&)obj;
53 pix.fX = fX;
54 pix.fY = fY;
55 pix.fD = fD;
56 pix.fA = fA;
57 pix.fNumNeighbors = fNumNeighbors;
58 pix.fSector = fSector;
59 pix.fAidx = fAidx;
60 pix.fUserBits = fUserBits;
61 for (int i=0; i<6; i++)
62 pix.fNeighbors[i] = fNeighbors[i];
63
64 TObject::Copy(obj);
65 }
66
67 void Print(Option_t *opt=NULL) const;
68
69 void Set(Float_t x, Float_t y, Float_t d=1, UInt_t s=0, UInt_t aidx=0) { fX=x; fY=y; fD=d; fA=d*d*gsTan60/2; fSector=s; fAidx=aidx; }
70
71 void SetNeighbors(Short_t i0=-1, Short_t i1=-1, Short_t i2=-1,
72 Short_t i3=-1, Short_t i4=-1, Short_t i5=-1);
73
74 void CheckOuterRing(const MGeomCam &cam);
75
76 Float_t GetX() const { return fX; }
77 Float_t GetY() const { return fY; }
78 Float_t GetD() const { return fD; } // Distance between two parellel sides
79 Float_t GetL() const { return fD*gsTan30; } // Length of one of the parallel sides
80 Float_t GetT() const { return fD/gsTan60; } // Distance between two opposite edges (traverse)
81 UInt_t GetSector() const { return fSector; }
82
83 TVector2 GetP() const;
84
85 Float_t GetDist() const;
86 Float_t GetDist(const MGeomPix &pix) const;
87 Float_t GetAngle(const MGeomPix &pix) const;
88
89 Float_t GetA() const { return fA; /*fD*fD*gsTan60/2;*/ }
90 Int_t GetAidx() const { return fAidx; }
91
92 Byte_t GetNumNeighbors() const { return fNumNeighbors; }
93 Short_t GetNeighbor(Byte_t i) const { return fNeighbors[i]; }
94
95 Bool_t IsInOutermostRing() const { return TESTBIT(fUserBits, kIsInOutermostRing); }
96 Bool_t IsInOuterRing() const { return TESTBIT(fUserBits, kIsInOuterRing); }
97
98 Bool_t IsInside(Float_t px, Float_t py) const;
99 Int_t GetDirection(const MGeomPix &pix) const;
100
101 virtual Float_t DistanceToPrimitive(Float_t px, Float_t py) const;
102 //void GetIntersectionBorder(TOrdCollection &col, const MGeomPix &hex) const;
103 //Double_t CalcOverlapArea(const MGeomPix &cam) const;
104
105 //TObject *GetGraphics() { return new MHexagon(*this); }
106
107 ClassDef(MGeomPix, 4) // Geometry class describing the geometry of one pixel
108};
109
110#endif
Note: See TracBrowser for help on using the repository browser.