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 {
24 void BringTo02Pi(double &phi);
25 Bool_t OKforPhiMin(double phiMin,double phi);
26 Bool_t OKforPhiMax(double phiMax,double phi);
27 Double_t MeanPhiSmall(double phi0, double phi1);
28 Double_t DeltaPhiSmall(double phi0, double phi1);
29 UInt_t PackCluster(Int_t lr, Int_t clID);
30 Int_t UnpackCluster(UInt_t p, Int_t &lr);
31 Int_t UnpackLayer(UInt_t p);
32 Int_t UnpackCluster(UInt_t p);
33 Bool_t IsCluster(UInt_t p);
34 Int_t NumberOfBitsSet(UInt_t x);
35 void PrintBits(ULong64_t patt, Int_t maxBits);
37 const Double_t kNominalBz = 5.01; // nominal field
38 const Double_t kPionMass = 1.3957e-01;
39 const UInt_t kLrBitLow = 28; // layer mask lowest bit
40 const UInt_t kLrMask = 0xf0000000; // layer mask
41 const UInt_t kClMask = 0x0fffffff; // cluster mask
42 const UInt_t kMaxLayers = 15; // max number of active layers
43 const UInt_t kMaxLrMask = 0x7fff; // bitmask for allowed layers
46 //_________________________________________________________________________________
47 inline void AliITSUAux::BringTo02Pi(double &phi) {
48 // bring phi to 0-2pi range
49 if (phi<0) phi+=TwoPi(); else if (phi>TwoPi()) phi-=TwoPi();
52 //_________________________________________________________________________________
53 inline Bool_t AliITSUAux::OKforPhiMin(double phiMin,double phi) {
54 // check if phi is above the phiMin, phi's must be in 0-2pi range
55 double dphi = phi-phiMin;
56 return ((dphi>0 && dphi<Pi()) || dphi<-Pi()) ? kTRUE:kFALSE;
59 //_________________________________________________________________________________
60 inline Bool_t AliITSUAux::OKforPhiMax(double phiMax,double phi) {
61 // check if phi is below the phiMax, phi's must be in 0-2pi range
62 double dphi = phi-phiMax;
63 return ((dphi<0 && dphi>-Pi()) || dphi>Pi()) ? kTRUE:kFALSE;
66 //_________________________________________________________________________________
67 inline UInt_t AliITSUAux::PackCluster(Int_t lr, Int_t clID) {
68 // pack layer/cluster into single uint
69 UInt_t p = (clID<0 ? 0 : clID+1) + (lr<<=kLrBitLow);
73 //_________________________________________________________________________________
74 inline Int_t AliITSUAux::UnpackCluster(UInt_t p, Int_t &lr) {
75 // unpack layer/cluster
76 lr = (p&kLrMask)>>kLrBitLow;
81 //_________________________________________________________________________________
82 inline Int_t AliITSUAux::UnpackLayer(UInt_t p) {
84 return (p&kLrMask)>>kLrBitLow;
87 //_________________________________________________________________________________
88 inline Int_t AliITSUAux::UnpackCluster(UInt_t p) {
90 return int(p&kClMask)-1;
93 //_________________________________________________________________________________
94 inline Bool_t AliITSUAux::IsCluster(UInt_t p) {
95 // does it correspond to cluster?
99 //_________________________________________________________________________________
100 inline Int_t AliITSUAux::NumberOfBitsSet(UInt_t x) {
101 // count number of non-0 bits in 32bit word
102 x = x - ((x >> 1) & 0x55555555);
103 x = (x & 0x33333333) + ((x >> 2) & 0x33333333);
104 return (((x + (x >> 4)) & 0x0F0F0F0F) * 0x01010101) >> 24;
107 //_________________________________________________________________________________
108 inline Double_t AliITSUAux::MeanPhiSmall(double phi0, double phi1) {
109 // return mean phi, assume phis in 0:2pi
111 if (!OKforPhiMin(phi0,phi1)) {phi=phi0; phi0=phi1; phi1=phi;}
112 if (phi0>phi1) phi = (phi1 - (TwoPi()-phi0))/2; // wrap
113 else phi = (phi0+phi1)/2;
118 //_________________________________________________________________________________
119 inline Double_t AliITSUAux::DeltaPhiSmall(double phi0, double phi1) {
120 // return delta phi, assume phis in 0:2pi
122 if (!OKforPhiMin(phi0,phi1)) {del=phi0; phi0=phi1; phi1=del;}
124 if (del<0) del += TwoPi();