Jpp  master_rocky-43-ge265d140c
the software that should make you happy
JGeometry.cc
Go to the documentation of this file.
1 #include <iostream>
2 #include <iomanip>
3 #include <fstream>
4 
5 #include "JTools/JGrid.hh"
7 #include "JAcoustics/JModel.hh"
8 
9 #include "Jeep/JParser.hh"
10 #include "Jeep/JMessage.hh"
11 
12 
13 /**
14  * Example application for acoustics geometry.
15  */
16 int main(int argc, char **argv)
17 {
18  using namespace std;
19  using namespace JPP;
20 
21  typedef JGrid<double> grid_type;
22 
23  JMODEL::JString parameters;
24  JMechanics mechanics;
25  grid_type grid;
26  string outputFile;
27  int debug;
28 
29  try {
30 
31  JParser<> zap("Example application for acoustics geometry.");
32 
33  zap['S'] = make_field(parameters) = JPARSER::initialised();
34  zap['M'] = make_field(mechanics) = JPARSER::initialised();
35  zap['G'] = make_field(grid);
36  zap['o'] = make_field(outputFile) = "";
37  zap['d'] = make_field(debug) = 3;
38 
39  zap(argc, argv);
40  }
41  catch(const exception &error) {
42  FATAL(error.what() << endl);
43  }
44 
45 
46  // build string
47 
48  const double x0 = 0.0;
49  const double y0 = 0.0;
50  const double z0 = 0.0;
51 
52  JGEOMETRY::JString string(JPosition3D(x0, y0, z0), mechanics);
53 
54  string.has_hydrophone = true;
55 
56  string[0] = JGEOMETRY::JFloor(z0);
57 
58  for (int i = 1; i <= grid.getSize(); ++i) {
59  string[i] = JGEOMETRY::JFloor(z0 + grid.getX(i - 1));
60  }
61 
62  cout << "tilt: "
63  << FIXED(6,3) << parameters.tx << ' '
64  << FIXED(6,3) << parameters.ty << endl;
65 
66  cout << " " << ' '
67  << " x " << ' '
68  << " y " << ' '
69  << " z " << ' '
70  << " dx " << ' '
71  << " dy " << ' '
72  << " dz " << endl;
73 
74  for (int i = 1; i <= grid.getSize(); ++i) {
75 
76  const JPosition3D pos[] = {
77  string.getPosition(parameters, i - 1),
78  string.getPosition(parameters, i)
79  };
80 
81  cout << setw(2) << i << ' '
82  << FIXED(7,3) << pos[1].getX() << ' '
83  << FIXED(7,3) << pos[1].getY() << ' '
84  << FIXED(7,3) << pos[1].getZ() << ' '
85  << FIXED(7,3) << pos[1].getX() - pos[0].getX() << ' '
86  << FIXED(7,3) << pos[1].getY() - pos[0].getY() << ' '
87  << FIXED(7,3) << pos[1].getZ() - pos[0].getZ() << endl;
88  }
89 
90  if (outputFile != "") {
91 
92  ofstream out(outputFile.c_str());
93 
94  for (int i = 1; i <= grid.getSize(); ++i) {
95 
96  const JPosition3D pos = string.getPosition(parameters, i);
97 
98  out << FIXED(7,3) << pos.getX() << ' ' << FIXED(7,3) << pos.getZ() << endl;
99  }
100 
101  out.close();
102  }
103 }
Model for fit to acoutsics data.
string outputFile
int main(int argc, char **argv)
Example application for acoustics geometry.
Definition: JGeometry.cc:16
Acoustic geometries.
General purpose messaging.
#define FATAL(A)
Definition: JMessage.hh:67
int debug
debug level
Definition: JSirene.cc:69
Utility class to parse command line options.
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
Definition: JParser.hh:2142
Data structure for position in three dimensions.
Definition: JPosition3D.hh:38
const JPosition3D & getPosition() const
Get position.
Definition: JPosition3D.hh:130
double getY() const
Get y position.
Definition: JVector3D.hh:104
double getZ() const
Get z position.
Definition: JVector3D.hh:115
double getX() const
Get x position.
Definition: JVector3D.hh:94
Utility class to parse command line options.
Definition: JParser.hh:1698
This name space includes all other name spaces (except KM3NETDAQ, KM3NET and ANTARES).
Definition: JSTDTypes.hh:14
Auxiliary data structure for floating point format specification.
Definition: JManip.hh:448
Auxiliary data structure for parameters of mechanical model.
Definition: JMechanics.hh:41
Empty structure for specification of parser element that is initialised (i.e. does not require input)...
Definition: JParser.hh:68