Geant4 9.6.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 * @version $Id: DefaultHepRepPoint.cc,v 1.5 2005-06-02 21:28:45 duns Exp $
15 */
16namespace cheprep {
17
18DefaultHepRepPoint::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
56vector<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
85double DefaultHepRepPoint::getX(double xVertex, double, double) {
86 return x - xVertex;
87}
88
89double DefaultHepRepPoint::getY(double, double yVertex, double) {
90 return y - yVertex;
91}
92
93double DefaultHepRepPoint::getZ(double, double, double zVertex) {
94 return z - zVertex;
95}
96
97double 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
103double DefaultHepRepPoint::getPhi(double xVertex, double yVertex, double zVertex) {
104 return atan2(getY(xVertex, yVertex, zVertex), getX(xVertex, yVertex, zVertex));
105}
106
107double DefaultHepRepPoint::getTheta(double xVertex, double yVertex, double zVertex) {
108 return atan2(getRho(xVertex, yVertex, zVertex), getZ(xVertex, yVertex, zVertex));
109}
110
111double 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
117double 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
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)