]> git.uio.no Git - u/mrichter/AliRoot.git/blob - ITS/UPGRADE/AliITSUClusterPix.h
9b7f324851b5bd5711f4e5f3af1dfd2eb5170aec
[u/mrichter/AliRoot.git] / ITS / UPGRADE / AliITSUClusterPix.h
1 #ifndef ALIITSUCLUSTERPIX_H
2 #define ALIITSUCLUSTERPIX_H
3
4 #include "AliCluster.h"
5 #include <TMath.h>
6
7 class TGeoHMatrix;
8 class AliITSUGeomTGeo;
9
10
11 class AliITSUClusterPix : public AliCluster
12 {
13  public:
14   enum { // frame in which the track is currently defined
15     kFrameLoc  = BIT(16)
16     ,kFrameTrk = BIT(17)
17     ,kFrameGlo = BIT(18)
18     ,kFrameBits = kFrameLoc|kFrameTrk|kFrameGlo
19     ,kSplit    = BIT(19)
20   };
21   //
22   enum SortMode_t { // various modes
23     kSortIdLocXZ  = BIT(0)    // sort according to ID, then X,Z of local frame
24     ,kSortIdTrkYZ = BIT(1)    // sort according to ID, then Y,Z of tracking frame
25     ,kSortBits = kSortIdLocXZ|kSortIdTrkYZ
26   };
27
28  public:
29   AliITSUClusterPix();
30   AliITSUClusterPix(const AliITSUClusterPix& cluster);
31   AliITSUClusterPix &operator=(const AliITSUClusterPix& cluster);
32   virtual ~AliITSUClusterPix();
33   //
34   Bool_t  IsFrameLoc()         const {return TestBit(kFrameLoc);}
35   Bool_t  IsFrameGlo()         const {return TestBit(kFrameGlo);}
36   Bool_t  IsFrameTrk()         const {return TestBit(kFrameTrk);}
37   //
38   Bool_t  IsSplit()            const {return TestBit(kSplit);}
39   //
40   void    SetFrameLoc()              {ResetBit(kFrameBits); SetBit(kFrameLoc);}
41   void    SetFrameGlo()              {ResetBit(kFrameBits); SetBit(kFrameGlo);}
42   void    SetFrameTrk()              {ResetBit(kFrameTrk);  SetBit(kFrameTrk);}
43   //
44   void    SetSplit(Bool_t v=kTRUE)   {SetBit(kSplit,v);}
45   //
46   void    GoToFrameGlo();
47   void    GoToFrameLoc();
48   void    GoToFrameTrk();
49   void    GetLocalXYZ(Float_t xyz[3])                       const;
50   void    GetTrackingXYZ(Float_t xyz[3])                    const; 
51   //
52   void    SetNxNzN(UChar_t nx,UChar_t nz,UShort_t n)              {fNxNzN = ( ((n&0xff)<<16)) + ((nx&0xff)<<8) + (nz&0xff);}
53   void    SetClUsage(Int_t n);
54   void    ModClUsage(Bool_t used=kTRUE)                           {used ? IncClUsage() : DecClUsage();}
55   void    IncClUsage()                                            {SetClUsage(GetClUsage()+1); IncreaseClusterUsage();}
56   void    DecClUsage();
57   Int_t   GetNx()                                           const {return (fNxNzN>>8)&0xff;}
58   Int_t   GetNz()                                           const {return fNxNzN&0xff;}
59   Int_t   GetNPix()                                         const {return (fNxNzN>>16)&0xff;}
60   Int_t   GetClUsage()                                      const {return (fNxNzN>>24)&0xff;}
61   //
62   void    SetQ(UShort_t q)                                        {fCharge = q;}
63   Int_t   GetQ()                                            const {return fCharge;}
64   //
65   virtual void                 Print(Option_t* option = "") const;
66   virtual const TGeoHMatrix*   GetTracking2LocalMatrix()           const;
67   virtual TGeoHMatrix*         GetMatrix(Bool_t original = kFALSE) const;
68   virtual Bool_t               GetGlobalXYZ(Float_t xyz[3]) const;
69   virtual Bool_t               GetGlobalCov(Float_t cov[6]) const;
70   virtual Bool_t               GetXRefPlane(Float_t &xref)  const;
71   //
72   virtual Bool_t               IsSortable()                 const {return kTRUE;}
73   virtual Bool_t               IsEqual(const TObject* obj)  const;
74   virtual Int_t                Compare(const TObject* obj)  const;
75   //
76   Bool_t  HasCommonTrack(const AliCluster* cl)          const;
77   //
78   static  void                 SetGeom(AliITSUGeomTGeo* gm) {fgGeom = gm;}
79   static  void                 SetSortMode(SortMode_t md)   {fgMode &= ~kSortBits; fgMode |= md;}
80   static  UInt_t               GetSortMode()                {return fgMode&kSortBits;}
81   static  UInt_t               GetMode()                    {return fgMode;}
82   static  SortMode_t           SortModeIdTrkYZ()            {return kSortIdTrkYZ;}
83   static  SortMode_t           SortModeIdLocXZ()            {return kSortIdLocXZ;}
84   //
85  protected:
86   //
87   UShort_t                fCharge;        //  charge (for MC studies only)
88   Int_t                   fNxNzN;         //  effective cluster size in X (1st byte) and Z (2nd byte) directions 
89                                           //  and total Npix(3d byte). 4th byte is used for clusters usage counter
90   static UInt_t           fgMode;         //! general mode (sorting mode etc)
91   static AliITSUGeomTGeo* fgGeom;         //! pointer on the geometry data
92
93   ClassDef(AliITSUClusterPix,1)
94 };
95
96 //______________________________________________________
97 inline void AliITSUClusterPix::DecClUsage() {
98   // decrease cluster usage counter
99   int n=GetClUsage(); 
100   if (n) SetClUsage(--n);
101   //
102 }
103
104 //______________________________________________________
105 inline void AliITSUClusterPix::SetClUsage(Int_t n) {
106   // set cluster usage counter
107   fNxNzN &= ((n&0xff)<<24)&0x00ffffff; 
108   if (n<2) SetBit(kShared,kFALSE);
109   if (!n)  SetBit(kUsed,kFALSE);
110 }
111
112 #endif