Hall-D Software  alpha
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
DLine.cc
Go to the documentation of this file.
1 #include "DLine.h"
2 using namespace std;
3 
4 #define DELTA_R = 10000.0
5 
6 // default constructor line along z-axis
7 DLine::DLine() : r0(0.0, 0.0, 0.0), r1(0.0, 0.0, 1.0), debug_level(0) {}
8 
9 DLine::DLine(Hep3Vector r0_in, Hep3Vector r1_in, int level): r0(r0_in), r1(r1_in), debug_level(level) {};
10 
11 DLine::DLine(double x, double y, double z, double theta, double phi, int level) : debug_level(level) {
12  r0(0) = x;
13  r0(1) = y;
14  r0(2) = z;
15  double sinth = sin(theta);
16  r1(0) = x + sinth*cos(phi);
17  r1(1) = y + sinth*sin(phi);
18  r1(2) = z + cos(theta);
19  if (debug_level > 2) cout << "DLine::DLine: line constructed: " << r0 << r1 << endl;
20  return;
21 }
22 
23 double DLine::doca(HepVector point) {
24  Hep3Vector point3(point(1), point(2), point(3));
25  return doca(point3);
26 }
27 
28 double DLine::doca(Hep3Vector point) {
29  Hep3Vector num, diff;
30  diff = r1 - r0;
31  num = diff.cross(r0 - point);
32  double doca = num.mag()/diff.mag();
33  if (debug_level >= 4) cout << "DLine:doca: num = " << num.mag() << " diff = " << diff.mag() << " doca = " << doca << endl;
34  return doca;
35 };
36 
37 HepVector DLine::poca(HepVector point) {
38  Hep3Vector point3(point(1), point(2), point(3)), poca3;
39  poca3 = poca(point3);
40  HepVector poca(3);
41  poca(1) = poca3(0);
42  poca(2) = poca3(1);
43  poca(3) = poca3(2);
44  return poca;
45 }
46 
47 Hep3Vector DLine::poca(Hep3Vector point) {
48  double t;
49  Hep3Vector diff;
50  diff = r1 - r0;
51  t = (point - r0)*diff/diff.mag2();
52  Hep3Vector poca = r0 + diff*t;
53  // cout << point << r0 << r1 << diff << t << poca << endl;
54  return poca;
55 };
56 
double doca(HepVector point)
Definition: DLine.cc:23
Hep3Vector r1
Definition: DLine.h:18
Double_t x[NCHANNELS]
Definition: st_tw_resols.C:39
#define y
int debug_level
Definition: DLine.h:19
HepVector poca(HepVector point)
Definition: DLine.cc:37
Hep3Vector r0
Definition: DLine.h:18
DLine()
Definition: DLine.cc:7
double sin(double)