Logo ROOT  
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#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;
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);
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
float Float_t
Definition: RtypesCore.h:57
const char Option_t
Definition: RtypesCore.h:66
#define ClassImp(name)
Definition: Rtypes.h:375
Option_t Option_t option
Option_t Option_t TPoint TPoint const char x2
Option_t Option_t TPoint TPoint const char x1
Option_t Option_t TPoint TPoint const char y2
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t TString Int_t GCValues_t GetPrimarySelectionOwner GetDisplay GetScreen GetColormap GetNativeEvent const char const char dpyName wid window const char font_name cursor keysym reg const char only_if_exist regb h Point_t winding char text const char depth char const char Int_t count const char ColorStruct_t color const char Pixmap_t Pixmap_t PictureAttributes_t attr const char char ret_data h unsigned char height h Atom_t Int_t ULong_t ULong_t unsigned char prop_list Atom_t Atom_t Atom_t Time_t type
Option_t Option_t TPoint TPoint const char y1
char name[80]
Definition: TGX11.cxx:110
void Printf(const char *fmt,...)
Formats a string in a circular formatting buffer and prints the string.
Definition: TString.cxx:2466
#define gPad
Definition: TVirtualPad.h:288
#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.
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
const char * GetName() const override
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...
Definition: TPolyLine.cxx:643
void Paint(Option_t *option="") override
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: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
static constexpr double second
Double_t Sqrt(Double_t x)
Returns the square root of x.
Definition: TMath.h:660
Definition: first.py:1
Definition: rbox.py:1
TPolyLine * pline
Definition: polyline.C:4