ECCE @ EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
DefaultHepRepPoint.cc
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file DefaultHepRepPoint.cc
1 // Copyright FreeHEP, 2005.
2 
3 #include <string>
4 #include <iostream>
5 #include <cmath>
6 
8 
9 using namespace std;
10 using namespace HEPREP;
11 
15 namespace cheprep {
16 
17 DefaultHepRepPoint::DefaultHepRepPoint(HepRepInstance* inst, double xx, double yy, double zz)
18  : DefaultHepRepAttribute(), instance(inst), x(xx), y(yy), z(zz) {
19 
20  if (instance == NULL) {
21  cerr << "HepRepPoints cannot be created without a HepRepInstance." << endl;
22  } else {
23  instance->addPoint(this);
24  }
25 }
26 
28 }
29 
31  return instance;
32 }
33 
35  HepRepAttValue* value = getAttValueFromNode(lowerCaseName);
36  return (value != NULL) ? value : instance->getAttValue(lowerCaseName);
37 }
38 
40  return new DefaultHepRepPoint(inst, x, y, z);
41 }
42 
44  return x;
45 }
46 
48  return y;
49 }
50 
52  return z;
53 }
54 
55 vector<double>* DefaultHepRepPoint::getXYZ(vector<double>* xyz) {
56  (*xyz)[0] = x;
57  (*xyz)[1] = y;
58  (*xyz)[2] = z;
59  return xyz;
60 }
61 
63  return sqrt(x*x + y*y);
64 }
65 
67  return atan2(y, x);
68 }
69 
71  return atan2(getRho(), z);
72 }
73 
75  double r = getRho();
76  return sqrt(r*r + z*z);
77 }
78 
80  double ct = cos(getTheta());
81  return -0.5*log((1.-ct)/(1.+ct));
82 }
83 
84 double DefaultHepRepPoint::getX(double xVertex, double, double) {
85  return x - xVertex;
86 }
87 
88 double DefaultHepRepPoint::getY(double, double yVertex, double) {
89  return y - yVertex;
90 }
91 
92 double DefaultHepRepPoint::getZ(double, double, double zVertex) {
93  return z - zVertex;
94 }
95 
96 double DefaultHepRepPoint::getRho(double xVertex, double yVertex, double zVertex) {
97  double dx = getX(xVertex, yVertex, zVertex);
98  double dy = getY(xVertex, yVertex, zVertex);
99  return sqrt(dx*dx + dy*dy);
100 }
101 
102 double DefaultHepRepPoint::getPhi(double xVertex, double yVertex, double zVertex) {
103  return atan2(getY(xVertex, yVertex, zVertex), getX(xVertex, yVertex, zVertex));
104 }
105 
106 double DefaultHepRepPoint::getTheta(double xVertex, double yVertex, double zVertex) {
107  return atan2(getRho(xVertex, yVertex, zVertex), getZ(xVertex, yVertex, zVertex));
108 }
109 
110 double DefaultHepRepPoint::getR(double xVertex, double yVertex, double zVertex) {
111  double dr = getRho(xVertex, yVertex, zVertex);
112  double dz = getZ(xVertex, yVertex, zVertex);
113  return sqrt(dr*dr + dz*dz);
114 }
115 
116 double DefaultHepRepPoint::getEta(double xVertex, double yVertex, double zVertex) {
117  double ct = cos(getTheta(xVertex, yVertex, zVertex));
118  return -0.5*log((1.-ct)/(1.+ct));
119 }
120 
121 
122 } // cheprep
123