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