]> git.uio.no Git - u/mrichter/AliRoot.git/blob - ITS/UPGRADE/AliITSURecoSens.cxx
a83bd653db2c38343a8b4da8414b8f7f8ff26cde
[u/mrichter/AliRoot.git] / ITS / UPGRADE / AliITSURecoSens.cxx
1 #include "AliITSURecoSens.h"
2 #include "AliITSUGeomTGeo.h"
3 #include "AliITSsegmentation.h"
4 #include "AliExternalTrackParam.h"
5 #include "AliITSUAux.h"
6 #include "AliLog.h"
7
8 using namespace AliITSUAux;
9 using namespace TMath;
10
11 ClassImp(AliITSURecoSens)
12
13 //______________________________________________________
14 AliITSURecoSens::AliITSURecoSens(Int_t id)
15 :  fNClusters(0)
16   ,fFirstClusterId(-1)
17   ,fXTF(0)
18   ,fPhiTF(0)
19   ,fPhiMin(0)
20   ,fPhiMax(0)
21   ,fZMin(0)
22   ,fZMax(0)
23 {
24   // def. c-tor
25   SetID(id);
26 }
27
28 //______________________________________________________
29 AliITSURecoSens::AliITSURecoSens(const AliITSURecoSens &source)
30   :TObject(source)
31   ,fNClusters(source.fNClusters)
32   ,fFirstClusterId(source.fFirstClusterId)
33   ,fXTF(source.fXTF)
34   ,fPhiTF(source.fPhiTF)
35   ,fPhiMin(source.fPhiMin)
36   ,fPhiMax(source.fPhiMax)
37   ,fZMin(source.fZMin)
38   ,fZMax(source.fZMax)
39 {
40   // copy c-tor
41 }
42
43 //______________________________________________________
44 AliITSURecoSens& AliITSURecoSens::operator=(const AliITSURecoSens &source)
45 {
46   // = operator
47   if (&source==this) return *this;
48   TObject::operator=(source);
49   fNClusters = source.fNClusters;
50   fFirstClusterId = source.fFirstClusterId;
51   fXTF = source.fXTF;
52   fPhiTF = source.fPhiTF;
53   fPhiMin = source.fPhiMin;
54   fPhiMax = source.fPhiMax;
55   fZMin   = source.fZMin;
56   fZMax   = source.fZMax;
57   //
58   return *this;
59 }
60
61 //______________________________________________________
62 void AliITSURecoSens::SetBoundaries(double phiMn,double phiMx, double zMn, double zMx)
63 {
64   // set phi,z limits 
65   fPhiMin = phiMn;
66   fPhiMax = phiMx;
67   fZMin = zMn;
68   fZMax = zMx;
69 }
70
71 //______________________________________________________
72 void AliITSURecoSens::Print(Option_t*) const                          
73 {
74   //print 
75   printf("Sensor%4d xTF=%+.3e phiTF=%+.3e | Phi:[%5.3f:%5.3f] Z:[%+7.3f:%+7.3f]\n",
76          GetID(),GetXTF(),GetPhiTF(), fPhiMin,fPhiMax, fZMin,fZMax);
77 }
78
79 //______________________________________________________
80 void AliITSURecoSens::ResetClusters()
81 {
82   // discard old clusters
83   fNClusters = 0;
84   fFirstClusterId = -1;
85 }
86
87 //______________________________________________________
88 void AliITSURecoSens::ProcessClusters(Int_t)
89 {
90   // create structures for fast finding
91   //
92   // to do
93 }
94
95 //______________________________________________________________________________
96 Int_t AliITSURecoSens::Compare(const TObject* obj)  const
97 {
98   // compare sensor positions
99   AliITSURecoSens* copy = (AliITSURecoSens*)obj;
100   double phi  = MeanPhiSmall(fPhiMin,fPhiMax);
101   double phiC = MeanPhiSmall(copy->fPhiMin,copy->fPhiMax);
102   double span = DeltaPhiSmall(fPhiMin,fPhiMax)/2;
103   double dPhi = DeltaPhiSmall(phi,phiC);
104   //
105   // special case to well define 1st raw (closest to 0 from above): wrap around 0/2pi
106   if (dPhi>span) return phi<phiC ? -1 : 1;
107   //
108   double phiT = phi+span;
109   BringTo02Pi(phiT);
110   //  if (phiT<phiC && OKforPhiMin(phiT,phiC)) return -1;
111   if (OKforPhiMin(phiT,phiC)) return -1;
112   phiT = phi-span;
113   BringTo02Pi(phiT);
114   //if (phiT>phiC && OKforPhiMax( phiT,phiC)) return 1;
115   if (OKforPhiMax( phiT,phiC)) return 1;
116   //
117   // sane phi range, check Z
118   double dz = (fZMax-fZMin)/2;
119   if (fZMax+dz < copy->fZMax) return -1;
120   if (fZMin-dz > copy->fZMin) return 1;
121   AliError(Form("Same chip compared? %d %d",GetID(),copy->GetID()));
122   Print();
123   copy->Print();
124   return 0;
125   //
126 }
127
128 //______________________________________________________________________________
129 Int_t AliITSURecoSens::CheckCoverage(double phi, double z) const
130 {
131   // check if the sensor contains the impact point phi, z
132   // if not, tell in which direction to move. 
133   // kLeft, kRight are for smaller/larger angles, kUp,kDown for larger/smaller Z
134   //
135   int res = 0;
136   if      (z<fZMin) res |= kDown;
137   else if (z>fZMax) res |= kUp;
138   //
139   if      (!OKforPhiMin(fPhiMin,phi)) res |= kLeft;
140   else if (!OKforPhiMax(fPhiMax,phi)) res |= kRight;
141   return res;
142 }