Geant4  10.01.p02
DefaultHepRepPoint.cc
Go to the documentation of this file.
1 // Copyright FreeHEP, 2005.
2 
3 #include <string>
4 #include <iostream>
5 #include <cmath>
6 
7 #include "cheprep/DefaultHepRepPoint.h"
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 
28 DefaultHepRepPoint::~DefaultHepRepPoint() {
29 }
30 
31 HepRepInstance* DefaultHepRepPoint::getInstance() {
32  return instance;
33 }
34 
35 HepRepAttValue* DefaultHepRepPoint::getAttValue(string lowerCaseName) {
36  HepRepAttValue* value = getAttValueFromNode(lowerCaseName);
37  return (value != NULL) ? value : instance->getAttValue(lowerCaseName);
38 }
39 
40 HepRepPoint* DefaultHepRepPoint::copy(HepRepInstance* inst) {
41  return new DefaultHepRepPoint(inst, x, y, z);
42 }
43 
44 double DefaultHepRepPoint::getX() {
45  return x;
46 }
47 
48 double DefaultHepRepPoint::getY() {
49  return y;
50 }
51 
52 double DefaultHepRepPoint::getZ() {
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 
63 double DefaultHepRepPoint::getRho() {
64  return sqrt(x*x + y*y);
65 }
66 
67 double DefaultHepRepPoint::getPhi() {
68  return atan2(y, x);
69 }
70 
71 double DefaultHepRepPoint::getTheta() {
72  return atan2(getRho(), z);
73 }
74 
75 double DefaultHepRepPoint::getR() {
76  double r = getRho();
77  return sqrt(r*r + z*z);
78 }
79 
80 double DefaultHepRepPoint::getEta() {
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 
G4double z
Definition: TRTMaterials.hh:39
void copy(std::vector< T > &main, const std::vector< T > &data)
Definition: DicomRun.hh:91
static MCTruthManager * instance