]>
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_ |
a11ef2e4 | 15 | |
16 | class AliITSUGeomTGeo; | |
17 | class AliITSsegmentation; | |
18 | using namespace TMath; | |
19 | ||
08419930 | 20 | |
a11ef2e4 | 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); | |
c61e50c3 | 26 | UInt_t PackCluster(Int_t lr, Int_t clID); |
f8832015 | 27 | Int_t UnpackCluster(UInt_t p, Int_t &lr); |
28 | Int_t UnpackLayer(UInt_t p); | |
29 | Int_t UnpackCluster(UInt_t p); | |
c61e50c3 | 30 | Bool_t IsCluster(UInt_t p); |
f8832015 | 31 | Int_t NumberOfBitsSet(UInt_t x); |
3c18eefd | 32 | void PrintBits(ULong64_t patt, Int_t maxBits); |
32d38de2 | 33 | // |
34 | const Double_t kNominalBz = 5.01; // nominal field | |
c61e50c3 | 35 | const Double_t kPionMass = 1.3957e-01; |
5a0f97ba | 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 | |
f8832015 | 39 | const UInt_t kMaxLayers = 15; // max number of active layers |
a11ef2e4 | 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 | ||
c61e50c3 | 62 | //_________________________________________________________________________________ |
63 | inline UInt_t AliITSUAux::PackCluster(Int_t lr, Int_t clID) { | |
64 | // pack layer/cluster into single uint | |
a616242b | 65 | UInt_t p = (clID<0 ? 0 : clID+1) + (lr<<=kLrBitLow); |
5a0f97ba | 66 | return p; |
c61e50c3 | 67 | } |
68 | ||
69 | //_________________________________________________________________________________ | |
f8832015 | 70 | inline Int_t AliITSUAux::UnpackCluster(UInt_t p, Int_t &lr) { |
c61e50c3 | 71 | // unpack layer/cluster |
5a0f97ba | 72 | lr = (p&kLrMask)>>kLrBitLow; |
73 | p &= kClMask; | |
c61e50c3 | 74 | return int(p)-1; |
75 | } | |
76 | ||
f8832015 | 77 | //_________________________________________________________________________________ |
78 | inline Int_t AliITSUAux::UnpackLayer(UInt_t p) { | |
79 | // unpack layer | |
5a0f97ba | 80 | return (p&kLrMask)>>kLrBitLow; |
f8832015 | 81 | } |
82 | ||
83 | //_________________________________________________________________________________ | |
84 | inline Int_t AliITSUAux::UnpackCluster(UInt_t p) { | |
85 | // unpack cluster | |
a616242b | 86 | return int(p&kClMask)-1; |
f8832015 | 87 | } |
88 | ||
c61e50c3 | 89 | //_________________________________________________________________________________ |
90 | inline Bool_t AliITSUAux::IsCluster(UInt_t p) { | |
91 | // does it correspond to cluster? | |
5a0f97ba | 92 | return (p&kClMask); |
c61e50c3 | 93 | } |
94 | ||
f8832015 | 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 | ||
a11ef2e4 | 103 | |
104 | #endif |