Geant4_10
DefaultHepRepPoint.cc
Go to the documentation of this file.
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 
16 namespace cheprep {
17 
18 DefaultHepRepPoint::DefaultHepRepPoint(HepRepInstance* inst, double xx, double yy, double zz)
19  : DefaultHepRepAttribute(), instance(inst), x(xx), y(yy), z(zz) {
20 
21  if (instance == NULL) {
22  cerr << "HepRepPoints cannot be created without a HepRepInstance." << endl;
23  } else {
24  instance->addPoint(this);
25  }
26 }
27 
29 }
30 
32  return instance;
33 }
34 
36  HepRepAttValue* value = getAttValueFromNode(lowerCaseName);
37  return (value != NULL) ? value : instance->getAttValue(lowerCaseName);
38 }
39 
41  return new DefaultHepRepPoint(inst, x, y, z);
42 }
43 
45  return x;
46 }
47 
49  return y;
50 }
51 
53  return z;
54 }
55 
56 vector<double>* DefaultHepRepPoint::getXYZ(vector<double>* xyz) {
57  (*xyz)[0] = x;
58  (*xyz)[1] = y;
59  (*xyz)[2] = z;
60  return xyz;
61 }
62 
64  return sqrt(x*x + y*y);
65 }
66 
68  return atan2(y, x);
69 }
70 
72  return atan2(getRho(), z);
73 }
74 
76  double r = getRho();
77  return sqrt(r*r + z*z);
78 }
79 
81  double ct = cos(getTheta());
82  return -0.5*log((1.-ct)/(1.+ct));
83 }
84 
85 double DefaultHepRepPoint::getX(double xVertex, double, double) {
86  return x - xVertex;
87 }
88 
89 double DefaultHepRepPoint::getY(double, double yVertex, double) {
90  return y - yVertex;
91 }
92 
93 double DefaultHepRepPoint::getZ(double, double, double zVertex) {
94  return z - zVertex;
95 }
96 
97 double DefaultHepRepPoint::getRho(double xVertex, double yVertex, double zVertex) {
98  double dx = getX(xVertex, yVertex, zVertex);
99  double dy = getY(xVertex, yVertex, zVertex);
100  return sqrt(dx*dx + dy*dy);
101 }
102 
103 double DefaultHepRepPoint::getPhi(double xVertex, double yVertex, double zVertex) {
104  return atan2(getY(xVertex, yVertex, zVertex), getX(xVertex, yVertex, zVertex));
105 }
106 
107 double DefaultHepRepPoint::getTheta(double xVertex, double yVertex, double zVertex) {
108  return atan2(getRho(xVertex, yVertex, zVertex), getZ(xVertex, yVertex, zVertex));
109 }
110 
111 double DefaultHepRepPoint::getR(double xVertex, double yVertex, double zVertex) {
112  double dr = getRho(xVertex, yVertex, zVertex);
113  double dz = getZ(xVertex, yVertex, zVertex);
114  return sqrt(dr*dr + dz*dz);
115 }
116 
117 double DefaultHepRepPoint::getEta(double xVertex, double yVertex, double zVertex) {
118  double ct = cos(getTheta(xVertex, yVertex, zVertex));
119  return -0.5*log((1.-ct)/(1.+ct));
120 }
121 
122 
123 } // cheprep
124 
Double_t yy
Definition: macro.C:11
Double_t xx
Definition: macro.C:10
HEPREP::HepRepInstance * getInstance()
tuple x
Definition: test.py:50
Double_t y
Definition: plot.C:279
virtual void addPoint(HepRepPoint *point)=0
std::vector< double > * getXYZ(std::vector< double > *xyz)
HEPREP::HepRepPoint * copy(HEPREP::HepRepInstance *parent)
Double_t zz
Definition: macro.C:12
jump r
Definition: plot.C:36
virtual HepRepAttValue * getAttValue(std::string name)=0
HEPREP::HepRepAttValue * getAttValueFromNode(std::string lowerCaseName)
tuple z
Definition: test.py:28
const XML_Char int const XML_Char * value
Definition: expat.h:331
DefaultHepRepPoint(HEPREP::HepRepInstance *instance, double x, double y, double z)
HEPREP::HepRepAttValue * getAttValue(std::string lowerCaseName)