Jpp  18.0.0-rc.1
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 JGeometry &geometry, 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 556 of file JKatoomba.hh.

Member Typedef Documentation

Definition at line 559 of file JKatoomba.hh.

Constructor & Destructor Documentation

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

Constructor.

Parameters
geometrydetector geometry
velocitysound velocity
optionoption

Definition at line 569 of file JKatoomba.hh.

571  :
572  JKatoomba<>(geometry, velocity, option)
573  {};

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 584 of file JKatoomba.hh.

585  {
586  using namespace std;
587  using namespace JPP;
588 
589  value.setOption(this->option);
590 
591  const int N = value.getN();
592 
593  V.resize(N);
594  Y.resize(N);
595  h.resize(N);
596 
597  lambda = LAMBDA_MIN;
598 
599  result_type precessor = numeric_limits<double>::max();
600 
602 
603  DEBUG("step: " << numberOfIterations << endl);
604 
605  evaluate(__begin, __end);
606 
607  DEBUG("lambda: " << FIXED(12,5) << lambda << endl);
608  DEBUG("chi2: " << FIXED(12,5) << successor << endl);
609 
610  if (successor < precessor) {
611 
612  if (numberOfIterations != 0) {
613 
614  if (fabs(precessor - successor) < EPSILON*fabs(precessor)) {
615  return successor;
616  }
617 
618  if (lambda > LAMBDA_MIN) {
619  lambda /= LAMBDA_DOWN;
620  }
621  }
622 
623  precessor = successor;
624  previous = value;
625 
626  } else {
627 
628  value = previous;
629  lambda *= LAMBDA_UP;
630 
631  if (lambda > LAMBDA_MAX) {
632  return precessor; // no improvement found
633  }
634 
635  evaluate(__begin, __end);
636  }
637 
638 
639  // force definite positiveness
640 
641  for (int i = 0; i != N; ++i) {
642 
643  if (V(i,i) < PIVOT) {
644  V(i,i) = PIVOT;
645  }
646 
647  h[i] = 1.0 / sqrt(V(i,i));
648  }
649 
650 
651  // normalisation
652 
653  for (int i = 0; i != N; ++i) {
654  for (int j = 0; j != i; ++j) {
655  V(j,i) *= h[i] * h[j];
656  V(i,j) = V(j,i);
657  }
658  }
659 
660  for (int i = 0; i != N; ++i) {
661  V(i,i) = 1.0 + lambda;
662  }
663 
664 
665  try {
666  V.invert();
667  }
668  catch (const JException& error) {
669  ERROR("JKatoomb<JGandalf>: " << error.what() << endl);
670  return precessor;
671  }
672 
673 
674  for (int i = 0; i != N; ++i) {
675 
676  DEBUG("u[" << noshowpos << setw(3) << i << "] = " << showpos << FIXED(20,5) << value[i]);
677 
678  double y = 0.0;
679 
680  for (int j = 0; j != N; ++j) {
681  y += V(i,j) * Y[j] * h[i] * h[j];
682  }
683 
684  value[i] -= y;
685 
686  DEBUG(' ' << FIXED(20,10) << y << noshowpos << endl);
687  }
688  }
689 
690  return precessor;
691  }
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:698
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:695
static double LAMBDA_MIN
minimal value control parameter
Definition: JKatoomba.hh:696
void evaluate(T __begin, T __end)
Evaluation of fit.
Definition: JKatoomba.hh:715
#define ERROR(A)
Definition: JMessage.hh:66
static double LAMBDA_MAX
maximal value control parameter
Definition: JKatoomba.hh:697
static int MAXIMUM_ITERATIONS
maximal number of iterations
Definition: JKatoomba.hh:694
std::vector< double > h
Definition: JKatoomba.hh:818
void invert()
Invert matrix according LDU decomposition.
Definition: JMatrixNS.hh:80
virtual const char * what() const override
Get error message.
Definition: JException.hh:48
then usage $script< input file >[option[primary[working directory]]] nWhere option can be N
Definition: JMuonPostfit.sh:36
static double LAMBDA_DOWN
multiplication factor control parameter
Definition: JKatoomba.hh:699
static double PIVOT
minimal value diagonal element of matrix
Definition: JKatoomba.hh:700
int j
Definition: JPolint.hh:703
#define DEBUG(A)
Message macros.
Definition: JMessage.hh:62
std::vector< double > Y
Definition: JKatoomba.hh:815
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 715 of file JKatoomba.hh.

716  {
717  using namespace std;
718  using namespace JPP;
719 
720  successor = 0.0;
721 
722  V.reset();
723 
724  for (std::vector<double>::iterator i = Y.begin(); i != Y.end(); ++i) {
725  *i = 0.0;
726  }
727 
728  for (T hit = __begin; hit != __end; ++hit) {
729 
730  const JGEOMETRY::JString& string = geometry[hit->getString()];
731  const JMODEL ::JString& parameters = value.string[hit->getString()];
732  const JPosition3D position = string.getPosition(parameters, hit->getFloor());
733 
734  const double D = hit->getDistance(position);
735  const double Vi = velocity.getInverseVelocity(D, hit->getZ(), position.getZ());
736  const double toa_s = value.emission[hit->getEKey()].t1 + D * Vi;
737 
738  const double u = (toa_s - hit->getValue()) / hit->getSigma();
739  const double W = sqrt(hit->getWeight());
740 
741  successor += (W*W) * estimator->getRho(u);
742 
743  H_t H(1.0, string.getGradient(parameters, hit->getPosition(), hit->getFloor()) * Vi);
744 
745  H *= W * estimator->getPsi(u) / hit->getSigma();
746 
747  I_t i;
748 
749  i.t1 = value.getIndex(hit->getEKey(), &H_t::t1);
750  i.tx = value.getIndex(hit->getString(), &H_t::tx);
751  i.ty = value.getIndex(hit->getString(), &H_t::ty);
752  i.tx2 = value.getIndex(hit->getString(), &H_t::tx2);
753  i.ty2 = value.getIndex(hit->getString(), &H_t::ty2);
754  i.vs = value.getIndex(hit->getString(), &H_t::vs);
755 
756  V(i.t1, i.t1) += H.t1 * H.t1;
757 
758  Y[i.t1] += W * H.t1;
759 
760  if (hit->getFloor() != 0) {
761 
762  switch (this->option) {
763 
765  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;
766 
767  V(i.vs, i.t1) += H.vs * H.t1;
768  V(i.vs, i.tx) += H.vs * H.tx;
769  V(i.vs, i.ty) += H.vs * H.ty;
770  V(i.vs, i.tx2) += H.vs * H.tx2;
771  V(i.vs, i.ty2) += H.vs * H.ty2;
772 
773  V(i.vs, i.vs) += H.vs * H.vs;
774 
775  Y[i.vs] += W * H.vs;
776 
778  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;
779 
780  V(i.tx2, i.t1) += H.tx2 * H.t1;
781  V(i.tx2, i.tx) += H.tx2 * H.tx;
782  V(i.tx2, i.ty) += H.tx2 * H.ty;
783 
784  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;
785 
786  V(i.ty2, i.t1) += H.ty2 * H.t1;
787  V(i.ty2, i.tx) += H.ty2 * H.tx;
788  V(i.ty2, i.ty) += H.ty2 * H.ty;
789 
790  V(i.tx2, i.tx2) += H.tx2 * H.tx2; V(i.tx2, i.ty2) += H.tx2 * H.ty2;
791  V(i.ty2, i.tx2) += H.ty2 * H.tx2; V(i.ty2, i.ty2) += H.ty2 * H.ty2;
792 
793  Y[i.tx2] += W * H.tx2;
794  Y[i.ty2] += W * H.ty2;
795 
797  V(i.t1, i.tx) += H.t1 * H.tx; V(i.t1, i.ty) += H.t1 * H.ty;
798  V(i.tx, i.t1) += H.tx * H.t1; V(i.ty, i.t1) += H.ty * H.t1;
799 
800  V(i.tx, i.tx) += H.tx * H.tx; V(i.tx, i.ty) += H.tx * H.ty;
801  V(i.ty, i.tx) += H.ty * H.tx; V(i.ty, i.ty) += H.ty * H.ty;
802 
803  Y[i.tx] += W * H.tx;
804  Y[i.ty] += W * H.ty;
805  break;
806 
807  default:
808  break;
809  }
810  }
811  }
812  }
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
std::vector< double > vs
do set_variable OUTPUT_DIRECTORY $WORKDIR T
JACOUSTICS::JModel::emission_type emission
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
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:815

Member Data Documentation

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

debug level

debug level.

Definition at line 693 of file JKatoomba.hh.

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

maximal number of iterations

maximal number of iterations.

Definition at line 694 of file JKatoomba.hh.

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

maximal distance to minimum

maximal distance to minimum.

Definition at line 695 of file JKatoomba.hh.

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

minimal value control parameter

Definition at line 696 of file JKatoomba.hh.

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

maximal value control parameter

Definition at line 697 of file JKatoomba.hh.

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

multiplication factor control parameter

Definition at line 698 of file JKatoomba.hh.

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

multiplication factor control parameter

Definition at line 699 of file JKatoomba.hh.

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

minimal value diagonal element of matrix

Definition at line 700 of file JKatoomba.hh.

double JACOUSTICS::JKatoomba< JGandalf >::lambda

Definition at line 702 of file JKatoomba.hh.

Definition at line 703 of file JKatoomba.hh.

int JACOUSTICS::JKatoomba< JGandalf >::numberOfIterations

Definition at line 704 of file JKatoomba.hh.

Definition at line 705 of file JKatoomba.hh.

Definition at line 815 of file JKatoomba.hh.

Definition at line 816 of file JKatoomba.hh.

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

Definition at line 817 of file JKatoomba.hh.

Definition at line 818 of file JKatoomba.hh.


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