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 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_t.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 629 of file JKatoomba_t.hh.

Member Typedef Documentation

Definition at line 632 of file JKatoomba_t.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 642 of file JKatoomba_t.hh.

644  :
645  JKatoomba<>(geometry, velocity, option)
646  {};

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 657 of file JKatoomba_t.hh.

658  {
659  using namespace std;
660  using namespace JPP;
661 
662  value.setOption(this->option);
663 
664  const int N = value.getN();
665 
666  V.resize(N);
667  Y.resize(N);
668  h.resize(N);
669 
670  lambda = LAMBDA_MIN;
671 
672  result_type precessor = numeric_limits<double>::max();
673 
675 
676  DEBUG("step: " << numberOfIterations << endl);
677 
678  evaluate(__begin, __end);
679 
680  DEBUG("lambda: " << FIXED(12,5) << lambda << endl);
681  DEBUG("chi2: " << FIXED(12,5) << successor << endl);
682 
683  if (successor < precessor) {
684 
685  if (numberOfIterations != 0) {
686 
687  if (fabs(precessor - successor) < EPSILON*fabs(precessor)) {
688  return successor;
689  }
690 
691  if (lambda > LAMBDA_MIN) {
692  lambda /= LAMBDA_DOWN;
693  }
694  }
695 
696  precessor = successor;
697  previous = value;
698 
699  } else {
700 
701  value = previous;
702  lambda *= LAMBDA_UP;
703 
704  if (lambda > LAMBDA_MAX) {
705  return precessor; // no improvement found
706  }
707 
708  evaluate(__begin, __end);
709  }
710 
711 
712  // force definite positiveness
713 
714  for (int i = 0; i != N; ++i) {
715 
716  if (V(i,i) < PIVOT) {
717  V(i,i) = PIVOT;
718  }
719 
720  h[i] = 1.0 / sqrt(V(i,i));
721  }
722 
723 
724  // normalisation
725 
726  for (int i = 0; i != N; ++i) {
727  for (int j = 0; j != i; ++j) {
728  V(j,i) *= h[i] * h[j];
729  V(i,j) = V(j,i);
730  }
731  }
732 
733  for (int i = 0; i != N; ++i) {
734  V(i,i) = 1.0 + lambda;
735  }
736 
737 
738  try {
739  V.invert();
740  }
741  catch (const JException& error) {
742  ERROR("JKatoomb<JGandalf>: " << error.what() << endl);
743  return precessor;
744  }
745 
746 
747  for (int i = 0; i != N; ++i) {
748 
749  DEBUG("u[" << noshowpos << setw(3) << i << "] = " << showpos << FIXED(20,5) << value[i]);
750 
751  double y = 0.0;
752 
753  for (int j = 0; j != N; ++j) {
754  y += V(i,j) * Y[j] * h[i] * h[j];
755  }
756 
757  value[i] -= y;
758 
759  DEBUG(' ' << FIXED(20,10) << y << noshowpos << endl);
760  }
761  }
762 
763  return precessor;
764  }
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_t.hh:771
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_t.hh:768
static double LAMBDA_MIN
minimal value control parameter
Definition: JKatoomba_t.hh:769
void evaluate(T __begin, T __end)
Evaluation of fit.
Definition: JKatoomba_t.hh:788
#define ERROR(A)
Definition: JMessage.hh:66
static double LAMBDA_MAX
maximal value control parameter
Definition: JKatoomba_t.hh:770
static int MAXIMUM_ITERATIONS
maximal number of iterations
Definition: JKatoomba_t.hh:767
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:40
static double LAMBDA_DOWN
multiplication factor control parameter
Definition: JKatoomba_t.hh:772
static double PIVOT
minimal value diagonal element of matrix
Definition: JKatoomba_t.hh:773
int j
Definition: JPolint.hh:703
#define DEBUG(A)
Message macros.
Definition: JMessage.hh:62
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 788 of file JKatoomba_t.hh.

789  {
790  using namespace std;
791  using namespace JPP;
792 
793  successor = 0.0;
794 
795  V.reset();
796 
797  for (std::vector<double>::iterator i = Y.begin(); i != Y.end(); ++i) {
798  *i = 0.0;
799  }
800 
801  for (T hit = __begin; hit != __end; ++hit) {
802 
803  const JGEOMETRY::JString& string = geometry[hit->getString()];
804  const JMODEL ::JString& parameters = value.string[hit->getString()];
805  const JPosition3D position = string.getPosition(parameters, hit->getFloor());
806 
807  const double D = hit->getDistance(position);
808  const double Vi = velocity.getInverseVelocity(D, hit->getZ(), position.getZ());
809  const double toa_s = value.emission[hit->getEKey()].t1 + D * Vi;
810 
811  const double u = (toa_s - hit->getValue()) / hit->getSigma();
812  const double W = sqrt(hit->getWeight());
813 
814  successor += (W*W) * estimator->getRho(u);
815 
816  H_t H(1.0, string.getGradient(parameters, hit->getPosition(), hit->getFloor()) * Vi);
817 
818  H *= W * estimator->getPsi(u) / hit->getSigma();
819 
820  I_t i;
821 
822  i.t1 = value.getIndex(hit->getEKey(), &H_t::t1);
823  i.tx = value.getIndex(hit->getString(), &H_t::tx);
824  i.ty = value.getIndex(hit->getString(), &H_t::ty);
825  i.tx2 = value.getIndex(hit->getString(), &H_t::tx2);
826  i.ty2 = value.getIndex(hit->getString(), &H_t::ty2);
827  i.vs = value.getIndex(hit->getString(), &H_t::vs);
828 
829  V(i.t1, i.t1) += H.t1 * H.t1;
830 
831  Y[i.t1] += W * H.t1;
832 
833  if (hit->getFloor() != 0) {
834 
835  switch (this->option) {
836 
838  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;
839 
840  V(i.vs, i.t1) += H.vs * H.t1;
841  V(i.vs, i.tx) += H.vs * H.tx;
842  V(i.vs, i.ty) += H.vs * H.ty;
843  V(i.vs, i.tx2) += H.vs * H.tx2;
844  V(i.vs, i.ty2) += H.vs * H.ty2;
845 
846  V(i.vs, i.vs) += H.vs * H.vs;
847 
848  Y[i.vs] += W * H.vs;
849 
851  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;
852 
853  V(i.tx2, i.t1) += H.tx2 * H.t1;
854  V(i.tx2, i.tx) += H.tx2 * H.tx;
855  V(i.tx2, i.ty) += H.tx2 * H.ty;
856 
857  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;
858 
859  V(i.ty2, i.t1) += H.ty2 * H.t1;
860  V(i.ty2, i.tx) += H.ty2 * H.tx;
861  V(i.ty2, i.ty) += H.ty2 * H.ty;
862 
863  V(i.tx2, i.tx2) += H.tx2 * H.tx2; V(i.tx2, i.ty2) += H.tx2 * H.ty2;
864  V(i.ty2, i.tx2) += H.ty2 * H.tx2; V(i.ty2, i.ty2) += H.ty2 * H.ty2;
865 
866  Y[i.tx2] += W * H.tx2;
867  Y[i.ty2] += W * H.ty2;
868 
870  V(i.t1, i.tx) += H.t1 * H.tx; V(i.t1, i.ty) += H.t1 * H.ty;
871  V(i.tx, i.t1) += H.tx * H.t1; V(i.ty, i.t1) += H.ty * H.t1;
872 
873  V(i.tx, i.tx) += H.tx * H.tx; V(i.tx, i.ty) += H.tx * H.ty;
874  V(i.ty, i.tx) += H.ty * H.tx; V(i.ty, i.ty) += H.ty * H.ty;
875 
876  Y[i.tx] += W * H.tx;
877  Y[i.ty] += W * H.ty;
878  break;
879 
880  default:
881  break;
882  }
883  }
884  }
885  }
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

Member Data Documentation

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

debug level

debug level.

Definition at line 766 of file JKatoomba_t.hh.

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

maximal number of iterations

maximal number of iterations.

Definition at line 767 of file JKatoomba_t.hh.

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

maximal distance to minimum

maximal distance to minimum.

Definition at line 768 of file JKatoomba_t.hh.

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

minimal value control parameter

Definition at line 769 of file JKatoomba_t.hh.

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

maximal value control parameter

Definition at line 770 of file JKatoomba_t.hh.

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

multiplication factor control parameter

Definition at line 771 of file JKatoomba_t.hh.

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

multiplication factor control parameter

Definition at line 772 of file JKatoomba_t.hh.

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

minimal value diagonal element of matrix

Definition at line 773 of file JKatoomba_t.hh.

double JACOUSTICS::JKatoomba< JGandalf >::lambda

Definition at line 775 of file JKatoomba_t.hh.

Definition at line 776 of file JKatoomba_t.hh.

int JACOUSTICS::JKatoomba< JGandalf >::numberOfIterations

Definition at line 777 of file JKatoomba_t.hh.

Definition at line 778 of file JKatoomba_t.hh.

Definition at line 888 of file JKatoomba_t.hh.

Definition at line 889 of file JKatoomba_t.hh.

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

Definition at line 890 of file JKatoomba_t.hh.

Definition at line 891 of file JKatoomba_t.hh.


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