7 ///////////////////////////////////////////////////////////////////////
9 // Namespace AliITSUAux //
10 // Set of utilities for the ITSU classes //
12 ///////////////////////////////////////////////////////////////////////
14 #define _ITSU_TUNING_MODE_
15 //#define _ITSU_DEBUG_
17 class AliITSUGeomTGeo;
18 class AliITSsegmentation;
19 using namespace TMath;
23 namespace AliITSUAux {
25 void BringTo02Pi(F &phi);
26 Bool_t OKforPhiMin(double phiMin,double phi);
27 Bool_t OKforPhiMax(double phiMax,double phi);
28 Double_t MeanPhiSmall(double phi0, double phi1);
29 Double_t DeltaPhiSmall(double phi0, double phi1);
30 UInt_t PackCluster(Int_t lr, Int_t clID);
31 Int_t UnpackCluster(UInt_t p, Int_t &lr);
32 Int_t UnpackLayer(UInt_t p);
33 Int_t UnpackCluster(UInt_t p);
34 Bool_t IsCluster(UInt_t p);
35 Int_t NumberOfBitsSet(UInt_t x);
36 void PrintBits(ULong64_t patt, Int_t maxBits);
38 const Double_t kNominalBz = 5.01; // nominal field
39 const Double_t kPionMass = 1.3957e-01;
40 const UInt_t kLrBitLow = 28; // layer mask lowest bit
41 const UInt_t kLrMask = 0xf0000000; // layer mask
42 const UInt_t kClMask = 0x0fffffff; // cluster mask
43 const UInt_t kMaxLayers = 15; // max number of active layers
44 const UInt_t kMaxLrMask = 0x7fff; // bitmask for allowed layers
47 //_________________________________________________________________________________
49 inline void AliITSUAux::BringTo02Pi(F &phi) {
50 // bring phi to 0-2pi range
51 if (phi<0) phi+=TwoPi(); else if (phi>TwoPi()) phi-=TwoPi();
54 //_________________________________________________________________________________
55 inline Bool_t AliITSUAux::OKforPhiMin(double phiMin,double phi) {
56 // check if phi is above the phiMin, phi's must be in 0-2pi range
57 double dphi = phi-phiMin;
58 return ((dphi>0 && dphi<Pi()) || dphi<-Pi()) ? kTRUE:kFALSE;
61 //_________________________________________________________________________________
62 inline Bool_t AliITSUAux::OKforPhiMax(double phiMax,double phi) {
63 // check if phi is below the phiMax, phi's must be in 0-2pi range
64 double dphi = phi-phiMax;
65 return ((dphi<0 && dphi>-Pi()) || dphi>Pi()) ? kTRUE:kFALSE;
68 //_________________________________________________________________________________
69 inline UInt_t AliITSUAux::PackCluster(Int_t lr, Int_t clID) {
70 // pack layer/cluster into single uint
71 UInt_t p = (clID<0 ? 0 : clID+1) + (lr<<=kLrBitLow);
75 //_________________________________________________________________________________
76 inline Int_t AliITSUAux::UnpackCluster(UInt_t p, Int_t &lr) {
77 // unpack layer/cluster
78 lr = (p&kLrMask)>>kLrBitLow;
83 //_________________________________________________________________________________
84 inline Int_t AliITSUAux::UnpackLayer(UInt_t p) {
86 return (p&kLrMask)>>kLrBitLow;
89 //_________________________________________________________________________________
90 inline Int_t AliITSUAux::UnpackCluster(UInt_t p) {
92 return int(p&kClMask)-1;
95 //_________________________________________________________________________________
96 inline Bool_t AliITSUAux::IsCluster(UInt_t p) {
97 // does it correspond to cluster?
101 //_________________________________________________________________________________
102 inline Int_t AliITSUAux::NumberOfBitsSet(UInt_t x) {
103 // count number of non-0 bits in 32bit word
104 x = x - ((x >> 1) & 0x55555555);
105 x = (x & 0x33333333) + ((x >> 2) & 0x33333333);
106 return (((x + (x >> 4)) & 0x0F0F0F0F) * 0x01010101) >> 24;
109 //_________________________________________________________________________________
110 inline Double_t AliITSUAux::MeanPhiSmall(double phi0, double phi1) {
111 // return mean phi, assume phis in 0:2pi
113 if (!OKforPhiMin(phi0,phi1)) {phi=phi0; phi0=phi1; phi1=phi;}
114 if (phi0>phi1) phi = (phi1 - (TwoPi()-phi0))/2; // wrap
115 else phi = (phi0+phi1)/2;
120 //_________________________________________________________________________________
121 inline Double_t AliITSUAux::DeltaPhiSmall(double phi0, double phi1) {
122 // return delta phi, assume phis in 0:2pi
124 if (!OKforPhiMin(phi0,phi1)) {del=phi0; phi0=phi1; phi1=del;}
126 if (del<0) del += TwoPi();