Geant4 10.7.0
Toolkit for the simulation of the passage of particles through matter
Loading...
Searching...
No Matches
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
9using namespace std;
10using namespace HEPREP;
11
12/**
13 * @author Mark Donszelmann
14 */
15namespace cheprep {
16
17DefaultHepRepPoint::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
55vector<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
84double DefaultHepRepPoint::getX(double xVertex, double, double) {
85 return x - xVertex;
86}
87
88double DefaultHepRepPoint::getY(double, double yVertex, double) {
89 return y - yVertex;
90}
91
92double DefaultHepRepPoint::getZ(double, double, double zVertex) {
93 return z - zVertex;
94}
95
96double 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
102double DefaultHepRepPoint::getPhi(double xVertex, double yVertex, double zVertex) {
103 return atan2(getY(xVertex, yVertex, zVertex), getX(xVertex, yVertex, zVertex));
104}
105
106double DefaultHepRepPoint::getTheta(double xVertex, double yVertex, double zVertex) {
107 return atan2(getRho(xVertex, yVertex, zVertex), getZ(xVertex, yVertex, zVertex));
108}
109
110double 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
116double 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
virtual HepRepAttValue * getAttValue(std::string name)=0
virtual void addPoint(HepRepPoint *point)=0
HEPREP::HepRepAttValue * getAttValueFromNode(std::string lowerCaseName)
DefaultHepRepPoint(HEPREP::HepRepInstance *instance, double x, double y, double z)
HEPREP::HepRepAttValue * getAttValue(std::string lowerCaseName)
std::vector< double > * getXYZ(std::vector< double > *xyz)
HEPREP::HepRepInstance * getInstance()
HEPREP::HepRepPoint * copy(HEPREP::HepRepInstance *parent)