]> git.uio.no Git - u/mrichter/AliRoot.git/blob - ITS/UPGRADE/AliITSUClusterPix.h
f51dc43f98bc969d2d4aede2fa34541584064be6
[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 // uncomment this to have cluster topology in stored
8
9 //#define _ClusterTopology_  
10
11 #define CLUSTER_VERSION 2 
12
13 class TGeoHMatrix;
14 class AliITSUGeomTGeo;
15
16
17
18 class AliITSUClusterPix : public AliCluster
19 {
20  public:
21   enum { // frame in which the track is currently defined
22     kFrameLoc  = BIT(16)
23     ,kFrameTrk = BIT(17)
24     ,kFrameGlo = BIT(18)
25     ,kFrameBits = kFrameLoc|kFrameTrk|kFrameGlo
26     ,kSplit    = BIT(19)
27   };
28   //
29   enum SortMode_t { // various modes
30     kSortIdLocXZ  = BIT(0)    // sort according to ID, then X,Z of local frame
31     ,kSortIdTrkYZ = BIT(1)    // sort according to ID, then Y,Z of tracking frame
32     ,kSortBits = kSortIdLocXZ|kSortIdTrkYZ
33   };
34   enum {kOffsNZ=0,kMaskNZ=0xff,kOffsNX=8,kMaskNX=0xff,kOffsNPix=16,kMaskNPix=0x1ff,kOffsClUse=25,kMaskClUse=0x7f};
35   //
36 #ifdef _ClusterTopology_
37   enum {kMaxPatternBits=32*16, kMaxPatternBytes=kMaxPatternBits/8,
38         kSpanMask=0x7fff,kTruncateMask=0x8000};
39 #endif
40  public:
41   AliITSUClusterPix();
42   AliITSUClusterPix(const AliITSUClusterPix& cluster);
43   AliITSUClusterPix &operator=(const AliITSUClusterPix& cluster);
44   virtual ~AliITSUClusterPix();
45   //
46   Bool_t  IsFrameLoc()         const {return TestBit(kFrameLoc);}
47   Bool_t  IsFrameGlo()         const {return TestBit(kFrameGlo);}
48   Bool_t  IsFrameTrk()         const {return TestBit(kFrameTrk);}
49   //
50   Bool_t  IsSplit()            const {return TestBit(kSplit);}
51   //
52   void    SetFrameLoc()              {ResetBit(kFrameBits); SetBit(kFrameLoc);}
53   void    SetFrameGlo()              {ResetBit(kFrameBits); SetBit(kFrameGlo);}
54   void    SetFrameTrk()              {ResetBit(kFrameTrk);  SetBit(kFrameTrk);}
55   //
56   void    SetSplit(Bool_t v=kTRUE)   {SetBit(kSplit,v);}
57   //
58   void    GoToFrameGlo();
59   void    GoToFrameLoc();
60   void    GoToFrameTrk();
61   void    GetLocalXYZ(Float_t xyz[3])                       const;
62   void    GetTrackingXYZ(Float_t xyz[3])                    const; 
63   //
64   void    SetNxNzN(UChar_t nx,UChar_t nz,UShort_t n)              {fNxNzN = ((n&kMaskNPix)<<kOffsNPix) + ((nx&kMaskNX)<<kOffsNX) + ((nz&kMaskNZ)<<kOffsNZ);}
65   void    SetClUsage(Int_t n);
66   void    ModClUsage(Bool_t used=kTRUE)                           {used ? IncClUsage() : DecClUsage();}
67   void    IncClUsage()                                            {SetClUsage(GetClUsage()+1); IncreaseClusterUsage();}
68   void    DecClUsage();
69   Int_t   GetNx()                                           const {return (fNxNzN>>kOffsNX)&kMaskNX;}
70   Int_t   GetNz()                                           const {return (fNxNzN>>kOffsNZ)&kMaskNZ;}
71   Int_t   GetNPix()                                         const {return (fNxNzN>>kOffsNPix)&kMaskNPix;}
72   Int_t   GetClUsage()                                      const {return (fNxNzN>>kOffsClUse)&kMaskClUse;}
73   //
74   void    SetQ(UShort_t q)                                        {fCharge = q;}
75   Int_t   GetQ()                                            const {return fCharge;}
76   //
77   virtual void                 Print(Option_t* option = "") const;
78   virtual const TGeoHMatrix*   GetTracking2LocalMatrix()           const;
79   virtual TGeoHMatrix*         GetMatrix(Bool_t original = kFALSE) const;
80   virtual Bool_t               GetGlobalXYZ(Float_t xyz[3]) const;
81   virtual Bool_t               GetGlobalXYZ(Double_t xyz[3]) const;
82   virtual Bool_t               GetGlobalCov(Float_t cov[6]) const;
83   virtual Bool_t               GetXRefPlane(Float_t &xref)  const;
84   //
85   virtual Bool_t               IsSortable()                 const {return kTRUE;}
86   virtual Bool_t               IsEqual(const TObject* obj)  const;
87   virtual Int_t                Compare(const TObject* obj)  const;
88   //
89   UShort_t                     GetRecoInfo()                const {return fRecoInfo;}
90   void                         SetRecoInfo(UShort_t v)            {fRecoInfo = v; ModClUsage(v>0);}
91   //
92   Bool_t  HasCommonTrack(const AliCluster* cl)          const;
93   //
94   static  void                 SetGeom(AliITSUGeomTGeo* gm) {fgGeom = gm;}
95   static  void                 SetSortMode(SortMode_t md)   {fgMode &= ~kSortBits; fgMode |= md;}
96   static  UInt_t               GetSortMode()                {return fgMode&kSortBits;}
97   static  UInt_t               GetMode()                    {return fgMode;}
98   static  SortMode_t           SortModeIdTrkYZ()            {return kSortIdTrkYZ;}
99   static  SortMode_t           SortModeIdLocXZ()            {return kSortIdLocXZ;}
100   //
101 #ifdef _ClusterTopology_
102   Int_t    GetPatternRowSpan()                       const  {return fPatternNRows&kSpanMask;}
103   Int_t    GetPatternColSpan()                       const  {return fPatternNCols&kSpanMask;}
104   Bool_t   IsPatternRowsTruncated()                  const  {return fPatternNRows&kTruncateMask;}
105   Bool_t   IsPatternColsTruncated()                  const  {return fPatternNRows&kTruncateMask;}
106   Bool_t   IsPatternTruncated()                      const  {return IsPatternRowsTruncated()||IsPatternColsTruncated();}
107   void     SetPatternRowSpan(UShort_t nr, Bool_t truncated);
108   void     SetPatternColSpan(UShort_t nc, Bool_t truncated);
109   void     SetPatternMinRow(UShort_t row)            {fPatternMinRow = row;}
110   void     SetPatternMinCol(UShort_t col)            {fPatternMinCol = col;}
111   void     ResetPattern();
112   Bool_t   TestPixel(UShort_t row,UShort_t col)      const;
113   void     SetPixel(UShort_t row,UShort_t col, Bool_t fired=kTRUE);
114   void     GetPattern(UChar_t patt[kMaxPatternBytes]) {for(Int_t i=0; i<kMaxPatternBytes; i++) patt[i]=fPattern[i];}
115   Int_t    GetPatternMinRow()                        const {return fPatternMinRow;}
116   Int_t    GetPatternMinCol()                        const {return fPatternMinCol;}
117
118 #endif
119   //
120  protected:
121   //
122   UShort_t                fCharge;        //  charge (for MC studies only)
123   UShort_t                fRecoInfo;      //! space reserved for reco time manipulations
124   Int_t                   fNxNzN;         //  effective cluster size in X (1st byte) and Z (2nd byte) directions 
125                                           //  and total Npix(next 9 bits). last 7 bits are used for clusters usage counter
126   static UInt_t           fgMode;         //! general mode (sorting mode etc)
127   static AliITSUGeomTGeo* fgGeom;         //! pointer on the geometry data
128
129 #ifdef  _ClusterTopology_
130   UShort_t fPatternNRows;                 // pattern span in rows
131   UShort_t fPatternNCols;                 // pattern span in columns
132   UShort_t fPatternMinRow;                // pattern start row
133   UShort_t fPatternMinCol;                // pattern start column
134   UChar_t  fPattern[kMaxPatternBytes];    // cluster topology
135   //
136   ClassDef(AliITSUClusterPix,CLUSTER_VERSION+1)
137 #else
138   ClassDef(AliITSUClusterPix,CLUSTER_VERSION)
139 #endif
140 };
141
142 //______________________________________________________
143 inline void AliITSUClusterPix::DecClUsage() {
144   // decrease cluster usage counter
145   int n=GetClUsage(); 
146   if (n) SetClUsage(--n);
147   //
148 }
149
150 //______________________________________________________
151 inline void AliITSUClusterPix::SetClUsage(Int_t n) {
152   // set cluster usage counter
153   fNxNzN &= ~(kMaskClUse<<kOffsClUse);
154   fNxNzN |= (n&kMaskClUse)<<kOffsClUse;
155   if (n<2) SetBit(kShared,kFALSE);
156   if (!n)  SetBit(kUsed,kFALSE);
157 }
158
159 #endif