7 ///////////////////////////////////////////////////////////////////////
9 // Namespace AliITSUAux //
10 // Set of utilities for the ITSU classes //
12 ///////////////////////////////////////////////////////////////////////
14 #define _ITSU_TUNING_MODE_
16 class AliITSUGeomTGeo;
17 class AliITSsegmentation;
18 using namespace TMath;
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);
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
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();
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;
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;
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);
69 //_________________________________________________________________________________
70 inline Int_t AliITSUAux::UnpackCluster(UInt_t p, Int_t &lr) {
71 // unpack layer/cluster
72 lr = (p&kLrMask)>>kLrBitLow;
77 //_________________________________________________________________________________
78 inline Int_t AliITSUAux::UnpackLayer(UInt_t p) {
80 return (p&kLrMask)>>kLrBitLow;
83 //_________________________________________________________________________________
84 inline Int_t AliITSUAux::UnpackCluster(UInt_t p) {
86 return int(p&kClMask)-1;
89 //_________________________________________________________________________________
90 inline Bool_t AliITSUAux::IsCluster(UInt_t p) {
91 // does it correspond to cluster?
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;