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

Last change on this file since 8765 was 8756, checked in by tbretz, 17 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;
9
10class MGeomPix : public MParContainer
11{
12public:
13 static const Float_t gsTan60; // tan(60/kRad2Deg);
14 static const Float_t gsTan30; // tan(30/kRad2Deg);
15
16 enum {
17 kRightTop,
18 kRight,
19 kRightBottom,
20 kLeftBottom,
21 kLeft,
22 kLeftTop
23 };
24
25private:
26 enum {
27 kIsInOutermostRing = BIT(22),
28 kIsInOuterRing = BIT(23),
29 kUserBits = 0x1fc000 // 14-21 are allowed
30 };
31
32 Float_t fX; // [mm] the x coordinate of the center
33 Float_t fY; // [mm] the y coordinate of the center
34 Float_t fD; // [mm] the d coordinate of the pixel (dist between two parallel sides)
35 Float_t fA; // [mm^2] Area of the pixel
36
37 Byte_t fNumNeighbors; // number of valid neighbors
38 Short_t fNeighbors[6]; // the IDs of the pixel next to it (we are assuming an hexagonal geometry)
39
40 UInt_t fSector; // Number of sector the pixels corresponds to
41 UInt_t fAidx; // Area index of the pixel
42
43public:
44 MGeomPix(Float_t x=0, Float_t y=0, Float_t d=1, UInt_t s=0, UInt_t aidx=0);
45
46 void Copy(TObject &obj) const
47 {
48 MGeomPix &pix = (MGeomPix&)obj;
49 pix.fX = fX;
50 pix.fY = fY;
51 pix.fD = fD;
52 pix.fA = fA;
53 pix.fNumNeighbors = fNumNeighbors;
54 pix.fSector = fSector;
55 pix.fAidx = fAidx;
56 for (int i=0; i<6; i++)
57 pix.fNeighbors[i] = fNeighbors[i];
58 }
59
60 void Print(Option_t *opt=NULL) const;
61
62 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; }
63
64 void SetNeighbors(Short_t i0=-1, Short_t i1=-1, Short_t i2=-1,
65 Short_t i3=-1, Short_t i4=-1, Short_t i5=-1);
66
67 void CheckOuterRing(const MGeomCam &cam);
68
69 Float_t GetX() const { return fX; }
70 Float_t GetY() const { return fY; }
71 Float_t GetD() const { return fD; }
72 Float_t GetL() const { return fD*gsTan30; } // Length of one of the parallel sides
73 UInt_t GetSector() const { return fSector; }
74
75 Float_t GetDist() const { return TMath::Hypot(fX, fY); }
76 Float_t GetDist(const MGeomPix &pix) const { return TMath::Hypot(fX-pix.fX, fY-pix.fY); }
77 Float_t GetAngle(const MGeomPix &pix) const { return TMath::ATan2(fX - pix.GetX(), fY - pix.GetY()); }
78
79 Float_t GetA() const { return fA; /*fD*fD*gsTan60/2;*/ }
80 Int_t GetAidx() const { return fAidx; }
81
82 Byte_t GetNumNeighbors() const { return fNumNeighbors; }
83 Short_t GetNeighbor(Byte_t i) const { return fNeighbors[i]; }
84
85 Bool_t IsInOutermostRing() const { return TestBit(kIsInOutermostRing); }
86 Bool_t IsInOuterRing() const { return TestBit(kIsInOuterRing); }
87
88 Bool_t IsInside(Float_t px, Float_t py) const;
89 Int_t GetDirection(const MGeomPix &pix) const;
90
91 /*
92 //
93 // These function are for future usage. They are not virtual in
94 // root by now.
95 //
96 void SetBit(UInt_t f, Bool_t set) { set ? TObject::SetBit(f) : TObject::ResetBit(f); }
97 void SetBit(UInt_t f) { TObject::SetBit(f & kUserBits); }
98 void ResetBit(UInt_t f) { TObject::ResetBit(f & kUserBits); }
99 void InvertBit(UInt_t f) { TObject InvertBit(f & kUserBits); }
100 */
101
102 ClassDef(MGeomPix, 3) // Geometry class describing the geometry of one pixel
103};
104
105#endif
Note: See TracBrowser for help on using the repository browser.