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
29
30////////////////////////////////////////////////////////////////////////////////
31/// Virtual tracks default constructor
32
34{
35 fPDG = 0;
36 fId = -1;
37 fParent = nullptr;
38 fParticle = nullptr;
39 fTracks = nullptr;
40}
41
42////////////////////////////////////////////////////////////////////////////////
43/// Constructor providing ID for parent track (-1 for primaries), ID of this
44/// track and related particle pointer.
45
47{
48 fPDG = pdgcode;
49 fId = id;
50 fParent = parent;
51 fParticle = particle;
52 fTracks = nullptr;
53}
54
55////////////////////////////////////////////////////////////////////////////////
56/// Destructor.
57
59{
60 if (fTracks) {
61 fTracks->Delete();
62 delete fTracks;
63 }
64}
65
66////////////////////////////////////////////////////////////////////////////////
67/// Returns daughter id.
68
70{
72 if (!daughter) {
73 Error("GetDaughterId", "No daughter track with index %d", index);
74 return -1;
75 }
76 return daughter->GetId();
77}
78
79////////////////////////////////////////////////////////////////////////////////
80/// Recursively search through this track for a daughter
81/// particle (at any depth) with the specified id
82
84{
85 TVirtualGeoTrack *trk = nullptr;
86 if (GetId() == id) {
87 trk = (TVirtualGeoTrack *)this;
88 return trk;
89 }
90 TVirtualGeoTrack *kid = nullptr;
91 Int_t nd = GetNdaughters();
92 for (Int_t i = 0; i < nd; i++)
93 if (GetDaughterId(i) == id)
94 return GetDaughter(i);
95 for (Int_t i = 0; i < nd; i++) {
96 kid = GetDaughter(i);
97 if (kid != nullptr) {
98 trk = kid->FindTrackWithId(id);
99 if (trk != nullptr)
100 break;
101 }
102 }
103 return trk;
104}
105
106////////////////////////////////////////////////////////////////////////////////
107/// Get the PDG name.
108
109const char *TVirtualGeoTrack::GetName() const
110{
111 return gGeoManager->GetPdgName(fPDG);
112}
113
114////////////////////////////////////////////////////////////////////////////////
115/// True if track TOF range overlaps with time interval of TGeoManager
116
118{
119 Double_t tmin, tmax;
120 Bool_t timecut = gGeoManager->GetTminTmax(tmin, tmax);
121 if (!timecut)
122 return kTRUE;
123 const Double_t *point = GetFirstPoint();
124 if (!point)
125 return kFALSE;
126 if (point[3] > tmax)
127 return kFALSE;
128 point = GetLastPoint();
129 if (point[3] < tmin)
130 return kFALSE;
131 return kTRUE;
132}
133
134////////////////////////////////////////////////////////////////////////////////
135/// Set a default name for this track.
136
138{
140 if (!strcmp(name, "gamma")) {
143 SetLineWidth(1);
145 return;
146 }
147 if (!strcmp(name, "pi+") || !strcmp(name, "proton") || !strcmp(name, "K+")) {
150 SetLineWidth(2);
151 return;
152 }
153 if (!strcmp(name, "pi-") || !strcmp(name, "K-")) {
154 SetLineColor(30);
155 SetMarkerColor(30);
156 SetLineWidth(2);
157 return;
158 }
159 if (!strcmp(name, "pi0") || !strcmp(name, "K0")) {
162 SetLineWidth(2);
163 return;
164 }
165 if (!strcmp(name, "neutron")) {
166 SetLineColor(16);
167 SetMarkerColor(16);
168 SetLineWidth(1);
170 return;
171 }
172 if (!strcmp(name, "Alpha") || !strcmp(name, "Deuteron") || !strcmp(name, "Triton")) {
175 SetLineWidth(3);
176 return;
177 }
178 if (!strcmp(name, "e-") || !strcmp(name, "mu-")) {
181 SetLineWidth(1);
183 return;
184 }
185 if (!strcmp(name, "e+") || !strcmp(name, "mu+")) {
188 SetLineWidth(1);
190 return;
191 }
192}
constexpr Bool_t kFALSE
Definition RtypesCore.h:101
constexpr Bool_t kTRUE
Definition RtypesCore.h:100
#define ClassImp(name)
Definition Rtypes.h:377
@ kRed
Definition Rtypes.h:66
@ kGreen
Definition Rtypes.h:66
@ kMagenta
Definition Rtypes.h:66
@ kCyan
Definition Rtypes.h:66
@ kBlue
Definition Rtypes.h:66
@ kDotted
Definition TAttLine.h:48
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:42
virtual void SetMarkerColor(Color_t mcolor=1)
Set the marker color.
Definition TAttMarker.h:38
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:987
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