Integrating the Cooked Matrix tracker into the commom reconstruction framework
[u/mrichter/AliRoot.git] / ITS / UPGRADE / AliITSUAux.h
CommitLineData
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_
e1ef49ad 15//#define _ITSU_DEBUG_
a11ef2e4 16
17class AliITSUGeomTGeo;
18class AliITSsegmentation;
19using namespace TMath;
20
08419930 21
a11ef2e4 22
23namespace AliITSUAux {
24 void BringTo02Pi(double &phi);
25 Bool_t OKforPhiMin(double phiMin,double phi);
26 Bool_t OKforPhiMax(double phiMax,double phi);
68b7631d 27 Double_t MeanPhiSmall(double phi0, double phi1);
28 Double_t DeltaPhiSmall(double phi0, double phi1);
c61e50c3 29 UInt_t PackCluster(Int_t lr, Int_t clID);
f8832015 30 Int_t UnpackCluster(UInt_t p, Int_t &lr);
31 Int_t UnpackLayer(UInt_t p);
32 Int_t UnpackCluster(UInt_t p);
c61e50c3 33 Bool_t IsCluster(UInt_t p);
f8832015 34 Int_t NumberOfBitsSet(UInt_t x);
3c18eefd 35 void PrintBits(ULong64_t patt, Int_t maxBits);
32d38de2 36 //
37 const Double_t kNominalBz = 5.01; // nominal field
c61e50c3 38 const Double_t kPionMass = 1.3957e-01;
5a0f97ba 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
f8832015 42 const UInt_t kMaxLayers = 15; // max number of active layers
70f61d86 43 const UInt_t kMaxLrMask = 0x7fff; // bitmask for allowed layers
a11ef2e4 44}
45
46//_________________________________________________________________________________
47inline void AliITSUAux::BringTo02Pi(double &phi) {
48 // bring phi to 0-2pi range
49 if (phi<0) phi+=TwoPi(); else if (phi>TwoPi()) phi-=TwoPi();
50}
51
52//_________________________________________________________________________________
53inline 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;
57}
58
59//_________________________________________________________________________________
60inline 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;
64}
65
c61e50c3 66//_________________________________________________________________________________
67inline UInt_t AliITSUAux::PackCluster(Int_t lr, Int_t clID) {
68 // pack layer/cluster into single uint
a616242b 69 UInt_t p = (clID<0 ? 0 : clID+1) + (lr<<=kLrBitLow);
5a0f97ba 70 return p;
c61e50c3 71}
72
73//_________________________________________________________________________________
f8832015 74inline Int_t AliITSUAux::UnpackCluster(UInt_t p, Int_t &lr) {
c61e50c3 75 // unpack layer/cluster
5a0f97ba 76 lr = (p&kLrMask)>>kLrBitLow;
77 p &= kClMask;
c61e50c3 78 return int(p)-1;
79}
80
81//_________________________________________________________________________________
f8832015 82inline Int_t AliITSUAux::UnpackLayer(UInt_t p) {
83 // unpack layer
5a0f97ba 84 return (p&kLrMask)>>kLrBitLow;
f8832015 85}
86
87//_________________________________________________________________________________
88inline Int_t AliITSUAux::UnpackCluster(UInt_t p) {
89 // unpack cluster
a616242b 90 return int(p&kClMask)-1;
f8832015 91}
92
93//_________________________________________________________________________________
c61e50c3 94inline Bool_t AliITSUAux::IsCluster(UInt_t p) {
95 // does it correspond to cluster?
5a0f97ba 96 return (p&kClMask);
c61e50c3 97}
98
f8832015 99//_________________________________________________________________________________
100inline 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;
105}
106
68b7631d 107//_________________________________________________________________________________
108inline Double_t AliITSUAux::MeanPhiSmall(double phi0, double phi1) {
109 // return mean phi, assume phis in 0:2pi
110 double phi;
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;
114 BringTo02Pi(phi);
115 return phi;
116}
117
118//_________________________________________________________________________________
119inline Double_t AliITSUAux::DeltaPhiSmall(double phi0, double phi1) {
120 // return delta phi, assume phis in 0:2pi
121 double del;
122 if (!OKforPhiMin(phi0,phi1)) {del=phi0; phi0=phi1; phi1=del;}
123 del = phi1 - phi0;
124 if (del<0) del += TwoPi();
125 return del;
126}
127
a11ef2e4 128
129#endif