forked from root-project/root
-
Notifications
You must be signed in to change notification settings - Fork 0
/
TEveTrack.cxx
1180 lines (1000 loc) · 33.3 KB
/
TEveTrack.cxx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
// @(#)root/eve:$Id$
// Authors: Matevz Tadel & Alja Mrak-Tadel: 2006, 2007
/*************************************************************************
* Copyright (C) 1995-2007, Rene Brun and Fons Rademakers. *
* All rights reserved. *
* *
* For the licensing terms see $ROOTSYS/LICENSE. *
* For the list of contributors see $ROOTSYS/README/CREDITS. *
*************************************************************************/
#include "TEveTrack.h"
#include "TEveTrackPropagator.h"
#include "TEvePointSet.h"
#include "TPolyLine3D.h"
#include "TMarker.h"
#include "TPolyMarker3D.h"
#include "TColor.h"
#include "TParticlePDG.h"
// Updates
#include "TEveManager.h"
#include "TEveBrowser.h"
#include "TEveTrackProjected.h"
#include "Riostream.h"
#include <vector>
#include <algorithm>
#include <functional>
/** \class TEveTrack
\ingroup TEve
Visual representation of a track.
If member fDpDs is set, the momentum is reduced on all path-marks that do
not fix the momentum according to the distance travelled from the previous
pathmark.
*/
ClassImp(TEveTrack);
////////////////////////////////////////////////////////////////////////////////
/// Default constructor.
TEveTrack::TEveTrack() :
TEveLine(),
fV(),
fP(),
fPEnd(),
fBeta(0),
fDpDs(0),
fPdg(0),
fCharge(0),
fLabel(kMinInt),
fIndex(kMinInt),
fStatus(0),
fLockPoints(kFALSE),
fPathMarks(),
fLastPMIdx(0),
fPropagator(0)
{
}
////////////////////////////////////////////////////////////////////////////////
/// Constructor from TParticle.
TEveTrack::TEveTrack(TParticle* t, Int_t label, TEveTrackPropagator* prop):
TEveLine(),
fV(t->Vx(), t->Vy(), t->Vz()),
fP(t->Px(), t->Py(), t->Pz()),
fPEnd(),
fBeta(t->P()/t->Energy()),
fDpDs(0),
fPdg(0),
fCharge(0),
fLabel(label),
fIndex(kMinInt),
fStatus(t->GetStatusCode()),
fLockPoints(kFALSE),
fPathMarks(),
fLastPMIdx(0),
fPropagator(0)
{
SetPropagator(prop);
fMainColorPtr = &fLineColor;
TParticlePDG* pdgp = t->GetPDG();
if (pdgp) {
fPdg = pdgp->PdgCode();
fCharge = (Int_t) TMath::Nint(pdgp->Charge()/3);
}
SetName(t->GetName());
}
////////////////////////////////////////////////////////////////////////////////
TEveTrack::TEveTrack(TEveMCTrack* t, TEveTrackPropagator* prop):
TEveLine(),
fV(t->Vx(), t->Vy(), t->Vz()),
fP(t->Px(), t->Py(), t->Pz()),
fPEnd(),
fBeta(t->P()/t->Energy()),
fDpDs(0),
fPdg(0),
fCharge(0),
fLabel(t->fLabel),
fIndex(t->fIndex),
fStatus(t->GetStatusCode()),
fLockPoints(kFALSE),
fPathMarks(),
fLastPMIdx(0),
fPropagator(0)
{
// Constructor from TEveUtil Monte Carlo track.
SetPropagator(prop);
fMainColorPtr = &fLineColor;
TParticlePDG* pdgp = t->GetPDG();
if (pdgp) {
fCharge = (Int_t) TMath::Nint(pdgp->Charge()/3);
}
SetName(t->GetName());
}
////////////////////////////////////////////////////////////////////////////////
/// Constructor from TEveRecTrack<double> reconstructed track.
TEveTrack::TEveTrack(TEveRecTrackD* t, TEveTrackPropagator* prop) :
TEveLine(),
fV(t->fV),
fP(t->fP),
fPEnd(),
fBeta(t->fBeta),
fDpDs(0),
fPdg(0),
fCharge(t->fSign),
fLabel(t->fLabel),
fIndex(t->fIndex),
fStatus(t->fStatus),
fLockPoints(kFALSE),
fPathMarks(),
fLastPMIdx(0),
fPropagator(0)
{
SetPropagator(prop);
fMainColorPtr = &fLineColor;
SetName(t->GetName());
}
////////////////////////////////////////////////////////////////////////////////
/// Constructor from TEveRecTrack<float> reconstructed track.
/// It is recommended to use constructor with TEveRecTrack<double> since
/// TEveTrackPropagator operates with double type.
TEveTrack::TEveTrack(TEveRecTrack* t, TEveTrackPropagator* prop) :
TEveLine(),
fV(t->fV),
fP(t->fP),
fPEnd(),
fBeta(t->fBeta),
fDpDs(0),
fPdg(0),
fCharge(t->fSign),
fLabel(t->fLabel),
fIndex(t->fIndex),
fStatus(t->fStatus),
fLockPoints(kFALSE),
fPathMarks(),
fLastPMIdx(0),
fPropagator(0)
{
SetPropagator(prop);
fMainColorPtr = &fLineColor;
SetName(t->GetName());
}
////////////////////////////////////////////////////////////////////////////////
/// Copy constructor. Track parameters are copied but the
/// extrapolation is not performed so you should still call
/// MakeTrack() to do that.
/// If points of 't' are locked, they are cloned.
TEveTrack::TEveTrack(const TEveTrack& t) :
TEveLine(),
fV(t.fV),
fP(t.fP),
fPEnd(),
fBeta(t.fBeta),
fDpDs(t.fDpDs),
fPdg(t.fPdg),
fCharge(t.fCharge),
fLabel(t.fLabel),
fIndex(t.fIndex),
fStatus(t.fStatus),
fLockPoints(t.fLockPoints),
fPathMarks(),
fLastPMIdx(t.fLastPMIdx),
fPropagator(0)
{
if (fLockPoints)
ClonePoints(t);
SetPathMarks(t);
SetPropagator (t.fPropagator);
CopyVizParams(&t);
}
////////////////////////////////////////////////////////////////////////////////
/// Destructor.
TEveTrack::~TEveTrack()
{
SetPropagator(0);
}
////////////////////////////////////////////////////////////////////////////////
/// Returns list-tree icon for TEveTrack.
const TGPicture* TEveTrack::GetListTreeIcon(Bool_t)
{
return fgListTreeIcons[4];
}
////////////////////////////////////////////////////////////////////////////////
/// Compute the bounding box of the track.
void TEveTrack::ComputeBBox()
{
if (Size() > 0 || ! fPathMarks.empty())
{
BBoxInit();
Int_t n = Size();
Float_t* p = TPolyMarker3D::fP;
for (Int_t i = 0; i < n; ++i, p += 3)
{
BBoxCheckPoint(p);
}
for (vPathMark_ci i = fPathMarks.begin(); i != fPathMarks.end(); ++i)
{
BBoxCheckPoint(i->fV.fX, i->fV.fY,i->fV.fZ);
}
}
else
{
BBoxZero();
}
}
////////////////////////////////////////////////////////////////////////////////
/// Set standard track title based on most data-member values.
void TEveTrack::SetStdTitle()
{
TString idx(fIndex == kMinInt ? "<undef>" : Form("%d", fIndex));
TString lbl(fLabel == kMinInt ? "<undef>" : Form("%d", fLabel));
SetTitle(Form("Index=%s, Label=%s\nChg=%d, Pdg=%d\n"
"pT=%.3f, pZ=%.3f\nV=(%.3f, %.3f, %.3f)",
idx.Data(), lbl.Data(), fCharge, fPdg,
fP.Perp(), fP.fZ, fV.fX, fV.fY, fV.fZ));
}
////////////////////////////////////////////////////////////////////////////////
/// Copy track parameters from t. Track-propagator is set, too.
/// PathMarks are cleared - you can copy them via SetPathMarks(t).
/// If track 't' is locked, you should probably clone its points
/// over - use TEvePointSet::ClonePoints(t);
void TEveTrack::SetTrackParams(const TEveTrack& t)
{
fV = t.fV;
fP = t.fP;
fBeta = t.fBeta;
fPdg = t.fPdg;
fCharge = t.fCharge;
fLabel = t.fLabel;
fIndex = t.fIndex;
fPathMarks.clear();
SetPropagator(t.fPropagator);
}
////////////////////////////////////////////////////////////////////////////////
/// Copy path-marks from t.
void TEveTrack::SetPathMarks(const TEveTrack& t)
{
std::copy(t.RefPathMarks().begin(), t.RefPathMarks().end(),
std::back_insert_iterator<vPathMark_t>(fPathMarks));
}
////////////////////////////////////////////////////////////////////////////////
/// Set track's render style.
/// Reference counts of old and new propagator are updated.
void TEveTrack::SetPropagator(TEveTrackPropagator* prop)
{
if (fPropagator == prop) return;
if (fPropagator) fPropagator->DecRefCount(this);
fPropagator = prop;
if (fPropagator) fPropagator->IncRefCount(this);
}
////////////////////////////////////////////////////////////////////////////////
/// Set line and marker attributes from TEveTrackList.
void TEveTrack::SetAttLineAttMarker(TEveTrackList* tl)
{
SetRnrLine(tl->GetRnrLine());
SetLineColor(tl->GetLineColor());
SetLineStyle(tl->GetLineStyle());
SetLineWidth(tl->GetLineWidth());
SetRnrPoints(tl->GetRnrPoints());
SetMarkerColor(tl->GetMarkerColor());
SetMarkerStyle(tl->GetMarkerStyle());
SetMarkerSize(tl->GetMarkerSize());
}
////////////////////////////////////////////////////////////////////////////////
/// Calculate track representation based on track data and current
/// settings of the propagator.
/// If recurse is true, descend into children.
void TEveTrack::MakeTrack(Bool_t recurse)
{
if (!fLockPoints)
{
Reset(0);
fLastPMIdx = 0;
TEveTrackPropagator& rTP((fPropagator != 0) ? *fPropagator : TEveTrackPropagator::fgDefault);
const Double_t maxRsq = rTP.GetMaxR() * rTP.GetMaxR();
const Double_t maxZ = rTP.GetMaxZ();
if ( ! TEveTrackPropagator::IsOutsideBounds(fV, maxRsq, maxZ))
{
TEveVectorD currP = fP;
Bool_t decay = kFALSE;
rTP.InitTrack(fV, fCharge);
for (vPathMark_i pm = fPathMarks.begin(); pm != fPathMarks.end(); ++pm, ++fLastPMIdx)
{
Int_t start_point = rTP.GetCurrentPoint();
if (rTP.GetFitReferences() && pm->fType == TEvePathMarkD::kReference)
{
if (TEveTrackPropagator::IsOutsideBounds(pm->fV, maxRsq, maxZ))
break;
if (rTP.GoToVertex(pm->fV, currP))
{
currP.fX = pm->fP.fX; currP.fY = pm->fP.fY; currP.fZ = pm->fP.fZ;
}
else
{
break;
}
}
else if (rTP.GetFitDaughters() && pm->fType == TEvePathMarkD::kDaughter)
{
if (TEveTrackPropagator::IsOutsideBounds(pm->fV, maxRsq, maxZ))
break;
if (rTP.GoToVertex(pm->fV, currP))
{
currP.fX -= pm->fP.fX; currP.fY -= pm->fP.fY; currP.fZ -= pm->fP.fZ;
if (fDpDs != 0)
{
Double_t dp = fDpDs * rTP.GetTrackLength(start_point);
Double_t p = currP.Mag();
if (p > dp) currP *= 1.0 - dp / p;
}
}
else
{
break;
}
}
else if (rTP.GetFitDecay() && pm->fType == TEvePathMarkD::kDecay)
{
if (TEveTrackPropagator::IsOutsideBounds(pm->fV, maxRsq, maxZ))
break;
rTP.GoToVertex(pm->fV, currP);
decay = kTRUE;
++fLastPMIdx;
break;
}
else if (rTP.GetFitCluster2Ds() && pm->fType == TEvePathMarkD::kCluster2D)
{
TEveVectorD itsect;
if (rTP.IntersectPlane(currP, pm->fV, pm->fP, itsect))
{
TEveVectorD delta = itsect - pm->fV;
TEveVectorD vtopass = pm->fV + pm->fE*(pm->fE.Dot(delta));
if (TEveTrackPropagator::IsOutsideBounds(vtopass, maxRsq, maxZ))
break;
if ( ! rTP.GoToVertex(vtopass, currP))
break;
if (fDpDs != 0)
{
Double_t dp = fDpDs * rTP.GetTrackLength(start_point);
Double_t p = currP.Mag();
if (p > dp) currP *= 1.0 - dp / p;
}
}
else
{
Warning("TEveTrack::MakeTrack", "Failed to intersect plane for Cluster2D. Ignoring path-mark.");
}
}
else if (rTP.GetFitLineSegments() && pm->fType == TEvePathMarkD::kLineSegment)
{
if (TEveTrackPropagator::IsOutsideBounds(pm->fV, maxRsq, maxZ))
break;
if (rTP.GoToLineSegment(pm->fV, pm->fE, currP))
{
if (fDpDs != 0)
{
Double_t dp = fDpDs * rTP.GetTrackLength(start_point);
Double_t p = currP.Mag();
if (p > dp) currP *= 1.0 - dp / p;
}
}
else
{
break;
}
}
else
{
if (TEveTrackPropagator::IsOutsideBounds(pm->fV, maxRsq, maxZ))
break;
}
} // loop path-marks
if (!decay)
{
// printf("%s loop to bounds \n",fName.Data() );
rTP.GoToBounds(currP);
}
fPEnd = currP;
// make_polyline:
rTP.FillPointSet(this);
rTP.ResetTrack();
}
}
if (recurse)
{
for (List_i i=fChildren.begin(); i!=fChildren.end(); ++i)
{
TEveTrack* t = dynamic_cast<TEveTrack*>(*i);
if (t) t->MakeTrack(recurse);
}
}
}
////////////////////////////////////////////////////////////////////////////////
/// Copy visualization parameters from element el.
void TEveTrack::CopyVizParams(const TEveElement* el)
{
// No local parameters.
// const TEveTrack* t = dynamic_cast<const TEveTrack*>(el);
// if (t)
// {}
TEveLine::CopyVizParams(el);
}
////////////////////////////////////////////////////////////////////////////////
/// Write visualization parameters.
void TEveTrack::WriteVizParams(std::ostream& out, const TString& var)
{
TEveLine::WriteVizParams(out, var);
// TString t = " " + var + "->";
}
////////////////////////////////////////////////////////////////////////////////
/// Virtual from TEveProjectable, return TEveTrackProjected class.
TClass* TEveTrack::ProjectedClass(const TEveProjection*) const
{
return TEveTrackProjected::Class();
}
namespace
{
struct Cmp_pathmark_t
{
bool operator()(TEvePathMarkD const & a, TEvePathMarkD const & b)
{ return a.fTime < b.fTime; }
};
}
////////////////////////////////////////////////////////////////////////////////
/// Sort registered pat-marks by time.
void TEveTrack::SortPathMarksByTime()
{
std::sort(fPathMarks.begin(), fPathMarks.end(), Cmp_pathmark_t());
}
////////////////////////////////////////////////////////////////////////////////
/// Print registered path-marks.
void TEveTrack::PrintPathMarks()
{
static const TEveException eh("TEveTrack::PrintPathMarks ");
printf("TEveTrack '%s', number of path marks %d, label %d\n",
GetName(), (Int_t)fPathMarks.size(), fLabel);
for (vPathMark_i pm = fPathMarks.begin(); pm != fPathMarks.end(); ++pm)
{
printf(" %-9s p: %8f %8f %8f Vertex: %8e %8e %8e %g Extra:%8f %8f %8f\n",
pm->TypeName(),
pm->fP.fX, pm->fP.fY, pm->fP.fZ,
pm->fV.fX, pm->fV.fY, pm->fV.fZ,
pm->fE.fX, pm->fE.fY, pm->fE.fZ,
pm->fTime);
}
}
//------------------------------------------------------------------------------
////////////////////////////////////////////////////////////////////////////////
/// Emits "SecSelected(TEveTrack*)" signal.
/// Called from TEveTrackGL on secondary-selection.
void TEveTrack::SecSelected(TEveTrack* track)
{
Emit("SecSelected(TEveTrack*)", (Long_t)track);
}
/** \class TEveTrackList
\ingroup TEve
A list of tracks supporting change of common attributes and
selection based on track parameters.
*/
ClassImp(TEveTrackList);
////////////////////////////////////////////////////////////////////////////////
/// Constructor. If track-propagator argument is 0, a new default
/// one is created.
TEveTrackList::TEveTrackList(TEveTrackPropagator* prop) :
TEveElementList(),
TAttMarker(1, 20, 1),
TAttLine(1,1,1),
fPropagator(0),
fRecurse(kTRUE),
fRnrLine(kTRUE),
fRnrPoints(kFALSE),
fMinPt (0), fMaxPt (0), fLimPt (0),
fMinP (0), fMaxP (0), fLimP (0)
{
fChildClass = TEveTrack::Class(); // override member from base TEveElementList
fMainColorPtr = &fLineColor;
if (prop == 0) prop = new TEveTrackPropagator;
SetPropagator(prop);
}
////////////////////////////////////////////////////////////////////////////////
/// Constructor. If track-propagator argument is 0, a new default
/// one is created.
TEveTrackList::TEveTrackList(const char* name, TEveTrackPropagator* prop) :
TEveElementList(name),
TAttMarker(1, 20, 1),
TAttLine(1,1,1),
fPropagator(0),
fRecurse(kTRUE),
fRnrLine(kTRUE),
fRnrPoints(kFALSE),
fMinPt (0), fMaxPt (0), fLimPt (0),
fMinP (0), fMaxP (0), fLimP (0)
{
fChildClass = TEveTrack::Class(); // override member from base TEveElementList
fMainColorPtr = &fLineColor;
if (prop == 0) prop = new TEveTrackPropagator;
SetPropagator(prop);
}
////////////////////////////////////////////////////////////////////////////////
/// Destructor.
TEveTrackList::~TEveTrackList()
{
SetPropagator(0);
}
////////////////////////////////////////////////////////////////////////////////
/// Set default propagator for tracks.
/// This is not enforced onto the tracks themselves but this is the
/// propagator that is shown in the TEveTrackListEditor.
void TEveTrackList::SetPropagator(TEveTrackPropagator* prop)
{
if (fPropagator == prop) return;
if (fPropagator) fPropagator->DecRefCount();
fPropagator = prop;
if (fPropagator) fPropagator->IncRefCount();
}
////////////////////////////////////////////////////////////////////////////////
/// Regenerate the visual representations of tracks.
/// The momentum limits are rescanned during the same traversal.
void TEveTrackList::MakeTracks(Bool_t recurse)
{
fLimPt = fLimP = 0;
for (List_i i=fChildren.begin(); i!=fChildren.end(); ++i)
{
TEveTrack* track = dynamic_cast<TEveTrack*>(*i);
if (track)
{
track->MakeTrack(recurse);
fLimPt = TMath::Max(fLimPt, track->fP.Perp());
fLimP = TMath::Max(fLimP, track->fP.Mag());
}
if (recurse)
FindMomentumLimits(*i, recurse);
}
fLimPt = RoundMomentumLimit(fLimPt);
fLimP = RoundMomentumLimit(fLimP);
SanitizeMinMaxCuts();
}
////////////////////////////////////////////////////////////////////////////////
/// Loop over children and find highest pT and p of contained TEveTracks.
/// These are stored in members fLimPt and fLimP.
void TEveTrackList::FindMomentumLimits(Bool_t recurse)
{
fLimPt = fLimP = 0;
if (HasChildren())
{
for (List_i i=BeginChildren(); i!=EndChildren(); ++i)
{
TEveTrack* track = dynamic_cast<TEveTrack*>(*i);
if (track)
{
fLimPt = TMath::Max(fLimPt, track->fP.Perp());
fLimP = TMath::Max(fLimP, track->fP.Mag());
}
if (recurse)
FindMomentumLimits(*i, recurse);
}
fLimPt = RoundMomentumLimit(fLimPt);
fLimP = RoundMomentumLimit(fLimP);
}
SanitizeMinMaxCuts();
}
////////////////////////////////////////////////////////////////////////////////
/// Loop over track elements of argument el and find highest pT and p.
/// These are stored in members fLimPt and fLimP.
void TEveTrackList::FindMomentumLimits(TEveElement* el, Bool_t recurse)
{
for (List_i i=el->BeginChildren(); i!=el->EndChildren(); ++i)
{
TEveTrack* track = dynamic_cast<TEveTrack*>(*i);
if (track)
{
fLimPt = TMath::Max(fLimPt, track->fP.Perp());
fLimP = TMath::Max(fLimP, track->fP.Mag());
}
if (recurse)
FindMomentumLimits(*i, recurse);
}
}
////////////////////////////////////////////////////////////////////////////////
/// Round the momentum limit up to a nice value.
Double_t TEveTrackList::RoundMomentumLimit(Double_t x)
{
using namespace TMath;
if (x < 1e-3) return 1e-3;
Double_t fac = Power(10, 1 - Floor(Log10(x)));
return Ceil(fac*x) / fac;
}
////////////////////////////////////////////////////////////////////////////////
/// Set Min/Max cuts so that they are within detected limits.
void TEveTrackList::SanitizeMinMaxCuts()
{
using namespace TMath;
fMinPt = Min(fMinPt, fLimPt);
fMaxPt = fMaxPt == 0 ? fLimPt : Min(fMaxPt, fLimPt);
fMinP = Min(fMinP, fLimP);
fMaxP = fMaxP == 0 ? fLimP : Min(fMaxP, fLimP);
}
////////////////////////////////////////////////////////////////////////////////
/// Set rendering of track as line for the list and the elements.
void TEveTrackList::SetRnrLine(Bool_t rnr)
{
for (List_i i=BeginChildren(); i!=EndChildren(); ++i)
{
TEveTrack* track = (TEveTrack*)(*i);
if (track->GetRnrLine() == fRnrLine)
track->SetRnrLine(rnr);
if (fRecurse)
SetRnrLine(rnr, *i);
}
fRnrLine = rnr;
}
////////////////////////////////////////////////////////////////////////////////
/// Set rendering of track as line for children of el.
void TEveTrackList::SetRnrLine(Bool_t rnr, TEveElement* el)
{
TEveTrack* track;
for (List_i i=el->BeginChildren(); i!=el->EndChildren(); ++i)
{
track = dynamic_cast<TEveTrack*>(*i);
if (track && (track->GetRnrLine() == fRnrLine))
track->SetRnrLine(rnr);
if (fRecurse)
SetRnrLine(rnr, *i);
}
}
////////////////////////////////////////////////////////////////////////////////
/// Set rendering of track as points for the list and the elements.
void TEveTrackList::SetRnrPoints(Bool_t rnr)
{
for (List_i i=BeginChildren(); i!=EndChildren(); ++i)
{
TEveTrack* track = (TEveTrack*)(*i);
if (track->GetRnrPoints() == fRnrPoints)
track->SetRnrPoints(rnr);
if (fRecurse)
SetRnrPoints(rnr, *i);
}
fRnrPoints = rnr;
}
////////////////////////////////////////////////////////////////////////////////
/// Set rendering of track as points for children of el.
void TEveTrackList::SetRnrPoints(Bool_t rnr, TEveElement* el)
{
TEveTrack* track;
for (List_i i=el->BeginChildren(); i!=el->EndChildren(); ++i)
{
track = dynamic_cast<TEveTrack*>(*i);
if (track)
if (track->GetRnrPoints() == fRnrPoints)
track->SetRnrPoints(rnr);
if (fRecurse)
SetRnrPoints(rnr, *i);
}
}
////////////////////////////////////////////////////////////////////////////////
/// Set main (line) color for the list and the elements.
void TEveTrackList::SetMainColor(Color_t col)
{
for (List_i i=BeginChildren(); i!=EndChildren(); ++i)
{
TEveTrack* track = (TEveTrack*)(*i);
if (track->GetLineColor() == fLineColor)
track->SetLineColor(col);
if (fRecurse)
SetLineColor(col, *i);
}
TEveElement::SetMainColor(col);
}
////////////////////////////////////////////////////////////////////////////////
/// Set line color for children of el.
void TEveTrackList::SetLineColor(Color_t col, TEveElement* el)
{
TEveTrack* track;
for (List_i i=el->BeginChildren(); i!=el->EndChildren(); ++i)
{
track = dynamic_cast<TEveTrack*>(*i);
if (track && track->GetLineColor() == fLineColor)
track->SetLineColor(col);
if (fRecurse)
SetLineColor(col, *i);
}
}
////////////////////////////////////////////////////////////////////////////////
/// Set line width for the list and the elements.
void TEveTrackList::SetLineWidth(Width_t width)
{
for (List_i i=BeginChildren(); i!=EndChildren(); ++i)
{
TEveTrack* track = (TEveTrack*)(*i);
if (track->GetLineWidth() == fLineWidth)
track->SetLineWidth(width);
if (fRecurse)
SetLineWidth(width, *i);
}
fLineWidth = width;
}
////////////////////////////////////////////////////////////////////////////////
/// Set line width for children of el.
void TEveTrackList::SetLineWidth(Width_t width, TEveElement* el)
{
TEveTrack* track;
for (List_i i=el->BeginChildren(); i!=el->EndChildren(); ++i)
{
track = dynamic_cast<TEveTrack*>(*i);
if (track && track->GetLineWidth() == fLineWidth)
track->SetLineWidth(width);
if (fRecurse)
SetLineWidth(width, *i);
}
}
////////////////////////////////////////////////////////////////////////////////
/// Set line style for the list and the elements.
void TEveTrackList::SetLineStyle(Style_t style)
{
for (List_i i=BeginChildren(); i!=EndChildren(); ++i)
{
TEveTrack* track = (TEveTrack*)(*i);
if (track->GetLineStyle() == fLineStyle)
track->SetLineStyle(style);
if (fRecurse)
SetLineStyle(style, *i);
}
fLineStyle = style;
}
////////////////////////////////////////////////////////////////////////////////
/// Set line style for children of el.
void TEveTrackList::SetLineStyle(Style_t style, TEveElement* el)
{
TEveTrack* track;
for (List_i i=el->BeginChildren(); i!=el->EndChildren(); ++i)
{
track = dynamic_cast<TEveTrack*>(*i);
if (track && track->GetLineStyle() == fLineStyle)
track->SetLineStyle(style);
if (fRecurse)
SetLineStyle(style, *i);
}
}
////////////////////////////////////////////////////////////////////////////////
/// Set marker style for the list and the elements.
void TEveTrackList::SetMarkerStyle(Style_t style)
{
for (List_i i=BeginChildren(); i!=EndChildren(); ++i)
{
TEveTrack* track = (TEveTrack*)(*i);
if (track->GetMarkerStyle() == fMarkerStyle)
track->SetMarkerStyle(style);
if (fRecurse)
SetMarkerStyle(style, *i);
}
fMarkerStyle = style;
}
////////////////////////////////////////////////////////////////////////////////
/// Set marker style for children of el.
void TEveTrackList::SetMarkerStyle(Style_t style, TEveElement* el)
{
TEveTrack* track;
for (List_i i=el->BeginChildren(); i!=el->EndChildren(); ++i)
{
track = dynamic_cast<TEveTrack*>(*i);
if (track && track->GetMarkerStyle() == fMarkerStyle)
track->SetMarkerStyle(style);
if (fRecurse)
SetMarkerStyle(style, *i);
}
}
////////////////////////////////////////////////////////////////////////////////
/// Set marker color for the list and the elements.
void TEveTrackList::SetMarkerColor(Color_t col)
{
for (List_i i=BeginChildren(); i!=EndChildren(); ++i)
{
TEveTrack* track = (TEveTrack*)(*i);
if (track->GetMarkerColor() == fMarkerColor)
track->SetMarkerColor(col);
if (fRecurse)
SetMarkerColor(col, *i);
}
fMarkerColor = col;
}
////////////////////////////////////////////////////////////////////////////////
/// Set marker color for children of el.
void TEveTrackList::SetMarkerColor(Color_t col, TEveElement* el)
{
TEveTrack* track;
for (List_i i=el->BeginChildren(); i!=el->EndChildren(); ++i)
{
track = dynamic_cast<TEveTrack*>(*i);
if (track && track->GetMarkerColor() == fMarkerColor)
track->SetMarkerColor(col);
if (fRecurse)
SetMarkerColor(col, *i);
}
}
////////////////////////////////////////////////////////////////////////////////
/// Set marker size for the list and the elements.
void TEveTrackList::SetMarkerSize(Size_t size)
{
for (List_i i=BeginChildren(); i!=EndChildren(); ++i)
{
TEveTrack* track = (TEveTrack*)(*i);
if (track->GetMarkerSize() == fMarkerSize)
track->SetMarkerSize(size);
if (fRecurse)
SetMarkerSize(size, *i);
}
fMarkerSize = size;
}
////////////////////////////////////////////////////////////////////////////////
/// Set marker size for children of el.
void TEveTrackList::SetMarkerSize(Size_t size, TEveElement* el)
{
TEveTrack* track;
for (List_i i=el->BeginChildren(); i!=el->EndChildren(); ++i)
{
track = dynamic_cast<TEveTrack*>(*i);
if (track && track->GetMarkerSize() == fMarkerSize)
track->SetMarkerSize(size);
if (fRecurse)
SetMarkerSize(size, *i);
}
}
////////////////////////////////////////////////////////////////////////////////
/// Select visibility of tracks by transverse momentum.
/// If data-member fRecurse is set, the selection is applied
/// recursively to all children.
void TEveTrackList::SelectByPt(Double_t min_pt, Double_t max_pt)
{
fMinPt = min_pt;
fMaxPt = max_pt;