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