Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
REveTrack.cxx
Go to the documentation of this file.
1// @(#)root/eve7:$Id$
2// Authors: Matevz Tadel & Alja Mrak-Tadel: 2006, 2007
3
4/*************************************************************************
5 * Copyright (C) 1995-2019, Rene Brun and Fons Rademakers. *
6 * All rights reserved. *
7 * *
8 * For the licensing terms see $ROOTSYS/LICENSE. *
9 * For the list of contributors see $ROOTSYS/README/CREDITS. *
10 *************************************************************************/
11
12#include <ROOT/REveTrack.hxx>
14#include <ROOT/REvePointSet.hxx>
15#include <ROOT/REveManager.hxx>
17
18#include "TParticle.h"
19#include "TParticlePDG.h"
20#include "TClass.h"
21
22#include <iostream>
23#include <vector>
24#include <algorithm>
25#include <functional>
26
27
28using namespace ROOT::Experimental;
29
30/** \class REveTrack
31\ingroup REve
32Visual representation of a track.
33
34If member fDpDs is set, the momentum is reduced on all path-marks that do
35not fix the momentum according to the distance travelled from the previous
36pathmark.
37*/
38
39////////////////////////////////////////////////////////////////////////////////
40/// Default constructor.
41
42REveTrack::REveTrack() :
43 REveLine(),
44
45 fV(),
46 fP(),
47 fPEnd(),
48 fBeta(0),
49 fDpDs(0),
50 fPdg(0),
51 fCharge(0),
52 fLabel(kMinInt),
53 fIndex(kMinInt),
54 fStatus(0),
55 fLockPoints(kFALSE),
56 fPathMarks(),
57 fLastPMIdx(0),
58 fPropagator(nullptr)
59{
60}
61
62////////////////////////////////////////////////////////////////////////////////
63/// Constructor from TParticle.
64
66 REveLine(),
67
68 fV(t->Vx(), t->Vy(), t->Vz()),
69 fP(t->Px(), t->Py(), t->Pz()),
70 fPEnd(),
71 fBeta(t->P()/t->Energy()),
72 fDpDs(0),
73 fPdg(0),
74 fCharge(0),
75 fLabel(label),
76 fIndex(kMinInt),
77 fStatus(t->GetStatusCode()),
78 fLockPoints(kFALSE),
79 fPathMarks(),
80 fLastPMIdx(0),
81 fPropagator(nullptr)
82{
85
86 TParticlePDG *pdgp = t->GetPDG();
87 if (pdgp) {
88 fPdg = pdgp->PdgCode();
89 fCharge = (Int_t) TMath::Nint(pdgp->Charge()/3);
90 }
91
92 SetName(t->GetName());
93}
94
95////////////////////////////////////////////////////////////////////////////////
96
98 REveLine(),
99
100 fV(t->Vx(), t->Vy(), t->Vz()),
101 fP(t->Px(), t->Py(), t->Pz()),
102 fPEnd(),
103 fBeta(t->P()/t->Energy()),
104 fDpDs(0),
105 fPdg(0),
106 fCharge(0),
107 fLabel(t->fLabel),
108 fIndex(t->fIndex),
109 fStatus(t->GetStatusCode()),
110 fLockPoints(kFALSE),
111 fPathMarks(),
112 fLastPMIdx(0),
113 fPropagator(nullptr)
114{
115 // Constructor from REveUtil Monte Carlo track.
116
119
120 TParticlePDG* pdgp = t->GetPDG();
121 if (pdgp) {
122 fCharge = (Int_t) TMath::Nint(pdgp->Charge()/3);
123 }
124
125 SetName(t->GetName());
126}
127
128////////////////////////////////////////////////////////////////////////////////
129/// Constructor from REveRecTrack<double> reconstructed track.
130
132 REveLine(),
133
134 fV(t->fV),
135 fP(t->fP),
136 fPEnd(),
137 fBeta(t->fBeta),
138 fDpDs(0),
139 fPdg(0),
140 fCharge(t->fSign),
141 fLabel(t->fLabel),
142 fIndex(t->fIndex),
143 fStatus(t->fStatus),
144 fLockPoints(kFALSE),
145 fPathMarks(),
146 fLastPMIdx(0),
147 fPropagator(nullptr)
148{
151}
152
153////////////////////////////////////////////////////////////////////////////////
154/// Constructor from REveRecTrack<float> reconstructed track.
155/// It is recommended to use constructor with REveRecTrack<double> since
156/// REveTrackPropagator operates with double type.
157
159 REveLine(),
160
161 fV(t->fV),
162 fP(t->fP),
163 fPEnd(),
164 fBeta(t->fBeta),
165 fDpDs(0),
166 fPdg(0),
167 fCharge(t->fSign),
168 fLabel(t->fLabel),
169 fIndex(t->fIndex),
170 fStatus(t->fStatus),
171 fLockPoints(kFALSE),
172 fPathMarks(),
173 fLastPMIdx(0),
174 fPropagator(nullptr)
175{
178}
179
180////////////////////////////////////////////////////////////////////////////////
181/// Copy constructor. Track parameters are copied but the
182/// extrapolation is not performed so you should still call
183/// MakeTrack() to do that.
184/// If points of 't' are locked, they are cloned.
185
187 REveLine(t),
188 fV(t.fV),
189 fP(t.fP),
190 fPEnd(),
191 fBeta(t.fBeta),
192 fDpDs(t.fDpDs),
193 fPdg(t.fPdg),
194 fCharge(t.fCharge),
195 fLabel(t.fLabel),
196 fIndex(t.fIndex),
197 fStatus(t.fStatus),
198 fLockPoints(t.fLockPoints),
199 fPathMarks(),
200 fLastPMIdx(t.fLastPMIdx),
201 fPropagator(nullptr)
202{
203 if (fLockPoints)
204 ClonePoints(t);
205
206 SetPathMarks(t);
208
209 CopyVizParams(&t);
210}
211
212////////////////////////////////////////////////////////////////////////////////
213/// Destructor.
214
216{
217 SetPropagator(nullptr);
218}
219
220////////////////////////////////////////////////////////////////////////////////
221/// Compute the bounding box of the track.
222
224{
225 if (fSize > 0 || ! fPathMarks.empty())
226 {
227 BBoxInit();
228 Int_t n = fSize;
229 Float_t *p = & fPoints[0].fX;
230 for (Int_t i = 0; i < n; ++i, p += 3)
231 {
233 }
234 for (const auto &pm: fPathMarks)
235 {
236 BBoxCheckPoint(pm.fV.fX, pm.fV.fY, pm.fV.fZ);
237 }
238 }
239 else
240 {
241 BBoxZero();
242 }
243}
244
245////////////////////////////////////////////////////////////////////////////////
246/// Set standard track title based on most data-member values.
247
249{
250 TString idx(fIndex == kMinInt ? "<undef>" : Form("%d", fIndex));
251 TString lbl(fLabel == kMinInt ? "<undef>" : Form("%d", fLabel));
252 SetTitle(Form("Index=%s, Label=%s\nChg=%d, Pdg=%d\n"
253 "pT=%.3f, pZ=%.3f\nV=(%.3f, %.3f, %.3f)",
254 idx.Data(), lbl.Data(), fCharge, fPdg,
255 fP.Perp(), fP.fZ, fV.fX, fV.fY, fV.fZ));
256}
257
258////////////////////////////////////////////////////////////////////////////////
259/// Copy track parameters from t. Track-propagator is set, too.
260/// PathMarks are cleared - you can copy them via SetPathMarks(t).
261/// If track 't' is locked, you should probably clone its points
262/// over - use REvePointSet::ClonePoints(t);
263
265{
266 fV = t.fV;
267 fP = t.fP;
268 fBeta = t.fBeta;
269 fPdg = t.fPdg;
270 fCharge = t.fCharge;
271 fLabel = t.fLabel;
272 fIndex = t.fIndex;
273
274 fPathMarks.clear();
276}
277
278////////////////////////////////////////////////////////////////////////////////
279/// Copy path-marks from t.
280
282{
283 std::copy(t.RefPathMarks().begin(), t.RefPathMarks().end(),
284 std::back_insert_iterator<vPathMark_t>(fPathMarks));
285}
286
287////////////////////////////////////////////////////////////////////////////////
288/// Set track's propagator.
289/// Reference counts of old and new propagator are updated.
290
292{
293 if (fPropagator == prop) return;
297}
298
299////////////////////////////////////////////////////////////////////////////////
300/// Set line and marker attributes from REveTrackList.
301
303{
304 SetRnrLine(tl->GetRnrLine());
308
313}
314
315////////////////////////////////////////////////////////////////////////////////
316/// Calculate track representation based on track data and current
317/// settings of the propagator.
318/// If recurse is true, descend into children.
319
321{
322 if (!fLockPoints)
323 {
324 Reset(0);
325 fLastPMIdx = 0;
326
328
329 const Double_t maxRsq = rTP.GetMaxR() * rTP.GetMaxR();
330 const Double_t maxZ = rTP.GetMaxZ();
331
332 if ( ! REveTrackPropagator::IsOutsideBounds(fV, maxRsq, maxZ))
333 {
334 REveVectorD currP = fP;
335 Bool_t decay = kFALSE;
336 rTP.InitTrack(fV, fCharge);
337 for (auto pm = fPathMarks.begin(); pm != fPathMarks.end(); ++pm, ++fLastPMIdx)
338 {
339 Int_t start_point = rTP.GetCurrentPoint();
340
341 if (rTP.GetFitReferences() && pm->fType == REvePathMarkD::kReference)
342 {
343 if (REveTrackPropagator::IsOutsideBounds(pm->fV, maxRsq, maxZ))
344 break;
345 if (rTP.GoToVertex(pm->fV, currP))
346 {
347 currP.fX = pm->fP.fX; currP.fY = pm->fP.fY; currP.fZ = pm->fP.fZ;
348 }
349 else
350 {
351 break;
352 }
353 }
354 else if (rTP.GetFitDaughters() && pm->fType == REvePathMarkD::kDaughter)
355 {
356 if (REveTrackPropagator::IsOutsideBounds(pm->fV, maxRsq, maxZ))
357 break;
358 if (rTP.GoToVertex(pm->fV, currP))
359 {
360 currP.fX -= pm->fP.fX; currP.fY -= pm->fP.fY; currP.fZ -= pm->fP.fZ;
361 if (fDpDs != 0)
362 {
363 Double_t dp = fDpDs * rTP.GetTrackLength(start_point);
364 Double_t p = currP.Mag();
365 if (p > dp) currP *= 1.0 - dp / p;
366 }
367 }
368 else
369 {
370 break;
371 }
372 }
373 else if (rTP.GetFitDecay() && pm->fType == REvePathMarkD::kDecay)
374 {
375 if (REveTrackPropagator::IsOutsideBounds(pm->fV, maxRsq, maxZ))
376 break;
377 rTP.GoToVertex(pm->fV, currP);
378 decay = kTRUE;
379 ++fLastPMIdx;
380 break;
381 }
382 else if (rTP.GetFitCluster2Ds() && pm->fType == REvePathMarkD::kCluster2D)
383 {
384 REveVectorD itsect;
385 if (rTP.IntersectPlane(currP, pm->fV, pm->fP, itsect))
386 {
387 REveVectorD delta = itsect - pm->fV;
388 REveVectorD vtopass = pm->fV + pm->fE*(pm->fE.Dot(delta));
389 if (REveTrackPropagator::IsOutsideBounds(vtopass, maxRsq, maxZ))
390 break;
391 if ( ! rTP.GoToVertex(vtopass, currP))
392 break;
393
394 if (fDpDs != 0)
395 {
396 Double_t dp = fDpDs * rTP.GetTrackLength(start_point);
397 Double_t p = currP.Mag();
398 if (p > dp) currP *= 1.0 - dp / p;
399 }
400 }
401 else
402 {
403 Warning("REveTrack::MakeTrack", "Failed to intersect plane for Cluster2D. Ignoring path-mark.");
404 }
405 }
406 else if (rTP.GetFitLineSegments() && pm->fType == REvePathMarkD::kLineSegment)
407 {
408 if (REveTrackPropagator::IsOutsideBounds(pm->fV, maxRsq, maxZ))
409 break;
410
411 if (rTP.GoToLineSegment(pm->fV, pm->fE, currP))
412 {
413 if (fDpDs != 0)
414 {
415 Double_t dp = fDpDs * rTP.GetTrackLength(start_point);
416 Double_t p = currP.Mag();
417 if (p > dp) currP *= 1.0 - dp / p;
418 }
419 }
420 else
421 {
422 break;
423 }
424 }
425 else
426 {
427 if (REveTrackPropagator::IsOutsideBounds(pm->fV, maxRsq, maxZ))
428 break;
429 }
430 } // loop path-marks
431
432 if (!decay)
433 {
434 // printf("%s loop to bounds \n",fName.Data() );
435 rTP.GoToBounds(currP);
436 }
437 fPEnd = currP;
438 // make_polyline:
439 rTP.FillPointSet(this);
440 rTP.ResetTrack();
441 }
442 }
443
444 if (recurse)
445 {
446 for (auto &c: fChildren) {
447 REveTrack* t = dynamic_cast<REveTrack *>(c);
448 if (t) t->MakeTrack(recurse);
449 }
450 }
451}
452
453////////////////////////////////////////////////////////////////////////////////
454/// Copy visualization parameters from element el.
455
457{
458 // No local parameters.
459
460 // const REveTrack* t = dynamic_cast<const REveTrack*>(el);
461 // if (t)
462 // {}
463
465}
466
467////////////////////////////////////////////////////////////////////////////////
468/// Write visualization parameters.
469
470void REveTrack::WriteVizParams(std::ostream& out, const TString& var)
471{
472 REveLine::WriteVizParams(out, var);
473
474 // TString t = " " + var + "->";
475}
476
477////////////////////////////////////////////////////////////////////////////////
478/// Virtual from REveProjectable, return REveTrackProjected class.
479
481{
482 return TClass::GetClass<REveTrackProjected>();
483}
484
485namespace
486{
487 struct Cmp_pathmark_t
488 {
489 bool operator()(REvePathMarkD const & a, REvePathMarkD const & b)
490 { return a.fTime < b.fTime; }
491 };
492}
493
494////////////////////////////////////////////////////////////////////////////////
495/// Sort registered pat-marks by time.
496
498{
499 std::sort(fPathMarks.begin(), fPathMarks.end(), Cmp_pathmark_t());
500}
501
502////////////////////////////////////////////////////////////////////////////////
503/// Print registered path-marks.
504
506{
507 static const REveException eh("REveTrack::PrintPathMarks ");
508
509 printf("REveTrack '%s', number of path marks %d, label %d\n",
510 GetCName(), (Int_t)fPathMarks.size(), fLabel);
511
512 for (auto &pm: fPathMarks)
513 {
514 printf(" %-9s p: %8f %8f %8f Vertex: %8e %8e %8e %g Extra:%8f %8f %8f\n",
515 pm.TypeName(),
516 pm.fP.fX, pm.fP.fY, pm.fP.fZ,
517 pm.fV.fX, pm.fV.fY, pm.fV.fZ,
518 pm.fE.fX, pm.fE.fY, pm.fE.fZ,
519 pm.fTime);
520 }
521}
522
523////////////////////////////////////////////////////////////////////////////////
524/// Fill core part of JSON representation.
525
526Int_t REveTrack::WriteCoreJson(nlohmann::json &j, Int_t rnr_offset)
527{
528 // TODO: missing streaming of fitting points
529 return REveLine::WriteCoreJson(j, rnr_offset);
530}
531
532////////////////////////////////////////////////////////////////////////////////
533/// Crates 3D point array for rendering.
534
536{
537 // TODO: missing streaming o fitting points
539}
540
541////////////////////////////////////////////////////////////////////////////////
542/// Emits "SecSelected(REveTrack*)" signal.
543
545{
546 // Emit("SecSelected(REveTrack*)", (Long_t)track);
547}
548
549
550//==============================================================================
551//==============================================================================
552
553/** \class REveTrackList
554\ingroup REve
555A list of tracks supporting change of common attributes and
556selection based on track parameters.
557*/
558
559////////////////////////////////////////////////////////////////////////////////
560/// Constructor. If track-propagator argument is 0, a new default
561/// one is created.
562
564 REveElement(),
565 TAttMarker(1, 20, 1),
566 TAttLine(1,1,1),
567
568 fPropagator(nullptr),
569 fRecurse(kTRUE),
570 fRnrLine(kTRUE),
571 fRnrPoints(kFALSE),
572
573 fMinPt (0), fMaxPt (0), fLimPt (0),
574 fMinP (0), fMaxP (0), fLimP (0)
575{
576
577 fChildClass = TClass::GetClass<REveTrack>(); // override member from base REveElementList
578
580
581 if (!prop) prop = new REveTrackPropagator;
583}
584
585////////////////////////////////////////////////////////////////////////////////
586/// Constructor. If track-propagator argument is 0, a new default
587/// one is created.
588
591 TAttMarker(1, 20, 1),
592 TAttLine(1,1,1),
593
594 fPropagator(nullptr),
595 fRecurse(kTRUE),
596 fRnrLine(kTRUE),
597 fRnrPoints(kFALSE),
598
599 fMinPt (0), fMaxPt (0), fLimPt (0),
600 fMinP (0), fMaxP (0), fLimP (0)
601{
602 fChildClass = TClass::GetClass<REveTrack>(); // override member from base REveElementList
603
605
606 if (!prop) prop = new REveTrackPropagator;
608}
609
610////////////////////////////////////////////////////////////////////////////////
611/// Destructor.
612
614{
615 SetPropagator(nullptr);
616}
617
618////////////////////////////////////////////////////////////////////////////////
619/// Set default propagator for tracks.
620/// This is not enforced onto the tracks themselves but this is the
621/// propagator that is shown in the GUI.
622
624{
625 if (fPropagator == prop) return;
629}
630
631////////////////////////////////////////////////////////////////////////////////
632/// Regenerate the visual representations of tracks.
633/// The momentum limits are rescanned during the same traversal.
634
636{
637 fLimPt = fLimP = 0;
638
639 for (auto &c: fChildren) {
640 REveTrack* track = dynamic_cast<REveTrack*>(c);
641 if (track) {
642 track->MakeTrack(recurse);
643
644 fLimPt = TMath::Max(fLimPt, track->fP.Perp());
645 fLimP = TMath::Max(fLimP, track->fP.Mag());
646 }
647 if (recurse)
648 FindMomentumLimits(c, recurse);
649 }
650
653
655}
656
657////////////////////////////////////////////////////////////////////////////////
658/// Loop over children and find highest pT and p of contained EveTracks.
659/// These are stored in members fLimPt and fLimP.
660
662{
663 fLimPt = fLimP = 0;
664
665 if (HasChildren())
666 {
667 for (auto &c: RefChildren())
668 {
669 REveTrack* track = dynamic_cast<REveTrack *>(c);
670 if (track)
671 {
672 fLimPt = TMath::Max(fLimPt, track->fP.Perp());
673 fLimP = TMath::Max(fLimP, track->fP.Mag());
674 }
675 if (recurse)
676 FindMomentumLimits(c, recurse);
677 }
678
681 }
682
684}
685
686////////////////////////////////////////////////////////////////////////////////
687/// Loop over track elements of argument el and find highest pT and p.
688/// These are stored in members fLimPt and fLimP.
689
691{
692 for (auto &c: el->RefChildren()) {
693 auto track = dynamic_cast<REveTrack *>(c);
694 if (track) {
695 fLimPt = TMath::Max(fLimPt, track->fP.Perp());
696 fLimP = TMath::Max(fLimP, track->fP.Mag());
697 }
698 if (recurse)
699 FindMomentumLimits(c, recurse);
700 }
701}
702
703////////////////////////////////////////////////////////////////////////////////
704/// Round the momentum limit up to a nice value.
705
707{
708 using namespace TMath;
709
710 if (x < 1e-3) return 1e-3;
711
712 Double_t fac = Power(10, 1 - Floor(Log10(x)));
713 return Ceil(fac*x) / fac;
714}
715
716////////////////////////////////////////////////////////////////////////////////
717/// Set Min/Max cuts so that they are within detected limits.
718
720{
724 fMaxP = (fMaxP == 0) ? fLimP : TMath::Min(fMaxP, fLimP);
725}
726
727////////////////////////////////////////////////////////////////////////////////
728/// Set rendering of track as line for the list and the elements.
729
731{
732 for (auto &c: RefChildren()) {
733 auto track = (REveTrack *)(c);
734 if (track->GetRnrLine() == fRnrLine)
735 track->SetRnrLine(rnr);
736 if (fRecurse)
737 SetRnrLine(rnr, c);
738 }
739 fRnrLine = rnr;
740}
741
742////////////////////////////////////////////////////////////////////////////////
743/// Set rendering of track as line for children of el.
744
746{
747 for (auto &c: el->RefChildren()) {
748 auto track = dynamic_cast<REveTrack *>(c);
749 if (track && (track->GetRnrLine() == fRnrLine))
750 track->SetRnrLine(rnr);
751 if (fRecurse)
752 SetRnrLine(rnr, c);
753 }
754}
755
756////////////////////////////////////////////////////////////////////////////////
757/// Set rendering of track as points for the list and the elements.
758
760{
761 for (auto &c: RefChildren()) {
762 auto track = (REveTrack *)(c);
763 if (track->GetRnrPoints() == fRnrPoints)
764 track->SetRnrPoints(rnr);
765 if (fRecurse)
766 SetRnrPoints(rnr, c);
767 }
768 fRnrPoints = rnr;
769}
770
771////////////////////////////////////////////////////////////////////////////////
772/// Set rendering of track as points for children of el.
773
775{
776 for (auto &c: el->RefChildren()) {
777 auto track = dynamic_cast<REveTrack *>(c);
778 if (track)
779 if (track->GetRnrPoints() == fRnrPoints)
780 track->SetRnrPoints(rnr);
781 if (fRecurse)
782 SetRnrPoints(rnr, c);
783 }
784}
785
786////////////////////////////////////////////////////////////////////////////////
787/// Set main (line) color for the list and the elements.
788
790{
791 for (auto &c: RefChildren()) {
792 auto track = (REveTrack *)(c);
793 if (track->GetLineColor() == fLineColor)
794 track->SetLineColor(col);
795 if (fRecurse)
796 SetLineColor(col, c);
797 }
799}
800
801////////////////////////////////////////////////////////////////////////////////
802/// Set line color for children of el.
803
805{
806 for (auto &c: el->RefChildren()) {
807 auto track = dynamic_cast<REveTrack *>(c);
808 if (track && track->GetLineColor() == fLineColor)
809 track->SetLineColor(col);
810 if (fRecurse)
811 SetLineColor(col, c);
812 }
813}
814
815////////////////////////////////////////////////////////////////////////////////
816/// Set line width for the list and the elements.
817
819{
820 for (auto &c: RefChildren()) {
821 auto track = (REveTrack *)(c);
822 if (track->GetLineWidth() == fLineWidth)
823 track->SetLineWidth(width);
824 if (fRecurse)
826 }
828}
829
830////////////////////////////////////////////////////////////////////////////////
831/// Set line width for children of el.
832
834{
835 for (auto &c: el->RefChildren()) {
836 auto track = dynamic_cast<REveTrack *>(c);
837 if (track && track->GetLineWidth() == fLineWidth)
838 track->SetLineWidth(width);
839 if (fRecurse)
841 }
842}
843
844////////////////////////////////////////////////////////////////////////////////
845/// Set line style for the list and the elements.
846
848{
849 for (auto &c: RefChildren()) {
850 auto track = (REveTrack *)(c);
851 if (track->GetLineStyle() == fLineStyle)
852 track->SetLineStyle(style);
853 if (fRecurse)
855 }
857}
858
859////////////////////////////////////////////////////////////////////////////////
860/// Set line style for children of el.
861
863{
864 for (auto &c: el->RefChildren()) {
865 auto track = dynamic_cast<REveTrack *>(c);
866 if (track && track->GetLineStyle() == fLineStyle)
867 track->SetLineStyle(style);
868 if (fRecurse)
870 }
871}
872
873////////////////////////////////////////////////////////////////////////////////
874/// Set marker style for the list and the elements.
875
877{
878 for (auto &c: RefChildren()) {
879 auto track = (REveTrack *)(c);
880 if (track->GetMarkerStyle() == fMarkerStyle)
881 track->SetMarkerStyle(style);
882 if (fRecurse)
884 }
886}
887
888////////////////////////////////////////////////////////////////////////////////
889/// Set marker style for children of el.
890
892{
893 for (auto &c: el->RefChildren()) {
894 auto track = dynamic_cast<REveTrack *>(c);
895 if (track && track->GetMarkerStyle() == fMarkerStyle)
896 track->SetMarkerStyle(style);
897 if (fRecurse)
899 }
900}
901
902////////////////////////////////////////////////////////////////////////////////
903/// Set marker color for the list and the elements.
904
906{
907 for (auto &c: RefChildren()) {
908 auto track = (REveTrack *)(c);
909 if (track->GetMarkerColor() == fMarkerColor)
910 track->SetMarkerColor(col);
911 if (fRecurse)
912 SetMarkerColor(col, c);
913 }
914 fMarkerColor = col;
915}
916
917////////////////////////////////////////////////////////////////////////////////
918/// Set marker color for children of el.
919
921{
922 for (auto &c: el->RefChildren()) {
923 auto track = dynamic_cast<REveTrack *>(c);
924 if (track && track->GetMarkerColor() == fMarkerColor)
925 track->SetMarkerColor(col);
926 if (fRecurse)
927 SetMarkerColor(col, c);
928 }
929}
930
931////////////////////////////////////////////////////////////////////////////////
932/// Set marker size for the list and the elements.
933
935{
936 for (auto &c: RefChildren()) {
937 auto track = (REveTrack *)(c);
938 if (track->GetMarkerSize() == fMarkerSize)
939 track->SetMarkerSize(size);
940 if (fRecurse)
942 }
944}
945
946////////////////////////////////////////////////////////////////////////////////
947/// Set marker size for children of el.
948
950{
951 for (auto &c: el->RefChildren()) {
952 auto track = dynamic_cast<REveTrack*>(c);
953 if (track && track->GetMarkerSize() == fMarkerSize)
954 track->SetMarkerSize(size);
955 if (fRecurse)
957 }
958}
959
960////////////////////////////////////////////////////////////////////////////////
961/// Select visibility of tracks by transverse momentum.
962/// If data-member fRecurse is set, the selection is applied
963/// recursively to all children.
964
966{
967 fMinPt = min_pt;
968 fMaxPt = max_pt;
969
970 const Double_t minptsq = min_pt*min_pt;
971 const Double_t maxptsq = max_pt*max_pt;
972
973 for (auto &c: RefChildren()) {
974 const Double_t ptsq = ((REveTrack*)c)->fP.Perp2();
975 Bool_t on = ptsq >= minptsq && ptsq <= maxptsq;
976 c->SetRnrState(on);
977 if (on && fRecurse)
978 SelectByPt(min_pt, max_pt, c);
979 }
980}
981
982////////////////////////////////////////////////////////////////////////////////
983/// Select visibility of el's children tracks by transverse momentum.
984
986{
987 const Double_t minptsq = min_pt*min_pt;
988 const Double_t maxptsq = max_pt*max_pt;
989
990 for (auto &c: el->RefChildren()) {
991 auto track = (REveTrack *)(c);
992 if (track) {
993 const Double_t ptsq = track->fP.Perp2();
994 Bool_t on = ptsq >= minptsq && ptsq <= maxptsq;
995 track->SetRnrState(on);
996 if (on && fRecurse)
997 SelectByPt(min_pt, max_pt, c);
998 }
999 }
1000}
1001
1002////////////////////////////////////////////////////////////////////////////////
1003/// Select visibility of tracks by momentum.
1004/// If data-member fRecurse is set, the selection is applied
1005/// recursively to all children.
1006
1008{
1009 fMinP = min_p;
1010 fMaxP = max_p;
1011
1012 const Double_t minpsq = min_p*min_p;
1013 const Double_t maxpsq = max_p*max_p;
1014
1015 for (auto &c: RefChildren()) {
1016 const Double_t psq = ((REveTrack*)c)->fP.Mag2();
1017 Bool_t on = psq >= minpsq && psq <= maxpsq;
1018 c->SetRnrState(psq >= minpsq && psq <= maxpsq);
1019 if (on && fRecurse)
1020 SelectByP(min_p, max_p, c);
1021 }
1022}
1023
1024////////////////////////////////////////////////////////////////////////////////
1025/// Select visibility of el's children tracks by momentum.
1026
1028{
1029 const Double_t minpsq = min_p*min_p;
1030 const Double_t maxpsq = max_p*max_p;
1031
1032 for (auto &c: el->RefChildren()) {
1033 auto track = (REveTrack *)(c);
1034 if (track) {
1035 const Double_t psq = ((REveTrack*)c)->fP.Mag2();
1036 Bool_t on = psq >= minpsq && psq <= maxpsq;
1037 track->SetRnrState(on);
1038 if (on && fRecurse)
1039 SelectByP(min_p, max_p, c);
1040 }
1041 }
1042}
1043
1044////////////////////////////////////////////////////////////////////////////////
1045/// Find track by label, select it and display it in the editor.
1046
1048{
1049 for (auto &c: fChildren) {
1050 if (((REveTrack*)c)->GetLabel() == label)
1051 {
1052 // TGListTree *lt = REX::gEve->GetLTEFrame()->GetListTree();
1053 // TGListTreeItem *mlti = lt->GetSelected();
1054 // if (mlti->GetUserData() != this)
1055 // mlti = FindListTreeItem(lt);
1056 // TGListTreeItem *tlti = (*i)->FindListTreeItem(lt, mlti);
1057 // lt->HighlightItem(tlti);
1058 // lt->SetSelected(tlti);
1059 // REX::gEve->EditElement(*i);
1060 return (REveTrack*) c;
1061 }
1062 }
1063 return nullptr;
1064}
1065
1066////////////////////////////////////////////////////////////////////////////////
1067/// Find track by index, select it and display it in the editor.
1068
1070{
1071 for (auto &c: fChildren) {
1072 if (((REveTrack *)c)->GetIndex() == index) {
1073 // TGListTree *lt = REX::gEve->GetLTEFrame()->GetListTree();
1074 // TGListTreeItem *mlti = lt->GetSelected();
1075 // if (mlti->GetUserData() != this)
1076 // mlti = FindListTreeItem(lt);
1077 // TGListTreeItem *tlti = (*i)->FindListTreeItem(lt, mlti);
1078 // lt->HighlightItem(tlti);
1079 // lt->SetSelected(tlti);
1080 // REX::gEve->EditElement(*i);
1081 return (REveTrack *) c;
1082 }
1083 }
1084 return nullptr;
1085}
1086
1087////////////////////////////////////////////////////////////////////////////////
1088/// Copy visualization parameters from element el.
1089
1091{
1092 const REveTrackList* m = dynamic_cast<const REveTrackList*>(el);
1093 if (m)
1094 {
1095 TAttMarker::operator=(*m);
1096 TAttLine::operator=(*m);
1097 fRecurse = m->fRecurse;
1098 fRnrLine = m->fRnrLine;
1099 fRnrPoints = m->fRnrPoints;
1100 fMinPt = m->fMinPt;
1101 fMaxPt = m->fMaxPt;
1102 fLimPt = m->fLimPt;
1103 fMinP = m->fMinP;
1104 fMaxP = m->fMaxP;
1105 fLimP = m->fLimP;
1106 }
1107
1109}
1110
1111////////////////////////////////////////////////////////////////////////////////
1112/// Write visualization parameters.
1113
1114void REveTrackList::WriteVizParams(std::ostream& out, const TString& var)
1115{
1117
1118 TString t = " " + var + "->";
1120 TAttLine ::SaveLineAttributes (out, var);
1121 out << t << "SetRecurse(" << ToString(fRecurse) << ");\n";
1122 out << t << "SetRnrLine(" << ToString(fRnrLine) << ");\n";
1123 out << t << "SetRnrPoints(" << ToString(fRnrPoints) << ");\n";
1124 // These setters are not available -- need proper AND/OR mode.
1125 // out << t << "SetMinPt(" << fMinPt << ");\n";
1126 // out << t << "SetMaxPt(" << fMaxPt << ");\n";
1127 // out << t << "SetLimPt(" << fLimPt << ");\n";
1128 // out << t << "SetMinP(" << fMinP << ");\n";
1129 // out << t << "SetMaxP(" << fMaxP << ");\n";
1130 // out << t << "SetLimP(" << fLimP << ");\n";
1131}
1132
1133////////////////////////////////////////////////////////////////////////////////
1134/// Virtual from REveProjectable, returns REveTrackListProjected class.
1135
1137{
1138 return TClass::GetClass<REveTrackListProjected>();
1139}
#define b(i)
Definition RSha256.hxx:100
#define c(i)
Definition RSha256.hxx:101
#define a(i)
Definition RSha256.hxx:99
#define e(i)
Definition RSha256.hxx:103
size_t size(const MatrixT &matrix)
retrieve the size of a square matrix
short Style_t
Definition RtypesCore.h:82
int Int_t
Definition RtypesCore.h:45
short Color_t
Definition RtypesCore.h:85
float Size_t
Definition RtypesCore.h:89
constexpr Int_t kMinInt
Definition RtypesCore.h:106
short Width_t
Definition RtypesCore.h:84
constexpr Bool_t kFALSE
Definition RtypesCore.h:94
constexpr Bool_t kTRUE
Definition RtypesCore.h:93
void Warning(const char *location, const char *msgfmt,...)
Use this function in warning situations.
Definition TError.cxx:229
winID h TVirtualViewer3D TVirtualGLPainter p
Option_t Option_t SetLineWidth
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t TString Int_t GCValues_t GetPrimarySelectionOwner GetDisplay GetScreen GetColormap GetNativeEvent const char const char dpyName wid window const char font_name cursor keysym reg const char only_if_exist regb h Point_t winding char text const char depth char const char Int_t count const char ColorStruct_t color const char Pixmap_t Pixmap_t PictureAttributes_t attr const char char ret_data h unsigned char height h prop
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t index
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void on
Option_t Option_t SetLineColor
Option_t Option_t SetMarkerStyle
Option_t Option_t width
Option_t Option_t style
char name[80]
Definition TGX11.cxx:110
TRObject operator()(const T1 &t1) const
char * Form(const char *fmt,...)
Formats a string in a circular formatting buffer.
Definition TString.cxx:2489
void SetMainColorPtr(Color_t *colptr)
const char * GetCName() const
virtual void WriteVizParams(std::ostream &out, const TString &var)
Write-out visual parameters for this object.
void SetTitle(const std::string &title)
Set title of an element.
static const std::string & ToString(Bool_t b)
Convert Bool_t to string - kTRUE or kFALSE.
virtual void CopyVizParams(const REveElement *el)
Copy visualization parameters from element el.
virtual void SetMainColor(Color_t color)
Set main color of the element.
void SetName(const std::string &name)
Set name of an element.
REveException Exception-type thrown by Eve classes.
Definition REveTypes.hxx:43
REveLine An arbitrary polyline with fixed line and marker attributes.
Definition REveLine.hxx:30
void CopyVizParams(const REveElement *el) override
Copy visualization parameters from element el.
Definition REveLine.cxx:245
void SetMarkerColor(Color_t col) override
Set marker color. Propagate to projected lines.
Definition REveLine.cxx:58
void WriteVizParams(std::ostream &out, const TString &var) override
Write visualization parameters.
Definition REveLine.cxx:262
void SetLineWidth(Width_t lwidth) override
Set line-style of the line.
Definition REveLine.cxx:94
void SetLineColor(Color_t col) override
Set the line color.
Definition REveLine.hxx:48
void SetLineStyle(Style_t lstyle) override
Set line-style of the line.
Definition REveLine.cxx:76
Int_t WriteCoreJson(nlohmann::json &cj, Int_t rnr_offset) override
Write core json.
Definition REveLine.cxx:283
void SetRnrLine(Bool_t r)
Set rendering of line. Propagate to projected lines.
Definition REveLine.cxx:112
void SetRnrPoints(Bool_t r)
Set rendering of points. Propagate to projected lines.
Definition REveLine.cxx:130
void BuildRenderData() override
Virtual from REveElement. Prepares render data for binary streaming to client.
Definition REveLine.cxx:297
virtual void ClonePoints(const REvePointSet &e)
Clone points and all point-related information from point-set 'e'.
void SetMarkerSize(Size_t msize=1) override
Set marker size, propagate to projecteds.
std::vector< REveVector > fPoints
void Reset(Int_t n_points=0)
Drop all data and set-up the data structures to recive new data.
void SetMarkerStyle(Style_t mstyle=1) override
Set marker style, propagate to projecteds.
REveProjection Base for specific classes that implement non-linear projections.
REveRecTrack Template for reconstructed track (also used in VSD).
virtual void IncRefCount(REveElement *re)
Increase reference count and add re to the list of back-references.
Definition REveUtil.cxx:417
virtual void DecRefCount(REveElement *re)
Decrease reference count and remove re from the list of back-references.
Definition REveUtil.cxx:426
REveTrackList A list of tracks supporting change of common attributes and selection based on track pa...
void CopyVizParams(const REveElement *el) override
Copy visualization parameters from element el.
void SetRnrLine(Bool_t rnr)
Set rendering of track as line for the list and the elements.
void SetRnrPoints(Bool_t r)
Set rendering of track as points for the list and the elements.
void MakeTracks(Bool_t recurse=kTRUE)
Regenerate the visual representations of tracks.
REveTrackPropagator * fPropagator
void SetMarkerSize(Size_t s) override
Set marker size for the list and the elements.
REveTrackList(const REveTrackList &)=delete
TClass * ProjectedClass(const REveProjection *p) const override
Virtual from REveProjectable, returns REveTrackListProjected class.
REveTrack * FindTrackByLabel(Int_t label)
Find track by label, select it and display it in the editor.
void WriteVizParams(std::ostream &out, const TString &var) override
Write visualization parameters.
Double_t RoundMomentumLimit(Double_t x)
Round the momentum limit up to a nice value.
void SelectByP(Double_t min_p, Double_t max_p)
Select visibility of tracks by momentum.
void SelectByPt(Double_t min_pt, Double_t max_pt)
Select visibility of tracks by transverse momentum.
void SetLineWidth(Width_t w) override
Set line width for the list and the elements.
void SanitizeMinMaxCuts()
Set Min/Max cuts so that they are within detected limits.
REveTrack * FindTrackByIndex(Int_t index)
Find track by index, select it and display it in the editor.
void SetMainColor(Color_t c) override
Set main (line) color for the list and the elements.
~REveTrackList() override
Destructor.
void SetPropagator(REveTrackPropagator *prop)
Set default propagator for tracks.
void SetLineStyle(Style_t s) override
Set line style for the list and the elements.
void SetMarkerColor(Color_t c) override
Set marker color for the list and the elements.
void SetLineColor(Color_t c) override
Set the line color.
void FindMomentumLimits(REveElement *el, Bool_t recurse=kTRUE)
Loop over track elements of argument el and find highest pT and p.
void SetMarkerStyle(Style_t s) override
Set marker style for the list and the elements.
REveTrackPropagator Calculates path of a particle taking into account special path-marks and imposed ...
virtual Bool_t GoToVertex(REveVectorD &v, REveVectorD &p)
Propagate particle with momentum p to vertex v.
static Bool_t IsOutsideBounds(const REveVectorD &point, Double_t maxRsqr, Double_t maxZ)
void ResetTrack()
Reset cache holding particle trajectory.
Double_t GetTrackLength(Int_t start_point=0, Int_t end_point=-1) const
Calculate track length from start_point to end_point.
void InitTrack(const REveVectorD &v, Int_t charge)
Initialize internal data-members for given particle parameters.
Bool_t IntersectPlane(const REveVectorD &p, const REveVectorD &point, const REveVectorD &normal, REveVectorD &itsect)
Find intersection of currently propagated track with a plane.
Int_t GetCurrentPoint() const
Get index of current point on track.
void FillPointSet(REvePointSet *ps) const
Reset ps and populate it with points in propagation cache.
virtual Bool_t GoToLineSegment(const REveVectorD &s, const REveVectorD &r, REveVectorD &p)
Propagate particle with momentum p to line with start point s and vector r to the second point.
virtual void GoToBounds(REveVectorD &p)
Propagate particle to bounds.
REveTrack Track with given vertex, momentum and optional referece-points (path-marks) along its path.
Definition REveTrack.hxx:40
Int_t WriteCoreJson(nlohmann::json &cj, Int_t rnr_offset) override
Fill core part of JSON representation.
virtual void SecSelected(REveTrack *)
Emits "SecSelected(REveTrack*)" signal.
REveTrackPropagator * fPropagator
Last path-mark index tried in track-propagation.
Definition REveTrack.hxx:68
void SetAttLineAttMarker(REveTrackList *tl)
Set line and marker attributes from REveTrackList.
virtual void SetTrackParams(const REveTrack &t)
Copy track parameters from t.
virtual void MakeTrack(Bool_t recurse=kTRUE)
Calculate track representation based on track data and current settings of the propagator.
REveTrack()
Default constructor.
Definition REveTrack.cxx:42
TClass * ProjectedClass(const REveProjection *p) const override
Virtual from REveProjectable, return REveTrackProjected class.
void WriteVizParams(std::ostream &out, const TString &var) override
Write visualization parameters.
virtual void SetPathMarks(const REveTrack &t)
Copy path-marks from t.
void SetPropagator(REveTrackPropagator *prop)
Set track's propagator.
void PrintPathMarks()
Print registered path-marks.
void BuildRenderData() override
Crates 3D point array for rendering.
void ComputeBBox() override
Compute the bounding box of the track.
virtual void SetStdTitle()
Set standard track title based on most data-member values.
void CopyVizParams(const REveElement *el) override
Copy visualization parameters from element el.
void SortPathMarksByTime()
Sort registered pat-marks by time.
~REveTrack() override
Destructor.
void BBoxCheckPoint(Float_t x, Float_t y, Float_t z)
Definition TAttBBox.h:69
void BBoxZero(Float_t epsilon=0, Float_t x=0, Float_t y=0, Float_t z=0)
Create cube of volume (2*epsilon)^3 at (x,y,z).
Definition TAttBBox.cxx:42
void BBoxInit(Float_t infinity=1e6)
Dynamic Float_t[6] X(min,max), Y(min,max), Z(min,max)
Definition TAttBBox.cxx:29
Line Attributes class.
Definition TAttLine.h:18
virtual Color_t GetLineColor() const
Return the line color.
Definition TAttLine.h:33
virtual Width_t GetLineWidth() const
Return the line width.
Definition TAttLine.h:35
Width_t fLineWidth
Line width.
Definition TAttLine.h:23
virtual Style_t GetLineStyle() const
Return the line style.
Definition TAttLine.h:34
Style_t fLineStyle
Line style.
Definition TAttLine.h:22
Color_t fLineColor
Line color.
Definition TAttLine.h:21
Marker Attributes class.
Definition TAttMarker.h:19
virtual void SaveMarkerAttributes(std::ostream &out, const char *name, Int_t coldef=1, Int_t stydef=1, Int_t sizdef=1)
Save line attributes as C++ statement(s) on output stream out.
virtual Style_t GetMarkerStyle() const
Return the marker style.
Definition TAttMarker.h:32
virtual Color_t GetMarkerColor() const
Return the marker color.
Definition TAttMarker.h:31
Color_t fMarkerColor
Marker color.
Definition TAttMarker.h:22
virtual Size_t GetMarkerSize() const
Return the marker size.
Definition TAttMarker.h:33
Size_t fMarkerSize
Marker size.
Definition TAttMarker.h:24
Style_t fMarkerStyle
Marker style.
Definition TAttMarker.h:23
TClass instances represent classes, structs and namespaces in the ROOT type system.
Definition TClass.h:81
Description of the static properties of a particle.
Int_t PdgCode() const
Double_t Charge() const
Description of the dynamic properties of a particle.
Definition TParticle.h:26
TParticlePDG * GetPDG(Int_t mode=0) const
Returns a pointer to the TParticlePDG object using the pdgcode.
const char * GetName() const override
Return particle name.
Basic string class.
Definition TString.h:139
const char * Data() const
Definition TString.h:376
Double_t x[n]
Definition legend1.C:17
const Int_t n
Definition legend1.C:16
TMath.
Definition TMathBase.h:35
Int_t Nint(T x)
Round to nearest integer. Rounds half integers to the nearest even integer.
Definition TMath.h:697
Short_t Max(Short_t a, Short_t b)
Returns the largest of a and b.
Definition TMathBase.h:250
Short_t Min(Short_t a, Short_t b)
Returns the smallest of a and b.
Definition TMathBase.h:198
TMarker m
Definition textangle.C:8