Improve handling of multi-level track containers for kinematic trees.
[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
a8a51cc7 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) {
a8a51cc7 242 for(List_i i=fChildren.begin(); i!=fChildren.end(); ++i)
243 {
244 Track* t = dynamic_cast<Track*>(*i);
245 if(t) t->MakeTrack(recurse);
2fbbf445 246 }
247 }
5a5a1232 248}
249
250/**************************************************************************/
a8a51cc7 251
ba008f46 252namespace {
a8a51cc7 253
254struct cmp_pathmark
255{
ba008f46 256 bool operator()(PathMark* const & a, PathMark* const & b)
257 { return a->time < b->time; }
258};
a8a51cc7 259
ba008f46 260}
261
262void Track::SortPathMarksByTime()
263{
264 sort(fPathMarks.begin(), fPathMarks.end(), cmp_pathmark());
265}
266
ba008f46 267/**************************************************************************/
5a5a1232 268
48dc973d 269void Track::ImportHits()
270{
271 Reve::LoadMacro("hits_from_label.C");
2fbbf445 272 gROOT->ProcessLine(Form("hits_from_label(%d, (Reve::RenderElement*)%p);",
273 fLabel, this));
48dc973d 274}
275
276void Track::ImportClusters()
277{
278 Reve::LoadMacro("clusters_from_label.C");
2fbbf445 279 gROOT->ProcessLine(Form("clusters_from_label(%d, (Reve::RenderElement*)%p);",
280 fLabel, this));
48dc973d 281}
282
fa446a68 283void Track::ImportClustersFromIndex()
284{
7cbaaebd 285 static const Exc_t eH("Track::ImportClustersFromIndex ");
286
287 if (fIndex < 0)
288 throw(eH + "index not set.");
289
fa446a68 290 Reve::LoadMacro("clusters_from_index.C");
2fbbf445 291 gROOT->ProcessLine(Form("clusters_from_index(%d, (Reve::RenderElement*)%p);",
292 fIndex, this));
fa446a68 293}
294
b8879e69 295/**************************************************************************/
296
297void Track::ImportKine()
298{
299 static const Exc_t eH("Track::ImportKine ");
300
301 if (fLabel < 0)
302 throw(eH + "label not set.");
303
304 Reve::LoadMacro("kine_tracks.C");
2fbbf445 305 gROOT->ProcessLine(Form("kine_track(%d, kFALSE, kTRUE, (Reve::RenderElement*)%p);",
306 fLabel, this));
307
b8879e69 308}
309
310void Track::ImportKineWithArgs(Bool_t importMother, Bool_t importDaugters)
a525aa60 311{
b8879e69 312 static const Exc_t eH("Track::ImportKineWithArgs ");
a525aa60 313
314 if (fLabel < 0)
315 throw(eH + "label not set.");
316
b8879e69 317 Reve::LoadMacro("kine_tracks.C");
2fbbf445 318 gROOT->ProcessLine(Form("kine_track(%d, %d, %d, (Reve::RenderElement*)%p);",
319 fLabel, importMother, importDaugters, this));
320
a525aa60 321}
322
323/**************************************************************************/
324
b1f08706 325void Track::PrintKineStack()
326{
327 Reve::LoadMacro("print_kine_from_label.C");
328 gROOT->ProcessLine(Form("print_kine_from_label(%d);", fLabel));
329}
330
a525aa60 331
332void Track::PrintPathMarks()
333{
334 static const Exc_t eH("Track::PrintPathMarks ");
335
336 if (fLabel < 0)
337 throw(eH + "label not set.");
338
339 printf("Number of path marks %d label %d\n",
340 fPathMarks.size(), fLabel);
341
342 PathMark* pm;
343 for(vpPathMark_i i=fPathMarks.begin(); i!=fPathMarks.end(); i++)
344 {
345 pm = *i;
346 printf("Reve::PathMark: %-9s p: %8f %8f %8f Vertex: %8e %8e %8e %g \n",
347 pm->type_name(),
348 pm->P.x, pm->P.y, pm->P.z,
349 pm->V.x, pm->V.y, pm->V.z,
350 pm->time);
351 }
352}
353
9c39ede9 354/**************************************************************************/
355
356void Track::CtrlClicked(Reve::Track* track)
357{
358 Emit("CtrlClicked(Reve::Track*)", (Long_t)track);
359}
360
48dc973d 361
362/**************************************************************************/
363/**************************************************************************/
364
5a5a1232 365//______________________________________________________________________
366// TrackRnrStyle
367//
368
369ClassImp(Reve::TrackRnrStyle)
370
48dc973d 371Float_t TrackRnrStyle::fgDefMagField = 5;
372const Float_t TrackRnrStyle::fgkB2C = 0.299792458e-3;
5a5a1232 373TrackRnrStyle TrackRnrStyle::fgDefStyle;
374
265ecb21 375TrackRnrStyle::TrackRnrStyle() :
376 TObject(),
5a5a1232 377
265ecb21 378 fColor(1),
2074deef 379 fWidth(1),
265ecb21 380 fMagField(fgDefMagField),
5a5a1232 381
265ecb21 382 fMaxR (350),
383 fMaxZ (450),
5a5a1232 384
265ecb21 385 fMaxOrbs (0.5),
386 fMinAng (45),
387 fDelta (0.1),
5a5a1232 388
22df2a83 389 fMinPt (0.1),
390 fMaxPt (10),
391
7cbaaebd 392 fFitDaughters (kTRUE),
393 fFitReferences (kTRUE),
394 fFitDecay (kTRUE),
5a5a1232 395
7cbaaebd 396 fRnrDaughters (kTRUE),
397 fRnrReferences (kTRUE),
398 fRnrDecay (kTRUE)
399{}
5a5a1232 400/**************************************************************************/
401/**************************************************************************/
402
403//______________________________________________________________________
404// TrackList
405//
406
407ClassImp(Reve::TrackList)
408
409void TrackList::Init()
410{
139b93bd 411 fMarkerStyle = 2;
a4fc27a6 412 fMarkerColor = 4;
139b93bd 413 fMarkerSize = 0.6;
5a5a1232 414
a8600b56 415 if (fRnrStyle== 0) fRnrStyle = new TrackRnrStyle;
416 SetMainColorPtr(&fRnrStyle->fColor);
5a5a1232 417}
418
a8600b56 419TrackList::TrackList(Int_t n_tracks, TrackRnrStyle* rs) :
2fbbf445 420 RenderElement(),
265ecb21 421 TPolyMarker3D(n_tracks),
422
423 fTitle(),
424
7cbaaebd 425 fRnrStyle (rs),
426 fRnrTracks (kTRUE),
427 fEditPathMarks (kFALSE)
5a5a1232 428{
429 Init();
430}
431
a8600b56 432TrackList::TrackList(const Text_t* name, Int_t n_tracks, TrackRnrStyle* rs) :
2fbbf445 433 RenderElement(),
265ecb21 434 TPolyMarker3D(n_tracks),
a8600b56 435
265ecb21 436 fTitle(),
437
139b93bd 438 fRnrStyle (rs),
439 fRnrTracks (kTRUE),
440 fEditPathMarks (kFALSE)
5a5a1232 441{
442 Init();
443 SetName(name);
444}
445
446void TrackList::Reset(Int_t n_tracks)
447{
448 delete [] fP; fP = 0;
449 fN = n_tracks;
450 if(fN) fP = new Float_t [3*fN];
451 memset(fP, 0, 3*fN*sizeof(Float_t));
452 fLastPoint = -1;
453}
454
455/**************************************************************************/
456
457void TrackList::Paint(Option_t* option)
458{
2fbbf445 459 if(fRnrSelf) {
5a5a1232 460 if(fRnrMarkers) {
461 TPolyMarker3D::Paint(option);
462 }
2fbbf445 463 if(fRnrTracks && fRnrChildren) {
9c39ede9 464 for(List_i i=fChildren.begin(); i!=fChildren.end(); ++i) {
2fbbf445 465 if((*i)->GetRnrSelf())
5a5a1232 466 (*i)->GetObject()->Paint(option);
467 }
468 }
469 }
470}
471
472/**************************************************************************/
473
474void TrackList::AddElement(RenderElement* el)
475{
476 static const Exc_t eH("TrackList::AddElement ");
477 if (dynamic_cast<Track*>(el) == 0)
478 throw(eH + "new element not a Track.");
2fbbf445 479 RenderElement::AddElement(el);
5a5a1232 480}
481
482/**************************************************************************/
483
a8a51cc7 484void TrackList::MakeTracks(Bool_t recurse)
5a5a1232 485{
a8a51cc7 486 for(List_i i=fChildren.begin(); i!=fChildren.end(); ++i)
487 {
488 ((Track*)(*i))->MakeTrack(recurse);
5a5a1232 489 }
490 gReve->Redraw3D();
491}
492
493
494void TrackList::MakeMarkers()
495{
7d42b6c2 496 Reset(fChildren.size());
9c39ede9 497 for(List_i i=fChildren.begin(); i!=fChildren.end(); ++i) {
5a5a1232 498 Track& t = *((Track*)(*i));
499 if(t.GetN() > 0)
500 SetNextPoint(t.fV.x, t.fV.y, t.fV.z);
501 }
502 gReve->Redraw3D();
503}
504
505/**************************************************************************/
506/*************************************************************************/
507
2074deef 508void TrackList::SetWidth(Width_t w)
509{
510 Width_t oldw = fRnrStyle->fWidth;
511 fRnrStyle->fWidth = w;
9c39ede9 512 for (List_i i=fChildren.begin(); i!=fChildren.end(); ++i) {
2074deef 513 Track& t = *((Track*)(*i));
514 if (t.GetLineWidth() == oldw)
515 t.SetLineWidth(w);
516 }
517}
518
5a5a1232 519void TrackList::SetMaxR(Float_t x)
520{
a8600b56 521 fRnrStyle->fMaxR = x;
5a5a1232 522 MakeTracks();
523 MakeMarkers();
524}
525
526void TrackList::SetMaxZ(Float_t x)
527{
a8600b56 528 fRnrStyle->fMaxZ = x;
5a5a1232 529 MakeTracks();
530 MakeMarkers();
531}
532
533void TrackList::SetMaxOrbs(Float_t x)
534{
a8600b56 535 fRnrStyle->fMaxOrbs = x;
5a5a1232 536 MakeTracks();
537}
538
539void TrackList::SetMinAng(Float_t x)
540{
a8600b56 541 fRnrStyle->fMinAng = x;
5a5a1232 542 MakeTracks();
543}
544
545void TrackList::SetDelta(Float_t x)
546{
a8600b56 547 fRnrStyle->fDelta = x;
5a5a1232 548 MakeTracks();
549}
550
551void TrackList::SetFitDaughters(Bool_t x)
552{
a8600b56 553 fRnrStyle->fFitDaughters = x;
5a5a1232 554 MakeTracks();
555}
556
7cbaaebd 557void TrackList::SetFitReferences(Bool_t x)
558{
559 fRnrStyle->fFitReferences = x;
560 MakeTracks();
561}
562
5a5a1232 563void TrackList::SetFitDecay(Bool_t x)
564{
a8600b56 565 fRnrStyle->fFitDecay = x;
5a5a1232 566 MakeTracks();
567}
568
7cbaaebd 569void TrackList::SetRnrDecay(Bool_t rnr)
570{
571 fRnrStyle->fRnrDecay = rnr;
572 MakeTracks();
573}
574
575void TrackList::SetRnrDaughters(Bool_t rnr)
576{
577 fRnrStyle->fRnrDaughters = rnr;
578 MakeTracks();
579}
580
581void TrackList::SetRnrReferences(Bool_t rnr)
582{
583 fRnrStyle->fRnrReferences = rnr;
584 MakeTracks();
585}
586
587void TrackList::SetRnrMarkers(Bool_t rnr)
588{
589 fRnrMarkers = rnr;
590 gReve->Redraw3D();
591}
592
593void TrackList::SetRnrTracks(Bool_t rnr)
594{
595
596 fRnrTracks = rnr;
597 gReve->Redraw3D();
598}
599
5a5a1232 600/**************************************************************************/
601/**************************************************************************/
602
603void TrackList::SelectByPt(Float_t min_pt, Float_t max_pt)
604{
22df2a83 605 fRnrStyle->fMinPt = min_pt;
606 fRnrStyle->fMaxPt = max_pt;
607
5a5a1232 608 Float_t minptsq = min_pt*min_pt;
609 Float_t maxptsq = max_pt*max_pt;
610 Float_t ptsq;
611
9c39ede9 612 for(List_i i=fChildren.begin(); i!=fChildren.end(); ++i) {
5a5a1232 613 ptsq = ((Track*)(*i))->fP.Perp2();
a8a51cc7 614 Bool_t on = ptsq >= minptsq && ptsq <= maxptsq;
615 (*i)->SetRnrSelf(on);
616 (*i)->SetRnrChildren(on);
5a5a1232 617 }
618}
619
620/**************************************************************************/
621
b99aed53 622void TrackList::ImportHits()
5a5a1232 623{
9c39ede9 624 for(List_i i=fChildren.begin(); i!=fChildren.end(); ++i) {
b99aed53 625 ((Track*)(*i))->ImportHits();
626 }
5a5a1232 627}
628
b99aed53 629void TrackList::ImportClusters()
5a5a1232 630{
9c39ede9 631 for(List_i i=fChildren.begin(); i!=fChildren.end(); ++i) {
b99aed53 632 ((Track*)(*i))->ImportClusters();
633 }
5a5a1232 634}
9c39ede9 635
636/**************************************************************************/
637/**************************************************************************/
638/**************************************************************************/
639
640#include "RGEditor.h"
641
642//______________________________________________________________________
643// TrackCounter
644//
645
646ClassImp(TrackCounter)
647
b1f08706 648TrackCounter* TrackCounter::fgInstance = 0;
649
9c39ede9 650TrackCounter::TrackCounter(const Text_t* name, const Text_t* title) :
651 RenderElement(),
652 TNamed(name, title),
653
654 fBadLineStyle (6),
655 fClickAction (CA_ToggleTrack),
656 fAllTracks (0),
657 fGoodTracks (0),
658 fTrackLists ()
659{
b1f08706 660 if (fgInstance == 0) fgInstance = this;
9c39ede9 661 TQObject::Connect("Reve::Track", "CtrlClicked(Reve::Track*)",
662 "Reve::TrackCounter", this, "DoTrackAction(Reve::Track*)");
663}
664
665TrackCounter::~TrackCounter()
666{
667 TQObject::Disconnect("Reve::Track", "DoTrackAction(Reve::Track*)");
b1f08706 668 if (fgInstance == this) fgInstance = 0;
9c39ede9 669}
670
671/**************************************************************************/
672
673void TrackCounter::Reset()
674{
675 printf("TrackCounter::Reset()\n");
676 fAllTracks = 0;
677 fGoodTracks = 0;
678 TIter next(&fTrackLists);
679 TrackList* tlist;
680 while ((tlist = dynamic_cast<TrackList*>(next())))
681 tlist->RemoveParent(this);
682 fTrackLists.Clear();
683}
684
685void TrackCounter::RegisterTracks(TrackList* tlist, Bool_t goodTracks)
686{
687 // printf("TrackCounter::RegisterTracks '%s', %s\n",
688 // tlist->GetObject()->GetName(), goodTracks ? "good" : "bad");
689
690 tlist->AddParent(this);
691 fTrackLists.Add(tlist);
692
693 List_i i = tlist->BeginChildren();
694 while (i != tlist->EndChildren())
695 {
696 Track* t = dynamic_cast<Track*>(*i);
697 if (t != 0)
698 {
699 if (goodTracks)
700 {
701 ++fGoodTracks;
702 } else {
703 t->SetLineStyle(fBadLineStyle);
704 }
705 ++fAllTracks;
706 }
707 ++i;
708 }
709}
710
711void TrackCounter::DoTrackAction(Track* track)
712{
713 // !!!! No check done if ok.
714 // !!!! Should also override RemoveElementLocal
7af62191 715 // !!!! But then ... should also sotre local information if track is ok.
9c39ede9 716
717 switch (fClickAction)
718 {
719
720 case CA_PrintTrackInfo:
721 {
722 printf("Track '%s'\n", track->GetObject()->GetName());
723 Vector &v = track->fV, &p = track->fP;
724 printf(" Vx=%f, Vy=%f, Vz=%f; Pt=%f, Pz=%f, phi=%f)\n",
725 v.x, v.y, v.z, p.Perp(), p.z, TMath::RadToDeg()*p.Phi());
726 printf(" <other information should be printed ... full AliESDtrack>\n");
727 break;
728 }
729
730 case CA_ToggleTrack:
731 {
732 if (track->GetLineStyle() == 1)
733 {
734 track->SetLineStyle(fBadLineStyle);
735 --fGoodTracks;
736 } else {
737 track->SetLineStyle(1);
738 ++fGoodTracks;
739 }
740 gReve->Redraw3D();
741
742 printf("TrackCounter::CountTrack All=%d, Good=%d, Bad=%d\n",
743 fAllTracks, fGoodTracks, fAllTracks-fGoodTracks);
744
745 if (gReve->GetEditor()->GetModel() == GetObject())
746 gReve->EditRenderElement(this);
747
748 break;
749 }
750
751 } // end switch fClickAction
752}
7af62191 753
754/**************************************************************************/
755
756void TrackCounter::OutputEventTracks(FILE* out)
757{
758 if (out == 0)
759 {
760 out = stdout;
761 fprintf(out, "TrackCounter::FinalizeEvent()\n");
762 }
763
764 fprintf(out, "Event = %d Ntracks = %d\n", fEventId, fGoodTracks);
765
766 TIter tlists(&fTrackLists);
767 TrackList* tlist;
768 Int_t cnt = 0;
769 while ((tlist = (TrackList*) tlists()) != 0)
770 {
771 List_i i = tlist->BeginChildren();
772 while (i != tlist->EndChildren())
773 {
774 Track* t = dynamic_cast<Track*>(*i);
775 if (t != 0 && t->GetLineStyle() == 1)
776 {
777 ++cnt;
778 fprintf(out, " %2d: chg=%+2d pt=%8.5f eta=%+8.5f\n",
779 cnt, t->fCharge, t->fP.Perp(), t->fP.Eta());
780 }
781 ++i;
782 }
7af62191 783 }
784}