]> git.uio.no Git - u/mrichter/AliRoot.git/blame - EVE/Reve/Track.cxx
New functions in Vector class.
[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
ba008f46 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
5a5a1232 267/**************************************************************************/
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
4f5ee1c6 392 fMinP (0.1),
393 fMaxP (100),
394
7cbaaebd 395 fFitDaughters (kTRUE),
396 fFitReferences (kTRUE),
397 fFitDecay (kTRUE),
5a5a1232 398
7cbaaebd 399 fRnrDaughters (kTRUE),
400 fRnrReferences (kTRUE),
401 fRnrDecay (kTRUE)
402{}
5a5a1232 403/**************************************************************************/
404/**************************************************************************/
405
406//______________________________________________________________________
407// TrackList
408//
409
410ClassImp(Reve::TrackList)
411
412void TrackList::Init()
413{
139b93bd 414 fMarkerStyle = 2;
a4fc27a6 415 fMarkerColor = 4;
139b93bd 416 fMarkerSize = 0.6;
5a5a1232 417
a8600b56 418 if (fRnrStyle== 0) fRnrStyle = new TrackRnrStyle;
419 SetMainColorPtr(&fRnrStyle->fColor);
5a5a1232 420}
421
a8600b56 422TrackList::TrackList(Int_t n_tracks, TrackRnrStyle* rs) :
2fbbf445 423 RenderElement(),
265ecb21 424 TPolyMarker3D(n_tracks),
425
426 fTitle(),
427
7cbaaebd 428 fRnrStyle (rs),
429 fRnrTracks (kTRUE),
430 fEditPathMarks (kFALSE)
5a5a1232 431{
432 Init();
433}
434
a8600b56 435TrackList::TrackList(const Text_t* name, Int_t n_tracks, TrackRnrStyle* rs) :
2fbbf445 436 RenderElement(),
265ecb21 437 TPolyMarker3D(n_tracks),
a8600b56 438
265ecb21 439 fTitle(),
440
139b93bd 441 fRnrStyle (rs),
442 fRnrTracks (kTRUE),
443 fEditPathMarks (kFALSE)
5a5a1232 444{
445 Init();
446 SetName(name);
447}
448
449void TrackList::Reset(Int_t n_tracks)
450{
451 delete [] fP; fP = 0;
452 fN = n_tracks;
453 if(fN) fP = new Float_t [3*fN];
454 memset(fP, 0, 3*fN*sizeof(Float_t));
455 fLastPoint = -1;
456}
457
458/**************************************************************************/
459
460void TrackList::Paint(Option_t* option)
461{
2fbbf445 462 if(fRnrSelf) {
5a5a1232 463 if(fRnrMarkers) {
464 TPolyMarker3D::Paint(option);
465 }
2fbbf445 466 if(fRnrTracks && fRnrChildren) {
9c39ede9 467 for(List_i i=fChildren.begin(); i!=fChildren.end(); ++i) {
2fbbf445 468 if((*i)->GetRnrSelf())
5a5a1232 469 (*i)->GetObject()->Paint(option);
470 }
471 }
472 }
473}
474
475/**************************************************************************/
476
477void TrackList::AddElement(RenderElement* el)
478{
479 static const Exc_t eH("TrackList::AddElement ");
480 if (dynamic_cast<Track*>(el) == 0)
481 throw(eH + "new element not a Track.");
2fbbf445 482 RenderElement::AddElement(el);
5a5a1232 483}
484
485/**************************************************************************/
486
a8a51cc7 487void TrackList::MakeTracks(Bool_t recurse)
5a5a1232 488{
a8a51cc7 489 for(List_i i=fChildren.begin(); i!=fChildren.end(); ++i)
490 {
491 ((Track*)(*i))->MakeTrack(recurse);
5a5a1232 492 }
493 gReve->Redraw3D();
494}
495
496
497void TrackList::MakeMarkers()
498{
7d42b6c2 499 Reset(fChildren.size());
9c39ede9 500 for(List_i i=fChildren.begin(); i!=fChildren.end(); ++i) {
5a5a1232 501 Track& t = *((Track*)(*i));
4f5ee1c6 502 if(t.GetRnrSelf() && t.GetN() > 0)
5a5a1232 503 SetNextPoint(t.fV.x, t.fV.y, t.fV.z);
504 }
505 gReve->Redraw3D();
506}
507
508/**************************************************************************/
509/*************************************************************************/
510
2074deef 511void TrackList::SetWidth(Width_t w)
512{
513 Width_t oldw = fRnrStyle->fWidth;
514 fRnrStyle->fWidth = w;
9c39ede9 515 for (List_i i=fChildren.begin(); i!=fChildren.end(); ++i) {
2074deef 516 Track& t = *((Track*)(*i));
517 if (t.GetLineWidth() == oldw)
518 t.SetLineWidth(w);
519 }
520}
521
5a5a1232 522void TrackList::SetMaxR(Float_t x)
523{
a8600b56 524 fRnrStyle->fMaxR = x;
5a5a1232 525 MakeTracks();
526 MakeMarkers();
527}
528
529void TrackList::SetMaxZ(Float_t x)
530{
a8600b56 531 fRnrStyle->fMaxZ = x;
5a5a1232 532 MakeTracks();
533 MakeMarkers();
534}
535
536void TrackList::SetMaxOrbs(Float_t x)
537{
a8600b56 538 fRnrStyle->fMaxOrbs = x;
5a5a1232 539 MakeTracks();
540}
541
542void TrackList::SetMinAng(Float_t x)
543{
a8600b56 544 fRnrStyle->fMinAng = x;
5a5a1232 545 MakeTracks();
546}
547
548void TrackList::SetDelta(Float_t x)
549{
a8600b56 550 fRnrStyle->fDelta = x;
5a5a1232 551 MakeTracks();
552}
553
554void TrackList::SetFitDaughters(Bool_t x)
555{
a8600b56 556 fRnrStyle->fFitDaughters = x;
5a5a1232 557 MakeTracks();
558}
559
7cbaaebd 560void TrackList::SetFitReferences(Bool_t x)
561{
562 fRnrStyle->fFitReferences = x;
563 MakeTracks();
564}
565
5a5a1232 566void TrackList::SetFitDecay(Bool_t x)
567{
a8600b56 568 fRnrStyle->fFitDecay = x;
5a5a1232 569 MakeTracks();
570}
571
7cbaaebd 572void TrackList::SetRnrDecay(Bool_t rnr)
573{
574 fRnrStyle->fRnrDecay = rnr;
575 MakeTracks();
576}
577
578void TrackList::SetRnrDaughters(Bool_t rnr)
579{
580 fRnrStyle->fRnrDaughters = rnr;
581 MakeTracks();
582}
583
584void TrackList::SetRnrReferences(Bool_t rnr)
585{
586 fRnrStyle->fRnrReferences = rnr;
587 MakeTracks();
588}
589
590void TrackList::SetRnrMarkers(Bool_t rnr)
591{
592 fRnrMarkers = rnr;
593 gReve->Redraw3D();
594}
595
596void TrackList::SetRnrTracks(Bool_t rnr)
597{
7cbaaebd 598 fRnrTracks = rnr;
599 gReve->Redraw3D();
600}
601
5a5a1232 602/**************************************************************************/
603/**************************************************************************/
604
605void TrackList::SelectByPt(Float_t min_pt, Float_t max_pt)
606{
22df2a83 607 fRnrStyle->fMinPt = min_pt;
608 fRnrStyle->fMaxPt = max_pt;
609
5a5a1232 610 Float_t minptsq = min_pt*min_pt;
611 Float_t maxptsq = max_pt*max_pt;
612 Float_t ptsq;
613
9c39ede9 614 for(List_i i=fChildren.begin(); i!=fChildren.end(); ++i) {
5a5a1232 615 ptsq = ((Track*)(*i))->fP.Perp2();
a8a51cc7 616 Bool_t on = ptsq >= minptsq && ptsq <= maxptsq;
617 (*i)->SetRnrSelf(on);
618 (*i)->SetRnrChildren(on);
5a5a1232 619 }
620}
621
4f5ee1c6 622void TrackList::SelectByP(Float_t min_p, Float_t max_p)
623{
624 fRnrStyle->fMinP = min_p;
625 fRnrStyle->fMaxP = max_p;
626
627 Float_t minpsq = min_p*min_p;
628 Float_t maxpsq = max_p*max_p;
629 Float_t psq;
630
631 for(List_i i=fChildren.begin(); i!=fChildren.end(); ++i) {
e7c2ba6b 632 psq = ((Track*)(*i))->fP.Mag();
633 psq *= psq;
4f5ee1c6 634 (*i)->SetRnrSelf(psq >= minpsq && psq <= maxpsq);
635 }
636}
637
5a5a1232 638/**************************************************************************/
639
b99aed53 640void TrackList::ImportHits()
5a5a1232 641{
9c39ede9 642 for(List_i i=fChildren.begin(); i!=fChildren.end(); ++i) {
b99aed53 643 ((Track*)(*i))->ImportHits();
644 }
5a5a1232 645}
646
b99aed53 647void TrackList::ImportClusters()
5a5a1232 648{
9c39ede9 649 for(List_i i=fChildren.begin(); i!=fChildren.end(); ++i) {
b99aed53 650 ((Track*)(*i))->ImportClusters();
651 }
5a5a1232 652}
9c39ede9 653
654/**************************************************************************/
655/**************************************************************************/
656/**************************************************************************/
657
658#include "RGEditor.h"
659
660//______________________________________________________________________
661// TrackCounter
662//
663
664ClassImp(TrackCounter)
665
b1f08706 666TrackCounter* TrackCounter::fgInstance = 0;
667
9c39ede9 668TrackCounter::TrackCounter(const Text_t* name, const Text_t* title) :
669 RenderElement(),
670 TNamed(name, title),
671
672 fBadLineStyle (6),
673 fClickAction (CA_ToggleTrack),
674 fAllTracks (0),
675 fGoodTracks (0),
676 fTrackLists ()
677{
b1f08706 678 if (fgInstance == 0) fgInstance = this;
9c39ede9 679 TQObject::Connect("Reve::Track", "CtrlClicked(Reve::Track*)",
680 "Reve::TrackCounter", this, "DoTrackAction(Reve::Track*)");
681}
682
683TrackCounter::~TrackCounter()
684{
685 TQObject::Disconnect("Reve::Track", "DoTrackAction(Reve::Track*)");
b1f08706 686 if (fgInstance == this) fgInstance = 0;
9c39ede9 687}
688
689/**************************************************************************/
690
691void TrackCounter::Reset()
692{
693 printf("TrackCounter::Reset()\n");
694 fAllTracks = 0;
695 fGoodTracks = 0;
696 TIter next(&fTrackLists);
697 TrackList* tlist;
698 while ((tlist = dynamic_cast<TrackList*>(next())))
699 tlist->RemoveParent(this);
700 fTrackLists.Clear();
701}
702
703void TrackCounter::RegisterTracks(TrackList* tlist, Bool_t goodTracks)
704{
705 // printf("TrackCounter::RegisterTracks '%s', %s\n",
706 // tlist->GetObject()->GetName(), goodTracks ? "good" : "bad");
707
708 tlist->AddParent(this);
709 fTrackLists.Add(tlist);
710
711 List_i i = tlist->BeginChildren();
712 while (i != tlist->EndChildren())
713 {
714 Track* t = dynamic_cast<Track*>(*i);
715 if (t != 0)
716 {
717 if (goodTracks)
718 {
719 ++fGoodTracks;
720 } else {
721 t->SetLineStyle(fBadLineStyle);
722 }
723 ++fAllTracks;
724 }
725 ++i;
726 }
727}
728
729void TrackCounter::DoTrackAction(Track* track)
730{
731 // !!!! No check done if ok.
732 // !!!! Should also override RemoveElementLocal
7af62191 733 // !!!! But then ... should also sotre local information if track is ok.
9c39ede9 734
735 switch (fClickAction)
736 {
737
738 case CA_PrintTrackInfo:
739 {
740 printf("Track '%s'\n", track->GetObject()->GetName());
741 Vector &v = track->fV, &p = track->fP;
742 printf(" Vx=%f, Vy=%f, Vz=%f; Pt=%f, Pz=%f, phi=%f)\n",
743 v.x, v.y, v.z, p.Perp(), p.z, TMath::RadToDeg()*p.Phi());
744 printf(" <other information should be printed ... full AliESDtrack>\n");
745 break;
746 }
747
748 case CA_ToggleTrack:
749 {
750 if (track->GetLineStyle() == 1)
751 {
752 track->SetLineStyle(fBadLineStyle);
753 --fGoodTracks;
754 } else {
755 track->SetLineStyle(1);
756 ++fGoodTracks;
757 }
758 gReve->Redraw3D();
759
760 printf("TrackCounter::CountTrack All=%d, Good=%d, Bad=%d\n",
761 fAllTracks, fGoodTracks, fAllTracks-fGoodTracks);
762
763 if (gReve->GetEditor()->GetModel() == GetObject())
764 gReve->EditRenderElement(this);
765
766 break;
767 }
768
769 } // end switch fClickAction
770}
7af62191 771
772/**************************************************************************/
773
774void TrackCounter::OutputEventTracks(FILE* out)
775{
776 if (out == 0)
777 {
778 out = stdout;
779 fprintf(out, "TrackCounter::FinalizeEvent()\n");
780 }
781
782 fprintf(out, "Event = %d Ntracks = %d\n", fEventId, fGoodTracks);
783
784 TIter tlists(&fTrackLists);
785 TrackList* tlist;
786 Int_t cnt = 0;
787 while ((tlist = (TrackList*) tlists()) != 0)
788 {
789 List_i i = tlist->BeginChildren();
790 while (i != tlist->EndChildren())
791 {
792 Track* t = dynamic_cast<Track*>(*i);
793 if (t != 0 && t->GetLineStyle() == 1)
794 {
795 ++cnt;
796 fprintf(out, " %2d: chg=%+2d pt=%8.5f eta=%+8.5f\n",
797 cnt, t->fCharge, t->fP.Perp(), t->fP.Eta());
798 }
799 ++i;
800 }
7af62191 801 }
802}