Jpp  17.3.2
the software that should make you happy
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
JAcousticsToolkit.hh
Go to the documentation of this file.
1 #ifndef __JACOUSTICS__JACOUSTICSTOOLKIT__
2 #define __JACOUSTICS__JACOUSTICSTOOLKIT__
3 
5 
6 #include "JLang/JException.hh"
7 #include "JLang/JPredicate.hh"
8 
10 
11 
12 /**
13  * \file
14  *
15  * Acoustics toolkit.
16  * \author mdejong
17  */
18 namespace JACOUSTICS {}
19 namespace JPP { using namespace JACOUSTICS; }
20 
21 namespace JACOUSTICS {
22 
24  using JLANG::JPredicate;
26 
27 
28  /**
29  * Get position from element in data which corresponds to given predicate.
30  *
31  * \param __begin begin of data
32  * \param __end end of data
33  * \param predicate predicate
34  * \return position
35  */
36  template<class T, class JTypename_t, class JComparator_t>
37  inline JVector3D getPosition(T __begin,
38  T __end,
40  {
41  T p = std::find_if(__begin, __end, predicate);
42 
43  if (p != __end)
44  return p->getPosition();
45  else
46  THROW(JValueOutOfRange, "No element in container which corresponds to given predicate.");
47  }
48 
49 
50  /**
51  * Get position from element in data which corresponds to given predicate.
52  *
53  * \param __begin begin of data
54  * \param __end end of data
55  * \param predicate predicate
56  * \param position default position
57  * \return position
58  */
59  template<class T, class JTypename_t, class JComparator_t>
60  inline JVector3D getPosition(T __begin,
61  T __end,
63  const JVector3D& position)
64  {
65  try {
66  return getPosition(__begin, __end, predicate);
67  }
68  catch(const std::exception&) {
69  return position;
70  }
71  }
72 
73 
74  /**
75  * Get UNIX time of given DAQ object.
76  *
77  * \param chronometer chronometer
78  * \return UNIX time [s]
79  */
80  inline double getUNIXTime(const KM3NETDAQ::JDAQChronometer& chronometer)
81  {
82  return chronometer.getTimesliceStart().getTimeNanoSecond() * 1.0e-9;
83  }
84 }
85 
86 #endif
Exceptions.
double getUNIXTime(const KM3NETDAQ::JDAQChronometer &chronometer)
Get UNIX time of given DAQ object.
JDAQUTCExtended getTimesliceStart() const
Get start of timeslice.
Template definition of auxiliary class to select objects.
Definition: JPredicate.hh:23
#define THROW(JException_t, A)
Marco for throwing exception with std::ostream compatible message.
Definition: JException.hh:696
Data structure for vector in three dimensions.
Definition: JVector3D.hh:34
do set_variable OUTPUT_DIRECTORY $WORKDIR T
JPosition3D getPosition(const Vec &pos)
Get position.
Exception for accessing a value in a collection that is outside of its range.
Definition: JException.hh:162
double getTimeNanoSecond() const
Get time (limited to 16 ns cycles).