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 = 0;
38 fParticle = 0;
39 fTracks = 0;
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 = 0;
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=0;
86 if (GetId()==id) {
87 trk = (TVirtualGeoTrack*)this;
88 return trk;
89 }
90 TVirtualGeoTrack* kid=0;
91 Int_t nd = GetNdaughters();
92 for (Int_t i=0; i<nd; i++) if (GetDaughterId(i) == id) return GetDaughter(i);
93 for (Int_t i=0; i<nd; i++) {
94 kid = GetDaughter(i);
95 if (kid!=0) {
96 trk = kid->FindTrackWithId(id);
97 if (trk!=0) break;
98 }
99 }
100 return trk;
101}
102
103////////////////////////////////////////////////////////////////////////////////
104/// Get the PDG name.
105
106const char *TVirtualGeoTrack::GetName() const
107{
108 return gGeoManager->GetPdgName(fPDG);
109}
110
111////////////////////////////////////////////////////////////////////////////////
112/// True if track TOF range overlaps with time interval of TGeoManager
113
115{
116 Double_t tmin, tmax;
117 Bool_t timecut = gGeoManager->GetTminTmax(tmin,tmax);
118 if (!timecut) return kTRUE;
119 const Double_t *point = GetFirstPoint();
120 if (!point) return kFALSE;
121 if (point[3]>tmax) return kFALSE;
122 point = GetLastPoint();
123 if (point[3]<tmin) return kFALSE;
124 return kTRUE;
125}
126
127////////////////////////////////////////////////////////////////////////////////
128/// Set a default name for this track.
129
131{
133 if (!strcmp(name, "gamma")) {
136 SetLineWidth(1);
138 return;
139 }
140 if (!strcmp(name, "pi+") || !strcmp(name, "proton") || !strcmp(name, "K+")) {
143 SetLineWidth(2);
144 return;
145 }
146 if (!strcmp(name, "pi-") || !strcmp(name, "K-")) {
147 SetLineColor(30);
148 SetMarkerColor(30);
149 SetLineWidth(2);
150 return;
151 }
152 if (!strcmp(name, "pi0") || !strcmp(name, "K0")) {
155 SetLineWidth(2);
156 return;
157 }
158 if (!strcmp(name, "neutron")) {
159 SetLineColor(16);
160 SetMarkerColor(16);
161 SetLineWidth(1);
163 return;
164 }
165 if (!strcmp(name, "Alpha") || !strcmp(name, "Deuteron") || !strcmp(name, "Triton")) {
168 SetLineWidth(3);
169 return;
170 }
171 if (!strcmp(name, "e-") || !strcmp(name, "mu-")) {
174 SetLineWidth(1);
176 return;
177 }
178 if (!strcmp(name, "e+") || !strcmp(name, "mu+")) {
181 SetLineWidth(1);
183 return;
184 }
185}
186
187
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:970
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
void SetName(const char *name)
Set a default name for this track.
virtual const char * GetName() const
Get the PDG name.
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.
virtual ~TVirtualGeoTrack()
Destructor.
Int_t GetNdaughters() const