Jpp
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
JAcoustics/JHit.hh
Go to the documentation of this file.
1 #ifndef __JACOUSTICS__JHIT__
2 #define __JACOUSTICS__JHIT__
3 
4 #include <ostream>
5 
6 #include "JDetector/JLocation.hh"
8 #include "JMath/JGauss.hh"
9 #include "Jeep/JPrint.hh"
10 
11 #include "JAcoustics/JEmitter.hh"
12 #include "JAcoustics/JCounter.hh"
13 #include "JAcoustics/JEKey.hh"
14 
15 
16 /**
17  * \file
18  *
19  * Acoustic hit.
20  * \author mdejong
21  */
22 namespace JACOUSTICS {}
23 namespace JPP { using namespace JACOUSTICS; }
24 
25 namespace JACOUSTICS {
26 
27  using JMATH::JGauss;
30 
31 
32  /**
33  * Custom probability density function of time-of-arrival.
34  */
35  struct JPDFGauss :
36  public JGauss
37  {
38  using JGauss::getValue;
39 
40  /**
41  * Default constructor.
42  */
44  JGauss()
45  {}
46 
47 
48  /**
49  * Constructor.
50  *
51  * \param t1_s time-of-arrival [s]
52  * \param sigma_s resolution [s]
53  * \param background background probability \[0,1>
54  */
55  JPDFGauss(const double t1_s,
56  const double sigma_s,
57  const double background = 0.0) :
58  JGauss(t1_s, sigma_s, 1.0 - background, background)
59  {}
60 
61 
62  /**
63  * Get expectation value of time-of-arrival.
64  *
65  * \return time-of-arrival [s]
66  */
67  double getValue() const
68  {
69  return mean;
70  }
71 
72 
73  /**
74  * Get weight.
75  *
76  * \return weight
77  */
78  double getWeight() const
79  {
80  return 1.0 / sigma;
81  }
82  };
83 
84 
85  /**
86  * Acoustics hit.
87  *
88  * The template parameter should correspond to a data type which provides for the following policy methods.
89  * <pre>
90  * double getValue() const;
91  * double getValue(double) const;
92  * double getDerivative(double) const;
93  * </pre>
94  * These should return
95  * the expectation value,
96  * the probability to observe a hit at a given time and
97  * the derivative thereof, respectively.
98  */
99  template<class JPDF_t = JPDFGauss>
100  struct JHit :
101  public JEmitter,
102  public JCounter,
103  public JLocation,
104  public JPDF_t
105  {
106  /**
107  * Default constructor.
108  */
110  {}
111 
112 
113  /**
114  * Constructor.
115  *
116  * \param emitter emitter
117  * \param counter counter
118  * \param location receiver location
119  * \param pdf probability density function
120  */
121  JHit(const JEmitter& emitter,
122  const JCounter& counter,
123  const JLocation& location,
124  const JPDF_t& pdf) :
125  JEmitter(emitter),
126  JCounter(counter),
127  JLocation(location),
128  JPDF_t(pdf)
129  {}
130 
131 
132  /**
133  * Constructor.
134  *
135  * \param key emitter key
136  * \param position emitter position
137  * \param location receiver location
138  * \param pdf probability density function
139  */
140  JHit(const JEKey& key,
141  const JVector3D& position,
142  const JLocation& location,
143  const JPDF_t& pdf) :
144  JEmitter(key.getID(), position),
145  JCounter(key.getCounter()),
146  JLocation(location),
147  JPDF_t(pdf)
148  {}
149 
150 
151  /**
152  * Get emitter hash key of this hot.
153  *
154  * \return hash key
155  */
156  JEKey getEKey() const
157  {
158  return JEKey(getID(), getCounter());
159  }
160 
161 
162  /**
163  * Write hit to output stream.
164  *
165  * \param out output stream
166  * \param hit hit
167  * \return output stream
168  */
169  friend inline std::ostream& operator<<(std::ostream& out, const JHit& hit)
170  {
171  using namespace std;
172  using namespace JPP;
173 
174  out << setw(3) << hit.getID() << ' '
175  << setw(8) << hit.getCounter() << ' '
176  << getLabel(hit.getLocation()) << ' '
177  << FIXED(20,5) << hit.getValue();
178 
179  return out;
180  }
181  };
182 }
183 
184 #endif
Acoustic counter.
double mean
Definition: JGauss.hh:162
Acoustic counter.
friend std::ostream & operator<<(std::ostream &out, const JHit &hit)
Write hit to output stream.
std::string getLabel(const JLocation &location)
Get module label for monitoring and other applications.
Definition: JLocation.hh:246
int getCounter() const
Get counter.
Auxiliary data structure for floating point format specification.
Definition: JPrint.hh:481
JEKey getEKey() const
Get emitter hash key of this hot.
Acoustic emitter.
double getValue() const
Get expectation value of time-of-arrival.
Acoustics hit.
Gauss function object.
Definition: JGauss.hh:174
double getWeight() const
Get weight.
JPDFGauss()
Default constructor.
JHit()
Default constructor.
I/O formatting auxiliaries.
Data structure for vector in three dimensions.
Definition: JVector3D.hh:33
Acoustic emitter.
Definition: JEmitter.hh:27
Logical location of module.
Definition: JLocation.hh:37
const JLocation & getLocation() const
Get location.
Definition: JLocation.hh:69
JHit(const JEmitter &emitter, const JCounter &counter, const JLocation &location, const JPDF_t &pdf)
Constructor.
int getID() const
Get identifier.
Definition: JObjectID.hh:55
Logical location of module.
Emitter hash key.
JHit(const JEKey &key, const JVector3D &position, const JLocation &location, const JPDF_t &pdf)
Constructor.
double background
Definition: JGauss.hh:165
double sigma
Definition: JGauss.hh:163
Emitter key.
Definition: JEKey.hh:29
double getValue(const double x) const
Function value.
Definition: JGauss.hh:223
Custom probability density function of time-of-arrival.
JPDFGauss(const double t1_s, const double sigma_s, const double background=0.0)
Constructor.