Jpp
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Public Member Functions | Public Attributes | Private Attributes | List of all members
JACOUSTICS::JKatoomba< JEstimator > Struct Template Reference

Template specialisation of fit function of acoustic model based on linear approximation. More...

#include <JKatoomba.hh>

Inheritance diagram for JACOUSTICS::JKatoomba< JEstimator >:
JACOUSTICS::JKatoomba_t JACOUSTICS::JGeometry

Public Member Functions

 JKatoomba (const JDetector &detector, const JSoundVelocity &velocity)
 Constructor. More...
 
template<class T >
const JModeloperator() (T __begin, T __end) const
 Get start values of string parameters. More...
 
template<class JPDF_t >
double getToA (const JModel &model, const JHit< JPDF_t > &hit) const
 Get estimated time-of-arrival for given hit. More...
 

Public Attributes

const JDetectordetector
 
const JSoundVelocityvelocity
 
JLANG::JSharedPointer
< JMEstimator
estimator
 M-Estimator function. More...
 

Private Attributes

JModel value
 

Detailed Description

template<>
struct JACOUSTICS::JKatoomba< JEstimator >

Template specialisation of fit function of acoustic model based on linear approximation.

Definition at line 153 of file JKatoomba.hh.

Constructor & Destructor Documentation

JACOUSTICS::JKatoomba< JEstimator >::JKatoomba ( const JDetector detector,
const JSoundVelocity velocity 
)
inline

Constructor.

Parameters
detectordetector
velocitysound velocity

Definition at line 162 of file JKatoomba.hh.

163  :
164  JKatoomba_t(detector, velocity)
165  {};
JKatoomba_t(const JDetector &detector, const JSoundVelocity &velocity)
Constructor.
Definition: JKatoomba.hh:47
const JDetector & detector
Definition: JKatoomba.hh:75

Member Function Documentation

template<class T >
const JModel& JACOUSTICS::JKatoomba< JEstimator >::operator() ( T  __begin,
T  __end 
) const
inline

Get start values of string parameters.


Note that this method may throw an exception.

Parameters
__beginbegin of hits
__endend of hits
Returns
model

Definition at line 177 of file JKatoomba.hh.

178  {
179  using namespace std;
180  using namespace JPP;
181 
182  value = JModel(__begin, __end); // set up global model according data
183 
184  struct H_t : // H-equation as per hit
185  public JModel::JString,
186  public JModel::JEmitter
187  {} H;
188 
189  struct { int t1; int tx; int ty; } i; // indices of H-equation in global model
190 
191  JMatrixNS V(value.getN()); // V = H^T x H
192  vector<double> Y(value.getN(), 0.0); // Y = H^T x y
193 
194 
195  for (T hit = __begin; hit != __end; ++hit) {
196 
197  const JString& string = detector[hit->getString()];
198  const JPosition3D position = string.getPosition(hit->getFloor());
199  const double Vi = velocity.getInverseVelocity(hit->getDistance(position), hit->getZ(), position.getZ());
200 
201  const double h1 = string[hit->getFloor()].getHeight();
202  const JPosition3D p1 = string.getPosition() - hit->getPosition();
203  const double ds = sqrt(p1.getLengthSquared() + h1*h1 + 2.0*p1.getZ()*h1);
204  const double y = hit->getValue() - Vi*ds;
205 
206  H.t1 = 1.0;
207  H.tx = Vi * p1.getX() * h1 / ds;
208  H.ty = Vi * p1.getY() * h1 / ds;
209 
210  i.t1 = value.getIndex(hit->getEKey(), &H_t::t1);
211  i.tx = value.getIndex(hit->getString(), &H_t::tx);
212  i.ty = value.getIndex(hit->getString(), &H_t::ty);
213 
214  V(i.t1, i.t1) += H.t1 * H.t1;
215  V(i.t1, i.tx) += H.t1 * H.tx;
216  V(i.t1, i.ty) += H.t1 * H.ty;
217 
218  V(i.tx, i.t1) += H.tx * H.t1;
219  V(i.ty, i.t1) += H.ty * H.t1;
220 
221  V(i.tx, i.tx) += H.tx * H.tx;
222  V(i.tx, i.ty) += H.tx * H.ty;
223 
224  V(i.ty, i.tx) += H.ty * H.tx;
225 
226  V(i.ty, i.ty) += H.ty * H.ty;
227 
228  Y[i.t1] += H.t1 * y;
229  Y[i.tx] += H.tx * y;
230  Y[i.ty] += H.ty * y;
231  }
232 
233  // evaluate (H^T x H)^-1 x H^T x y
234 
235  V.invert();
236 
237  for (size_t row = 0; row != value.getN(); ++row) {
238  for (size_t col = 0; col != value.getN(); ++col) {
239  value[row] += V(row,col) * Y[col];
240  }
241  }
242 
243  return value;
244  }
static const double H
Planck constant [eV s].
Definition: JConstants.hh:25
size_t getN() const
Get number of fit parameters.
TPaveText * p1
then for HISTOGRAM in h0 h1
Definition: JMatrixNZ.sh:69
Model for fit to acoustics data.
virtual double getInverseVelocity(const double D_m, const double z1, const double z2) const
Get inverse velocity of sound.
do set_variable OUTPUT_DIRECTORY $WORKDIR T
size_t getIndex(int id, double JString::*p) const
Get index of fit parameter for given string.
const JDetector & detector
Definition: JKatoomba.hh:75
const JSoundVelocity & velocity
Definition: JKatoomba.hh:76
template<class JPDF_t >
double JACOUSTICS::JKatoomba_t::getToA ( const JModel model,
const JHit< JPDF_t > &  hit 
) const
inlineinherited

Get estimated time-of-arrival for given hit.

Parameters
modelmodel
hithit
Returns
time-of-arrival

Definition at line 62 of file JKatoomba.hh.

63  {
64  const JString& string = detector[hit.getString()];
65  const JModel::JString& parameters = model.string[hit.getString()];
66  const JPosition3D position = string.getPosition(parameters, hit.getFloor());
67 
68  const double D = hit.getDistance(position);
69  const double Vi = velocity.getInverseVelocity(D, hit.getZ(), position.getZ());
70 
71  return model.emitter[hit.getEKey()].t1 + D * Vi;
72  }
do echo Generating $dir eval D
Definition: JDrawLED.sh:50
int getFloor() const
Get floor number.
Definition: JLocation.hh:145
*fatal Wrong number of arguments esac JCookie sh typeset Z DETECTOR typeset Z SOURCE_RUN typeset Z TARGET_RUN set_variable PARAMETERS_FILE $WORKDIR parameters
Definition: diff-Tuna.sh:38
JEKey getEKey() const
Get emitter hash key of this hot.
double getDistance(const JVector3D &pos) const
Get distance to point.
Definition: JVector3D.hh:269
JACOUSTICS::JModel::emitter_map emitter
JACOUSTICS::JModel::string_map string
virtual double getInverseVelocity(const double D_m, const double z1, const double z2) const
Get inverse velocity of sound.
int getString() const
Get string number.
Definition: JLocation.hh:134
const JDetector & detector
Definition: JKatoomba.hh:75
const JSoundVelocity & velocity
Definition: JKatoomba.hh:76
double getZ() const
Get z position.
Definition: JVector3D.hh:114

Member Data Documentation

JModel JACOUSTICS::JKatoomba< JEstimator >::value
mutableprivate

Definition at line 247 of file JKatoomba.hh.

const JDetector& JACOUSTICS::JKatoomba_t::detector
inherited

Definition at line 75 of file JKatoomba.hh.

const JSoundVelocity& JACOUSTICS::JKatoomba_t::velocity
inherited

Definition at line 76 of file JKatoomba.hh.

JLANG::JSharedPointer<JMEstimator> JACOUSTICS::JKatoomba_t::estimator
inherited

M-Estimator function.

Definition at line 78 of file JKatoomba.hh.


The documentation for this struct was generated from the following file: