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