]>
Commit | Line | Data |
---|---|---|
a11ef2e4 | 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 | ||
08419930 | 14 | #define _ITSU_TUNING_MODE_ |
e1ef49ad | 15 | //#define _ITSU_DEBUG_ |
a11ef2e4 | 16 | |
17 | class AliITSUGeomTGeo; | |
18 | class AliITSsegmentation; | |
19 | using namespace TMath; | |
20 | ||
08419930 | 21 | |
a11ef2e4 | 22 | |
23 | namespace AliITSUAux { | |
24 | void BringTo02Pi(double &phi); | |
25 | Bool_t OKforPhiMin(double phiMin,double phi); | |
26 | Bool_t OKforPhiMax(double phiMax,double phi); | |
c61e50c3 | 27 | UInt_t PackCluster(Int_t lr, Int_t clID); |
f8832015 | 28 | Int_t UnpackCluster(UInt_t p, Int_t &lr); |
29 | Int_t UnpackLayer(UInt_t p); | |
30 | Int_t UnpackCluster(UInt_t p); | |
c61e50c3 | 31 | Bool_t IsCluster(UInt_t p); |
f8832015 | 32 | Int_t NumberOfBitsSet(UInt_t x); |
3c18eefd | 33 | void PrintBits(ULong64_t patt, Int_t maxBits); |
32d38de2 | 34 | // |
35 | const Double_t kNominalBz = 5.01; // nominal field | |
c61e50c3 | 36 | const Double_t kPionMass = 1.3957e-01; |
5a0f97ba | 37 | const UInt_t kLrBitLow = 28; // layer mask lowest bit |
38 | const UInt_t kLrMask = 0xf0000000; // layer mask | |
39 | const UInt_t kClMask = 0x0fffffff; // cluster mask | |
f8832015 | 40 | const UInt_t kMaxLayers = 15; // max number of active layers |
70f61d86 | 41 | const UInt_t kMaxLrMask = 0x7fff; // bitmask for allowed layers |
a11ef2e4 | 42 | } |
43 | ||
44 | //_________________________________________________________________________________ | |
45 | inline void AliITSUAux::BringTo02Pi(double &phi) { | |
46 | // bring phi to 0-2pi range | |
47 | if (phi<0) phi+=TwoPi(); else if (phi>TwoPi()) phi-=TwoPi(); | |
48 | } | |
49 | ||
50 | //_________________________________________________________________________________ | |
51 | inline Bool_t AliITSUAux::OKforPhiMin(double phiMin,double phi) { | |
52 | // check if phi is above the phiMin, phi's must be in 0-2pi range | |
53 | double dphi = phi-phiMin; | |
54 | return ((dphi>0 && dphi<Pi()) || dphi<-Pi()) ? kTRUE:kFALSE; | |
55 | } | |
56 | ||
57 | //_________________________________________________________________________________ | |
58 | inline Bool_t AliITSUAux::OKforPhiMax(double phiMax,double phi) { | |
59 | // check if phi is below the phiMax, phi's must be in 0-2pi range | |
60 | double dphi = phi-phiMax; | |
61 | return ((dphi<0 && dphi>-Pi()) || dphi>Pi()) ? kTRUE:kFALSE; | |
62 | } | |
63 | ||
c61e50c3 | 64 | //_________________________________________________________________________________ |
65 | inline UInt_t AliITSUAux::PackCluster(Int_t lr, Int_t clID) { | |
66 | // pack layer/cluster into single uint | |
a616242b | 67 | UInt_t p = (clID<0 ? 0 : clID+1) + (lr<<=kLrBitLow); |
5a0f97ba | 68 | return p; |
c61e50c3 | 69 | } |
70 | ||
71 | //_________________________________________________________________________________ | |
f8832015 | 72 | inline Int_t AliITSUAux::UnpackCluster(UInt_t p, Int_t &lr) { |
c61e50c3 | 73 | // unpack layer/cluster |
5a0f97ba | 74 | lr = (p&kLrMask)>>kLrBitLow; |
75 | p &= kClMask; | |
c61e50c3 | 76 | return int(p)-1; |
77 | } | |
78 | ||
f8832015 | 79 | //_________________________________________________________________________________ |
80 | inline Int_t AliITSUAux::UnpackLayer(UInt_t p) { | |
81 | // unpack layer | |
5a0f97ba | 82 | return (p&kLrMask)>>kLrBitLow; |
f8832015 | 83 | } |
84 | ||
85 | //_________________________________________________________________________________ | |
86 | inline Int_t AliITSUAux::UnpackCluster(UInt_t p) { | |
87 | // unpack cluster | |
a616242b | 88 | return int(p&kClMask)-1; |
f8832015 | 89 | } |
90 | ||
c61e50c3 | 91 | //_________________________________________________________________________________ |
92 | inline Bool_t AliITSUAux::IsCluster(UInt_t p) { | |
93 | // does it correspond to cluster? | |
5a0f97ba | 94 | return (p&kClMask); |
c61e50c3 | 95 | } |
96 | ||
f8832015 | 97 | //_________________________________________________________________________________ |
98 | inline Int_t AliITSUAux::NumberOfBitsSet(UInt_t x) { | |
99 | // count number of non-0 bits in 32bit word | |
100 | x = x - ((x >> 1) & 0x55555555); | |
101 | x = (x & 0x33333333) + ((x >> 2) & 0x33333333); | |
102 | return (((x + (x >> 4)) & 0x0F0F0F0F) * 0x01010101) >> 24; | |
103 | } | |
104 | ||
a11ef2e4 | 105 | |
106 | #endif |