Jpp  master_rocky
the software that should make you happy
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  * Get detector header.
73  *
74  * \return header
75  */
77  {
78  return static_cast<const JDetectorHeader&>(*this);
79  }
80 
81 
82  /**
83  * Check equality.
84  *
85  * \param header header
86  * \param precision precision
87  * \return true if headers are equal; else false
88  */
89  bool equals(const JDetectorHeader& header,
90  const double precision = std::numeric_limits<double>::min()) const
91  {
92  return (this->getUTMGrid() == header.getUTMGrid() && this->getDisplacement(header.getUTMPosition()) < precision);
93  }
94 
95 
96  /**
97  * Read detector header from input.
98  *
99  * \param in input stream
100  * \param header header
101  * \return input stream
102  */
103  friend inline std::istream& operator>>(std::istream& in, JDetectorHeader& header)
104  {
105  in >> static_cast<JUTCTimeRange&>(header);
106  in >> static_cast<JUTMGrid&> (header);
107  in >> static_cast<JUTMPosition&> (header);
108 
109  return in;
110  }
111 
112 
113  /**
114  * Write detector header to output.
115  *
116  * \param out output stream
117  * \param header header
118  * \return output stream
119  */
120  friend inline std::ostream& operator<<(std::ostream& out, const JDetectorHeader& header)
121  {
122  using namespace std;
123 
124  out << static_cast<const JUTCTimeRange&>(header);
125  out << endl;
126  out << static_cast<const JUTMGrid&> (header);
127  out << ' ';
128  out << static_cast<const JUTMPosition&> (header);
129 
130  return out;
131  }
132 
133 
134  /**
135  * Read detector header from input.
136  *
137  * \param in input stream
138  * \param header header
139  * \return input stream
140  */
141  friend inline JReader& operator>>(JReader& in, JDetectorHeader& header)
142  {
143  in >> static_cast<JUTCTimeRange&>(header);
144  in >> static_cast<JUTMGrid&> (header);
145  in >> static_cast<JUTMPosition&> (header);
146 
147  return in;
148  }
149 
150 
151  /**
152  * Write detector header to output.
153  *
154  * \param out output stream
155  * \param header header
156  * \return output stream
157  */
158  friend inline JWriter& operator<<(JWriter& out, const JDetectorHeader& header)
159  {
160  out << static_cast<const JUTCTimeRange&>(header);
161  out << static_cast<const JUTMGrid&> (header);
162  out << static_cast<const JUTMPosition&> (header);
163 
164  return out;
165  }
166 
167 
168  /**
169  * Get equation parameters.
170  *
171  * \return equation parameters
172  */
174  {
175  static JEquationParameters equation;
176 
177  return equation;
178  }
179 
180 
181 
182  /**
183  * Set equation parameters.
184  *
185  * \param equation equation parameters
186  */
187  static inline void setEquationParameters(const JEquationParameters& equation)
188  {
189  getEquationParameters() = 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  /**
205  * Get properties of this class.
206  *
207  * \param equation equation parameters
208  */
210  {
211  return JDetectorHeaderHelper(*this, equation);
212  }
213 
214 
215  private:
216  /**
217  * Auxiliary class for I/O of detector header.
218  */
220  public JProperties
221  {
222  public:
223  /**
224  * Constructor.
225  *
226  * \param object header
227  * \param equation equation parameters
228  */
229  template<class JDetectorHeader_t>
230  JDetectorHeaderHelper(JDetectorHeader_t& object,
231  const JEquationParameters& equation) :
232  JProperties(equation, 1)
233  {
234  insert(gmake_property(object.first));
235  insert(gmake_property(object.second));
236  insert(gmake_property(object.east));
237  insert(gmake_property(object.north));
238  insert(gmake_property(object.z));
239  insert(gmake_property(object.key));
240  insert(gmake_property(object.wgs));
241  insert(gmake_property(object.zone));
242  }
243  };
244  };
245 
246 
247  /**
248  * Get UTM grid for ARCA.
249  *
250  * \return UTM grid
251  */
253  {
254  return JUTMGrid("UTM", "WGS84", "33N");
255  }
256 
257 
258  /**
259  * Get UTM grid for ORCA.
260  *
261  * \return UTM grid
262  */
264  {
265  return JUTMGrid("UTM", "WGS84", "32N");
266  }
267 
268 
269  /**
270  * Get detector header for ARCA.
271  *
272  * \return detector header
273  */
275  {
276  return JDetectorHeader(JUTCTimeRange(0.0, 999999999999.9), getARCAUTMGrid(), JUTMPosition(587600, 4016800, -3450));
277  }
278 
279 
280  /**
281  * Get detector header for ORCA.
282  *
283  * \return detector header
284  */
286  {
287  return JDetectorHeader(JUTCTimeRange(0.0, 999999999999.9), getORCAUTMGrid(), JUTMPosition(256500, 4743000, -2440));
288  }
289 
290 
291  /**
292  * Check if given detector header is compatible with tat of ARCA.
293  *
294  * \param header header
295  * \return true if ARCA; else false
296  */
297  inline bool isARCADetector(const JDetectorHeader& header)
298  {
299  return header.getUTMGrid() == getARCADetectorHeader();
300  }
301 
302 
303  /**
304  * Check if given detector header is compatible with that of ORCA.
305  *
306  * \param header header
307  * \return true if ORCA; else false
308  */
309  inline bool isORCADetector(const JDetectorHeader& header)
310  {
311  return header.getUTMGrid() == getORCADetectorHeader();
312  }
313 }
314 
315 #endif
Utility class to parse parameter values.
#define gmake_property(A)
macros to convert (template) parameter to JPropertiesElement object
Auxiliary class for I/O of detector header.
JDetectorHeaderHelper(JDetectorHeader_t &object, const JEquationParameters &equation)
Constructor.
Data structure for detector header.
friend std::istream & operator>>(std::istream &in, JDetectorHeader &header)
Read detector header from input.
static JEquationParameters & getEquationParameters()
Get equation parameters.
bool equals(const JDetectorHeader &header, const double precision=std::numeric_limits< double >::min()) const
Check equality.
const JDetectorHeader & getDetectorHeader() const
Get detector header.
static void setEquationParameters(const JEquationParameters &equation)
Set equation parameters.
JDetectorHeader()
Default constructor.
friend std::ostream & operator<<(std::ostream &out, const JDetectorHeader &header)
Write detector header to output.
friend JReader & operator>>(JReader &in, JDetectorHeader &header)
Read detector header from input.
JProperties getProperties(const JEquationParameters &equation=JDetectorHeader::getEquationParameters())
Get properties of this class.
friend JWriter & operator<<(JWriter &out, const JDetectorHeader &header)
Write detector header to output.
JDetectorHeader(const JUTCTimeRange &range, const JUTMGrid &grid, const JUTMPosition &pos)
Constructor.
JProperties getProperties(const JEquationParameters &equation=JDetectorHeader::getEquationParameters()) const
Get properties of this class.
Utility class to parse parameter values.
Definition: JProperties.hh:501
Interface for binary input.
Interface for binary output.
Simple data structure to support I/O of equations (see class JLANG::JEquation).
UTC time range [s].
JUTCTimeRange()
Default constructor.
Data structure for UTM grid.
Definition: JUTMGrid.hh:39
const JUTMGrid & getUTMGrid() const
Get UTM grid.
Definition: JUTMGrid.hh:73
std::string key
Definition: JUTMGrid.hh:246
JUTMGrid()
Default constructor.
Definition: JUTMGrid.hh:44
std::string wgs
Definition: JUTMGrid.hh:247
std::string zone
Definition: JUTMGrid.hh:248
Data structure for UTM position.
Definition: JUTMPosition.hh:38
const JUTMPosition & getUTMPosition() const
Get UTM position.
Definition: JUTMPosition.hh:84
JUTMPosition()
Default constructor.
Definition: JUTMPosition.hh:43
file Auxiliary data structures and methods for detector calibration.
Definition: JAnchor.hh:12
JUTMGrid getORCAUTMGrid()
Get UTM grid for ORCA.
JDetectorHeader getARCADetectorHeader()
Get detector header for ARCA.
JUTMGrid getARCAUTMGrid()
Get UTM grid for ARCA.
bool isORCADetector(const JDetectorHeader &header)
Check if given detector header is compatible with that of ORCA.
bool isARCADetector(const JDetectorHeader &header)
Check if given detector header is compatible with tat of ARCA.
JDetectorHeader getORCADetectorHeader()
Get detector header for ORCA.
This name space includes all other name spaces (except KM3NETDAQ, KM3NET and ANTARES).
Definition: JSTDTypes.hh:14
Template definition of auxiliary base class for comparison of data structures.
Definition: JEquals.hh:84