1#ifndef __JACOUSTICS__JMODEL__
2#define __JACOUSTICS__JMODEL__
60 public JMath <JString>,
86 const double tx2 = 0.0,
87 const double ty2 = 0.0,
88 const double vs = 0.0) :
223 const double precision = std::numeric_limits<double>::min())
const
225 return (fabs(
tx -
string.
tx) <= precision &&
226 fabs(
ty -
string.
ty) <= precision &&
227 fabs(
tx2 -
string.
tx2) <= precision &&
228 fabs(
ty2 -
string.
ty2) <= precision &&
229 fabs(
vs -
string.
vs) <= precision);
262 return atan2(
ty,
tx);
274 return (
tx *
string.
tx +
291 return in >>
string.tx >>
string.ty >>
string.tx2 >>
string.ty2 >>
string.vs;
307 return out <<
FIXED(10,7) <<
string.tx <<
' '
308 <<
FIXED(10,7) <<
string.ty <<
' '
311 <<
FIXED(8,5) <<
string.vs;
327 public JMath <JEmission>,
444 const double precision = std::numeric_limits<double>::min())
const
446 return (fabs(
t1 - emission.
t1) <= precision);
462 return out <<
FIXED(20,6) << emission.
t1;
478 public JMath <JModel>,
489 option(JMODEL::FIT_UNDEFINED_t)
508 option(JMODEL::FIT_UNDEFINED_t)
510 for (T hit = __begin; hit != __end; ++hit) {
512 if (!this->
string.has(hit->getString())) {
513 this->
string[hit->getString()] =
JString();
555 using namespace JMODEL;
559 case FIT_EMITTERS_ONLY_t:
560 case FIT_EMITTERS_AND_STRINGS_1st_ORDER_t:
561 case FIT_EMITTERS_AND_STRINGS_2nd_ORDER_t:
562 case FIT_EMITTERS_AND_STRINGS_2nd_ORDER_AND_STRETCHING_t:
563 this->option =
static_cast<JOption_t
>(
option);
599 this->
string .evaluate(&JString ::negate);
614 this->
string .evaluate(model.
string, &JString ::add);
629 this->
string .evaluate(model.
string, &JString ::sub);
644 this->
string .evaluate(&JString ::mul, factor);
659 this->
string .evaluate(&JString ::div, factor);
674 const double precision = std::numeric_limits<double>::min())
const
676 return (this->
string .
equals(model.
string, precision) &&
677 this->emission.equals(model.emission, precision));
694 out <<
"string: " << setw(4) << i->first <<
' ' << i->second << endl;
698 out <<
"emission: " << setw(3) << i->first <<
' ' << i->second << endl;
756 if (i <
string .
getN(this->
option)) {
return string .getParameter(i, this->
option); }
776 if (i <
string .
getN(this->
option)) {
return string .getParameter(i, this->
option); }
808 template<
class key_type,
class value_type,
class evaluator_type = JHashEvaluator>
810 public JHashMap<key_type, value_type, evaluator_type>
822 return this->size() * value_type::getN(
option);
839 return static_cast<const hashmap_type&
>(*this).
getIndex(key) * value_type::getN(
option) + ((
double*) &(__p__->*p) - (
double*) __p__);
854 const size_t pos = index / value_type::getN(
option);
855 const size_t offset = index % value_type::getN(
option);
857 const value_type& value = this->data()[pos].second;
859 return ((
const double*) &value)[offset];
872 const size_t pos = index / value_type::getN(
option);
873 const size_t offset = index % value_type::getN(
option);
877 return ((
double*) &value)[offset];
903 ((*this)[i->first].*f1)(i->second);
917 (i->second.*f1)(factor);
932 q = buffer.begin(); ; ++p, ++q) {
934 if (p != this->end() && q != buffer.end()) {
936 if (p->first != q->first || p->second != q->second) {
940 }
else if (p == this->end() && q == buffer.end()) {
963 q = buffer.begin(); ; ++p, ++q) {
965 if (p != this->end() && q != buffer.end()) {
967 if (p->first != q->first || !p->second.equals(q->second, precision)) {
971 }
else if (p == this->end() && q == buffer.end()) {
1036 return helper(*
this,
id);
1046 public hash_map<int, JString, hash_evaluator>
#define THROW(JException_t, A)
Marco for throwing exception with std::ostream compatible message.
General purpose class for hash map of unique elements.
Base class for data structures with artithmetic capabilities.
Definition of zero value for any class.
Exception for accessing an index in a collection that is outside of its range.
Exception for accessing a value in a collection that is outside of its range.
@ 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_UNDEFINED_t
fit undefined
@ 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...
Auxiliary classes and methods for acoustic position calibration.
This name space includes all other name spaces (except KM3NETDAQ, KM3NET and ANTARES).
Auxiliary data structure for floating point format specification.
JEmission(const double t1)
Constructor.
bool equals(const JEmission &emission, const double precision=std::numeric_limits< double >::min()) const
Check equality.
static size_t getN(const JMODEL::JOption_t option)
Get number of fit parameters.
JEmission & add(const JEmission &emission)
Add emission.
JEmission & div(const double factor)
Scale emission.
JEmission()
Default constructor.
JEmission & negate()
Negate emission.
JEmission & mul(const double factor)
Scale emission.
JEmission & sub(const JEmission &emission)
Subtract emission.
friend std::ostream & operator<<(std::ostream &out, const JEmission &emission)
Write emission parameters to output stream.
static size_t getN(const JMODEL::JOption_t option)
Get number of fit parameters.
JString & add(const JString &string)
Add string.
double getAngle() const
Get angle.
double getLengthSquared() const
Get length squared.
JString & div(const double factor)
Scale string.
double getDot(const JString &string) const
Get dot product.
JString & sub(const JString &string)
Subtract string.
friend std::ostream & operator<<(std::ostream &out, const JString &string)
Write string parameters to output stream.
JString()
Default constructor.
JString & negate()
Negate string.
double getLength() const
Get length.
JString(const double tx, const double ty, const double tx2=0.0, const double ty2=0.0, const double vs=0.0)
Constructor.
JString & mul(const double factor)
Scale string.
friend std::istream & operator>>(std::istream &in, JString &string)
Read string parameters from input stream.
bool equals(const JString &string, const double precision=std::numeric_limits< double >::min()) const
Check equality.
Auxiliary class for multiple associative map operators.
helper(hash_map< JEKey, JEmission > &map, int id)
Constructor.
JEmission & operator[](const int counter)
Get value corresponding to event counter (i.e. second part of JEKey).
hash_map< JEKey, JEmission > & map
Map emission key to model parameters of emission.
helper operator[](int id)
Get helper corresponding to emission identifier (i.e. first part of JEKey).
Auxiliary data structure for common fit parameters.
int operator()(const unsigned long long int key) const
Get hash value.
int operator()(const long long int key) const
Get hash value.
int operator()(const int key) const
Get hash value.
int operator()(const unsigned char key) const
Get hash value.
static bool singularity
Option for common fit parameters.
int operator()(const short key) const
Get hash value.
int operator()(const unsigned int key) const
Get hash value.
int operator()(const unsigned long int key) const
Get hash value.
int operator()(const long int key) const
Get hash value.
int operator()(const unsigned short key) const
Get hash value.
int operator()(const char key) const
Get hash value.
Auxiliary data structure with extended functionality of hash-map.
void evaluate(value_type &(value_type::*f1)(const double), const double factor)
Evaluate arithmetic operation.
double & getParameter(const size_t index, const JMODEL::JOption_t option)
Get read/write access to fit parameter value at given index in buffer.
void evaluate(value_type &(value_type::*f1)())
Evaluate arithmetic operation.
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 getIndex(const key_type key, double value_type::*p, const JMODEL::JOption_t option) const
Get index of parameter.
JHashMap< key_type, value_type, evaluator_type > hashmap_type
size_t getN(const JMODEL::JOption_t option) const
Get number of fit parameters.
void evaluate(const hash_map &buffer, value_type &(value_type::*f1)(const value_type &))
Evaluate arithmetic operation.
bool equals(const hash_map &buffer, const double precision) const
Check equality of has map.
bool equals(const hash_map &buffer) const
Check equality of hash map.
Map string identifier to model parameters of string.
Model for fit to acoustics data.
JModel & div(const double factor)
Scale model.
void reset()
Reset parameters.
void setOption(const int option)
Set fit option.
size_t getIndex(const JEKey &id, double JEmission::*p) const
Get index of fit parameter for given emission.
size_t getN() const
Get number of fit parameters.
JACOUSTICS::JModel::emission_type emission
size_t getIndex(int id, double JString::*p) const
Get index of fit parameter for given string.
JMODEL::JEmission JEmission
JACOUSTICS::JModel::string_type string
JModel(T __begin, T __end)
Constructor.
JModel & sub(const JModel &model)
Subtract model.
JModel & operator=(const JMATH::JZero &zero)
Reset parameters.
JMODEL::JOption_t getOption() const
Get fit option.
bool equals(const JModel &model, const double precision=std::numeric_limits< double >::min()) const
Check equality.
JModel()
Default constructor.
double operator[](const size_t index) const
Read access to fit parameter value by index.
JModel & mul(const double factor)
Scale model.
double & operator[](const size_t index)
Read/write access to fit parameter value by index.
JModel & negate()
Negate model.
friend std::ostream & operator<<(std::ostream &out, const JModel &model)
Write model parameters to output stream.
void clear()
Clear parameters.
JModel & add(const JModel &model)
Add model.
Template definition of auxiliary base class for comparison of data structures.
Auxiliary base class for aritmetic operations of derived class types.
Auxiliary class to assign zero value.
Auxiliary data structure for floating point format specification.