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