Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
TVirtualGeoTrack.cxx
Go to the documentation of this file.
1// @(#)root/geom:$Id$
2// Author: Andrei Gheata 2003/04/10
3
4/*************************************************************************
5 * Copyright (C) 1995-2000, 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 "TVirtualGeoTrack.h"
13
14#include "Rtypes.h"
15#include "TGeoManager.h"
16#include "TObject.h"
17
18/** \class TVirtualGeoTrack
19\ingroup Geometry_classes
20
21Base class for user-defined tracks attached to a geometry.
22Tracks are 3D objects made of points and they store a
23pointer to a TParticle. The geometry manager holds a list
24of all tracks that will be deleted on destruction of
25gGeoManager.
26*/
27
28
29////////////////////////////////////////////////////////////////////////////////
30/// Virtual tracks default constructor
31
33{
34 fPDG = 0;
35 fId = -1;
36 fParent = nullptr;
37 fParticle = nullptr;
38 fTracks = nullptr;
39}
40
41////////////////////////////////////////////////////////////////////////////////
42/// Constructor providing ID for parent track (-1 for primaries), ID of this
43/// track and related particle pointer.
44
53
54////////////////////////////////////////////////////////////////////////////////
55/// Destructor.
56
58{
59 if (fTracks) {
60 fTracks->Delete();
61 delete fTracks;
62 }
63}
64
65////////////////////////////////////////////////////////////////////////////////
66/// Returns daughter id.
67
69{
71 if (!daughter) {
72 Error("GetDaughterId", "No daughter track with index %d", index);
73 return -1;
74 }
75 return daughter->GetId();
76}
77
78////////////////////////////////////////////////////////////////////////////////
79/// Recursively search through this track for a daughter
80/// particle (at any depth) with the specified id
81
83{
84 TVirtualGeoTrack *trk = nullptr;
85 if (GetId() == id) {
86 trk = (TVirtualGeoTrack *)this;
87 return trk;
88 }
89 TVirtualGeoTrack *kid = nullptr;
90 Int_t nd = GetNdaughters();
91 for (Int_t i = 0; i < nd; i++)
92 if (GetDaughterId(i) == id)
93 return GetDaughter(i);
94 for (Int_t i = 0; i < nd; i++) {
95 kid = GetDaughter(i);
96 if (kid != nullptr) {
97 trk = kid->FindTrackWithId(id);
98 if (trk != nullptr)
99 break;
100 }
101 }
102 return trk;
103}
104
105////////////////////////////////////////////////////////////////////////////////
106/// Get the PDG name.
107
108const char *TVirtualGeoTrack::GetName() const
109{
110 return gGeoManager->GetPdgName(fPDG);
111}
112
113////////////////////////////////////////////////////////////////////////////////
114/// True if track TOF range overlaps with time interval of TGeoManager
115
117{
118 Double_t tmin, tmax;
119 Bool_t timecut = gGeoManager->GetTminTmax(tmin, tmax);
120 if (!timecut)
121 return kTRUE;
122 const Double_t *point = GetFirstPoint();
123 if (!point)
124 return kFALSE;
125 if (point[3] > tmax)
126 return kFALSE;
127 point = GetLastPoint();
128 if (point[3] < tmin)
129 return kFALSE;
130 return kTRUE;
131}
132
133////////////////////////////////////////////////////////////////////////////////
134/// Set a default name for this track.
135
137{
139 if (!strcmp(name, "gamma")) {
142 SetLineWidth(1);
144 return;
145 }
146 if (!strcmp(name, "pi+") || !strcmp(name, "proton") || !strcmp(name, "K+")) {
149 SetLineWidth(2);
150 return;
151 }
152 if (!strcmp(name, "pi-") || !strcmp(name, "K-")) {
153 SetLineColor(30);
154 SetMarkerColor(30);
155 SetLineWidth(2);
156 return;
157 }
158 if (!strcmp(name, "pi0") || !strcmp(name, "K0")) {
161 SetLineWidth(2);
162 return;
163 }
164 if (!strcmp(name, "neutron")) {
165 SetLineColor(16);
166 SetMarkerColor(16);
167 SetLineWidth(1);
169 return;
170 }
171 if (!strcmp(name, "Alpha") || !strcmp(name, "Deuteron") || !strcmp(name, "Triton")) {
174 SetLineWidth(3);
175 return;
176 }
177 if (!strcmp(name, "e-") || !strcmp(name, "mu-")) {
180 SetLineWidth(1);
182 return;
183 }
184 if (!strcmp(name, "e+") || !strcmp(name, "mu+")) {
187 SetLineWidth(1);
189 return;
190 }
191}
constexpr Bool_t kFALSE
Definition RtypesCore.h:108
constexpr Bool_t kTRUE
Definition RtypesCore.h:107
@ kRed
Definition Rtypes.h:67
@ kGreen
Definition Rtypes.h:67
@ kMagenta
Definition Rtypes.h:67
@ kCyan
Definition Rtypes.h:67
@ kBlue
Definition Rtypes.h:67
@ kDotted
Definition TAttLine.h:52
ROOT::Detail::TRangeCast< T, true > TRangeDynCast
TRangeDynCast is an adapter class that allows the typed iteration through a TCollection.
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 index
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize id
Option_t Option_t SetLineColor
char name[80]
Definition TGX11.cxx:110
R__EXTERN TGeoManager * gGeoManager
virtual void SetLineStyle(Style_t lstyle)
Set the line style.
Definition TAttLine.h:44
virtual void SetMarkerColor(Color_t mcolor=1)
Set the marker color.
Definition TAttMarker.h:39
void SetPdgName(Int_t pdg, const char *name)
Set a name for a particle having a given pdg.
const char * GetPdgName(Int_t pdg) const
Get name for given pdg code;.
Bool_t GetTminTmax(Double_t &tmin, Double_t &tmax) const
Get time cut for drawing tracks.
void Delete(Option_t *option="") override
Remove all objects from the array AND delete all heap based objects.
Mother of all ROOT objects.
Definition TObject.h:41
virtual void Error(const char *method, const char *msgfmt,...) const
Issue error message.
Definition TObject.cxx:1071
Base class for user-defined tracks attached to a geometry.
const Double_t * GetFirstPoint() const
virtual Int_t GetDaughterId(Int_t index) const
Returns daughter id.
Int_t GetId() const
TVirtualGeoTrack * fParent
~TVirtualGeoTrack() override
Destructor.
void SetName(const char *name)
Set a default name for this track.
const Double_t * GetLastPoint() const
TVirtualGeoTrack * GetDaughter(Int_t index) const
TVirtualGeoTrack()
Virtual tracks default constructor.
virtual TVirtualGeoTrack * FindTrackWithId(Int_t id) const
Recursively search through this track for a daughter particle (at any depth) with the specified id.
Bool_t IsInTimeRange() const
True if track TOF range overlaps with time interval of TGeoManager.
const char * GetName() const override
Get the PDG name.
Int_t GetNdaughters() const