]> git.uio.no Git - u/mrichter/AliRoot.git/blob - EVE/Reve/GridStepper.cxx
From Cvetan: new macro to load ITS clusters.
[u/mrichter/AliRoot.git] / EVE / Reve / GridStepper.cxx
1 // $Header$
2
3 #include "GridStepper.h"
4 #include "ZTrans.h"
5
6 using namespace Reve;
7
8 //______________________________________________________________________
9 // GridStepper
10 //
11
12 ClassImp(GridStepper)
13
14 GridStepper::GridStepper(Int_t sm) : Mode(StepMode_e(sm))
15 {
16   switch(Mode) {
17   default:
18   case SM_XYZ:
19     ls[0] = &Nx; ls[1] = &Ny; ls[2] = &Nz;
20     ns[0] = &nx; ns[1] = &ny; ns[2] = &nz;
21     break;
22   case SM_YXZ:
23     ls[0] = &Ny; ls[1] = &Nx; ls[2] = &Nz;
24     ns[0] = &ny; ns[1] = &nx; ns[2] = &nz;
25     break;
26   case SM_XZY:
27     ls[0] = &Nx; ls[1] = &Nz; ls[2] = &Ny;
28     ns[0] = &nx; ns[1] = &nz; ns[2] = &ny;
29     break;
30   }
31
32   nx = ny = nz = 0;
33   Nx = Ny = Nz = 16;
34   Dx = Dy = Dz = 1;
35   Ox = Oy = Oz = 0;
36 }
37
38 void GridStepper::Reset()
39 {
40   nx = ny = nz = 0;
41 }
42
43 void GridStepper::Subtract(GridStepper& s)
44 {
45   Ox = -(s.Ox + s.nx*s.Dx);
46   Oy = -(s.Oy + s.ny*s.Dy);
47   Oz = -(s.Oz + s.nz*s.Dz);
48 }
49 /**************************************************************************/
50
51 bool GridStepper::Step()
52 {
53   (*ns[0])++;
54   if(*ns[0] >= *ls[0]) {
55     *ns[0] = 0; (*ns[1])++;
56     if(*ns[1] >= *ls[1]) {
57       *ns[1] = 0; (*ns[2])++;
58       if(*ns[2] >= *ls[2]) {
59         return false;
60       }
61     }
62   }
63   return true;
64 }
65
66 /**************************************************************************/
67
68 void GridStepper::GetPosition(Float_t* p)
69 {
70   p[0] = Ox + nx*Dx; p[1] = Oy + ny*Dy; p[2] = Oz + nz*Dz;
71 }
72
73 void GridStepper::SetTrans(ZTrans* mx)
74 {
75   mx->SetPos(Ox + nx*Dx, Oy + ny*Dy, Oz + nz*Dz);
76 }
77
78 void GridStepper::SetTransAdvance(ZTrans* mx)
79 {
80   SetTrans(mx);
81   Step();
82 }