Jpp  master_rocky-37-gf0c5bc59d
the software that should make you happy
Classes | Public Types | Public Member Functions | Public Attributes | Private Attributes | Friends | List of all members
JACOUSTICS::JModel Struct Reference

Model for fit to acoustics data. More...

#include <JModel.hh>

Inheritance diagram for JACOUSTICS::JModel:
JMATH::JMath< JFirst_t, JSecond_t > JLANG::JEquals< JFirst_t, JSecond_t > JACOUSTICS::getModel

Classes

struct  emission_type
 Map emission key to model parameters of emission. More...
 
struct  hash_evaluator
 Auxiliary data structure for common fit parameters. More...
 
struct  hash_map
 Auxiliary data structure with extended functionality of hash-map. More...
 
struct  string_type
 Map string identifier to model parameters of string. More...
 

Public Types

typedef JMODEL::JString JString
 
typedef JMODEL::JEmission JEmission
 

Public Member Functions

 JModel ()
 Default constructor. More...
 
template<class T >
 JModel (T __begin, T __end)
 Constructor. More...
 
JModeloperator= (const JMATH::JZero &zero)
 Reset parameters. More...
 
JMODEL::JOption_t getOption () const
 Get fit option. More...
 
void setOption (const int option)
 Set fit option. More...
 
void clear ()
 Clear parameters. More...
 
void reset ()
 Reset parameters. More...
 
JModelnegate ()
 Negate model. More...
 
JModeladd (const JModel &model)
 Add model. More...
 
JModelsub (const JModel &model)
 Subtract model. More...
 
JModelmul (const double factor)
 Scale model. More...
 
JModeldiv (const double factor)
 Scale model. More...
 
bool equals (const JModel &model, const double precision=std::numeric_limits< double >::min()) const
 Check equality. More...
 
size_t getN () const
 Get number of fit parameters. More...
 
size_t getIndex (int id, double JString::*p) const
 Get index of fit parameter for given string. More...
 
size_t getIndex (const JEKey &id, double JEmission::*p) const
 Get index of fit parameter for given emission. More...
 
double operator[] (const size_t index) const
 Read access to fit parameter value by index. More...
 
double & operator[] (const size_t index)
 Read/write access to fit parameter value by index. More...
 
JFirst_t & mul (const JSecond_t &object)
 Multiply with object. More...
 

Public Attributes

JACOUSTICS::JModel::emission_type emission
 
JACOUSTICS::JModel::string_type string
 

Private Attributes

JMODEL::JOption_t option
 

Friends

std::ostream & operator<< (std::ostream &out, const JModel &model)
 Write model parameters to output stream. More...
 

Detailed Description

Model for fit to acoustics data.

The model consists of string parameters and emission parameters.
These parameters relate to the string identifer and emission key, respectively.

Definition at line 477 of file JAcoustics/JModel.hh.

Member Typedef Documentation

◆ JString

Definition at line 481 of file JAcoustics/JModel.hh.

◆ JEmission

Definition at line 482 of file JAcoustics/JModel.hh.

Constructor & Destructor Documentation

◆ JModel() [1/2]

JACOUSTICS::JModel::JModel ( )
inline

Default constructor.

Definition at line 488 of file JAcoustics/JModel.hh.

488  :
490  {}
@ FIT_UNDEFINED_t
fit undefined
JMODEL::JOption_t option

◆ JModel() [2/2]

template<class T >
JACOUSTICS::JModel::JModel ( __begin,
__end 
)
inline

Constructor.

This constructor can be used to set up a default model (i.e. all values at zero) for the given set of hits.
The data type corresponding to the hits should provide for the following policy methods.

   int      getString();        // get string identifier
   JEKey    getEKey();          // get emission key
Parameters
__beginbegin of hits
__endend of hits

Definition at line 507 of file JAcoustics/JModel.hh.

507  :
509  {
510  for (T hit = __begin; hit != __end; ++hit) {
511 
512  if (!this->string.has(hit->getString())) {
513  this->string[hit->getString()] = JString();
514  }
515 
516  if (!this->emission.has(hit->getEKey())) {
517  this->emission[hit->getEKey()] = JEmission();
518  }
519  }
520  }
bool has(const T &value) const
Test whether given value is present.
JMODEL::JEmission JEmission
JMODEL::JString JString
JACOUSTICS::JModel::emission_type emission

Member Function Documentation

◆ operator=()

JModel& JACOUSTICS::JModel::operator= ( const JMATH::JZero zero)
inline

Reset parameters.

Parameters
zerozero
Returns
this model

Definition at line 529 of file JAcoustics/JModel.hh.

530  {
531  this->reset();
532 
533  return *this;
534  }
void reset()
Reset parameters.

◆ getOption()

JMODEL::JOption_t JACOUSTICS::JModel::getOption ( ) const
inline

Get fit option.

Returns
option

Definition at line 542 of file JAcoustics/JModel.hh.

543  {
544  return option;
545  }

◆ setOption()

void JACOUSTICS::JModel::setOption ( const int  option)
inline

Set fit option.

Parameters
optionoption

Definition at line 553 of file JAcoustics/JModel.hh.

554  {
555  using namespace JMODEL;
556 
557  switch (option) {
558 
559  case FIT_EMITTERS_ONLY_t:
563  this->option = static_cast<JOption_t>(option);
564  break;
565 
566  default:
567  THROW(JValueOutOfRange, "Invalid option " << option);
568  }
569  }
#define THROW(JException_t, A)
Marco for throwing exception with std::ostream compatible message.
Definition: JException.hh:712
Exception for accessing a value in a collection that is outside of its range.
Definition: JException.hh:180
@ FIT_EMITTERS_AND_STRINGS_1st_ORDER_t
fit times of emission of emitters and tilt angles of strings
@ FIT_EMITTERS_AND_STRINGS_2nd_ORDER_t
fit times of emission of emitters and tilt angles of strings with second order correction
@ FIT_EMITTERS_ONLY_t
fit only times of emission of emitters
@ FIT_EMITTERS_AND_STRINGS_2nd_ORDER_AND_STRETCHING_t
fit times of emission of emitters and tilt angles of strings with second order correction and stretch...
JOption_t
Fit options.
Definition: JFitK40.hh:52

◆ clear()

void JACOUSTICS::JModel::clear ( )
inline

Clear parameters.

Definition at line 575 of file JAcoustics/JModel.hh.

576  {
577  string .clear();
578  emission.clear();
579  }
virtual void clear() override
Clear.
Definition: JHashMap.hh:107

◆ reset()

void JACOUSTICS::JModel::reset ( )
inline

Reset parameters.

Definition at line 585 of file JAcoustics/JModel.hh.

586  {
587  string .reset();
588  emission.reset();
589  }
void reset()
Reset values.
Definition: JHashMap.hh:116

◆ negate()

JModel& JACOUSTICS::JModel::negate ( )
inline

Negate model.

Returns
this model

Definition at line 597 of file JAcoustics/JModel.hh.

598  {
599  this->string .evaluate(&JString ::negate);
601 
602  return *this;
603  }
JEmission & negate()
Negate emission.
JString & negate()
Negate string.
void evaluate(value_type &(value_type::*f1)())
Evaluate arithmetic operation.

◆ add()

JModel& JACOUSTICS::JModel::add ( const JModel model)
inline

Add model.

Parameters
modelmodel
Returns
this model

Definition at line 612 of file JAcoustics/JModel.hh.

613  {
614  this->string .evaluate(model.string, &JString ::add);
615  this->emission.evaluate(model.emission, &JEmission::add);
616 
617  return *this;
618  }
JEmission & add(const JEmission &emission)
Add emission.
JString & add(const JString &string)
Add string.
JACOUSTICS::JModel::string_type string

◆ sub()

JModel& JACOUSTICS::JModel::sub ( const JModel model)
inline

Subtract model.

Parameters
modelmodel
Returns
this model

Definition at line 627 of file JAcoustics/JModel.hh.

628  {
629  this->string .evaluate(model.string, &JString ::sub);
630  this->emission.evaluate(model.emission, &JEmission::sub);
631 
632  return *this;
633  }
JEmission & sub(const JEmission &emission)
Subtract emission.
JString & sub(const JString &string)
Subtract string.

◆ mul() [1/2]

JModel& JACOUSTICS::JModel::mul ( const double  factor)
inline

Scale model.

Parameters
factormultiplication factor
Returns
this model

Definition at line 642 of file JAcoustics/JModel.hh.

643  {
644  this->string .evaluate(&JString ::mul, factor);
645  this->emission.evaluate(&JEmission::mul, factor);
646 
647  return *this;
648  }
JEmission & mul(const double factor)
Scale emission.
JString & mul(const double factor)
Scale string.

◆ div()

JModel& JACOUSTICS::JModel::div ( const double  factor)
inline

Scale model.

Parameters
factordivision factor
Returns
this model

Definition at line 657 of file JAcoustics/JModel.hh.

658  {
659  this->string .evaluate(&JString ::div, factor);
660  this->emission.evaluate(&JEmission::div, factor);
661 
662  return *this;
663  }
JEmission & div(const double factor)
Scale emission.
JString & div(const double factor)
Scale string.

◆ equals()

bool JACOUSTICS::JModel::equals ( const JModel model,
const double  precision = std::numeric_limits<double>::min() 
) const
inline

Check equality.

Parameters
modelmodel
precisionprecision
Returns
true if models are equal; else false

Definition at line 673 of file JAcoustics/JModel.hh.

675  {
676  return (this->string .equals(model.string, precision) &&
677  this->emission.equals(model.emission, precision));
678  }
bool equals(const JModel &model, const double precision=std::numeric_limits< double >::min()) const
Check equality.

◆ getN()

size_t JACOUSTICS::JModel::getN ( ) const
inline

Get number of fit parameters.

Returns
number of parameters

Definition at line 710 of file JAcoustics/JModel.hh.

711  {
712  return emission.getN(this->option) + string.getN(this->option);
713  }
size_t getN(const JMODEL::JOption_t option) const
Get number of fit parameters.

◆ getIndex() [1/2]

size_t JACOUSTICS::JModel::getIndex ( int  id,
double JString::*  p 
) const
inline

Get index of fit parameter for given string.

Parameters
idstring identifier
ppointer to data member
Returns
parameter

Definition at line 723 of file JAcoustics/JModel.hh.

724  {
725  return emission.getN(this->option) + string.getIndex(id, p, this->option);
726  }

◆ getIndex() [2/2]

size_t JACOUSTICS::JModel::getIndex ( const JEKey id,
double JEmission::*  p 
) const
inline

Get index of fit parameter for given emission.

Parameters
idemission key
ppointer to data member
Returns
parameter

Definition at line 736 of file JAcoustics/JModel.hh.

737  {
738  return emission.getIndex(id, p, this->option);
739  }
size_t getIndex(const key_type key, double value_type::*p, const JMODEL::JOption_t option) const
Get index of parameter.

◆ operator[]() [1/2]

double JACOUSTICS::JModel::operator[] ( const size_t  index) const
inline

Read access to fit parameter value by index.

Parameters
indexindex
Returns
value

Definition at line 748 of file JAcoustics/JModel.hh.

749  {
750  size_t i = index;
751 
752  if (i < emission.getN(this->option)) { return emission.getParameter(i, this->option); }
753 
754  i -= emission.getN(this->option);
755 
756  if (i < string .getN(this->option)) { return string .getParameter(i, this->option); }
757 
758  THROW(JIndexOutOfRange, "Invalid index " << index << " >= " << getN());
759  }
Exception for accessing an index in a collection that is outside of its range.
Definition: JException.hh:108
double getParameter(const size_t index, const JMODEL::JOption_t option) const
Get read access to fit parameter value at given index in buffer.
size_t getN() const
Get number of fit parameters.

◆ operator[]() [2/2]

double& JACOUSTICS::JModel::operator[] ( const size_t  index)
inline

Read/write access to fit parameter value by index.

Parameters
indexindex
Returns
value

Definition at line 768 of file JAcoustics/JModel.hh.

769  {
770  size_t i = index;
771 
772  if (i < emission.getN(this->option)) { return emission.getParameter(i, this->option); }
773 
774  i -= emission.getN(this->option);
775 
776  if (i < string .getN(this->option)) { return string .getParameter(i, this->option); }
777 
778  THROW(JIndexOutOfRange, "Invalid index " << index << " >= " << getN());
779  }

◆ mul() [2/2]

template<class JFirst_t , class JSecond_t >
JFirst_t& JMATH::JMath< JFirst_t, JSecond_t >::mul ( const JSecond_t &  object)
inlineinherited

Multiply with object.

Parameters
objectobject
Returns
result object

Definition at line 354 of file JMath.hh.

355  {
356  return static_cast<JFirst_t&>(*this) = JFirst_t().mul(static_cast<const JFirst_t&>(*this), object);
357  }

Friends And Related Function Documentation

◆ operator<<

std::ostream& operator<< ( std::ostream &  out,
const JModel model 
)
friend

Write model parameters to output stream.

Parameters
outoutput stream
modelmodel
Returns
output stream

Definition at line 688 of file JAcoustics/JModel.hh.

689  {
690  using namespace std;
691  using namespace JPP;
692 
693  for (hash_map<int, JString>::const_iterator i = model.string.begin(); i != model.string.end(); ++i) {
694  out << "string: " << setw(4) << i->first << ' ' << i->second << endl;
695  }
696 
697  for (hash_map<JEKey, JEmission>::const_iterator i = model.emission.begin(); i != model.emission.end(); ++i) {
698  out << "emission: " << setw(3) << i->first << ' ' << i->second << endl;
699  }
700 
701  return out;
702  }
This name space includes all other name spaces (except KM3NETDAQ, KM3NET and ANTARES).
Definition: JSTDTypes.hh:14
container_type::const_iterator const_iterator
Definition: JHashMap.hh:86

Member Data Documentation

◆ emission

JACOUSTICS::JModel::emission_type JACOUSTICS::JModel::emission

◆ string

JACOUSTICS::JModel::string_type JACOUSTICS::JModel::string

◆ option

JMODEL::JOption_t JACOUSTICS::JModel::option
private

Definition at line 1050 of file JAcoustics/JModel.hh.


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