Logo ROOT   6.18/05
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/** \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
31
32////////////////////////////////////////////////////////////////////////////////
33///
34/// Primary vertex particle default constructor
35///
36
38{
39 //do nothing
40 fPart = 0;
41 fFirstMother = 0;
42 fSecondMother = 0;
43 fGeneration = 0;
44 fPx = 0;
45 fPy = 0;
46 fPz = 0;
47 fEtot = 0;
48 fVx = 0;
49 fVy = 0;
50 fVz = 0;
51 fTime = 0;
52 fTimeEnd = 0;
53 fType = "";
54
55}
56
57////////////////////////////////////////////////////////////////////////////////
58///
59/// TPrimary vertex particle normal constructor
60///
61
63 Double_t px, Double_t py, Double_t pz,
64 Double_t etot, Double_t vx, Double_t vy, Double_t vz,
65 Double_t time, Double_t timend, const char *type)
66{
67 fPart = part;
70 fGeneration = gener;
71 fPx = px;
72 fPy = py;
73 fPz = pz;
74 fEtot = etot;
75 fVx = vx;
76 fVy = vy;
77 fVz = vz;
78 fTime = time;
79 fTimeEnd = timend;
80 fType = type;
81}
82
83////////////////////////////////////////////////////////////////////////////////
84///
85/// Primaray vertex particle default destructor
86///
87
89{
90 //do nothing
91}
92
93
94////////////////////////////////////////////////////////////////////////////////
95/// Compute distance from point px,py to a primary track
96///
97/// Compute the closest distance of approach from point px,py to each segment
98/// of a track.
99/// The distance is computed in pixels units.
100///
101
103{
104 const Int_t big = 9999;
105 Float_t xv[3], xe[3], xndc[3];
106 Float_t rmin[3], rmax[3];
107 TView *view = gPad->GetView();
108 if(!view) return big;
109
110 // compute first and last point in pad coordinates
112 if (pmom == 0) return big;
113 view->GetRange(rmin,rmax);
114 Float_t rbox = rmax[2];
115 xv[0] = fVx;
116 xv[1] = fVy;
117 xv[2] = fVz;
118 xe[0] = fVx+rbox*fPx/pmom;
119 xe[1] = fVy+rbox*fPy/pmom;
120 xe[2] = fVz+rbox*fPz/pmom;
121 view->WCtoNDC(xv, xndc);
122 Float_t x1 = xndc[0];
123 Float_t y1 = xndc[1];
124 view->WCtoNDC(xe, xndc);
125 Float_t x2 = xndc[0];
126 Float_t y2 = xndc[1];
127
128 return DistancetoLine(px,py,x1,y1,x2,y2);
129}
130
131
132////////////////////////////////////////////////////////////////////////////////
133/// Execute action corresponding to one event
134///
135
137{
138 gPad->SetCursor(kPointer);
139}
140
141////////////////////////////////////////////////////////////////////////////////
142/// Return name of primary particle
143
144const char *TPrimary::GetName() const
145{
146 static char def[4] = "XXX";
147 const TAttParticle *ap = GetParticle();
148 if (ap) return ap->GetName();
149 else return def;
150}
151
152////////////////////////////////////////////////////////////////////////////////
153///
154/// Returning a pointer to the particle attributes
155///
156
158{
161}
162
163////////////////////////////////////////////////////////////////////////////////
164/// Return title of primary particle
165
166const char *TPrimary::GetTitle() const
167{
168 static char title[128];
170 snprintf(title,128,"pmom=%f GeV",pmom);
171 return title;
172}
173
174////////////////////////////////////////////////////////////////////////////////
175///
176/// Paint a primary track
177///
178
180{
181 Float_t rmin[3], rmax[3];
182 static TPolyLine3D *pline = 0;
183 if (!pline) {
184 pline = new TPolyLine3D(2);
185 }
187 if (pmom == 0) return;
188 TView *view = gPad->GetView();
189 if (!view) return;
190 view->GetRange(rmin,rmax);
191 Float_t rbox = rmax[2];
192 pline->SetPoint(0,fVx, fVy, fVz);
193 Float_t xend = fVx+rbox*fPx/pmom;
194 Float_t yend = fVy+rbox*fPy/pmom;
195 Float_t zend = fVz+rbox*fPz/pmom;
196 pline->SetPoint(1, xend, yend, zend);
200 pline->Paint(option);
201}
202
203////////////////////////////////////////////////////////////////////////////////
204///
205/// Print the internals of the primary vertex particle
206///
207
209{
210 char def[8] = "XXXXXXX";
211 const char *name;
213 if (ap) name = ap->GetName();
214 else name = def;
215 Printf("TPrimary: %-13s p: %8f %8f %8f Vertex: %8e %8e %8e %5d %5d %s",
218}
219
220////////////////////////////////////////////////////////////////////////////////
221/// Return total X3D size of this primary
222///
223
225{
227 if (pmom == 0) return;
228 Int_t npoints = 2;
229 gSize3D.numPoints += npoints;
230 gSize3D.numSegs += (npoints-1);
231 gSize3D.numPolys += 0;
232
233}
234
static const double x2[5]
static const double x1[5]
int Int_t
Definition: RtypesCore.h:41
double Double_t
Definition: RtypesCore.h:55
float Float_t
Definition: RtypesCore.h:53
const char Option_t
Definition: RtypesCore.h:62
#define ClassImp(name)
Definition: Rtypes.h:365
char name[80]
Definition: TGX11.cxx:109
int type
Definition: TGX11.cxx:120
void Printf(const char *fmt,...)
#define gPad
Definition: TVirtualPad.h:286
@ kPointer
Definition: TVirtualX.h:47
#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:198
Particle definition, partly based on GEANT3 particle definition.
Definition: TAttParticle.h:30
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
Definition: TAttParticle.h:51
virtual const char * GetName() const
Returns name of object.
Definition: TNamed.h:47
A 3-dimensional polyline.
Definition: TPolyLine3D.h:32
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...
Definition: TPolyLine.cxx:639
virtual void Paint(Option_t *option="")
Paint this polyline with its current attributes.
Definition: TPolyLine.cxx:531
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:136
virtual void Print(Option_t *option="") const
Print the internals of the primary vertex particle.
Definition: TPrimary.cxx:208
virtual void Paint(Option_t *option="")
Paint a primary track.
Definition: TPrimary.cxx:179
TString fType
Definition: TPrimary.h:47
Double_t fVy
Definition: TPrimary.h:43
TPrimary()
Primary vertex particle default constructor.
Definition: TPrimary.cxx:37
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:166
Double_t fPx
Definition: TPrimary.h:38
virtual ~TPrimary()
Primaray vertex particle default destructor.
Definition: TPrimary.cxx:88
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:157
virtual const char * GetName() const
Return name of primary particle.
Definition: TPrimary.cxx:144
Double_t fPz
Definition: TPrimary.h:40
virtual void Sizeof3D() const
Return total X3D size of this primary.
Definition: TPrimary.cxx:224
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:102
const char * Data() const
Definition: TString.h:364
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
static constexpr double second
Double_t Sqrt(Double_t x)
Definition: TMath.h:679
Definition: first.py:1
TPolyLine * pline
Definition: polyline.C:4