Jpp  15.0.3
the software that should make you happy
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
JAHRSCalibrationToolkit.hh
Go to the documentation of this file.
1 #ifndef __JDB_JAHRSCALIBRATIONTOOLKIT__
2 #define __JDB_JAHRSCALIBRATIONTOOLKIT__
3 
5 
6 #include "JTools/JRange.hh"
7 #include "JLang/JLangToolkit.hh"
8 #include "JLang/JManip.hh"
9 
10 /**
11  * \author mdejong
12  */
13 namespace JDATABASE {}
14 namespace JPP { using namespace JDATABASE; }
15 
16 namespace JDATABASE {
17 
18 
19  /**
20  * Read AHRS calibration from input stream.
21  *
22  * \param in input stream
23  * \param calibration AHRS calibration
24  * \return input stream
25  */
26  inline std::istream& operator>>(std::istream& in, JAHRSCalibration& calibration)
27  {
28  using namespace std;
29  using namespace JPP;
30 
31  in >> calibration.ACC_OFFSET_X
32  >> calibration.ACC_OFFSET_Y
33  >> calibration.ACC_OFFSET_Z;
34 
35  in >> calibration.ACC_ROT_XX >> calibration.ACC_ROT_XY >> calibration.ACC_ROT_XZ;
36  in >> calibration.ACC_ROT_YX >> calibration.ACC_ROT_YY >> calibration.ACC_ROT_YZ;
37  in >> calibration.ACC_ROT_ZX >> calibration.ACC_ROT_ZY >> calibration.ACC_ROT_ZZ;
38 
39  in >> calibration.MAG_XMIN
40  >> calibration.MAG_YMIN
41  >> calibration.MAG_ZMIN;
42 
43  in >> calibration.MAG_XMAX
44  >> calibration.MAG_YMAX
45  >> calibration.MAG_ZMAX;
46 
47  in >> calibration.MAG_ROT_XX >> calibration.MAG_ROT_XY >> calibration.MAG_ROT_XZ;
48  in >> calibration.MAG_ROT_YX >> calibration.MAG_ROT_YY >> calibration.MAG_ROT_YZ;
49  in >> calibration.MAG_ROT_ZX >> calibration.MAG_ROT_ZY >> calibration.MAG_ROT_ZZ;
50 
51  return in;
52  }
53 
54 
55  /**
56  * Write AHRS calibration to output stream.
57  *
58  * \param out output stream
59  * \param calibration AHRS calibration
60  * \return output stream
61  */
62  inline std::ostream& operator<<(std::ostream& out, const JAHRSCalibration& calibration)
63  {
64  using namespace std;
65  using namespace JPP;
66 
67  out << FIXED(9,6) << calibration.ACC_OFFSET_X << ' '
68  << FIXED(9,6) << calibration.ACC_OFFSET_Y << ' '
69  << FIXED(9,6) << calibration.ACC_OFFSET_Z << ' ';
70 
71  out << FIXED(9,6) << calibration.ACC_ROT_XX << ' ' << FIXED(9,6) << calibration.ACC_ROT_XY << ' ' << FIXED(9,6) << calibration.ACC_ROT_XZ << ' ';
72  out << FIXED(9,6) << calibration.ACC_ROT_YX << ' ' << FIXED(9,6) << calibration.ACC_ROT_YY << ' ' << FIXED(9,6) << calibration.ACC_ROT_YZ << ' ';
73  out << FIXED(9,6) << calibration.ACC_ROT_ZX << ' ' << FIXED(9,6) << calibration.ACC_ROT_ZY << ' ' << FIXED(9,6) << calibration.ACC_ROT_ZZ << ' ';
74 
75  out << FIXED(9,6) << calibration.MAG_XMIN << ' '
76  << FIXED(9,6) << calibration.MAG_YMIN << ' '
77  << FIXED(9,6) << calibration.MAG_ZMIN << ' ';
78 
79  out << FIXED(9,6) << calibration.MAG_XMAX << ' '
80  << FIXED(9,6) << calibration.MAG_YMAX << ' '
81  << FIXED(9,6) << calibration.MAG_ZMAX << ' ';
82 
83  out << FIXED(9,6) << calibration.MAG_ROT_XX << ' ' << FIXED(9,6) << calibration.MAG_ROT_XY << ' ' << FIXED(9,6) << calibration.MAG_ROT_XZ << ' ';
84  out << FIXED(9,6) << calibration.MAG_ROT_YX << ' ' << FIXED(9,6) << calibration.MAG_ROT_YY << ' ' << FIXED(9,6) << calibration.MAG_ROT_YZ << ' ';
85  out << FIXED(9,6) << calibration.MAG_ROT_ZX << ' ' << FIXED(9,6) << calibration.MAG_ROT_ZY << ' ' << FIXED(9,6) << calibration.MAG_ROT_ZZ << ' ';
86 
87  return out;
88  }
89 
90 
91  /**
92  * Get numerical value of AHRS calibration version.
93  *
94  * \param version version
95  * \return version
96  */
97  inline int getVersion(const std::string& version)
98  {
99  using namespace std;
100  using namespace JPP;
101 
102  size_t pos = version.find_last_of("vV");
103 
104  if (pos != string::npos)
105  return to_value<int>(version.substr(pos+1));
106  else
107  return -1;
108  }
109 
110 
111  /**
112  * Auxiliary data structure to check validity of AHRS calibration data.
113  */
115 
117 
118  /**
119  * Default constructor.
120  *
121  * This constructor sets default ranges of acceptance of AHRS calibration values.
122  */
124  {
125  ACC_OFFSET_X = range_type(-1.0, +1.0);
126  ACC_OFFSET_Y = range_type(-1.0, +1.0);
127  ACC_OFFSET_Z = range_type(-1.0, +1.0);
128 
129  ACC_ROT[0][0] = range_type(+0.6, +1.8); ACC_ROT[0][1] = range_type(-1.0, +1.0); ACC_ROT[0][2] = range_type(-1.0, +1.0);
130  ACC_ROT[1][0] = range_type(-1.0, +1.0); ACC_ROT[1][1] = range_type(+0.6, +1.8); ACC_ROT[1][2] = range_type(-1.0, +1.0);
131  ACC_ROT[2][0] = range_type(-1.0, +1.0); ACC_ROT[2][1] = range_type(-1.0, +1.0); ACC_ROT[2][2] = range_type(+0.6, +1.8);
132 
133  MAG_OFFSET_X = range_type(-1.0, +1.0);
134  MAG_OFFSET_Y = range_type(-1.0, +1.0);
135  MAG_OFFSET_Z = range_type(-1.0, +1.0);
136 
137  MAG_ROT[0][0] = range_type(+0.6, +1.8); MAG_ROT[0][1] = range_type(-1.0, +1.0); MAG_ROT[0][2] = range_type(-1.0, +1.0);
138  MAG_ROT[1][0] = range_type(-1.0, +1.0); MAG_ROT[1][1] = range_type(+0.6, +1.8); MAG_ROT[1][2] = range_type(-1.0, +1.0);
139  MAG_ROT[2][0] = range_type(-1.0, +1.0); MAG_ROT[2][1] = range_type(-1.0, +1.0); MAG_ROT[2][2] = range_type(+0.6, +1.8);
140  }
141 
142 
143  /**
144  * Check validity of AHRS calibration data.
145  *
146  * \param calibration AHRS calibration
147  * \return true if valid; else false
148  */
149  bool operator()(const JAHRSCalibration& calibration) const
150  {
151  return (ACC_OFFSET_X(calibration.ACC_OFFSET_X) &&
152  ACC_OFFSET_Y(calibration.ACC_OFFSET_Y) &&
153  ACC_OFFSET_Z(calibration.ACC_OFFSET_Z) &&
154 
155  ACC_ROT[0][0](calibration.ACC_ROT_XX) && ACC_ROT[0][1](calibration.ACC_ROT_XY) && ACC_ROT[0][2](calibration.ACC_ROT_XZ) &&
156  ACC_ROT[1][0](calibration.ACC_ROT_YX) && ACC_ROT[1][1](calibration.ACC_ROT_YY) && ACC_ROT[1][2](calibration.ACC_ROT_YZ) &&
157  ACC_ROT[2][0](calibration.ACC_ROT_ZX) && ACC_ROT[2][1](calibration.ACC_ROT_ZY) && ACC_ROT[2][2](calibration.ACC_ROT_ZZ) &&
158 
159  MAG_OFFSET_X(0.5 * (calibration.MAG_XMIN + calibration.MAG_XMAX)) &&
160  MAG_OFFSET_Y(0.5 * (calibration.MAG_YMIN + calibration.MAG_YMAX)) &&
161  MAG_OFFSET_Z(0.5 * (calibration.MAG_ZMIN + calibration.MAG_ZMAX)) &&
162 
163  MAG_ROT[0][0](calibration.MAG_ROT_XX) && MAG_ROT[0][1](calibration.MAG_ROT_XY) && MAG_ROT[0][2](calibration.MAG_ROT_XZ) &&
164  MAG_ROT[1][0](calibration.MAG_ROT_YX) && MAG_ROT[1][1](calibration.MAG_ROT_YY) && MAG_ROT[1][2](calibration.MAG_ROT_YZ) &&
165  MAG_ROT[2][0](calibration.MAG_ROT_ZX) && MAG_ROT[2][1](calibration.MAG_ROT_ZY) && MAG_ROT[2][2](calibration.MAG_ROT_ZZ));
166  }
167 
168 
172 
173  range_type ACC_ROT[3][3];
174 
178 
179  range_type MAG_ROT[3][3];
180  };
181 
182 
183  /**
184  * Auxiliary data structure for sorting of AHRS calibrations.
185  */
187  public std::binary_function<const JAHRSCalibration&, const JAHRSCalibration&, bool>
188  {
189  /**
190  * Comparison of operation identifiers.
191  *
192  * \param first first operation identifiers
193  * \param second second operation identifiers
194  * \return true if first calibration before second; else false
195  */
196  inline bool operator()(const std::string& first,
197  const std::string& second) const
198  {
199  using namespace std;
200  using namespace JPP;
201 
202  if (!first.empty() && !second.empty()) {
203 
204  if (first[0] == second[0])
205  return to_value<int>(first.substr(1)) < to_value<int>(second.substr(1));
206  else
207  return first[0] < second[0];
208 
209  } else {
210 
211  return first < second;
212  }
213  }
214 
215 
216  /**
217  * Comparison of AHRS calibrations.
218  *
219  * \param first first AHRS calibration
220  * \param second second AHRS calibration
221  * \return true if first AHRS calibration less then second; else false
222  */
223  inline bool operator()(const JAHRSCalibration& first,
224  const JAHRSCalibration& second) const
225  {
226  if (first.SERIALNUMBER == second.SERIALNUMBER) {
227 
228  if (first.TESTEND == second.TESTEND) {
229 
230  if (getVersion(first.TESTNAME) == getVersion(second.TESTNAME))
231  return (*this)(first.TESTOPID, second.TESTOPID);
232  else
233  return getVersion(first.TESTNAME) < getVersion(second.TESTNAME);
234 
235  } else {
236 
237  return first.TESTEND < second.TESTEND;
238  }
239 
240  } else {
241 
242  return first.SERIALNUMBER < second.SERIALNUMBER;
243  }
244  }
245  };
246 }
247 
248 #endif
bool operator()(const JAHRSCalibration &first, const JAHRSCalibration &second) const
Comparison of AHRS calibrations.
bool operator()(const JAHRSCalibration &calibration) const
Check validity of AHRS calibration data.
int getVersion(const std::string &version)
Get numerical value of AHRS calibration version.
Auxiliary data structure for floating point format specification.
Definition: JManip.hh:446
Auxiliary data structure for sorting of AHRS calibrations.
then echo The file $DIR KM3NeT_00000001_00000000 root already please rename or remove it first
I/O manipulators.
std::istream & operator>>(std::istream &in, JAANET::JHead &header)
Read header from input.
Definition: JHead.hh:1693
bool operator()(const std::string &first, const std::string &second) const
Comparison of operation identifiers.
Auxiliary class to define a range between two values.
Auxiliary data structure to check validity of AHRS calibration data.
std::ostream & operator<<(std::ostream &stream, const CLBCommonHeader &header)
then fatal Wrong number of arguments fi set_variable DETECTOR $argv[1] set_variable INPUT_FILE $argv[2] eval JPrintDetector a $DETECTOR O IDENTIFIER eval JPrintDetector a $DETECTOR O SUMMARY source JAcoustics sh $DETECTOR_ID CHECK_EXIT_CODE typeset A TRIPODS get_tripods $WORKDIR tripod txt TRIPODS for EMITTER in
Definition: JCanberra.sh:42
version
Definition: JCalibratePMT.sh:7