Jpp  17.2.1-pre0
the software that should make you happy
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Public Types | Public Member Functions | Public Attributes | Static Public Attributes | Private Member Functions | Private Attributes | List of all members
JACOUSTICS::JKatoomba< JGandalf > Struct Template Reference

Template specialisation of fit function of acoustic model based on JGandalf minimiser. More...

#include <JKatoomba.hh>

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

Public Types

typedef double result_type
 

Public Member Functions

 JKatoomba (const JDetector &detector, const JSoundVelocity &velocity, const int option)
 Constructor. More...
 
template<class T >
result_type operator() (T __begin, T __end)
 Fit. More...
 

Public Attributes

double lambda
 
JModel value
 
int numberOfIterations
 
JMATH::JMatrixNS V
 

Static Public Attributes

static int debug = 0
 debug level More...
 
static int MAXIMUM_ITERATIONS = 1000
 maximal number of iterations More...
 
static double EPSILON = 1.0e-3
 maximal distance to minimum More...
 
static double LAMBDA_MIN = 0.01
 minimal value control parameter More...
 
static double LAMBDA_MAX = 100.0
 maximal value control parameter More...
 
static double LAMBDA_UP = 9.0
 multiplication factor control parameter More...
 
static double LAMBDA_DOWN = 11.0
 multiplication factor control parameter More...
 
static double PIVOT = 1.0e-3
 minimal value diagonal element of matrix More...
 

Private Member Functions

template<class T >
void evaluate (T __begin, T __end)
 Evaluation of fit. More...
 

Private Attributes

std::vector< double > Y
 
result_type successor
 
JModel previous
 
std::vector< double > h
 

Detailed Description

template<>
struct JACOUSTICS::JKatoomba< JGandalf >

Template specialisation of fit function of acoustic model based on JGandalf minimiser.

Definition at line 552 of file JKatoomba.hh.

Member Typedef Documentation

Definition at line 555 of file JKatoomba.hh.

Constructor & Destructor Documentation

JACOUSTICS::JKatoomba< JGandalf >::JKatoomba ( const JDetector detector,
const JSoundVelocity velocity,
const int  option 
)
inline

Constructor.

Parameters
detectordetector
velocitysound velocity
optionoption

Definition at line 565 of file JKatoomba.hh.

567  :
568  JKatoomba<>(detector, velocity, option)
569  {};
do set_variable DETECTOR_TXT $WORKDIR detector

Member Function Documentation

template<class T >
result_type JACOUSTICS::JKatoomba< JGandalf >::operator() ( T  __begin,
T  __end 
)
inline

Fit.

Parameters
__beginbegin of hits
__endend of hits
Returns
chi2 and gradient

Definition at line 580 of file JKatoomba.hh.

581  {
582  using namespace std;
583  using namespace JPP;
584 
585  value.setOption(this->option);
586 
587  const int N = value.getN();
588 
589  V.resize(N);
590  Y.resize(N);
591  h.resize(N);
592 
593  lambda = LAMBDA_MIN;
594 
595  result_type precessor = numeric_limits<double>::max();
596 
598 
599  DEBUG("step: " << numberOfIterations << endl);
600 
601  evaluate(__begin, __end);
602 
603  DEBUG("lambda: " << FIXED(12,5) << lambda << endl);
604  DEBUG("chi2: " << FIXED(12,5) << successor << endl);
605 
606  if (successor < precessor) {
607 
608  if (numberOfIterations != 0) {
609 
610  if (fabs(precessor - successor) < EPSILON*fabs(precessor)) {
611  return successor;
612  }
613 
614  if (lambda > LAMBDA_MIN) {
615  lambda /= LAMBDA_DOWN;
616  }
617  }
618 
619  precessor = successor;
620  previous = value;
621 
622  } else {
623 
624  value = previous;
625  lambda *= LAMBDA_UP;
626 
627  if (lambda > LAMBDA_MAX) {
628  return precessor; // no improvement found
629  }
630 
631  evaluate(__begin, __end);
632  }
633 
634 
635  // force definite positiveness
636 
637  for (int i = 0; i != N; ++i) {
638 
639  if (V(i,i) < PIVOT) {
640  V(i,i) = PIVOT;
641  }
642 
643  h[i] = 1.0 / sqrt(V(i,i));
644  }
645 
646 
647  // normalisation
648 
649  for (int i = 0; i != N; ++i) {
650  for (int j = 0; j != i; ++j) {
651  V(j,i) *= h[i] * h[j];
652  V(i,j) = V(j,i);
653  }
654  }
655 
656  for (int i = 0; i != N; ++i) {
657  V(i,i) = 1.0 + lambda;
658  }
659 
660 
661  try {
662  V.invert();
663  }
664  catch (const JException& error) {
665  ERROR("JKatoomb<JGandalf>: " << error.what() << endl);
666  return precessor;
667  }
668 
669 
670  for (int i = 0; i != N; ++i) {
671 
672  DEBUG("u[" << noshowpos << setw(3) << i << "] = " << showpos << FIXED(20,5) << value[i]);
673 
674  double y = 0.0;
675 
676  for (int j = 0; j != N; ++j) {
677  y += V(i,j) * Y[j] * h[i] * h[j];
678  }
679 
680  value[i] -= y;
681 
682  DEBUG(' ' << FIXED(20,10) << y << noshowpos << endl);
683  }
684  }
685 
686  return precessor;
687  }
size_t getN() const
Get number of fit parameters.
General exception.
Definition: JException.hh:23
void setOption(const int option)
Set fit option.
static double LAMBDA_UP
multiplication factor control parameter
Definition: JKatoomba.hh:694
then JShowerPostfit f $INPUT_FILE o $OUTPUT_FILE N
Auxiliary data structure for floating point format specification.
Definition: JManip.hh:446
void resize(const size_t size)
Resize matrix.
Definition: JMatrixND.hh:421
static double EPSILON
maximal distance to minimum
Definition: JKatoomba.hh:691
static double LAMBDA_MIN
minimal value control parameter
Definition: JKatoomba.hh:692
void evaluate(T __begin, T __end)
Evaluation of fit.
Definition: JKatoomba.hh:711
#define ERROR(A)
Definition: JMessage.hh:66
static double LAMBDA_MAX
maximal value control parameter
Definition: JKatoomba.hh:693
static int MAXIMUM_ITERATIONS
maximal number of iterations
Definition: JKatoomba.hh:690
std::vector< double > h
Definition: JKatoomba.hh:814
void invert()
Invert matrix according LDU decomposition.
Definition: JMatrixNS.hh:80
virtual const char * what() const override
Get error message.
Definition: JException.hh:48
static double LAMBDA_DOWN
multiplication factor control parameter
Definition: JKatoomba.hh:695
static double PIVOT
minimal value diagonal element of matrix
Definition: JKatoomba.hh:696
int j
Definition: JPolint.hh:703
#define DEBUG(A)
Message macros.
Definition: JMessage.hh:62
std::vector< double > Y
Definition: JKatoomba.hh:811
template<class T >
void JACOUSTICS::JKatoomba< JGandalf >::evaluate ( T  __begin,
T  __end 
)
inlineprivate

Evaluation of fit.

Parameters
__beginbegin of data
__endend of data

Definition at line 711 of file JKatoomba.hh.

712  {
713  using namespace std;
714  using namespace JPP;
715 
716  successor = 0.0;
717 
718  V.reset();
719 
720  for (std::vector<double>::iterator i = Y.begin(); i != Y.end(); ++i) {
721  *i = 0.0;
722  }
723 
724  for (T hit = __begin; hit != __end; ++hit) {
725 
726  const JGEOMETRY::JString& string = detector[hit->getString()];
727  const JMODEL ::JString& parameters = value.string[hit->getString()];
728  const JPosition3D position = string.getPosition(parameters, hit->getFloor());
729 
730  const double D = hit->getDistance(position);
731  const double Vi = velocity.getInverseVelocity(D, hit->getZ(), position.getZ());
732  const double toa_s = value.emitter[hit->getEKey()].t1 + D * Vi;
733 
734  const double u = (toa_s - hit->getValue()) / hit->sigma;
735  const double W = sqrt(hit->getWeight());
736 
737  successor += (W*W) * estimator->getRho(u);
738 
739  H_t H(1.0, string.getGradient(parameters, hit->getPosition(), hit->getFloor()) * Vi);
740 
741  H *= W * estimator->getPsi(u) / hit->sigma;
742 
743  I_t i;
744 
745  i.t1 = value.getIndex(hit->getEKey(), &H_t::t1);
746  i.tx = value.getIndex(hit->getString(), &H_t::tx);
747  i.ty = value.getIndex(hit->getString(), &H_t::ty);
748  i.tx2 = value.getIndex(hit->getString(), &H_t::tx2);
749  i.ty2 = value.getIndex(hit->getString(), &H_t::ty2);
750  i.vs = value.getIndex(hit->getString(), &H_t::vs);
751 
752  V(i.t1, i.t1) += H.t1 * H.t1;
753 
754  Y[i.t1] += W * H.t1;
755 
756  if (hit->getFloor() != 0) {
757 
758  switch (this->option) {
759 
761  V(i.t1, i.vs) += H.t1 * H.vs; V(i.tx, i.vs) += H.tx * H.vs; V(i.ty, i.vs) += H.ty * H.vs; V(i.tx2, i.vs) += H.tx2 * H.vs; V(i.ty2, i.vs) += H.ty2 * H.vs;
762 
763  V(i.vs, i.t1) += H.vs * H.t1;
764  V(i.vs, i.tx) += H.vs * H.tx;
765  V(i.vs, i.ty) += H.vs * H.ty;
766  V(i.vs, i.tx2) += H.vs * H.tx2;
767  V(i.vs, i.ty2) += H.vs * H.ty2;
768 
769  V(i.vs, i.vs) += H.vs * H.vs;
770 
771  Y[i.vs] += W * H.vs;
772 
774  V(i.t1, i.tx2) += H.t1 * H.tx2; V(i.tx, i.tx2) += H.tx * H.tx2; V(i.ty, i.tx2) += H.ty * H.tx2;
775 
776  V(i.tx2, i.t1) += H.tx2 * H.t1;
777  V(i.tx2, i.tx) += H.tx2 * H.tx;
778  V(i.tx2, i.ty) += H.tx2 * H.ty;
779 
780  V(i.t1, i.ty2) += H.t1 * H.ty2; V(i.tx, i.ty2) += H.tx * H.ty2; V(i.ty, i.ty2) += H.ty * H.ty2;
781 
782  V(i.ty2, i.t1) += H.ty2 * H.t1;
783  V(i.ty2, i.tx) += H.ty2 * H.tx;
784  V(i.ty2, i.ty) += H.ty2 * H.ty;
785 
786  V(i.tx2, i.tx2) += H.tx2 * H.tx2; V(i.tx2, i.ty2) += H.tx2 * H.ty2;
787  V(i.ty2, i.tx2) += H.ty2 * H.tx2; V(i.ty2, i.ty2) += H.ty2 * H.ty2;
788 
789  Y[i.tx2] += W * H.tx2;
790  Y[i.ty2] += W * H.ty2;
791 
793  V(i.t1, i.tx) += H.t1 * H.tx; V(i.t1, i.ty) += H.t1 * H.ty;
794  V(i.tx, i.t1) += H.tx * H.t1; V(i.ty, i.t1) += H.ty * H.t1;
795 
796  V(i.tx, i.tx) += H.tx * H.tx; V(i.tx, i.ty) += H.tx * H.ty;
797  V(i.ty, i.tx) += H.ty * H.tx; V(i.ty, i.ty) += H.ty * H.ty;
798 
799  Y[i.tx] += W * H.tx;
800  Y[i.ty] += W * H.ty;
801  break;
802 
803  default:
804  break;
805  }
806  }
807  }
808  }
fit times of emission of emitters and tilt angles of strings with second order correction and stretch...
static const double H
Planck constant [eV s].
*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
JMatrixND & reset()
Set matrix to the null matrix.
Definition: JMatrixND.hh:434
fit times of emission of emitters and tilt angles of strings
Detector file.
Definition: JHead.hh:226
do set_variable OUTPUT_DIRECTORY $WORKDIR T
const JPosition3D & getPosition() const
Get position.
Definition: JPosition3D.hh:130
fit times of emission of emitters and tilt angles of strings with second order correction ...
size_t getIndex(int id, double JString::*p) const
Get index of fit parameter for given string.
JACOUSTICS::JModel::string_type string
JACOUSTICS::JModel::emitter_type emitter
Data structure for position in three dimensions.
Definition: JPosition3D.hh:36
double u[N+1]
Definition: JPolint.hh:776
do echo Generating $dir eval D
Definition: JDrawLED.sh:53
double getZ() const
Get z position.
Definition: JVector3D.hh:115
std::vector< double > Y
Definition: JKatoomba.hh:811

Member Data Documentation

int JACOUSTICS::JKatoomba< JGandalf >::debug = 0
static

debug level

debug level.

Definition at line 689 of file JKatoomba.hh.

int JACOUSTICS::JKatoomba< JGandalf >::MAXIMUM_ITERATIONS = 1000
static

maximal number of iterations

maximal number of iterations.

Definition at line 690 of file JKatoomba.hh.

double JACOUSTICS::JKatoomba< JGandalf >::EPSILON = 1.0e-3
static

maximal distance to minimum

maximal distance to minimum.

Definition at line 691 of file JKatoomba.hh.

double JACOUSTICS::JKatoomba< JGandalf >::LAMBDA_MIN = 0.01
static

minimal value control parameter

Definition at line 692 of file JKatoomba.hh.

double JACOUSTICS::JKatoomba< JGandalf >::LAMBDA_MAX = 100.0
static

maximal value control parameter

Definition at line 693 of file JKatoomba.hh.

double JACOUSTICS::JKatoomba< JGandalf >::LAMBDA_UP = 9.0
static

multiplication factor control parameter

Definition at line 694 of file JKatoomba.hh.

double JACOUSTICS::JKatoomba< JGandalf >::LAMBDA_DOWN = 11.0
static

multiplication factor control parameter

Definition at line 695 of file JKatoomba.hh.

double JACOUSTICS::JKatoomba< JGandalf >::PIVOT = 1.0e-3
static

minimal value diagonal element of matrix

Definition at line 696 of file JKatoomba.hh.

double JACOUSTICS::JKatoomba< JGandalf >::lambda

Definition at line 698 of file JKatoomba.hh.

Definition at line 699 of file JKatoomba.hh.

int JACOUSTICS::JKatoomba< JGandalf >::numberOfIterations

Definition at line 700 of file JKatoomba.hh.

Definition at line 701 of file JKatoomba.hh.

Definition at line 811 of file JKatoomba.hh.

Definition at line 812 of file JKatoomba.hh.

JModel JACOUSTICS::JKatoomba< JGandalf >::previous
private

Definition at line 813 of file JKatoomba.hh.

Definition at line 814 of file JKatoomba.hh.


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