Added method SortPathMarksByTime().
[u/mrichter/AliRoot.git] / EVE / Reve / Track.cxx
CommitLineData
5a5a1232 1// $Header$
2
3#include "Track.h"
4#include "MCHelixLine.hi"
7cbaaebd 5#include "PointSet.h"
5a5a1232 6
7#include <TPolyLine3D.h>
8#include <TPolyMarker3D.h>
9#include <TColor.h>
10
11// Updates
12#include <Reve/RGTopFrame.h>
13#include <TCanvas.h>
14
15#include <vector>
16
17using namespace Reve;
18
19//______________________________________________________________________
20// Track
21//
22
23ClassImp(Reve::Track)
24
265ecb21 25Track::Track() :
eadaa89b 26 Line(),
5a5a1232 27
265ecb21 28 fV(),
29 fP(),
30 fBeta(0),
31 fCharge(0),
7cbaaebd 32 fLabel(-1),
33 fIndex(-1),
265ecb21 34 fPathMarks(),
35
eadaa89b 36 fRnrStyle(0)
265ecb21 37{}
38
3d75306d 39Track::Track(TParticle* t, Int_t label, TrackRnrStyle* rs):
eadaa89b 40 Line(),
3d75306d 41
42 fV(t->Vx(), t->Vy(), t->Vz()),
43 fP(t->Px(), t->Py(), t->Pz()),
44 fBeta(t->P()/t->Energy()),
45 fCharge(0),
46 fLabel(label),
7cbaaebd 47 fIndex(-1),
3d75306d 48 fPathMarks(),
49
eadaa89b 50 fRnrStyle(rs)
3d75306d 51{
52 fLineColor = fRnrStyle->GetColor();
53 fMainColorPtr = &fLineColor;
54
55 TParticlePDG* pdgp = t->GetPDG();
56 if (pdgp)
57 fCharge = (Int_t) TMath::Nint(pdgp->Charge()/3);
eadaa89b 58
59 SetName(t->GetName());
3d75306d 60}
61
265ecb21 62Track::Track(Reve::MCTrack* t, TrackRnrStyle* rs):
eadaa89b 63 Line(),
5a5a1232 64
265ecb21 65 fV(t->Vx(), t->Vy(), t->Vz()),
66 fP(t->Px(), t->Py(), t->Pz()),
67 fBeta(t->P()/t->Energy()),
68 fCharge(0),
69 fLabel(t->label),
fa446a68 70 fIndex(t->index),
265ecb21 71 fPathMarks(),
72
eadaa89b 73 fRnrStyle(rs)
265ecb21 74{
5a5a1232 75 fLineColor = fRnrStyle->GetColor();
76 fMainColorPtr = &fLineColor;
77
5a5a1232 78 TParticlePDG* pdgp = t->GetPDG();
79 if(pdgp == 0) {
80 t->ResetPdgCode(); pdgp = t->GetPDG();
81 }
48dc973d 82 fCharge = (Int_t) TMath::Nint(pdgp->Charge()/3);
eadaa89b 83
84 SetName(t->GetName());
5a5a1232 85}
86
265ecb21 87Track::Track(Reve::RecTrack* t, TrackRnrStyle* rs) :
eadaa89b 88 Line(),
265ecb21 89
90 fV(t->V),
91 fP(t->P),
92 fBeta(t->beta),
93 fCharge(t->sign),
94 fLabel(t->label),
fa446a68 95 fIndex(t->index),
265ecb21 96 fPathMarks(),
97
eadaa89b 98 fRnrStyle(rs)
5a5a1232 99{
5a5a1232 100 fLineColor = fRnrStyle->GetColor();
101 fMainColorPtr = &fLineColor;
eadaa89b 102
103 SetName(t->GetName());
5a5a1232 104}
105
106Track::~Track()
265ecb21 107{
108 for (vpPathMark_i i=fPathMarks.begin(); i!=fPathMarks.end(); ++i)
109 delete *i;
110}
5a5a1232 111
eadaa89b 112/*
5a5a1232 113void Track::Reset(Int_t n_points)
114{
115 delete [] TPolyLine3D::fP; TPolyLine3D::fP = 0;
116 fN = n_points;
117 if(fN) TPolyLine3D::fP = new Float_t [3*fN];
118 memset(TPolyLine3D::fP, 0, 3*fN*sizeof(Float_t));
119 fLastPoint = -1;
120}
eadaa89b 121*/
5a5a1232 122
2fbbf445 123 /**************************************************************************/
5a5a1232 124
2fbbf445 125void Track::MakeTrack( Bool_t recurse)
5a5a1232 126{
5a5a1232 127 TrackRnrStyle& RS((fRnrStyle != 0) ? *fRnrStyle : TrackRnrStyle::fgDefStyle);
128
129 Float_t px = fP.x, py = fP.y, pz = fP.z;
130
131 MCVertex mc_v0;
132 mc_v0.x = fV.x;
133 mc_v0.y = fV.y;
134 mc_v0.z = fV.z;
135 mc_v0.t = 0;
136
137 std::vector<MCVertex> track_points;
48dc973d 138 Bool_t decay = kFALSE;
5a5a1232 139
140 if ((TMath::Abs(fV.z) > RS.fMaxZ) || (fV.x*fV.x + fV.y*fV.y > RS.fMaxR*RS.fMaxR))
141 goto make_polyline;
142
01024c63 143 if (fCharge != 0 && TMath::Abs(RS.fMagField) > 1e-5) {
144
145 // Charged particle in magnetic field
5a5a1232 146
48dc973d 147 Float_t a = RS.fgkB2C * RS.fMagField * fCharge;
5a5a1232 148
149 MCHelix helix(fRnrStyle, &mc_v0, TMath::C()*fBeta, &track_points, a); //m->cm
150 helix.Init(TMath::Sqrt(px*px+py*py), pz);
151
7cbaaebd 152 if(!fPathMarks.empty())
153 {
154 for(std::vector<Reve::PathMark*>::iterator i=fPathMarks.begin(); i!=fPathMarks.end(); ++i)
155 {
5a5a1232 156 Reve::PathMark* pm = *i;
157
7cbaaebd 158 if (RS.fFitReferences && pm->type == Reve::PathMark::Reference)
159 {
5a5a1232 160 if(TMath::Abs(pm->V.z) > RS.fMaxZ
161 || TMath::Sqrt(pm->V.x*pm->V.x + pm->V.y*pm->V.y) > RS.fMaxR )
162 goto helix_bounds;
163
7cbaaebd 164 // printf("%s fit reference \n", fName.Data());
165 helix.LoopToVertex(px, py, pz, pm->V.x, pm->V.y, pm->V.z);
166 px = pm->P.x;
167 py = pm->P.y;
168 pz = pm->P.z;
5a5a1232 169 }
7cbaaebd 170 else if(RS.fFitDaughters && pm->type == Reve::PathMark::Daughter)
171 {
5a5a1232 172 if(TMath::Abs(pm->V.z) > RS.fMaxZ
173 || TMath::Sqrt(pm->V.x*pm->V.x + pm->V.y*pm->V.y) > RS.fMaxR )
174 goto helix_bounds;
7cbaaebd 175
176 // printf("%s fit daughter \n", fName.Data());
177 helix.LoopToVertex(px, py, pz, pm->V.x, pm->V.y, pm->V.z);
178 px -= pm->P.x;
179 py -= pm->P.y;
180 pz -= pm->P.z;
181 }
182 else if(RS.fFitDecay && pm->type == Reve::PathMark::Decay)
183 {
184 if(TMath::Abs(pm->V.z) > RS.fMaxZ
185 || TMath::Sqrt(pm->V.x*pm->V.x + pm->V.y*pm->V.y) > RS.fMaxR )
186 goto helix_bounds;
187 helix.LoopToVertex(px, py, pz, pm->V.x, pm->V.y, pm->V.z);
5a5a1232 188 decay = true;
189 break;
190 }
191 }
192 }
193 helix_bounds:
7cbaaebd 194 // go to bounds
48dc973d 195 if(!decay || RS.fFitDecay == kFALSE){
5a5a1232 196 helix.LoopToBounds(px,py,pz);
197 // printf("%s loop to bounds \n",fName.Data() );
198 }
199
01024c63 200 } else {
201
202 // Neutral particle or no field
5a5a1232 203
204 MCLine line(fRnrStyle, &mc_v0, TMath::C()*fBeta, &track_points);
205
206 if(!fPathMarks.empty()){
207 for(std::vector<Reve::PathMark*>::iterator i=fPathMarks.begin(); i!=fPathMarks.end(); ++i) {
208 Reve::PathMark* pm = *i;
209
210 if(RS.fFitDaughters && pm->type == Reve::PathMark::Daughter){
211 if(TMath::Abs(pm->V.z) > RS.fMaxZ
212 || TMath::Sqrt(pm->V.x*pm->V.x + pm->V.y*pm->V.y) > RS.fMaxR )
213 goto line_bounds;
214 line.GotoVertex(pm->V.x, pm->V.y, pm->V.z);
215 fP.x -= pm->P.x;
216 fP.y -= pm->P.y;
217 fP.z -= pm->P.z;
218 }
219
220 if(RS.fFitDecay && pm->type == Reve::PathMark::Decay){
221 if(TMath::Abs(pm->V.z) > RS.fMaxZ
222 || TMath::Sqrt(pm->V.x*pm->V.x + pm->V.y*pm->V.y) > RS.fMaxR )
223 goto line_bounds;
224 line.GotoVertex(pm->V.x, pm->V.y, pm->V.z);
225 decay = true;
226 break;
227 }
228 }
229 }
230
231 line_bounds:
48dc973d 232 if(!decay || RS.fFitDecay == kFALSE)
5a5a1232 233 line.GotoBounds(px,py,pz);
234
235 }
236make_polyline:
237 Reset(track_points.size());
238 for(std::vector<MCVertex>::iterator i=track_points.begin(); i!=track_points.end(); ++i)
239 SetNextPoint(i->x, i->y, i->z);
2fbbf445 240
241 if(recurse) {
242 Track* t;
243 for(List_i i=fChildren.begin(); i!=fChildren.end(); ++i) {
244 t = dynamic_cast<Track*>(*i);
245 if(t)t->MakeTrack(recurse);
246 }
247 }
5a5a1232 248}
249
250/**************************************************************************/
ba008f46 251namespace {
252struct cmp_pathmark {
253 bool operator()(PathMark* const & a, PathMark* const & b)
254 { return a->time < b->time; }
255};
256}
257
258void Track::SortPathMarksByTime()
259{
260 sort(fPathMarks.begin(), fPathMarks.end(), cmp_pathmark());
261}
262
263
264/**************************************************************************/
5a5a1232 265
48dc973d 266void Track::ImportHits()
267{
268 Reve::LoadMacro("hits_from_label.C");
2fbbf445 269 gROOT->ProcessLine(Form("hits_from_label(%d, (Reve::RenderElement*)%p);",
270 fLabel, this));
48dc973d 271}
272
273void Track::ImportClusters()
274{
275 Reve::LoadMacro("clusters_from_label.C");
2fbbf445 276 gROOT->ProcessLine(Form("clusters_from_label(%d, (Reve::RenderElement*)%p);",
277 fLabel, this));
48dc973d 278}
279
fa446a68 280void Track::ImportClustersFromIndex()
281{
7cbaaebd 282 static const Exc_t eH("Track::ImportClustersFromIndex ");
283
284 if (fIndex < 0)
285 throw(eH + "index not set.");
286
fa446a68 287 Reve::LoadMacro("clusters_from_index.C");
2fbbf445 288 gROOT->ProcessLine(Form("clusters_from_index(%d, (Reve::RenderElement*)%p);",
289 fIndex, this));
fa446a68 290}
291
b8879e69 292/**************************************************************************/
293
294void Track::ImportKine()
295{
296 static const Exc_t eH("Track::ImportKine ");
297
298 if (fLabel < 0)
299 throw(eH + "label not set.");
300
301 Reve::LoadMacro("kine_tracks.C");
2fbbf445 302 gROOT->ProcessLine(Form("kine_track(%d, kFALSE, kTRUE, (Reve::RenderElement*)%p);",
303 fLabel, this));
304
b8879e69 305}
306
307void Track::ImportKineWithArgs(Bool_t importMother, Bool_t importDaugters)
a525aa60 308{
b8879e69 309 static const Exc_t eH("Track::ImportKineWithArgs ");
a525aa60 310
311 if (fLabel < 0)
312 throw(eH + "label not set.");
313
b8879e69 314 Reve::LoadMacro("kine_tracks.C");
2fbbf445 315 gROOT->ProcessLine(Form("kine_track(%d, %d, %d, (Reve::RenderElement*)%p);",
316 fLabel, importMother, importDaugters, this));
317
a525aa60 318}
319
320/**************************************************************************/
321
b1f08706 322void Track::PrintKineStack()
323{
324 Reve::LoadMacro("print_kine_from_label.C");
325 gROOT->ProcessLine(Form("print_kine_from_label(%d);", fLabel));
326}
327
a525aa60 328
329void Track::PrintPathMarks()
330{
331 static const Exc_t eH("Track::PrintPathMarks ");
332
333 if (fLabel < 0)
334 throw(eH + "label not set.");
335
336 printf("Number of path marks %d label %d\n",
337 fPathMarks.size(), fLabel);
338
339 PathMark* pm;
340 for(vpPathMark_i i=fPathMarks.begin(); i!=fPathMarks.end(); i++)
341 {
342 pm = *i;
343 printf("Reve::PathMark: %-9s p: %8f %8f %8f Vertex: %8e %8e %8e %g \n",
344 pm->type_name(),
345 pm->P.x, pm->P.y, pm->P.z,
346 pm->V.x, pm->V.y, pm->V.z,
347 pm->time);
348 }
349}
350
9c39ede9 351/**************************************************************************/
352
353void Track::CtrlClicked(Reve::Track* track)
354{
355 Emit("CtrlClicked(Reve::Track*)", (Long_t)track);
356}
357
48dc973d 358
359/**************************************************************************/
360/**************************************************************************/
361
5a5a1232 362//______________________________________________________________________
363// TrackRnrStyle
364//
365
366ClassImp(Reve::TrackRnrStyle)
367
48dc973d 368Float_t TrackRnrStyle::fgDefMagField = 5;
369const Float_t TrackRnrStyle::fgkB2C = 0.299792458e-3;
5a5a1232 370TrackRnrStyle TrackRnrStyle::fgDefStyle;
371
265ecb21 372TrackRnrStyle::TrackRnrStyle() :
373 TObject(),
5a5a1232 374
265ecb21 375 fColor(1),
2074deef 376 fWidth(1),
265ecb21 377 fMagField(fgDefMagField),
5a5a1232 378
265ecb21 379 fMaxR (350),
380 fMaxZ (450),
5a5a1232 381
265ecb21 382 fMaxOrbs (0.5),
383 fMinAng (45),
384 fDelta (0.1),
5a5a1232 385
22df2a83 386 fMinPt (0.1),
387 fMaxPt (10),
388
7cbaaebd 389 fFitDaughters (kTRUE),
390 fFitReferences (kTRUE),
391 fFitDecay (kTRUE),
5a5a1232 392
7cbaaebd 393 fRnrDaughters (kTRUE),
394 fRnrReferences (kTRUE),
395 fRnrDecay (kTRUE)
396{}
5a5a1232 397/**************************************************************************/
398/**************************************************************************/
399
400//______________________________________________________________________
401// TrackList
402//
403
404ClassImp(Reve::TrackList)
405
406void TrackList::Init()
407{
139b93bd 408 fMarkerStyle = 2;
a4fc27a6 409 fMarkerColor = 4;
139b93bd 410 fMarkerSize = 0.6;
5a5a1232 411
a8600b56 412 if (fRnrStyle== 0) fRnrStyle = new TrackRnrStyle;
413 SetMainColorPtr(&fRnrStyle->fColor);
5a5a1232 414}
415
a8600b56 416TrackList::TrackList(Int_t n_tracks, TrackRnrStyle* rs) :
2fbbf445 417 RenderElement(),
265ecb21 418 TPolyMarker3D(n_tracks),
419
420 fTitle(),
421
7cbaaebd 422 fRnrStyle (rs),
423 fRnrTracks (kTRUE),
424 fEditPathMarks (kFALSE)
5a5a1232 425{
426 Init();
427}
428
a8600b56 429TrackList::TrackList(const Text_t* name, Int_t n_tracks, TrackRnrStyle* rs) :
2fbbf445 430 RenderElement(),
265ecb21 431 TPolyMarker3D(n_tracks),
a8600b56 432
265ecb21 433 fTitle(),
434
139b93bd 435 fRnrStyle (rs),
436 fRnrTracks (kTRUE),
437 fEditPathMarks (kFALSE)
5a5a1232 438{
439 Init();
440 SetName(name);
441}
442
443void TrackList::Reset(Int_t n_tracks)
444{
445 delete [] fP; fP = 0;
446 fN = n_tracks;
447 if(fN) fP = new Float_t [3*fN];
448 memset(fP, 0, 3*fN*sizeof(Float_t));
449 fLastPoint = -1;
450}
451
452/**************************************************************************/
453
454void TrackList::Paint(Option_t* option)
455{
2fbbf445 456 if(fRnrSelf) {
5a5a1232 457 if(fRnrMarkers) {
458 TPolyMarker3D::Paint(option);
459 }
2fbbf445 460 if(fRnrTracks && fRnrChildren) {
9c39ede9 461 for(List_i i=fChildren.begin(); i!=fChildren.end(); ++i) {
2fbbf445 462 if((*i)->GetRnrSelf())
5a5a1232 463 (*i)->GetObject()->Paint(option);
464 }
465 }
466 }
467}
468
469/**************************************************************************/
470
471void TrackList::AddElement(RenderElement* el)
472{
473 static const Exc_t eH("TrackList::AddElement ");
474 if (dynamic_cast<Track*>(el) == 0)
475 throw(eH + "new element not a Track.");
2fbbf445 476 RenderElement::AddElement(el);
5a5a1232 477}
478
479/**************************************************************************/
480
5a5a1232 481void TrackList::MakeTracks()
482{
9c39ede9 483 for(List_i i=fChildren.begin(); i!=fChildren.end(); ++i) {
5a5a1232 484 ((Track*)(*i))->MakeTrack();
485 }
486 gReve->Redraw3D();
487}
488
489
490void TrackList::MakeMarkers()
491{
7d42b6c2 492 Reset(fChildren.size());
9c39ede9 493 for(List_i i=fChildren.begin(); i!=fChildren.end(); ++i) {
5a5a1232 494 Track& t = *((Track*)(*i));
495 if(t.GetN() > 0)
496 SetNextPoint(t.fV.x, t.fV.y, t.fV.z);
497 }
498 gReve->Redraw3D();
499}
500
501/**************************************************************************/
502/*************************************************************************/
503
2074deef 504void TrackList::SetWidth(Width_t w)
505{
506 Width_t oldw = fRnrStyle->fWidth;
507 fRnrStyle->fWidth = w;
9c39ede9 508 for (List_i i=fChildren.begin(); i!=fChildren.end(); ++i) {
2074deef 509 Track& t = *((Track*)(*i));
510 if (t.GetLineWidth() == oldw)
511 t.SetLineWidth(w);
512 }
513}
514
5a5a1232 515void TrackList::SetMaxR(Float_t x)
516{
a8600b56 517 fRnrStyle->fMaxR = x;
5a5a1232 518 MakeTracks();
519 MakeMarkers();
520}
521
522void TrackList::SetMaxZ(Float_t x)
523{
a8600b56 524 fRnrStyle->fMaxZ = x;
5a5a1232 525 MakeTracks();
526 MakeMarkers();
527}
528
529void TrackList::SetMaxOrbs(Float_t x)
530{
a8600b56 531 fRnrStyle->fMaxOrbs = x;
5a5a1232 532 MakeTracks();
533}
534
535void TrackList::SetMinAng(Float_t x)
536{
a8600b56 537 fRnrStyle->fMinAng = x;
5a5a1232 538 MakeTracks();
539}
540
541void TrackList::SetDelta(Float_t x)
542{
a8600b56 543 fRnrStyle->fDelta = x;
5a5a1232 544 MakeTracks();
545}
546
547void TrackList::SetFitDaughters(Bool_t x)
548{
a8600b56 549 fRnrStyle->fFitDaughters = x;
5a5a1232 550 MakeTracks();
551}
552
7cbaaebd 553void TrackList::SetFitReferences(Bool_t x)
554{
555 fRnrStyle->fFitReferences = x;
556 MakeTracks();
557}
558
5a5a1232 559void TrackList::SetFitDecay(Bool_t x)
560{
a8600b56 561 fRnrStyle->fFitDecay = x;
5a5a1232 562 MakeTracks();
563}
564
7cbaaebd 565void TrackList::SetRnrDecay(Bool_t rnr)
566{
567 fRnrStyle->fRnrDecay = rnr;
568 MakeTracks();
569}
570
571void TrackList::SetRnrDaughters(Bool_t rnr)
572{
573 fRnrStyle->fRnrDaughters = rnr;
574 MakeTracks();
575}
576
577void TrackList::SetRnrReferences(Bool_t rnr)
578{
579 fRnrStyle->fRnrReferences = rnr;
580 MakeTracks();
581}
582
583void TrackList::SetRnrMarkers(Bool_t rnr)
584{
585 fRnrMarkers = rnr;
586 gReve->Redraw3D();
587}
588
589void TrackList::SetRnrTracks(Bool_t rnr)
590{
591
592 fRnrTracks = rnr;
593 gReve->Redraw3D();
594}
595
5a5a1232 596/**************************************************************************/
597/**************************************************************************/
598
599void TrackList::SelectByPt(Float_t min_pt, Float_t max_pt)
600{
22df2a83 601 fRnrStyle->fMinPt = min_pt;
602 fRnrStyle->fMaxPt = max_pt;
603
5a5a1232 604 Float_t minptsq = min_pt*min_pt;
605 Float_t maxptsq = max_pt*max_pt;
606 Float_t ptsq;
607
9c39ede9 608 for(List_i i=fChildren.begin(); i!=fChildren.end(); ++i) {
5a5a1232 609 ptsq = ((Track*)(*i))->fP.Perp2();
2fbbf445 610 (*i)->SetRnrSelf(ptsq >= minptsq && ptsq <= maxptsq);
5a5a1232 611 }
612}
613
614/**************************************************************************/
615
b99aed53 616void TrackList::ImportHits()
5a5a1232 617{
9c39ede9 618 for(List_i i=fChildren.begin(); i!=fChildren.end(); ++i) {
b99aed53 619 ((Track*)(*i))->ImportHits();
620 }
5a5a1232 621}
622
b99aed53 623void TrackList::ImportClusters()
5a5a1232 624{
9c39ede9 625 for(List_i i=fChildren.begin(); i!=fChildren.end(); ++i) {
b99aed53 626 ((Track*)(*i))->ImportClusters();
627 }
5a5a1232 628}
9c39ede9 629
630/**************************************************************************/
631/**************************************************************************/
632/**************************************************************************/
633
634#include "RGEditor.h"
635
636//______________________________________________________________________
637// TrackCounter
638//
639
640ClassImp(TrackCounter)
641
b1f08706 642TrackCounter* TrackCounter::fgInstance = 0;
643
9c39ede9 644TrackCounter::TrackCounter(const Text_t* name, const Text_t* title) :
645 RenderElement(),
646 TNamed(name, title),
647
648 fBadLineStyle (6),
649 fClickAction (CA_ToggleTrack),
650 fAllTracks (0),
651 fGoodTracks (0),
652 fTrackLists ()
653{
b1f08706 654 if (fgInstance == 0) fgInstance = this;
9c39ede9 655 TQObject::Connect("Reve::Track", "CtrlClicked(Reve::Track*)",
656 "Reve::TrackCounter", this, "DoTrackAction(Reve::Track*)");
657}
658
659TrackCounter::~TrackCounter()
660{
661 TQObject::Disconnect("Reve::Track", "DoTrackAction(Reve::Track*)");
b1f08706 662 if (fgInstance == this) fgInstance = 0;
9c39ede9 663}
664
665/**************************************************************************/
666
667void TrackCounter::Reset()
668{
669 printf("TrackCounter::Reset()\n");
670 fAllTracks = 0;
671 fGoodTracks = 0;
672 TIter next(&fTrackLists);
673 TrackList* tlist;
674 while ((tlist = dynamic_cast<TrackList*>(next())))
675 tlist->RemoveParent(this);
676 fTrackLists.Clear();
677}
678
679void TrackCounter::RegisterTracks(TrackList* tlist, Bool_t goodTracks)
680{
681 // printf("TrackCounter::RegisterTracks '%s', %s\n",
682 // tlist->GetObject()->GetName(), goodTracks ? "good" : "bad");
683
684 tlist->AddParent(this);
685 fTrackLists.Add(tlist);
686
687 List_i i = tlist->BeginChildren();
688 while (i != tlist->EndChildren())
689 {
690 Track* t = dynamic_cast<Track*>(*i);
691 if (t != 0)
692 {
693 if (goodTracks)
694 {
695 ++fGoodTracks;
696 } else {
697 t->SetLineStyle(fBadLineStyle);
698 }
699 ++fAllTracks;
700 }
701 ++i;
702 }
703}
704
705void TrackCounter::DoTrackAction(Track* track)
706{
707 // !!!! No check done if ok.
708 // !!!! Should also override RemoveElementLocal
7af62191 709 // !!!! But then ... should also sotre local information if track is ok.
9c39ede9 710
711 switch (fClickAction)
712 {
713
714 case CA_PrintTrackInfo:
715 {
716 printf("Track '%s'\n", track->GetObject()->GetName());
717 Vector &v = track->fV, &p = track->fP;
718 printf(" Vx=%f, Vy=%f, Vz=%f; Pt=%f, Pz=%f, phi=%f)\n",
719 v.x, v.y, v.z, p.Perp(), p.z, TMath::RadToDeg()*p.Phi());
720 printf(" <other information should be printed ... full AliESDtrack>\n");
721 break;
722 }
723
724 case CA_ToggleTrack:
725 {
726 if (track->GetLineStyle() == 1)
727 {
728 track->SetLineStyle(fBadLineStyle);
729 --fGoodTracks;
730 } else {
731 track->SetLineStyle(1);
732 ++fGoodTracks;
733 }
734 gReve->Redraw3D();
735
736 printf("TrackCounter::CountTrack All=%d, Good=%d, Bad=%d\n",
737 fAllTracks, fGoodTracks, fAllTracks-fGoodTracks);
738
739 if (gReve->GetEditor()->GetModel() == GetObject())
740 gReve->EditRenderElement(this);
741
742 break;
743 }
744
745 } // end switch fClickAction
746}
7af62191 747
748/**************************************************************************/
749
750void TrackCounter::OutputEventTracks(FILE* out)
751{
752 if (out == 0)
753 {
754 out = stdout;
755 fprintf(out, "TrackCounter::FinalizeEvent()\n");
756 }
757
758 fprintf(out, "Event = %d Ntracks = %d\n", fEventId, fGoodTracks);
759
760 TIter tlists(&fTrackLists);
761 TrackList* tlist;
762 Int_t cnt = 0;
763 while ((tlist = (TrackList*) tlists()) != 0)
764 {
765 List_i i = tlist->BeginChildren();
766 while (i != tlist->EndChildren())
767 {
768 Track* t = dynamic_cast<Track*>(*i);
769 if (t != 0 && t->GetLineStyle() == 1)
770 {
771 ++cnt;
772 fprintf(out, " %2d: chg=%+2d pt=%8.5f eta=%+8.5f\n",
773 cnt, t->fCharge, t->fP.Perp(), t->fP.Eta());
774 }
775 ++i;
776 }
7af62191 777 }
778}