ROOT  6.06/09
Reference Guide
TPrimary.cxx
Go to the documentation of this file.
1 // @(#)root/eg:$Id$
2 // Author: Ola Nordmann 21/09/95
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 //______________________________________________________________________________
13 //
14 // old version of a dynamic particle class created by event generators.
15 // This class is now obsolete. Use TParticle instead.
16 
17 #include "TObject.h"
18 #include "Rtypes.h"
19 #include "TString.h"
20 #include "TAttParticle.h"
21 #include "TPrimary.h"
22 #include "TView.h"
23 #include "TMath.h"
24 #include "TVirtualPad.h"
25 #include "TPolyLine3D.h"
26 
28 
29 ////////////////////////////////////////////////////////////////////////////////
30 ///
31 /// Primary vertex particle default constructor
32 ///
33 
35 {
36  //do nothing
37  fPart = 0;
38  fFirstMother = 0;
39  fSecondMother = 0;
40  fGeneration = 0;
41  fPx = 0;
42  fPy = 0;
43  fPz = 0;
44  fEtot = 0;
45  fVx = 0;
46  fVy = 0;
47  fVz = 0;
48  fTime = 0;
49  fTimeEnd = 0;
50  fType = "";
51 
52 }
53 
54 ////////////////////////////////////////////////////////////////////////////////
55 ///
56 /// TPrimary vertex particle normal constructor
57 ///
58 
59 TPrimary::TPrimary(Int_t part, Int_t first, Int_t second, Int_t gener,
60  Double_t px, Double_t py, Double_t pz,
61  Double_t etot, Double_t vx, Double_t vy, Double_t vz,
62  Double_t time, Double_t timend, const char *type)
63 {
64  fPart = part;
65  fFirstMother = first;
66  fSecondMother = second;
67  fGeneration = gener;
68  fPx = px;
69  fPy = py;
70  fPz = pz;
71  fEtot = etot;
72  fVx = vx;
73  fVy = vy;
74  fVz = vz;
75  fTime = time;
76  fTimeEnd = timend;
77  fType = type;
78 }
79 
80 ////////////////////////////////////////////////////////////////////////////////
81 ///
82 /// Primaray vertex particle default destructor
83 ///
84 
86 {
87  //do nothing
88 }
89 
90 
91 ////////////////////////////////////////////////////////////////////////////////
92 ///*-*-*-*-*-*-*-*Compute distance from point px,py to a primary track*-*-*-*
93 ///*-* ====================================================
94 ///*-*
95 ///*-* Compute the closest distance of approach from point px,py to each segment
96 ///*-* of a track.
97 ///*-* The distance is computed in pixels units.
98 ///*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
99 
101 {
102  const Int_t big = 9999;
103  Float_t xv[3], xe[3], xndc[3];
104  Float_t rmin[3], rmax[3];
105  TView *view = gPad->GetView();
106  if(!view) return big;
107 
108  // compute first and last point in pad coordinates
110  if (pmom == 0) return big;
111  view->GetRange(rmin,rmax);
112  Float_t rbox = rmax[2];
113  xv[0] = fVx;
114  xv[1] = fVy;
115  xv[2] = fVz;
116  xe[0] = fVx+rbox*fPx/pmom;
117  xe[1] = fVy+rbox*fPy/pmom;
118  xe[2] = fVz+rbox*fPz/pmom;
119  view->WCtoNDC(xv, xndc);
120  Float_t x1 = xndc[0];
121  Float_t y1 = xndc[1];
122  view->WCtoNDC(xe, xndc);
123  Float_t x2 = xndc[0];
124  Float_t y2 = xndc[1];
125 
126  return DistancetoLine(px,py,x1,y1,x2,y2);
127 }
128 
129 
130 ////////////////////////////////////////////////////////////////////////////////
131 ///*-*-*-*-*-*-*-*-*-*-*Execute action corresponding to one event*-*-*-*
132 ///*-* =========================================
133 
135 {
136  gPad->SetCursor(kPointer);
137 }
138 
139 ////////////////////////////////////////////////////////////////////////////////
140 ///return name of primary particle
141 
142 const char *TPrimary::GetName() const
143 {
144  static char def[4] = "XXX";
145  const TAttParticle *ap = GetParticle();
146  if (ap) return ap->GetName();
147  else return def;
148 }
149 
150 ////////////////////////////////////////////////////////////////////////////////
151 ///
152 /// returning a pointer to the particle attributes
153 ///
154 
156 {
159 }
160 
161 ////////////////////////////////////////////////////////////////////////////////
162 ///return title of primary particle
163 
164 const char *TPrimary::GetTitle() const
165 {
166  static char title[128];
168  snprintf(title,128,"pmom=%f GeV",pmom);
169  return title;
170 }
171 
172 ////////////////////////////////////////////////////////////////////////////////
173 ///
174 /// Paint a primary track
175 ///
176 
178 {
179  Float_t rmin[3], rmax[3];
180  static TPolyLine3D *pline = 0;
181  if (!pline) {
182  pline = new TPolyLine3D(2);
183  }
185  if (pmom == 0) return;
186  TView *view = gPad->GetView();
187  if (!view) return;
188  view->GetRange(rmin,rmax);
189  Float_t rbox = rmax[2];
190  pline->SetPoint(0,fVx, fVy, fVz);
191  Float_t xend = fVx+rbox*fPx/pmom;
192  Float_t yend = fVy+rbox*fPy/pmom;
193  Float_t zend = fVz+rbox*fPz/pmom;
194  pline->SetPoint(1, xend, yend, zend);
195  pline->SetLineColor(GetLineColor());
196  pline->SetLineStyle(GetLineStyle());
197  pline->SetLineWidth(GetLineWidth());
198  pline->Paint(option);
199 }
200 
201 ////////////////////////////////////////////////////////////////////////////////
202 ///
203 /// Print the internals of the primary vertex particle
204 ///
205 
207 {
208  char def[8] = "XXXXXXX";
209  const char *name;
211  if (ap) name = ap->GetName();
212  else name = def;
213  Printf("TPrimary: %-13s p: %8f %8f %8f Vertex: %8e %8e %8e %5d %5d %s",
214  name,fPx,fPy,fPz,fVx,fVy,fVz,
216 }
217 
218 ////////////////////////////////////////////////////////////////////////////////
219 ///*-*-*-*-*-*Return total X3D size of this primary*-*-*-*-*-*-*
220 ///*-* =====================================
221 
222 void TPrimary::Sizeof3D() const
223 {
225  if (pmom == 0) return;
226  Int_t npoints = 2;
227  gSize3D.numPoints += npoints;
228  gSize3D.numSegs += (npoints-1);
229  gSize3D.numPolys += 0;
230 
231 }
232 
Double_t fPz
Definition: TPrimary.h:48
virtual Style_t GetLineStyle() const
Definition: TAttLine.h:48
virtual void SetLineWidth(Width_t lwidth)
Definition: TAttLine.h:57
virtual void Paint(Option_t *option="")
Paint a primary track.
Definition: TPrimary.cxx:177
virtual void WCtoNDC(const Float_t *pw, Float_t *pn)=0
float Float_t
Definition: RtypesCore.h:53
const char Option_t
Definition: RtypesCore.h:62
Double_t fEtot
Definition: TPrimary.h:49
Int_t fFirstMother
Definition: TPrimary.h:43
Int_t fSecondMother
Definition: TPrimary.h:44
Double_t fTime
Definition: TPrimary.h:53
See TView3D.
Definition: TView.h:36
int Int_t
Definition: RtypesCore.h:41
A 3-dimensional polyline.
Definition: TPolyLine3D.h:41
virtual const char * GetName() const
return name of primary particle
Definition: TPrimary.cxx:142
Double_t fVx
Definition: TPrimary.h:50
const char * Data() const
Definition: TString.h:349
static const double x2[5]
Int_t fPart
Definition: TPrimary.h:42
static void DefinePDG()
Defines particles according to the Particle Data Group.
TString fType
Definition: TPrimary.h:55
static TAttParticle * GetParticle(const char *name)
Get a pointer to the particle object according to the name given.
static THashList * fgList
Definition: TAttParticle.h:55
virtual void SetLineColor(Color_t lcolor)
Definition: TAttLine.h:54
Int_t fGeneration
Definition: TPrimary.h:45
#define gSize3D
Definition: X3DBuffer.h:42
ClassImp(TPrimary) TPrimary
Primary vertex particle default constructor.
Definition: TPrimary.cxx:27
virtual Int_t DistancetoPrimitive(Int_t px, Int_t py)
*-*-*-*-*-*-*-*Compute distance from point px,py to a primary track*-*-*-* *-* ======================...
Definition: TPrimary.cxx:100
virtual const char * GetName() const
Returns name of object.
Definition: TNamed.h:51
virtual Color_t GetLineColor() const
Definition: TAttLine.h:47
#define Printf
Definition: TGeoToOCC.h:18
Double_t fVy
Definition: TPrimary.h:51
Double_t fPy
Definition: TPrimary.h:47
PyObject * fType
virtual void SetPoint(Int_t point, Double_t x, Double_t y, Double_t z)
Set point n to x, y, z.
static const double x1[5]
double Double_t
Definition: RtypesCore.h:55
virtual void Print(Option_t *option="") const
Print the internals of the primary vertex particle.
Definition: TPrimary.cxx:206
int type
Definition: TGX11.cxx:120
virtual void Paint(Option_t *option="")
Paint a TPolyLine3D.
Int_t DistancetoLine(Int_t px, Int_t py, Double_t xp1, Double_t yp1, Double_t xp2, Double_t yp2)
Compute distance from point px,py to a line.
Definition: TAttLine.cxx:193
virtual void SetLineStyle(Style_t lstyle)
Definition: TAttLine.h:56
virtual const char * GetTitle() const
return title of primary particle
Definition: TPrimary.cxx:164
#define name(a, b)
Definition: linkTestLib0.cpp:5
virtual void GetRange(Float_t *min, Float_t *max)=0
virtual const TAttParticle * GetParticle() const
returning a pointer to the particle attributes
Definition: TPrimary.cxx:155
#define gPad
Definition: TVirtualPad.h:288
TPolyLine * pline
Definition: polyline.C:4
Double_t fPx
Definition: TPrimary.h:46
virtual void ExecuteEvent(Int_t event, Int_t px, Int_t py)
*-*-*-*-*-*-*-*-*-*-*Execute action corresponding to one event*-*-*-* *-* ===========================...
Definition: TPrimary.cxx:134
Double_t Sqrt(Double_t x)
Definition: TMath.h:464
virtual Width_t GetLineWidth() const
Definition: TAttLine.h:49
virtual ~TPrimary()
Primaray vertex particle default destructor.
Definition: TPrimary.cxx:85
Double_t fTimeEnd
Definition: TPrimary.h:54
virtual void Sizeof3D() const
*-*-*-*-*-*Return total X3D size of this primary*-*-*-*-*-*-* *-* ===================================...
Definition: TPrimary.cxx:222
Double_t fVz
Definition: TPrimary.h:52