]> git.uio.no Git - u/mrichter/AliRoot.git/blob - ITS/UPGRADE/AliITSUAux.h
Added shared cluster reduction.
[u/mrichter/AliRoot.git] / ITS / UPGRADE / AliITSUAux.h
1 #ifndef ALIITSUAUX
2 #define ALIITSUAUX
3
4 #include <TObject.h>
5 #include <TMath.h>
6
7 ///////////////////////////////////////////////////////////////////////
8 //                                                                   //
9 //  Namespace AliITSUAux                                             //
10 //  Set of utilities for the ITSU classes                            //
11 //                                                                   //
12 ///////////////////////////////////////////////////////////////////////
13
14 #define _ITSU_TUNING_MODE_
15
16 class AliITSUGeomTGeo;
17 class AliITSsegmentation;
18 using namespace TMath;
19
20
21
22 namespace AliITSUAux {
23   void   BringTo02Pi(double &phi);
24   Bool_t OKforPhiMin(double phiMin,double phi);
25   Bool_t OKforPhiMax(double phiMax,double phi);
26   UInt_t PackCluster(Int_t lr, Int_t clID);
27   Int_t  UnpackCluster(UInt_t p, Int_t &lr);
28   Int_t  UnpackLayer(UInt_t p);
29   Int_t  UnpackCluster(UInt_t p);
30   Bool_t IsCluster(UInt_t p);
31   Int_t  NumberOfBitsSet(UInt_t x);
32   void   PrintBits(ULong64_t patt, Int_t maxBits);
33   //
34   const Double_t kNominalBz = 5.01;           // nominal field
35   const Double_t kPionMass  = 1.3957e-01;
36   const UInt_t   kLrBitLow  = 28;             // layer mask lowest bit
37   const UInt_t   kLrMask    = 0xf0000000;     // layer mask
38   const UInt_t   kClMask    = 0x0fffffff;     // cluster mask
39   const UInt_t   kMaxLayers = 15;             // max number of active layers
40 }
41
42 //_________________________________________________________________________________
43 inline void AliITSUAux::BringTo02Pi(double &phi) {   
44   // bring phi to 0-2pi range
45   if (phi<0) phi+=TwoPi(); else if (phi>TwoPi()) phi-=TwoPi();
46 }
47
48 //_________________________________________________________________________________
49 inline Bool_t AliITSUAux::OKforPhiMin(double phiMin,double phi) {
50   // check if phi is above the phiMin, phi's must be in 0-2pi range
51   double dphi = phi-phiMin;
52   return ((dphi>0 && dphi<Pi()) || dphi<-Pi()) ? kTRUE:kFALSE;
53 }
54
55 //_________________________________________________________________________________
56 inline Bool_t AliITSUAux::OKforPhiMax(double phiMax,double phi) {
57   // check if phi is below the phiMax, phi's must be in 0-2pi range
58   double dphi = phi-phiMax;
59   return ((dphi<0 && dphi>-Pi()) || dphi>Pi()) ? kTRUE:kFALSE;
60 }
61
62 //_________________________________________________________________________________
63 inline UInt_t AliITSUAux::PackCluster(Int_t lr, Int_t clID) {
64   // pack layer/cluster into single uint
65   UInt_t p = (clID<0 ? 0 : clID+1) + (lr<<=kLrBitLow);
66   return p;
67 }
68
69 //_________________________________________________________________________________
70 inline Int_t AliITSUAux::UnpackCluster(UInt_t p, Int_t &lr) {
71   // unpack layer/cluster
72   lr = (p&kLrMask)>>kLrBitLow;
73   p &= kClMask;
74   return int(p)-1;
75 }
76
77 //_________________________________________________________________________________
78 inline Int_t AliITSUAux::UnpackLayer(UInt_t p) {
79   // unpack layer
80   return (p&kLrMask)>>kLrBitLow;
81 }
82
83 //_________________________________________________________________________________
84 inline Int_t AliITSUAux::UnpackCluster(UInt_t p) {
85   // unpack cluster
86   return int(p&kClMask)-1;
87 }
88
89 //_________________________________________________________________________________
90 inline Bool_t AliITSUAux::IsCluster(UInt_t p) {
91   // does it correspond to cluster?
92   return (p&kClMask);
93 }
94
95 //_________________________________________________________________________________
96 inline Int_t AliITSUAux::NumberOfBitsSet(UInt_t x) {
97   // count number of non-0 bits in 32bit word
98   x = x - ((x >> 1) & 0x55555555);
99   x = (x & 0x33333333) + ((x >> 2) & 0x33333333);
100   return (((x + (x >> 4)) & 0x0F0F0F0F) * 0x01010101) >> 24;
101 }
102
103
104 #endif