Jpp  15.0.1
the software that should make you happy
 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 "JLang/JManip.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 signal signal
54  * \param background background probability \[0,1>
55  */
56  JPDFGauss(const double t1_s,
57  const double sigma_s,
58  const double signal = 1.0,
59  const double background = 0.0) :
60  JGauss(t1_s, sigma_s, signal, background)
61  {}
62 
63 
64  /**
65  * Get expectation value of time-of-arrival.
66  *
67  * \return time-of-arrival [s]
68  */
69  double getValue() const
70  {
71  return mean;
72  }
73 
74 
75  /**
76  * Get weight.
77  *
78  * \return weight
79  */
80  double getWeight() const
81  {
82  return signal;
83  }
84  };
85 
86 
87  /**
88  * Acoustics hit.
89  *
90  * The template parameter should correspond to a data type which provides for the following policy methods.
91  * <pre>
92  * double getValue() const;
93  * double getValue(double) const;
94  * double getDerivative(double) const;
95  * </pre>
96  * These should return
97  * the expectation value,
98  * the probability to observe a hit at a given time and
99  * the derivative thereof, respectively.
100  */
101  template<class JPDF_t = JPDFGauss>
102  struct JHit :
103  public JEmitter,
104  public JCounter,
105  public JLocation,
106  public JPDF_t
107  {
108  /**
109  * Default constructor.
110  */
112  {}
113 
114 
115  /**
116  * Constructor.
117  *
118  * \param emitter emitter
119  * \param counter counter
120  * \param location receiver location
121  * \param pdf probability density function
122  */
123  JHit(const JEmitter& emitter,
124  const JCounter& counter,
125  const JLocation& location,
126  const JPDF_t& pdf) :
127  JEmitter(emitter),
128  JCounter(counter),
129  JLocation(location),
130  JPDF_t(pdf)
131  {}
132 
133 
134  /**
135  * Constructor.
136  *
137  * \param key emitter key
138  * \param position emitter position
139  * \param location receiver location
140  * \param pdf probability density function
141  */
142  JHit(const JEKey& key,
143  const JVector3D& position,
144  const JLocation& location,
145  const JPDF_t& pdf) :
146  JEmitter(key.getID(), position),
147  JCounter(key.getCounter()),
148  JLocation(location),
149  JPDF_t(pdf)
150  {}
151 
152 
153  /**
154  * Get emitter hash key of this hit.
155  *
156  * \return hash key
157  */
158  JEKey getEKey() const
159  {
160  return JEKey(getID(), getCounter());
161  }
162 
163 
164  /**
165  * Write hit to output stream.
166  *
167  * \param out output stream
168  * \param hit hit
169  * \return output stream
170  */
171  friend inline std::ostream& operator<<(std::ostream& out, const JHit& hit)
172  {
173  using namespace std;
174  using namespace JPP;
175 
176  out << setw(3) << hit.getID() << ' '
177  << setw(8) << hit.getCounter() << ' '
178  << getLabel(hit.getLocation())
179  << FIXED(20,5) << hit.getValue() << ' '
180  << FIXED(6,2) << hit.getWeight();
181 
182  return out;
183  }
184  };
185 }
186 
187 #endif
Acoustic counter.
double mean
Definition: JGauss.hh:161
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: JManip.hh:446
JEKey getEKey() const
Get emitter hash key of this hit.
Acoustic emitter.
double getValue() const
Get expectation value of time-of-arrival.
Acoustics hit.
Gauss function object.
Definition: JGauss.hh:173
double getWeight() const
Get weight.
JPDFGauss()
Default constructor.
JHit()
Default constructor.
Data structure for vector in three dimensions.
Definition: JVector3D.hh:34
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:50
JPDFGauss(const double t1_s, const double sigma_s, const double signal=1.0, const double background=0.0)
Constructor.
Logical location of module.
I/O manipulators.
sigma_s
Emitter hash key.
JHit(const JEKey &key, const JVector3D &position, const JLocation &location, const JPDF_t &pdf)
Constructor.
double signal
Definition: JGauss.hh:163
double background
Definition: JGauss.hh:164
Emitter key.
Definition: JEKey.hh:32
double getValue(const double x) const
Function value.
Definition: JGauss.hh:222
Custom probability density function of time-of-arrival.