Jpp - the software that should make you happy
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
JDetectorHeader.hh
Go to the documentation of this file.
1 #ifndef __JDETECTOR__JDETECTORHEADER__
2 #define __JDETECTOR__JDETECTORHEADER__
3 
4 #include <istream>
5 #include <ostream>
6 #include <limits>
7 
8 #include "JUTC/JUTCTimeRange.hh"
9 #include "JUTM/JUTMGrid.hh"
10 #include "JUTM/JUTMPosition.hh"
11 #include "JIO/JSerialisable.hh"
12 #include "JLang/JEquals.hh"
14 #include "Jeep/JProperties.hh"
15 
16 
17 /**
18  * \author mdejong
19  */
20 
21 namespace JDETECTOR {}
22 namespace JPP { using namespace JDETECTOR; }
23 
24 namespace JDETECTOR {
25 
26  using JUTC::JUTCTimeRange;
27  using JUTM::JUTMGrid;
28  using JUTM::JUTMPosition;
29  using JIO::JReader;
30  using JIO::JWriter;
31  using JLANG::JEquals;
33 
34 
35  /**
36  * Data structure for detector header.
37  */
39  public JUTCTimeRange,
40  public JUTMGrid,
41  public JUTMPosition,
42  public JEquals<JDetectorHeader>
43  {
44  public:
45  /**
46  * Default constructor.
47  */
49  JUTCTimeRange(),
50  JUTMGrid (),
51  JUTMPosition ()
52  {}
53 
54 
55  /**
56  * Constructor.
57  *
58  * \param range UTC time range
59  * \param grid UTM grid
60  * \param pos UTM position
61  */
63  const JUTMGrid& grid,
64  const JUTMPosition& pos) :
65  JUTCTimeRange(range),
66  JUTMGrid (grid),
67  JUTMPosition (pos)
68  {}
69 
70 
71  /**
72  * Check equality.
73  *
74  * \param header header
75  * \param precision precision
76  * \return true if headers are equal; else false
77  */
78  bool equals(const JDetectorHeader& header,
79  const double precision = std::numeric_limits<double>::min()) const
80  {
81  return (this->getUTMGrid() == header.getUTMGrid() && this->getDisplacement(header.getUTMPosition()) < precision);
82  }
83 
84 
85  /**
86  * Read detector header from input.
87  *
88  * \param in input stream
89  * \param header header
90  * \return input stream
91  */
92  friend inline std::istream& operator>>(std::istream& in, JDetectorHeader& header)
93  {
94  in >> static_cast<JUTCTimeRange&>(header);
95  in >> static_cast<JUTMGrid&> (header);
96  in >> static_cast<JUTMPosition&> (header);
97 
98  return in;
99  }
100 
101 
102  /**
103  * Write detector header to output.
104  *
105  * \param out output stream
106  * \param header header
107  * \return output stream
108  */
109  friend inline std::ostream& operator<<(std::ostream& out, const JDetectorHeader& header)
110  {
111  using namespace std;
112 
113  out << static_cast<const JUTCTimeRange&>(header);
114  out << endl;
115  out << static_cast<const JUTMGrid&> (header);
116  out << ' ';
117  out << static_cast<const JUTMPosition&> (header);
118 
119  return out;
120  }
121 
122 
123  /**
124  * Read detector header from input.
125  *
126  * \param in input stream
127  * \param header header
128  * \return input stream
129  */
130  friend inline JReader& operator>>(JReader& in, JDetectorHeader& header)
131  {
132  in >> static_cast<JUTCTimeRange&>(header);
133  in >> static_cast<JUTMGrid&> (header);
134  in >> static_cast<JUTMPosition&> (header);
135 
136  return in;
137  }
138 
139 
140  /**
141  * Write detector header to output.
142  *
143  * \param out output stream
144  * \param header header
145  * \return output stream
146  */
147  friend inline JWriter& operator<<(JWriter& out, const JDetectorHeader& header)
148  {
149  out << static_cast<const JUTCTimeRange&>(header);
150  out << static_cast<const JUTMGrid&> (header);
151  out << static_cast<const JUTMPosition&> (header);
152 
153  return out;
154  }
155 
156 
157  /**
158  * Get equation parameters.
159  *
160  * \return equation parameters
161  */
163  {
164  static JEquationParameters equation;
165 
166  return equation;
167  }
168 
169 
170 
171  /**
172  * Set equation parameters.
173  *
174  * \param equation equation parameters
175  */
176  static inline void setEquationParameters(const JEquationParameters& equation)
177  {
178  getEquationParameters() = equation;
179  }
180 
181 
182  /**
183  * Get properties of this class.
184  *
185  * \param equation equation parameters
186  */
188  {
189  return JDetectorHeaderHelper(*this, equation);
190  }
191 
192 
193  /**
194  * Get properties of this class.
195  *
196  * \param equation equation parameters
197  */
199  {
200  return JDetectorHeaderHelper(*this, equation);
201  }
202 
203 
204  private:
205  /**
206  * Auxiliary class for I/O of detector header.
207  */
209  public JProperties
210  {
211  public:
212  /**
213  * Constructor.
214  *
215  * \param object header
216  * \param equation equation parameters
217  */
218  template<class JDetectorHeader_t>
219  JDetectorHeaderHelper(JDetectorHeader_t& object,
220  const JEquationParameters& equation) :
221  JProperties(equation, 1)
222  {
223  insert(gmake_property(object.first));
224  insert(gmake_property(object.second));
225  insert(gmake_property(object.east));
226  insert(gmake_property(object.north));
227  insert(gmake_property(object.z));
228  insert(gmake_property(object.key));
229  insert(gmake_property(object.wgs));
230  insert(gmake_property(object.zone));
231  }
232  };
233  };
234 
235 
236  /**
237  * Get detector header for ARCA.
238  *
239  * \return detector header
240  */
242  {
243  return JDetectorHeader(JUTCTimeRange(0.0, 999999999999.9),
244  JUTMGrid ("UTM", "WGS84", "33N"),
245  JUTMPosition (587600, 4016800, -3450));
246  }
247 
248  /**
249  * Get detector header for ORCA.
250  *
251  * \return detector header
252  */
254  {
255  return JDetectorHeader(JUTCTimeRange(0.0, 999999999999.9),
256  JUTMGrid ("UTM", "WGS84", "32N"),
257  JUTMPosition (256500, 4743000, -2440));
258  }
259 
260 
261  /**
262  * Check if given detector header is compatible with tat of ARCA.
263  *
264  * \param header header
265  * \return true if ARCA; else false
266  */
267  inline bool isARCADetector(const JDetectorHeader& header)
268  {
269  return header.equals(getARCADetectorHeader(), 1.0);
270  }
271 
272 
273  /**
274  * Check if given detector header is compatible with that of ORCA.
275  *
276  * \param header header
277  * \return true if ORCA; else false
278  */
279  inline bool isORCADetector(const JDetectorHeader& header)
280  {
281  return header.equals(getORCADetectorHeader(), 1.0);
282  }
283 }
284 
285 #endif
JDetectorHeader getORCADetectorHeader()
Get detector header for ORCA.
bool isORCADetector(const JDetectorHeader &header)
Check if given detector header is compatible with that of ORCA.
Interface for binary output.
bool isARCADetector(const JDetectorHeader &header)
Check if given detector header is compatible with tat of ARCA.
const JUTMPosition & getUTMPosition() const
Get UTM position.
Definition: JUTMPosition.hh:84
static void setEquationParameters(const JEquationParameters &equation)
Set equation parameters.
#define gmake_property(A)
macro to convert (template) parameter to JPropertiesElement object
JDetectorHeader()
Default constructor.
double getDisplacement(const JUTMPosition &position) const
Get displacement to position.
Utility class to parse parameter values.
Definition: JProperties.hh:496
JDetectorHeader(const JUTCTimeRange &range, const JUTMGrid &grid, const JUTMPosition &pos)
Constructor.
Simple data structure to support I/O of equations (see class JLANG::JEquation).
friend std::ostream & operator<<(std::ostream &out, const JDetectorHeader &header)
Write detector header to output.
Data structure for UTM position.
Definition: JUTMPosition.hh:36
Data structure for detector header.
Utility class to parse parameter values.
JUTCTimeRange()
Default constructor.
bool equals(const JDetectorHeader &header, const double precision=std::numeric_limits< double >::min()) const
Check equality.
static JEquationParameters & getEquationParameters()
Get equation parameters.
std::string key
Definition: JUTMGrid.hh:223
std::string zone
Definition: JUTMGrid.hh:225
JDetectorHeaderHelper(JDetectorHeader_t &object, const JEquationParameters &equation)
Constructor.
Template definition of auxiliary base class for comparison of data structures.
Definition: JEquals.hh:24
std::string wgs
Definition: JUTMGrid.hh:224
JProperties getProperties(const JEquationParameters &equation=JDetectorHeader::getEquationParameters()) const
Get properties of this class.
Interface for binary input.
Data structure for UTM grid.
Definition: JUTMGrid.hh:36
JProperties getProperties(const JEquationParameters &equation=JDetectorHeader::getEquationParameters())
Get properties of this class.
z range($ZMAX-$ZMIN)< $MINIMAL_DZ." fi fi mv $WORKDIR/fit.root $MODULE_ROOT typeset -Z 4 STRING typeset -Z 2 FLOOR JPlot1D -f $
Definition: module-Z:fit.sh:84
const JUTMGrid & getUTMGrid() const
Get UTM grid.
Definition: JUTMGrid.hh:72
UTC time range [s].
Auxiliary class for I/O of detector header.
friend std::istream & operator>>(std::istream &in, JDetectorHeader &header)
Read detector header from input.
JDetectorHeader getARCADetectorHeader()
Get detector header for ARCA.
friend JReader & operator>>(JReader &in, JDetectorHeader &header)
Read detector header from input.
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:38
friend JWriter & operator<<(JWriter &out, const JDetectorHeader &header)
Write detector header to output.