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 
15 Old version of a dynamic particle class created by event generators.
16 
17 This 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 
145 const 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 
167 const 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 
225 void TPrimary::Sizeof3D() const
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 
first
Definition: first.py:1
snprintf
#define snprintf
Definition: civetweb.c:1540
Option_t
const char Option_t
Definition: RtypesCore.h:66
TPrimary::Print
virtual void Print(Option_t *option="") const
Print the internals of the primary vertex particle.
Definition: TPrimary.cxx:209
TPrimary::fTimeEnd
Double_t fTimeEnd
Definition: TPrimary.h:46
TString::Data
const char * Data() const
Definition: TString.h:369
ClassImp
#define ClassImp(name)
Definition: Rtypes.h:364
TPrimary
Old version of a dynamic particle class created by event generators.
Definition: TPrimary.h:31
TView.h
TPrimary::ExecuteEvent
virtual void ExecuteEvent(Int_t event, Int_t px, Int_t py)
Execute action corresponding to one event.
Definition: TPrimary.cxx:137
TMath::Sqrt
Double_t Sqrt(Double_t x)
Definition: TMath.h:691
Float_t
float Float_t
Definition: RtypesCore.h:57
TPrimary::TPrimary
TPrimary()
Primary vertex particle default constructor.
Definition: TPrimary.cxx:38
TPrimary::fPy
Double_t fPy
Definition: TPrimary.h:39
TAttLine::SetLineColor
virtual void SetLineColor(Color_t lcolor)
Set the line color.
Definition: TAttLine.h:40
TPrimary::fGeneration
Int_t fGeneration
Definition: TPrimary.h:37
TPolyLine::SetPoint
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:635
TAttParticle.h
TString.h
TPrimary::fVy
Double_t fVy
Definition: TPrimary.h:43
x1
static const double x1[5]
Definition: RooGaussKronrodIntegrator1D.cxx:346
TPrimary::GetTitle
virtual const char * GetTitle() const
Return title of primary particle.
Definition: TPrimary.cxx:167
TPrimary::fPx
Double_t fPx
Definition: TPrimary.h:38
TView
See TView3D.
Definition: TView.h:25
TPrimary::Paint
virtual void Paint(Option_t *option="")
Paint a primary track.
Definition: TPrimary.cxx:180
TAttLine::GetLineColor
virtual Color_t GetLineColor() const
Return the line color.
Definition: TAttLine.h:33
TPolyLine3D
A 3-dimensional polyline.
Definition: TPolyLine3D.h:33
TPrimary::~TPrimary
virtual ~TPrimary()
Primaray vertex particle default destructor.
Definition: TPrimary.cxx:89
TAttLine::GetLineStyle
virtual Style_t GetLineStyle() const
Return the line style.
Definition: TAttLine.h:34
TPolyLine3D.h
TPrimary::fVz
Double_t fVz
Definition: TPrimary.h:44
gSize3D
#define gSize3D
Definition: X3DBuffer.h:40
TPrimary::fEtot
Double_t fEtot
Definition: TPrimary.h:41
TVirtualPad.h
kPointer
@ kPointer
Definition: GuiTypes.h:374
TPrimary::fTime
Double_t fTime
Definition: TPrimary.h:45
Printf
void Printf(const char *fmt,...)
TView::GetRange
virtual void GetRange(Float_t *min, Float_t *max)=0
TAttLine::SetLineWidth
virtual void SetLineWidth(Width_t lwidth)
Set the line width.
Definition: TAttLine.h:43
pline
TPolyLine * pline
Definition: polyline.C:4
TPrimary::fPz
Double_t fPz
Definition: TPrimary.h:40
TAttParticle
Particle definition, partly based on GEANT3 particle definition.
Definition: TAttParticle.h:30
Double_t
double Double_t
Definition: RtypesCore.h:59
TObject.h
TPolyLine::Paint
virtual void Paint(Option_t *option="")
Paint this polyline with its current attributes.
Definition: TPolyLine.cxx:527
TPrimary::DistancetoPrimitive
virtual Int_t DistancetoPrimitive(Int_t px, Int_t py)
Compute distance from point px,py to a primary track.
Definition: TPrimary.cxx:103
TAttParticle::fgList
static THashList * fgList
Definition: TAttParticle.h:51
TAttParticle::DefinePDG
static void DefinePDG()
Defines particles according to the Particle Data Group.
Definition: TAttParticle.cxx:249
name
char name[80]
Definition: TGX11.cxx:110
TPrimary::fSecondMother
Int_t fSecondMother
Definition: TPrimary.h:36
x2
static const double x2[5]
Definition: RooGaussKronrodIntegrator1D.cxx:364
gPad
#define gPad
Definition: TVirtualPad.h:287
TPrimary::fType
TString fType
Definition: TPrimary.h:47
TAttLine::DistancetoLine
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:206
TPrimary::fPart
Int_t fPart
Definition: TPrimary.h:34
TAttLine::GetLineWidth
virtual Width_t GetLineWidth() const
Return the line width.
Definition: TAttLine.h:35
TNamed::GetName
virtual const char * GetName() const
Returns name of object.
Definition: TNamed.h:47
type
int type
Definition: TGX11.cxx:121
TPrimary::GetParticle
virtual const TAttParticle * GetParticle() const
Returning a pointer to the particle attributes.
Definition: TPrimary.cxx:158
TPrimary::Sizeof3D
virtual void Sizeof3D() const
Return total X3D size of this primary.
Definition: TPrimary.cxx:225
TAttLine::SetLineStyle
virtual void SetLineStyle(Style_t lstyle)
Set the line style.
Definition: TAttLine.h:42
TGeant4Unit::second
static constexpr double second
Definition: TGeant4SystemOfUnits.h:151
TPrimary::fFirstMother
Int_t fFirstMother
Definition: TPrimary.h:35
Rtypes.h
TAttParticle::GetParticle
static TAttParticle * GetParticle(const char *name)
Get a pointer to the particle object according to the name given.
Definition: TAttParticle.cxx:1505
TView::WCtoNDC
virtual void WCtoNDC(const Float_t *pw, Float_t *pn)=0
TPrimary.h
TPrimary::GetName
virtual const char * GetName() const
Return name of primary particle.
Definition: TPrimary.cxx:145
TMath.h
int
TPrimary::fVx
Double_t fVx
Definition: TPrimary.h:42