StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
helixTest1.cc
1 /***************************************************************************
2  *
3  * $Id: helixTest1.cc,v 1.4 2000/03/17 13:57:32 ullrich Exp $
4  *
5  * Author: Thomas Ullrich, April 1998
6  ***************************************************************************
7  *
8  * Description:
9  * Program to test StHelix
10  *
11  ***************************************************************************
12  *
13  * $Log: helixTest1.cc,v $
14  * Revision 1.4 2000/03/17 13:57:32 ullrich
15  * Updated. Include now also test of method which returns
16  * intersection with plane. Also made input more flexible.
17  *
18  * Revision 1.3 2000/02/02 19:05:15 ullrich
19  * Changed macros for CC5/CC4.2 compatibility
20  *
21  * Revision 1.2 1999/12/21 15:14:48 ullrich
22  * Modified to cope with new compiler version on Sun (CC5.0).
23  *
24  * Revision 1.1 1999/02/17 12:43:58 ullrich
25  * New Revision
26  *
27  * Revision 1.1 1999/01/23 00:26:44 ullrich
28  * Initial Revision
29  *
30  **************************************************************************/
31 #include "StHelix.hh"
32 #include "StPrompt.hh"
33 #include "SystemOfUnits.h"
34 
35 #ifndef ST_NO_NAMESPACES
36 using namespace units;
37 #endif
38 int main(int, char* argc[])
39 {
40  double curvature = 0;
41  double dipAngle = 0;
42  double phase = 0;
43  double x0 = 0;
44  double y0 = 0;
45  double z0 = 0;
46  int H = -1;
47  pair<double, double> s;
48 
49  StHelix *helix = 0;
50  bool moreHelices = true;
51  bool moreTests = true;
52  bool radunits = true;
53  double r = 0.1;
54  char selection = 'v';
55  double slow = 0, sup = 0, ds = 0, ss = 0;
56  StThreeVector<double> origin, point, mmpoint, rv, nv;
57 
58  cout << "This is test program " << argc[0] << endl << endl;
59 
60  while(moreHelices) {
61  moreTests = true;
62  cout << "Enter helix parameter:" << endl;
63  StPrompt("Angles in radians (else degrees)", radunits);
64  StPrompt("Enter curvature", curvature);
65  if (radunits) {
66  StPrompt("dipAngle in rad", dipAngle);
67  StPrompt("phase in rad", phase);
68  }
69  else {
70  StPrompt("dipAngle in degree", dipAngle);
71  StPrompt("phase in degree", phase);
72  }
73  StPrompt("-sign(q*B)", H);
74  StPrompt("xyz of origin", origin);
75 
76  delete helix;
77  helix = new StHelix(curvature,
78  (radunits ? dipAngle : dipAngle*degree),
79  (radunits ? phase : phase*degree),
80  origin,
81  H);
82  if (!helix->valid()) {
83  cerr << "Error: parametrization is not valid" << endl;
84  }
85  else {
86  //
87  // Print helix parameters
88  //
89  cout << endl;
90  cout << "The helix parameter are:" << endl;
91  cout << *helix << endl;
92  cout << "The period of the helix is: " << helix->period() << endl;
93 
94  while(moreTests) {
95  //
96  // Selection menu
97  //
98  cout << endl;
99  cout << "Select one of the following:" << endl;
100  cout << "Print helix points along its path ..... v" << endl;
101  cout << "Test pathLength(r) method ............. r" << endl;
102  cout << "Test pathLength(point) method ......... p" << endl;
103  cout << "Test pathLength(plane) method ......... e" << endl;
104  cout << "Test distance(point) method ........... d" << endl;
105  StPrompt("Enter your selection", selection);
106 
107  switch (selection) {
108  case 'e':
109  StPrompt("vector r to a point in the plane", rv);
110  StPrompt("normal vector n for plane", nv);
111  ss = helix->pathLength(rv, nv);
112  cout << "s = " << ss << " -> " << helix->at(ss) << endl;
113  break;
114  case 'v':
115  StPrompt("lower s", slow);
116  StPrompt("upper s", sup);
117  StPrompt("step size", ds);
118  for (ss = slow; ss < sup; ss+= ds)
119  cout << "s = " << ss << " -> " << helix->at(ss) << endl;
120  break;
121  case 'r':
122  StPrompt("Enter a radius", r);
123  s = helix->pathLength(r);
124  cout << "The helix reaches r at s1 = " << s.first
125  << " and s2 = " << s.second << endl;
126  cout << "Crosscheck radius1 = " << helix->at(s.first).perp()
127  << ", delta_r = " << r*meter-helix->at(s.first).perp() << endl;
128  cout << "Crosscheck radius2 = " << helix->at(s.second).perp()
129  << ", delta_r = " << r*meter-helix->at(s.second).perp() << endl;
130  break;
131  case 'p':
132  StPrompt("xyz of point", point);
133  mmpoint = point;
134  ss = helix->pathLength(mmpoint);
135  cout << "The helix reaches r at s = " << ss << endl;
136  cout << "Crosscheck point = " << helix->at(ss)
137  << ", delta = " << abs(mmpoint-helix->at(ss)) << endl;
138  break;
139  case 'd':
140  StPrompt("xyz of point", point);
141  mmpoint = point;
142  cout << "The closest distance from the helix to the point is: "
143  << helix->distance(mmpoint) << endl;
144  break;
145  default:
146  break;
147  }
148  cout << endl;
149 #if defined (__SUNPRO_CC) && __SUNPRO_CC < 0x500
150  StBoolPrompt("another test", moreTests);
151 #else
152  StPrompt("another test", moreTests);
153 #endif
154  }
155  cout << endl;
156 #if defined (__SUNPRO_CC) && __SUNPRO_CC < 0x500
157  StBoolPrompt("define another helix", moreHelices);
158 #else
159  StPrompt("define another helix", moreHelices);
160 #endif
161  }
162  }
163  cout << "end of example" << endl;
164  return 0;
165 }
bool valid(double world=1.e+5) const
checks for valid parametrization
Definition: StHelix.hh:128
double distance(const StThreeVector< double > &p, bool scanPeriods=true) const
minimal distance between point and helix
Definition: StHelix.cc:240
pair< double, double > pathLength(double r) const
path length at given r (cylindrical r)
Definition: StHelix.cc:351
double period() const
returns period length of helix
Definition: StHelix.cc:339