Logo ROOT   6.10/09
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 /// Copy ctor. NOT TO BE CALLED.
57 
59  :TObject(other), TGeoAtt(other), TAttLine(other), TAttMarker(other),
60  fPDG(other.fPDG),
61  fId(other.fId),
62  fParent(other.fParent),
63  fParticle(other.fParticle),
64  fTracks(other.fTracks)
65 {
66 }
67 
68 ////////////////////////////////////////////////////////////////////////////////
69 /// Assignment operator. NOT TO BE CALLED.
70 
72 {
73  if(this!=&gv) {
78  fPDG=gv.fPDG;
79  fId=gv.fId;
80  fParent=gv.fParent;
82  fTracks=gv.fTracks;
83  }
84  return *this;
85 }
86 
87 ////////////////////////////////////////////////////////////////////////////////
88 /// Destructor.
89 
91 {
92  if (fTracks) {
93  fTracks->Delete();
94  delete fTracks;
95  }
96 }
97 
98 ////////////////////////////////////////////////////////////////////////////////
99 /// Returns daughter id.
100 
102 {
103  TVirtualGeoTrack *daughter = GetDaughter(index);
104  if (!daughter) {
105  Error("GetDaughterId", "No daughter track with index %d", index);
106  return -1;
107  }
108  return daughter->GetId();
109 }
110 
111 ////////////////////////////////////////////////////////////////////////////////
112 /// Recursively search through this track for a daughter
113 /// particle (at any depth) with the specified id
114 
116 {
117  TVirtualGeoTrack* trk=0;
118  if (GetId()==id) {
119  trk = (TVirtualGeoTrack*)this;
120  return trk;
121  }
122  TVirtualGeoTrack* kid=0;
123  Int_t nd = GetNdaughters();
124  for (Int_t i=0; i<nd; i++) if (GetDaughterId(i) == id) return GetDaughter(i);
125  for (Int_t i=0; i<nd; i++) {
126  kid = GetDaughter(i);
127  if (kid!=0) {
128  trk = kid->FindTrackWithId(id);
129  if (trk!=0) break;
130  }
131  }
132  return trk;
133 }
134 
135 ////////////////////////////////////////////////////////////////////////////////
136 /// Get the PDG name.
137 
138 const char *TVirtualGeoTrack::GetName() const
139 {
140  return gGeoManager->GetPdgName(fPDG);
141 }
142 
143 ////////////////////////////////////////////////////////////////////////////////
144 /// True if track TOF range overlaps with time interval of TGeoManager
145 
147 {
148  Double_t tmin, tmax;
149  Bool_t timecut = gGeoManager->GetTminTmax(tmin,tmax);
150  if (!timecut) return kTRUE;
151  const Double_t *point = GetFirstPoint();
152  if (!point) return kFALSE;
153  if (point[3]>tmax) return kFALSE;
154  point = GetLastPoint();
155  if (point[3]<tmin) return kFALSE;
156  return kTRUE;
157 }
158 
159 ////////////////////////////////////////////////////////////////////////////////
160 /// Set a default name for this track.
161 
163 {
164  gGeoManager->SetPdgName(fPDG, name);
165  if (!strcmp(name, "gamma")) {
168  SetLineWidth(1);
170  return;
171  }
172  if (!strcmp(name, "pi+") || !strcmp(name, "proton") || !strcmp(name, "K+")) {
175  SetLineWidth(2);
176  return;
177  }
178  if (!strcmp(name, "pi-") || !strcmp(name, "K-")) {
179  SetLineColor(30);
180  SetMarkerColor(30);
181  SetLineWidth(2);
182  return;
183  }
184  if (!strcmp(name, "pi0") || !strcmp(name, "K0")) {
187  SetLineWidth(2);
188  return;
189  }
190  if (!strcmp(name, "neutron")) {
191  SetLineColor(16);
192  SetMarkerColor(16);
193  SetLineWidth(1);
195  return;
196  }
197  if (!strcmp(name, "Alpha") || !strcmp(name, "Deuteron") || !strcmp(name, "Triton")) {
200  SetLineWidth(3);
201  return;
202  }
203  if (!strcmp(name, "e-") || !strcmp(name, "mu-")) {
206  SetLineWidth(1);
208  return;
209  }
210  if (!strcmp(name, "e+") || !strcmp(name, "mu+")) {
213  SetLineWidth(1);
215  return;
216  }
217 }
218 
219 
const Double_t * GetLastPoint() const
virtual void SetLineWidth(Width_t lwidth)
Set the line width.
Definition: TAttLine.h:43
Bool_t GetTminTmax(Double_t &tmin, Double_t &tmax) const
Get time cut for drawing tracks.
virtual const char * GetName() const
Get the PDG name.
virtual Int_t GetDaughterId(Int_t index) const
Returns daughter id.
Bool_t IsInTimeRange() const
True if track TOF range overlaps with time interval of TGeoManager.
Visualization and tracking attributes for volumes and nodes.
Definition: TGeoAtt.h:17
virtual void Delete(Option_t *option="")
Remove all objects from the array AND delete all heap based objects.
Definition: TObjArray.cxx:329
Definition: Rtypes.h:56
int Int_t
Definition: RtypesCore.h:41
bool Bool_t
Definition: RtypesCore.h:59
Definition: Rtypes.h:56
Int_t GetId() const
const char * GetPdgName(Int_t pdg) const
Get name for given pdg code;.
Marker Attributes class.
Definition: TAttMarker.h:19
virtual void SetMarkerColor(Color_t mcolor=1)
Set the marker color.
Definition: TAttMarker.h:38
virtual TVirtualGeoTrack * FindTrackWithId(Int_t id) const
Recursively search through this track for a daughter particle (at any depth) with the specified id...
TObject & operator=(const TObject &rhs)
TObject assignment operator.
Definition: TObject.h:250
Base class for user-defined tracks attached to a geometry.
virtual void SetLineColor(Color_t lcolor)
Set the line color.
Definition: TAttLine.h:40
void SetPdgName(Int_t pdg, const char *name)
Set a name for a particle having a given pdg.
void SetName(const char *name)
Set a default name for this track.
virtual void Error(const char *method, const char *msgfmt,...) const
Issue error message.
Definition: TObject.cxx:873
TVirtualGeoTrack * GetDaughter(Int_t index) const
const Bool_t kFALSE
Definition: RtypesCore.h:92
#define ClassImp(name)
Definition: Rtypes.h:336
R__EXTERN TGeoManager * gGeoManager
Definition: TGeoManager.h:553
double Double_t
Definition: RtypesCore.h:55
TVirtualGeoTrack & operator=(const TVirtualGeoTrack &)
Assignment operator. NOT TO BE CALLED.
Definition: Rtypes.h:56
virtual void SetLineStyle(Style_t lstyle)
Set the line style.
Definition: TAttLine.h:42
const Double_t * GetFirstPoint() const
Binding & operator=(OUT(*fun)(void))
Mother of all ROOT objects.
Definition: TObject.h:37
TVirtualGeoTrack()
Virtual tracks default constructor.
TObjArray * fTracks
Definition: Rtypes.h:56
Int_t GetNdaughters() const
const Bool_t kTRUE
Definition: RtypesCore.h:91
TVirtualGeoTrack * fParent
Line Attributes class.
Definition: TAttLine.h:18
virtual ~TVirtualGeoTrack()
Destructor.