Logo ROOT   6.08/07
Reference Guide
Track.h
Go to the documentation of this file.
1 // dummy track class for testing I/o of matric
2 
3 #include "Math/Point3D.h"
4 #include "Math/Vector4D.h"
5 
6 #include <vector>
7 
8 #include "TRandom.h"
9 
10 typedef double Double32_t;
11 
12 
13 
16 //typedef ROOT::Math::LorentzVector<ROOT::Math::PtEtaPhiM4D<Double32_t> > Vector4D32;
17 
20 
21 
22 
23 // track class
24 class TrackD {
25 
26 public:
27 
29  typedef Point3D PointType;
30 
31  TrackD() {}
32 
33  TrackD(const Vector4D & q, const Point3D & p) : fVec(q), fPos(p) {}
34 
35  const Vector4D & Vec() const { return fVec; }
36  const Point3D & Pos() const { return fPos; }
37 
38  double mag2() const {
39  return fVec.mag2() + fPos.mag2();
40  }
41 
42  void Set( const Vector4D & q, const Point3D & p) {
43  fVec = q; fPos = p;
44  }
45 
46 private:
47 
50 
51 };
52 
53 // track class based on of Double32
54 
55 
56 class TrackD32 {
57 
58 public:
59 
62 
63 
64  TrackD32() {}
65 
66  TrackD32(const Vector4D32 & q, const Point3D32 & p) : fVec(q), fPos(p) {}
67 
68  const Vector4D32 & Vec() const { return fVec; }
69  const Point3D32 & Pos() const { return fPos; }
70 
71  double mag2() const {
72  return fVec.mag2() + fPos.mag2();
73  }
74 
75  void Set( const Vector4D32 & q, const Point3D32 & p) {
76  fVec = q;
77  fPos = p;
78  }
79 private:
80 
83 
84 };
85 
86 
87 // class containning a vector of tracks
88 class VecTrackD {
89 
90 public:
91 
92  typedef std::vector<TrackD>::const_iterator It;
94  typedef Point3D PointType;
95 
96 
97  VecTrackD() {}
98 
99  It begin() const { return fTrks.begin(); }
100  It end() const { return fTrks.end(); }
101 
102 
103  double mag2() const {
104  double s = 0;
105  for (unsigned int i = 0; i < fTrks.size() ; ++i)
106  s += fTrks[i].mag2();
107 
108  return s;
109  }
110 
111  void Set( const Vector4D & q, const Point3D & p) {
112  int n = (gRandom->Poisson(4) + 1);
113  fTrks.clear();
114  fTrks.reserve(n);
115  for (int i = 0; i < n; ++i) {
116  double x,y,z;
117  gRandom->Sphere(x,y,z, p.R() );
118  fTrks.push_back( TrackD(q,Point3D( x,y,z )) );
119  }
120  }
121 
122 private:
123 
124  std::vector<TrackD> fTrks;
125 
126 };
127 
128 // cluster class (containing a vector of points)
129 
130 class ClusterD {
131 
132 public:
133 
134  ClusterD() {}
135 
138 
139 
140  Vector4D & Vec() { return fVec; }
141  Point3D & Pos() { return fPos[0]; }
142 
143  double mag2() const {
144  double s = fVec.mag2();
145  for (unsigned int i = 0; i < fPos.size() ; ++i)
146  s += fPos[i].mag2();
147  return s;
148  }
149 
150  void Set( const Vector4D & q, const Point3D & p) {
151  fVec = q;
152  int n = (gRandom->Poisson(4) + 1);
153  fPos.clear();
154  fPos.reserve(n);
155  for (int i = 0; i < n; ++i) {
156  double x,y,z;
157  gRandom->Sphere(x,y,z,p.R() );
158  fPos.push_back( Point3D( x,y,z ) );
159  }
160  }
161 
162 private:
163 
165  std::vector<Point3D> fPos;
166 
167 };
Scalar R() const
Polar R, converting if necessary from internal coordinate system.
Class describing a generic LorentzVector in the 4D space-time, using the specified coordinate system ...
Definition: LorentzVector.h:54
double mag2() const
Definition: Track.h:103
const Vector4D & Vec() const
Definition: Track.h:35
std::vector< Point3D > fPos
Definition: Track.h:165
void Set(const Vector4D &q, const Point3D &p)
Definition: Track.h:42
double mag2() const
Definition: Track.h:38
Class describing a generic position vector (point) in 3 dimensions.
VecTrackD()
Definition: Track.h:97
Vector4D fVec
Definition: Track.h:48
Point3D PointType
Definition: Track.h:29
Vector4D32 fVec
Definition: Track.h:81
std::vector< TrackD >::const_iterator It
Definition: Track.h:92
const Point3D32 & Pos() const
Definition: Track.h:69
Vector4D fVec
Definition: Track.h:164
Double_t x[n]
Definition: legend1.C:17
ROOT::Math::LorentzVector< ROOT::Math::PxPyPzE4D< double > > Vector4D
Definition: Track.h:14
Vector4D VectorType
Definition: Track.h:93
It end() const
Definition: Track.h:100
Point3D32 fPos
Definition: Track.h:82
Definition: Track.h:24
Vector4D32 VectorType
Definition: Track.h:60
ClusterD()
Definition: Track.h:134
TrackD32(const Vector4D32 &q, const Point3D32 &p)
Definition: Track.h:66
Point3D fPos
Definition: Track.h:49
Vector4D VectorType
Definition: Track.h:136
Point3D PointType
Definition: Track.h:94
ROOT::Math::LorentzVector< ROOT::Math::PxPyPzE4D< Double32_t > > Vector4D32
Definition: Track.h:15
void Set(const Vector4D &q, const Point3D &p)
Definition: Track.h:150
std::vector< TrackD > fTrks
Definition: Track.h:124
R__EXTERN TRandom * gRandom
Definition: TRandom.h:66
It begin() const
Definition: Track.h:99
void Set(const Vector4D32 &q, const Point3D32 &p)
Definition: Track.h:75
double mag2() const
Definition: Track.h:143
Point3D PointType
Definition: Track.h:137
Vector4D & Vec()
Definition: Track.h:140
TrackD32()
Definition: Track.h:64
ROOT::Math::PositionVector3D< ROOT::Math::Cartesian3D< Double32_t > > Point3D32
Definition: Track.h:19
double mag2() const
Definition: Track.h:71
Double_t y[n]
Definition: legend1.C:17
void Set(const Vector4D &q, const Point3D &p)
Definition: Track.h:111
const Vector4D32 & Vec() const
Definition: Track.h:68
double Double32_t
Definition: Track.h:10
TrackD()
Definition: Track.h:31
TrackD(const Vector4D &q, const Point3D &p)
Definition: Track.h:33
virtual void Sphere(Double_t &x, Double_t &y, Double_t &z, Double_t r)
Generates random vectors, uniformly distributed over the surface of a sphere of given radius...
Definition: TRandom.cxx:588
you should not use this method at all Int_t Int_t z
Definition: TRolke.cxx:630
Vector4D VectorType
Definition: Track.h:28
Point3D & Pos()
Definition: Track.h:141
const Point3D & Pos() const
Definition: Track.h:36
Definition: Track.h:56
virtual Int_t Poisson(Double_t mean)
Generates a random integer N according to a Poisson law.
Definition: TRandom.cxx:362
float * q
Definition: THbookFile.cxx:87
const Int_t n
Definition: legend1.C:16
Point3D32 PointType
Definition: Track.h:61
ROOT::Math::PositionVector3D< ROOT::Math::Cartesian3D< double > > Point3D
Definition: Track.h:18