]> git.uio.no Git - u/mrichter/AliRoot.git/blob - EVE/Reve/NLTTrack.cxx
Dummy methods DefineParticle required by the interface added.
[u/mrichter/AliRoot.git] / EVE / Reve / NLTTrack.cxx
1 // $Header$
2
3 #include "NLTTrack.h"
4 #include <Reve/NLTProjector.h>
5 #include <Reve/PODs.h>
6
7 using namespace Reve;
8
9 //______________________________________________________________________________
10 // NLTTrack
11 //
12
13 ClassImp(NLTTrack)
14
15 //______________________________________________________________________________
16 NLTTrack::NLTTrack() :
17   Track     (),
18   fOrigPnts(0),
19   fProjection(0)
20 {
21   // Default constructor.
22 }
23
24 //______________________________________________________________________________
25 NLTTrack::~NLTTrack()
26 {
27   // Destructor. Noop.
28 }
29
30 /******************************************************************************/
31
32 //______________________________________________________________________________
33 void NLTTrack::SetProjection(NLTProjector* proj, NLTProjectable* model)
34 {
35   NLTProjected::SetProjection(proj, model);
36   Track* origTrack = dynamic_cast<Track*>(fProjectable);
37
38   SetTrackParams(*origTrack);
39   SetPathMarks  (*origTrack);
40 }
41
42 /******************************************************************************/
43
44 //______________________________________________________________________________
45 void NLTTrack::UpdateProjection()
46 {
47   fProjection = fProjector->GetProjection();
48   MakeTrack(kFALSE); // NLTProjector makes recursive calls
49 }
50
51 //______________________________________________________________________________
52 void NLTTrack::GetBreakPoint(Int_t idx, Bool_t back,
53                              Float_t& x, Float_t& y, Float_t& z)
54 {
55   Vector vL = fOrigPnts[idx];
56   Vector vR = fOrigPnts[idx+1];
57   Vector vM, vLP, vMP;
58   while((vL-vR).Mag() > 0.01)
59   { 
60     vM.Mult(vL+vR, 0.5f);
61     vLP.Set(vL); fProjection->ProjectPoint(vLP.x, vLP.y, vLP.z);
62     vMP.Set(vM); fProjection->ProjectPoint(vMP.x, vMP.y, vMP.z);
63     if(fProjection->AcceptSegment(vLP, vMP, 0.0f))
64     {
65       vL.Set(vM);
66     }
67     else 
68     {
69       vR.Set(vM);
70     }
71     //printf("new interval Mag %f (%f, %f, %f)(%f, %f, %f) \n",(vL-vR).Mag(), vL.x, vL.y, vL.z, vR.x, vR.y, vR.z);
72   }
73
74   if(back)
75   {
76     x = vL.x; y = vL.y; z = vL.z;
77   }
78   else
79   {
80     x = vR.x; y = vR.y; z = vR.z;
81   }
82   fProjection->ProjectPoint(x, y, z);
83   // printf("NLTTrack::GetBreakPoint %d (%f, %f, %f) \n", idx, x, y, z);
84 }
85
86 //______________________________________________________________________________
87 Int_t  NLTTrack::GetBreakPointIdx(Int_t start)
88 {
89   // Findex index of the last point that lies within the same
90   // segment of projected space.
91   // For example, rho-z projection separates upper and lower hemisphere
92   // and tracks break into two lines when crossing the y=0 plane.
93
94   Int_t val = fLastPoint;
95
96   Vector v1, v2;
97   if (Size() > 1)
98   {
99     Int_t i = start;
100     while(i < fLastPoint)
101     {
102       GetPoint(i,   v1.x, v1.y, v1.z);
103       GetPoint(i+1, v2.x, v2.y, v2.z);
104       if(fProjection->AcceptSegment(v1, v2, fRnrStyle->fDelta) == kFALSE)
105       {
106         val = i;
107         break;
108       }
109       i++;
110     }
111   }
112   // printf("BreakPoint IDX start:%d, BREAK %d,  total:%d \n", start, val, Size());
113   return val;
114 }
115
116 /******************************************************************************/
117
118 //______________________________________________________________________________
119 void NLTTrack::MakeTrack(Bool_t recurse)
120 {
121   // Calculate the points of the track for drawing.
122   // Call base-class, project, find break-points and insert points
123   // required for full representation.
124
125   Track::MakeTrack(recurse);
126
127   fBreakPoints.clear();
128   if(Size() == 0) return; // All points can be outside of MaxR / MaxZ limits.
129
130   // Project points, store originals (needed for break-points).
131   Float_t *p = GetP();
132   fOrigPnts  = new Vector[Size()];
133   for(Int_t i = 0; i < Size(); ++i, p+=3)
134   {
135     fOrigPnts[i].Set(p);
136     fProjection->ProjectPoint(p[0], p[1], p[2]);
137     p[2] = fDepth;
138   }
139
140   Float_t x, y, z;
141   std::vector<Vector> vvec;
142   Int_t bL = 0, bR = GetBreakPointIdx(0); 
143   while (1)
144   {
145     for(Int_t i=bL; i<=bR; i++)
146     {
147       GetPoint(i, x, y, z);
148       vvec.push_back(Vector(x, y, z));
149     }
150     if (bR == fLastPoint)
151       break;
152
153     GetBreakPoint(bR, kTRUE,  x, y, z); vvec.push_back(Vector(x, y, z));
154     fBreakPoints.push_back(vvec.size());
155     GetBreakPoint(bR, kFALSE, x, y, z); vvec.push_back(Vector(x, y, z));
156
157     bL = bR + 1;
158     bR = GetBreakPointIdx(bL);
159   }
160   fBreakPoints.push_back(vvec.size()); // Mark the track-end for drawing.
161
162   Reset(vvec.size());
163   for (std::vector<Reve::Vector>::iterator i=vvec.begin(); i!=vvec.end(); ++i)
164     SetNextPoint((*i).x, (*i).y, (*i).z); 
165   delete [] fOrigPnts;
166 }
167
168 /******************************************************************************/
169
170 //______________________________________________________________________________
171 void NLTTrack::PrintLineSegments()
172 {
173   printf("%s LineSegments:\n", GetName());
174   Int_t start = 0;
175   Int_t segment = 0;
176   Vector S;
177   Vector E;
178   for (std::vector<Int_t>::iterator bpi = fBreakPoints.begin();
179        bpi != fBreakPoints.end(); ++bpi)
180   {
181     Int_t size = *bpi - start;
182
183     GetPoint(start, S.x, S.y, S.z);
184     GetPoint((*bpi)-1, E.x, E.y, E.z);
185     printf("seg %d size %d start %d ::(%f, %f, %f) (%f, %f, %f)\n", 
186            segment, size, start, S.x, S.y, S.z, E.x, E.y, E.z);
187     start   += size;
188     segment ++;
189   }
190 }
191
192 /******************************************************************************/
193
194 //______________________________________________________________________________
195 void NLTTrack::CtrlClicked(Reve::Track* /*track*/)
196 {
197   Track* t = dynamic_cast<Track*>(fProjectable);
198   if (t)
199     t->CtrlClicked(t);
200 }
201
202
203 /******************************************************************************/
204 /******************************************************************************/
205
206
207 //______________________________________________________________________________
208 // NLTTrackList
209 //
210
211 ClassImp(NLTTrackList)
212
213 //______________________________________________________________________________
214 NLTTrackList::NLTTrackList() :
215   TrackList    (),
216   NLTProjected ()
217 {
218   // Default constructor.
219 }
220
221 /******************************************************************************/
222
223 //______________________________________________________________________________
224 void NLTTrackList::SetProjection(NLTProjector* proj, NLTProjectable* model)
225 {
226   NLTProjected::SetProjection(proj, model);
227  
228   TrackList& tl   = * dynamic_cast<TrackList*>(model);
229   SetLineColor(tl.GetLineColor());
230   SetLineStyle(tl.GetLineStyle());
231   SetLineWidth(tl.GetLineWidth());
232   SetMarkerColor(tl.GetMarkerColor());
233   SetMarkerStyle(tl.GetMarkerStyle());
234   SetMarkerSize(tl.GetMarkerSize());
235   SetRnrLine(tl.GetRnrLine());
236   SetRnrPoints(tl.GetRnrPoints());
237  
238   SetRnrStyle(tl.GetRnrStyle());
239 }