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 "TPrimary.h"
21
22#include "Rtypes.h"
23#include "TAttParticle.h"
24#include "TMath.h"
25#include "TPolyLine3D.h"
26#include "TString.h"
27#include "TView.h"
28#include "TVirtualPad.h"
29#include "X3DBuffer.h"
30
31#include <cstdio>
32
33
34////////////////////////////////////////////////////////////////////////////////
35///
36/// Primary vertex particle default constructor
37///
38
40{
41 //do nothing
42 fPart = 0;
43 fFirstMother = 0;
44 fSecondMother = 0;
45 fGeneration = 0;
46 fPx = 0;
47 fPy = 0;
48 fPz = 0;
49 fEtot = 0;
50 fVx = 0;
51 fVy = 0;
52 fVz = 0;
53 fTime = 0;
54 fTimeEnd = 0;
55 fType = "";
56
57}
58
59////////////////////////////////////////////////////////////////////////////////
60///
61/// TPrimary vertex particle normal constructor
62///
63
65 Double_t px, Double_t py, Double_t pz,
67 Double_t time, Double_t timend, const char *type)
68{
69 fPart = part;
70 fFirstMother = first;
71 fSecondMother = second;
73 fPx = px;
74 fPy = py;
75 fPz = pz;
76 fEtot = etot;
77 fVx = vx;
78 fVy = vy;
79 fVz = vz;
80 fTime = time;
82 fType = type;
83}
84
85////////////////////////////////////////////////////////////////////////////////
86///
87/// Primaray vertex particle default destructor
88///
89
91{
92 //do nothing
93}
94
95
96////////////////////////////////////////////////////////////////////////////////
97/// Compute distance from point px,py to a primary track
98///
99/// Compute the closest distance of approach from point px,py to each segment
100/// of a track.
101/// The distance is computed in pixels units.
102///
103
105{
106 const Int_t big = 9999;
107 Float_t xv[3], xe[3], xndc[3];
108 Float_t rmin[3], rmax[3];
109 TView *view = gPad->GetView();
110 if(!view) return big;
111
112 // compute first and last point in pad coordinates
114 if (pmom == 0) return big;
115 view->GetRange(rmin,rmax);
116 Float_t rbox = rmax[2];
117 xv[0] = fVx;
118 xv[1] = fVy;
119 xv[2] = fVz;
120 xe[0] = fVx+rbox*fPx/pmom;
121 xe[1] = fVy+rbox*fPy/pmom;
122 xe[2] = fVz+rbox*fPz/pmom;
123 view->WCtoNDC(xv, xndc);
124 Float_t x1 = xndc[0];
125 Float_t y1 = xndc[1];
126 view->WCtoNDC(xe, xndc);
127 Float_t x2 = xndc[0];
128 Float_t y2 = xndc[1];
129
130 return DistancetoLine(px,py,x1,y1,x2,y2);
131}
132
133
134////////////////////////////////////////////////////////////////////////////////
135/// Execute action corresponding to one event
136///
137
139{
140 gPad->SetCursor(kPointer);
141}
142
143////////////////////////////////////////////////////////////////////////////////
144/// Return name of primary particle
145
146const char *TPrimary::GetName() const
147{
148 static char def[4] = "XXX";
149 const TAttParticle *ap = GetParticle();
150 if (ap) return ap->GetName();
151 else return def;
152}
153
154////////////////////////////////////////////////////////////////////////////////
155///
156/// Returning a pointer to the particle attributes
157///
158
164
165////////////////////////////////////////////////////////////////////////////////
166/// Return title of primary particle
167
168const char *TPrimary::GetTitle() const
169{
170 static char title[128];
172 snprintf(title,128,"pmom=%f GeV",pmom);
173 return title;
174}
175
176////////////////////////////////////////////////////////////////////////////////
177///
178/// Paint a primary track
179///
180
182{
183 Float_t rmin[3], rmax[3];
184 static TPolyLine3D *pline = 0;
185 if (!pline) {
186 pline = new TPolyLine3D(2);
187 }
189 if (pmom == 0) return;
190 TView *view = gPad->GetView();
191 if (!view) return;
192 view->GetRange(rmin,rmax);
193 Float_t rbox = rmax[2];
194 pline->SetPoint(0,fVx, fVy, fVz);
195 Float_t xend = fVx+rbox*fPx/pmom;
196 Float_t yend = fVy+rbox*fPy/pmom;
197 Float_t zend = fVz+rbox*fPz/pmom;
198 pline->SetPoint(1, xend, yend, zend);
203}
204
205////////////////////////////////////////////////////////////////////////////////
206///
207/// Print the internals of the primary vertex particle
208///
209
211{
212 char def[8] = "XXXXXXX";
213 const char *name;
215 if (ap) name = ap->GetName();
216 else name = def;
217 Printf("TPrimary: %-13s p: %8f %8f %8f Vertex: %8e %8e %8e %5d %5d %s",
220}
221
222////////////////////////////////////////////////////////////////////////////////
223/// Return total X3D size of this primary
224///
225
227{
229 if (pmom == 0) return;
230 Int_t npoints = 2;
231 gSize3D.numPoints += npoints;
232 gSize3D.numSegs += (npoints-1);
233 gSize3D.numPolys += 0;
234
235}
236
@ kPointer
Definition GuiTypes.h:376
float Float_t
Float 4 bytes (float)
Definition RtypesCore.h:72
const char Option_t
Option string (const char)
Definition RtypesCore.h:81
ROOT::Detail::TRangeCast< T, true > TRangeDynCast
TRangeDynCast is an adapter class that allows the typed iteration through a TCollection.
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:142
void Printf(const char *fmt,...)
Formats a string in a circular formatting buffer and prints the string.
Definition TString.cxx:2585
#define gPad
virtual Color_t GetLineColor() const
Return the line color.
Definition TAttLine.h:36
virtual void SetLineStyle(Style_t lstyle)
Set the line style.
Definition TAttLine.h:46
virtual Width_t GetLineWidth() const
Return the line width.
Definition TAttLine.h:38
virtual void SetLineWidth(Width_t lwidth)
Set the line width.
Definition TAttLine.h:47
virtual void SetLineColor(Color_t lcolor)
Set the line color.
Definition TAttLine.h:44
virtual Style_t GetLineStyle() const
Return the line style.
Definition TAttLine.h:37
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:210
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
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...
void Paint(Option_t *option="") override
Paint this polyline with its current attributes.
~TPrimary() override
Primaray vertex particle default destructor.
Definition TPrimary.cxx:90
const char * GetTitle() const override
Return title of primary particle.
Definition TPrimary.cxx:168
const char * GetName() const override
Return name of primary particle.
Definition TPrimary.cxx:146
TString fType
Definition TPrimary.h:47
Double_t fVy
Definition TPrimary.h:43
TPrimary()
Primary vertex particle default constructor.
Definition TPrimary.cxx:39
void ExecuteEvent(Int_t event, Int_t px, Int_t py) override
Execute action corresponding to one event.
Definition TPrimary.cxx:138
Int_t fFirstMother
Definition TPrimary.h:35
Double_t fVx
Definition TPrimary.h:42
Double_t fPx
Definition TPrimary.h:38
void Paint(Option_t *option="") override
Paint a primary track.
Definition TPrimary.cxx:181
Double_t fPy
Definition TPrimary.h:39
void Print(Option_t *option="") const override
Print the internals of the primary vertex particle.
Definition TPrimary.cxx:210
Double_t fVz
Definition TPrimary.h:44
Int_t DistancetoPrimitive(Int_t px, Int_t py) override
Compute distance from point px,py to a primary track.
Definition TPrimary.cxx:104
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:159
Double_t fPz
Definition TPrimary.h:40
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
void Sizeof3D() const override
Return total X3D size of this primary.
Definition TPrimary.cxx:226
const char * Data() const
Definition TString.h:385
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)
Returns the square root of x.
Definition TMath.h:675
Definition rbox.py:1
TPolyLine * pline
Definition polyline.C:4