Logo ROOT  
Reference Guide
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 
21 Base class for user-defined tracks attached to a geometry.
22 Tracks are 3D objects made of points and they store a
23 pointer to a TParticle. The geometry manager holds a list
24 of all tracks that will be deleted on destruction of
25 gGeoManager.
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 {
71  TVirtualGeoTrack *daughter = GetDaughter(index);
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 
106 const 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 
TVirtualGeoTrack::GetDaughter
TVirtualGeoTrack * GetDaughter(Int_t index) const
Definition: TVirtualGeoTrack.h:49
TVirtualGeoTrack::FindTrackWithId
virtual TVirtualGeoTrack * FindTrackWithId(Int_t id) const
Recursively search through this track for a daughter particle (at any depth) with the specified id.
Definition: TVirtualGeoTrack.cxx:83
kTRUE
const Bool_t kTRUE
Definition: RtypesCore.h:100
TObjArray::Delete
virtual void Delete(Option_t *option="")
Remove all objects from the array AND delete all heap based objects.
Definition: TObjArray.cxx:356
TVirtualGeoTrack::TVirtualGeoTrack
TVirtualGeoTrack()
Virtual tracks default constructor.
Definition: TVirtualGeoTrack.cxx:33
kGreen
@ kGreen
Definition: Rtypes.h:66
gGeoManager
R__EXTERN TGeoManager * gGeoManager
Definition: TGeoManager.h:602
ClassImp
#define ClassImp(name)
Definition: Rtypes.h:364
TVirtualGeoTrack::GetNdaughters
Int_t GetNdaughters() const
Definition: TVirtualGeoTrack.h:53
TObject::Error
virtual void Error(const char *method, const char *msgfmt,...) const
Issue error message.
Definition: TObject.cxx:893
TVirtualGeoTrack::~TVirtualGeoTrack
virtual ~TVirtualGeoTrack()
Destructor.
Definition: TVirtualGeoTrack.cxx:58
TVirtualGeoTrack::fId
Int_t fId
Definition: TVirtualGeoTrack.h:30
TAttLine::SetLineColor
virtual void SetLineColor(Color_t lcolor)
Set the line color.
Definition: TAttLine.h:40
TVirtualGeoTrack::fParticle
TObject * fParticle
Definition: TVirtualGeoTrack.h:32
bool
id
XFontStruct * id
Definition: TGX11.cxx:109
TGeoManager::GetTminTmax
Bool_t GetTminTmax(Double_t &tmin, Double_t &tmax) const
Get time cut for drawing tracks.
Definition: TGeoManager.cxx:3939
TVirtualGeoTrack::GetFirstPoint
const Double_t * GetFirstPoint() const
Definition: TVirtualGeoTrack.h:59
kCyan
@ kCyan
Definition: Rtypes.h:66
kMagenta
@ kMagenta
Definition: Rtypes.h:66
TAttMarker::SetMarkerColor
virtual void SetMarkerColor(Color_t mcolor=1)
Set the marker color.
Definition: TAttMarker.h:38
TVirtualGeoTrack::GetId
Int_t GetId() const
Definition: TVirtualGeoTrack.h:47
kFALSE
const Bool_t kFALSE
Definition: RtypesCore.h:101
TVirtualGeoTrack::fTracks
TObjArray * fTracks
Definition: TVirtualGeoTrack.h:33
kRed
@ kRed
Definition: Rtypes.h:66
TVirtualGeoTrack::fParent
TVirtualGeoTrack * fParent
Definition: TVirtualGeoTrack.h:31
TGeoManager.h
TVirtualGeoTrack::GetName
virtual const char * GetName() const
Get the PDG name.
Definition: TVirtualGeoTrack.cxx:106
TAttLine::SetLineWidth
virtual void SetLineWidth(Width_t lwidth)
Set the line width.
Definition: TAttLine.h:43
Double_t
double Double_t
Definition: RtypesCore.h:59
TVirtualGeoTrack::IsInTimeRange
Bool_t IsInTimeRange() const
True if track TOF range overlaps with time interval of TGeoManager.
Definition: TVirtualGeoTrack.cxx:114
TVirtualGeoTrack.h
TObject.h
TVirtualGeoTrack::fPDG
Int_t fPDG
Definition: TVirtualGeoTrack.h:29
TVirtualGeoTrack::GetLastPoint
const Double_t * GetLastPoint() const
Definition: TVirtualGeoTrack.h:60
TObject
Mother of all ROOT objects.
Definition: TObject.h:37
TVirtualGeoTrack::GetDaughterId
virtual Int_t GetDaughterId(Int_t index) const
Returns daughter id.
Definition: TVirtualGeoTrack.cxx:69
name
char name[80]
Definition: TGX11.cxx:110
kBlue
@ kBlue
Definition: Rtypes.h:66
TGeoManager::GetPdgName
const char * GetPdgName(Int_t pdg) const
Get name for given pdg code;.
Definition: TGeoManager.cxx:1796
TVirtualGeoTrack::SetName
void SetName(const char *name)
Set a default name for this track.
Definition: TVirtualGeoTrack.cxx:130
TVirtualGeoTrack
Base class for user-defined tracks attached to a geometry.
Definition: TVirtualGeoTrack.h:27
TAttLine::SetLineStyle
virtual void SetLineStyle(Style_t lstyle)
Set the line style.
Definition: TAttLine.h:42
TGeoManager::SetPdgName
void SetPdgName(Int_t pdg, const char *name)
Set a name for a particle having a given pdg.
Definition: TGeoManager.cxx:1809
Rtypes.h
kDotted
@ kDotted
Definition: TAttLine.h:48
int