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