Jpp  18.0.0-rc.4
the software that should make you happy
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Public Member Functions | Static Public Attributes | Private Member Functions | Static Private Member Functions | Private Attributes | Static 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_t.hh>

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

Public Member Functions

 JKatoomba (const JGeometry &geometry, const JSoundVelocity &velocity, const int option)
 Constructor. More...
 
template<class T >
JModeloperator() (T __begin, T __end) const
 Get start values of string parameters. More...
 

Static Public Attributes

static constexpr double TOLERANCE = 1.0e-8
 Tolerance for SVD. More...
 
static JMatrix_t MATRIX_INVERSION = SVD_t
 

Private Member Functions

template<class T , class JMatrixNS_t >
JModelevaluate (T __begin, T __end, const JType< JMatrixNS_t > &type) const
 Get start values of string parameters. More...
 

Static Private Member Functions

static void invert (TMatrixD &V)
 Invert matrix using SVD algorithm. More...
 
static void invert (JMatrixNS &V)
 Invert matrix using LDU algorithm. More...
 

Private Attributes

JModel value
 

Static Private Attributes

static std::mutex mtx
 Declaration of mutex. More...
 

Detailed Description

template<>
struct JACOUSTICS::JKatoomba< JEstimator >

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

Definition at line 364 of file JKatoomba_t.hh.

Constructor & Destructor Documentation

JACOUSTICS::JKatoomba< JEstimator >::JKatoomba ( const JGeometry geometry,
const JSoundVelocity velocity,
const int  option 
)
inline

Constructor.

Parameters
geometrydetector geometry
velocitysound velocity
optionoption

Definition at line 376 of file JKatoomba_t.hh.

378  :
379  JKatoomba<>(geometry, velocity, option)
380  {};

Member Function Documentation

template<class T >
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 392 of file JKatoomba_t.hh.

393  {
394  switch (MATRIX_INVERSION) {
395 
396  case SVD_t:
397  return this->evaluate(__begin, __end, JType<TMatrixDS>());
398 
399  case LDU_t:
400  return this->evaluate(__begin, __end, JType<JMatrixNS>());
401 
402  default:
403  THROW(JValueOutOfRange, "Invalid matrix type " << MATRIX_INVERSION);
404  }
405  }
#define THROW(JException_t, A)
Marco for throwing exception with std::ostream compatible message.
Definition: JException.hh:696
Auxiliary class for a type holder.
Definition: JType.hh:19
JModel & evaluate(T __begin, T __end, const JType< JMatrixNS_t > &type) const
Get start values of string parameters.
Definition: JKatoomba_t.hh:421
Exception for accessing a value in a collection that is outside of its range.
Definition: JException.hh:162
template<class T , class JMatrixNS_t >
JModel& JACOUSTICS::JKatoomba< JEstimator >::evaluate ( T  __begin,
T  __end,
const JType< JMatrixNS_t > &  type 
) const
inlineprivate

Get start values of string parameters.


Note that this method may throw an exception.

Parameters
__beginbegin of hits
__endend of hits
typematrix type
Returns
model

Definition at line 421 of file JKatoomba_t.hh.

422  {
423  using namespace std;
424  using namespace JPP;
425  using namespace JGEOMETRY;
426 
427  value = move(JModel(__begin, __end)); // set up global model according data
428 
429  if (this->option == JMODEL::fit_emitters_only_t)
431  else
433 
434  H_t H; // H-equation as per hit
435  I_t i; // indices of H-equation in global model
436 
437  const size_t N = value.getN();
438 
439  JMatrixNS_t V(N); // V = H^T x H
440  vector<double> Y(N, 0.0); // Y = H^T x y
441 
442  for (T hit = __begin; hit != __end; ++hit) {
443 
444  const JString& string = geometry[hit->getString()];
445  const JPosition3D position = string.getPosition(hit->getFloor());
446  const double Vi = velocity.getInverseVelocity(hit->getDistance(position), hit->getZ(), position.getZ());
447 
448  const double h1 = string.getHeight(hit->getFloor());
449  const JPosition3D p1 = string.getPosition() - hit->getPosition();
450  const double ds = sqrt(p1.getLengthSquared() + h1*h1 + 2.0*p1.getZ()*h1);
451  const double y = hit->getValue() - Vi*ds;
452  const double W = sqrt(hit->getWeight());
453 
454  H.t1 = W * 1.0;
455  H.tx = W * Vi * p1.getX() * h1 / ds;
456  H.ty = W * Vi * p1.getY() * h1 / ds;
457 
458  i.t1 = value.getIndex(hit->getEKey(), &H_t::t1);
459  i.tx = value.getIndex(hit->getString(), &H_t::tx);
460  i.ty = value.getIndex(hit->getString(), &H_t::ty);
461 
462  V(i.t1, i.t1) += H.t1 * H.t1;
463 
464  Y[i.t1] += W * H.t1 * y;
465 
466  if (hit->getFloor() != 0) {
467 
468  if (this->option != JMODEL::fit_emitters_only_t) {
469 
470  V(i.t1, i.tx) += H.t1 * H.tx; V(i.t1, i.ty) += H.t1 * H.ty;
471  V(i.tx, i.t1) += H.tx * H.t1; V(i.ty, i.t1) += H.ty * H.t1;
472 
473  V(i.tx, i.tx) += H.tx * H.tx; V(i.tx, i.ty) += H.tx * H.ty;
474  V(i.ty, i.tx) += H.ty * H.tx; V(i.ty, i.ty) += H.ty * H.ty;
475 
476  Y[i.tx] += W * H.tx * y;
477  Y[i.ty] += W * H.ty * y;
478  }
479  }
480  }
481 
482  // evaluate (H^T x H)^-1 x H^T x y
483 
484  invert(V);
485 
486  for (size_t row = 0; row != N; ++row) {
487  for (size_t col = 0; col != N; ++col) {
488  value[row] += V(row,col) * Y[col];
489  }
490  }
491 
492  return value;
493  }
size_t getN() const
Get number of fit parameters.
void setOption(const int option)
Set fit option.
Wrapper class around STL string class.
Definition: JString.hh:27
TPaveText * p1
static void invert(TMatrixD &V)
Invert matrix using SVD algorithm.
Definition: JKatoomba_t.hh:501
static const double H
Planck constant [eV s].
then fatal Wrong number of arguments fi set_variable STRING $argv[1] set_variable DETECTORXY_TXT $WORKDIR $DETECTORXY_TXT tail read X Y CHI2 RMS printf optimum n $X $Y $CHI2 $RMS awk v Y
V(JDAQEvent-JTriggerReprocessor)*1.0/(JDAQEvent+1.0e-10)
fit times of emission of emitters and tilt angles of strings
Model for fit to acoustics data.
do set_variable OUTPUT_DIRECTORY $WORKDIR T
double getY() const
Get y position.
Definition: JVector3D.hh:104
const JPosition3D & getPosition() const
Get position.
Definition: JPosition3D.hh:130
double getLengthSquared() const
Get length squared.
Definition: JVector3D.hh:235
size_t getIndex(int id, double JString::*p) const
Get index of fit parameter for given string.
then usage $script< input file >[option[primary[working directory]]] nWhere option can be N
Definition: JMuonPostfit.sh:40
double getX() const
Get x position.
Definition: JVector3D.hh:94
Data structure for position in three dimensions.
Definition: JPosition3D.hh:36
fit only times of emission of emitters
double getZ() const
Get z position.
Definition: JVector3D.hh:115
static void JACOUSTICS::JKatoomba< JEstimator >::invert ( TMatrixD &  V)
inlinestaticprivate

Invert matrix using SVD algorithm.

Parameters
Vmatrix

Definition at line 501 of file JKatoomba_t.hh.

502  {
503 #ifdef THREAD_SAFE
504  using namespace std;
505 
506  unique_lock<mutex> lock(mtx);
507 #endif
508  TDecompSVD svd(V, TOLERANCE);
509 
510  Bool_t status;
511 
512  V = svd.Invert(status);
513  }
V(JDAQEvent-JTriggerReprocessor)*1.0/(JDAQEvent+1.0e-10)
static std::mutex mtx
Declaration of mutex.
Definition: JKatoomba_t.hh:528
static constexpr double TOLERANCE
Tolerance for SVD.
Definition: JKatoomba_t.hh:367
static void JACOUSTICS::JKatoomba< JEstimator >::invert ( JMatrixNS V)
inlinestaticprivate

Invert matrix using LDU algorithm.

Parameters
Vmatrix

Definition at line 521 of file JKatoomba_t.hh.

522  {
523  V.invert();
524  }
void invert()
Invert matrix according LDU decomposition.
Definition: JMatrixNS.hh:80

Member Data Documentation

constexpr double JACOUSTICS::JKatoomba< JEstimator >::TOLERANCE = 1.0e-8
static

Tolerance for SVD.

Definition at line 367 of file JKatoomba_t.hh.

JMatrix_t JACOUSTICS::JKatoomba< JEstimator >::MATRIX_INVERSION = SVD_t
static

Definition at line 408 of file JKatoomba_t.hh.

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

Definition at line 527 of file JKatoomba_t.hh.

std::mutex JACOUSTICS::JKatoomba< JEstimator >::mtx
staticprivate

Declaration of mutex.

Definition at line 528 of file JKatoomba_t.hh.


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