forked from root-project/root
-
Notifications
You must be signed in to change notification settings - Fork 0
/
TPrimary.cxx
234 lines (199 loc) · 6.08 KB
/
TPrimary.cxx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
// @(#)root/eg:$Id$
// Author: Ola Nordmann 21/09/95
/*************************************************************************
* Copyright (C) 1995-2000, Rene Brun and Fons Rademakers. *
* All rights reserved. *
* *
* For the licensing terms see $ROOTSYS/LICENSE. *
* For the list of contributors see $ROOTSYS/README/CREDITS. *
*************************************************************************/
/** \class TPrimary
\ingroup eg
Old version of a dynamic particle class created by event generators.
This class is now obsolete. Use TParticle instead.
*/
#include "TObject.h"
#include "Rtypes.h"
#include "TString.h"
#include "TAttParticle.h"
#include "TPrimary.h"
#include "TView.h"
#include "TMath.h"
#include "TVirtualPad.h"
#include "TPolyLine3D.h"
ClassImp(TPrimary)
////////////////////////////////////////////////////////////////////////////////
///
/// Primary vertex particle default constructor
///
TPrimary::TPrimary()
{
//do nothing
fPart = 0;
fFirstMother = 0;
fSecondMother = 0;
fGeneration = 0;
fPx = 0;
fPy = 0;
fPz = 0;
fEtot = 0;
fVx = 0;
fVy = 0;
fVz = 0;
fTime = 0;
fTimeEnd = 0;
fType = "";
}
////////////////////////////////////////////////////////////////////////////////
///
/// TPrimary vertex particle normal constructor
///
TPrimary::TPrimary(Int_t part, Int_t first, Int_t second, Int_t gener,
Double_t px, Double_t py, Double_t pz,
Double_t etot, Double_t vx, Double_t vy, Double_t vz,
Double_t time, Double_t timend, const char *type)
{
fPart = part;
fFirstMother = first;
fSecondMother = second;
fGeneration = gener;
fPx = px;
fPy = py;
fPz = pz;
fEtot = etot;
fVx = vx;
fVy = vy;
fVz = vz;
fTime = time;
fTimeEnd = timend;
fType = type;
}
////////////////////////////////////////////////////////////////////////////////
///
/// Primaray vertex particle default destructor
///
TPrimary::~TPrimary()
{
//do nothing
}
////////////////////////////////////////////////////////////////////////////////
/// Compute distance from point px,py to a primary track
///
/// Compute the closest distance of approach from point px,py to each segment
/// of a track.
/// The distance is computed in pixels units.
///
Int_t TPrimary::DistancetoPrimitive(Int_t px, Int_t py)
{
const Int_t big = 9999;
Float_t xv[3], xe[3], xndc[3];
Float_t rmin[3], rmax[3];
TView *view = gPad->GetView();
if(!view) return big;
// compute first and last point in pad coordinates
Float_t pmom = TMath::Sqrt(fPx*fPx+fPy*fPy+fPz*fPz);
if (pmom == 0) return big;
view->GetRange(rmin,rmax);
Float_t rbox = rmax[2];
xv[0] = fVx;
xv[1] = fVy;
xv[2] = fVz;
xe[0] = fVx+rbox*fPx/pmom;
xe[1] = fVy+rbox*fPy/pmom;
xe[2] = fVz+rbox*fPz/pmom;
view->WCtoNDC(xv, xndc);
Float_t x1 = xndc[0];
Float_t y1 = xndc[1];
view->WCtoNDC(xe, xndc);
Float_t x2 = xndc[0];
Float_t y2 = xndc[1];
return DistancetoLine(px,py,x1,y1,x2,y2);
}
////////////////////////////////////////////////////////////////////////////////
/// Execute action corresponding to one event
///
void TPrimary::ExecuteEvent(Int_t, Int_t, Int_t)
{
gPad->SetCursor(kPointer);
}
////////////////////////////////////////////////////////////////////////////////
/// Return name of primary particle
const char *TPrimary::GetName() const
{
static char def[4] = "XXX";
const TAttParticle *ap = GetParticle();
if (ap) return ap->GetName();
else return def;
}
////////////////////////////////////////////////////////////////////////////////
///
/// Returning a pointer to the particle attributes
///
const TAttParticle *TPrimary::GetParticle() const
{
if (!TAttParticle::fgList) TAttParticle::DefinePDG();
return TAttParticle::GetParticle(fPart);
}
////////////////////////////////////////////////////////////////////////////////
/// Return title of primary particle
const char *TPrimary::GetTitle() const
{
static char title[128];
Float_t pmom = TMath::Sqrt(fPx*fPx+fPy*fPy+fPz*fPz);
snprintf(title,128,"pmom=%f GeV",pmom);
return title;
}
////////////////////////////////////////////////////////////////////////////////
///
/// Paint a primary track
///
void TPrimary::Paint(Option_t *option)
{
Float_t rmin[3], rmax[3];
static TPolyLine3D *pline = 0;
if (!pline) {
pline = new TPolyLine3D(2);
}
Float_t pmom = TMath::Sqrt(fPx*fPx+fPy*fPy+fPz*fPz);
if (pmom == 0) return;
TView *view = gPad->GetView();
if (!view) return;
view->GetRange(rmin,rmax);
Float_t rbox = rmax[2];
pline->SetPoint(0,fVx, fVy, fVz);
Float_t xend = fVx+rbox*fPx/pmom;
Float_t yend = fVy+rbox*fPy/pmom;
Float_t zend = fVz+rbox*fPz/pmom;
pline->SetPoint(1, xend, yend, zend);
pline->SetLineColor(GetLineColor());
pline->SetLineStyle(GetLineStyle());
pline->SetLineWidth(GetLineWidth());
pline->Paint(option);
}
////////////////////////////////////////////////////////////////////////////////
///
/// Print the internals of the primary vertex particle
///
void TPrimary::Print(Option_t *) const
{
char def[8] = "XXXXXXX";
const char *name;
TAttParticle *ap = (TAttParticle*)GetParticle();
if (ap) name = ap->GetName();
else name = def;
Printf("TPrimary: %-13s p: %8f %8f %8f Vertex: %8e %8e %8e %5d %5d %s",
name,fPx,fPy,fPz,fVx,fVy,fVz,
fFirstMother,fSecondMother,fType.Data());
}
////////////////////////////////////////////////////////////////////////////////
/// Return total X3D size of this primary
///
void TPrimary::Sizeof3D() const
{
Float_t pmom = TMath::Sqrt(fPx*fPx+fPy*fPy+fPz*fPz);
if (pmom == 0) return;
Int_t npoints = 2;
gSize3D.numPoints += npoints;
gSize3D.numSegs += (npoints-1);
gSize3D.numPolys += 0;
}