]> git.uio.no Git - u/mrichter/AliRoot.git/blob - ITS/UPGRADE/AliITSUCACell.h
Merge branch 'master' of https://git.cern.ch/reps/AliRoot
[u/mrichter/AliRoot.git] / ITS / UPGRADE / AliITSUCACell.h
1 #ifndef ALIITSUCACELL_H
2 #define ALIITSUCACELL_H
3
4 #include <vector>
5 #include <iostream>
6
7 class AliITSUCACell {
8 public:
9         AliITSUCACell(int xx = 0u,int yy = 0u, int zz = 0u, int dd0 = 0,
10                 int dd1 = 0, float curv = 0.f, float n[3] = 0x0)
11           : f1OverR(curv), fd0(dd0), fd1(dd1), fN(), fVector()
12         {
13                 fVector.reserve(4);
14                 fVector.push_back(xx);
15                 fVector.push_back(yy);
16     fVector.push_back(zz);
17                 fVector.push_back(1u);
18     if(n) {
19       fN[0] = n[0];
20       fN[1] = n[1];
21       fN[2] = n[2];
22     }
23         }
24
25         int x() const { return fVector[0]; }
26         int y() const { return fVector[1]; }
27   int z() const { return fVector[2]; }
28         int d0() const { return fd0; }
29   int d1() const { return fd1; }
30   int GetLevel() const { return fVector[3]; }
31   float GetCurvature() const { return f1OverR; }
32   float* GetN() { return fN; }
33   
34         void SetLevel(int lev) { fVector[3] = lev; }
35
36         int operator()(const int i) { return fVector[4 + i]; }
37
38         size_t NumberOfNeighbours() { return (fVector.size() - 4u); }
39
40         bool Combine(AliITSUCACell &neigh, int idd)
41         {
42     // From outside inward
43                 if (this->y() == neigh.z() && this->x() == neigh.y()) // Cells sharing two points
44                 {
45       fVector.push_back(idd);
46       if (neigh.GetLevel() + 1 > GetLevel())
47       {
48         SetLevel(neigh.GetLevel() + 1u);
49       }
50       return true;
51     }
52     return false;
53   }
54
55 private:
56   float f1OverR;
57   int fd0,fd1;
58   float fN[3];
59         std::vector<int> fVector;
60 };
61
62 class AliITSUCARoad {
63 public:
64   AliITSUCARoad() : Elements(), N(0)
65   {
66     ResetElements();
67   }
68
69   AliITSUCARoad(int layer, int idd) : Elements(), N()
70   {
71     ResetElements();
72     N = 1;
73     Elements[layer] = idd;
74   }
75
76   AliITSUCARoad(const AliITSUCARoad& copy) : Elements(), N(copy.N)
77   
78   {
79     for ( int i=0; i<5; ++i )
80     {
81         Elements[i] = copy.Elements[i];
82     }
83   }
84
85   int &operator[] (const int &i) {
86     return Elements[i];
87   }
88
89   void ResetElements()
90   {
91     for ( int i=0; i<5; ++i )
92       Elements[i] = -1;
93     N = 0;
94   }
95
96   void AddElement(int i, int el)
97   {
98     ++N;
99     Elements[i] = el;
100   }
101
102   int Elements[5];
103   int N;
104 };
105
106 #endif // ALIITSUCACELL_H