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>,
510 for (T hit = __begin; hit != __end; ++hit) {
512 if (!this->
string.has(hit->getString())) {
513 this->
string[hit->getString()] =
JString();
516 if (!this->emission.has(hit->getEKey())) {
517 this->emission[hit->getEKey()] =
JEmission();
555 using namespace JMODEL;
563 this->option =
static_cast<JOption_t>(option);
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;
712 return emission.getN(this->option) +
string.getN(this->option);
725 return emission.getN(this->option) +
string.getIndex(
id, p, this->option);
738 return emission.getIndex(
id, p, this->option);
752 if (i < emission.getN(this->option)) {
return emission.getParameter(i, this->option); }
754 i -= emission.getN(this->option);
756 if (i <
string .
getN(this->option)) {
return string .getParameter(i, this->option); }
772 if (i < emission.getN(this->option)) {
return emission.getParameter(i, this->option); }
774 i -= emission.getN(this->option);
776 if (i <
string .
getN(this->option)) {
return string .getParameter(i, this->option); }
792 inline int operator()(
const char key)
const {
return (singularity ? 0 : (
int) key); }
793 inline int operator()(
const unsigned char key)
const {
return (singularity ? 0 : (
int) key); }
794 inline int operator()(
const short key)
const {
return (singularity ? 0 : (
int) key); }
795 inline int operator()(
const unsigned short key)
const {
return (singularity ? 0 : (
int) key); }
796 inline int operator()(
const int key)
const {
return (singularity ? 0 : (
int) key); }
797 inline int operator()(
const unsigned int key)
const {
return (singularity ? 0 : (
int) key); }
798 inline int operator()(
const long int key)
const {
return (singularity ? 0 : (
int) key); }
799 inline int operator()(
const unsigned long int key)
const {
return (singularity ? 0 : (
int) key); }
800 inline int operator()(
const long long int key)
const {
return (singularity ? 0 : (
int) key); }
801 inline int operator()(
const unsigned long long int key)
const {
return (singularity ? 0 : (
int) key); }
808 template<
class key_type,
class value_type,
class evaluator_type = JHashEvaluator>
810 public JHashMap<key_type, value_type, evaluator_type>
859 return ((
const double*) &value)[offset];
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.
const JPolynome f1(1.0, 2.0, 3.0)
Function.
@ 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.
static const JZero zero
Function object to assign zero value.
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.
JEmission & sub(const JEmission &emission)
Subtract emission.
JEmission & negate()
Negate emission.
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 & div(const double factor)
Scale emission.
JEmission & mul(const double factor)
Scale emission.
friend std::ostream & operator<<(std::ostream &out, const JEmission &emission)
Write emission parameters to output stream.
JEmission()
Default constructor.
JEmission & add(const JEmission &emission)
Add emission.
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 & mul(const double factor)
Scale string.
double getDot(const JString &string) const
Get dot product.
JString & sub(const JString &string)
Subtract string.
JString & negate()
Negate string.
friend std::ostream & operator<<(std::ostream &out, const JString &string)
Write string parameters to output stream.
JString()
Default constructor.
friend std::istream & operator>>(std::istream &in, JString &string)
Read string parameters from input stream.
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 & div(const double factor)
Scale string.
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.
hash_map< JEKey, JEmission > & map
JEmission & operator[](const int counter)
Get value corresponding to event counter (i.e. second part of JEKey).
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.
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.
double & getParameter(const size_t index, const JMODEL::JOption_t option)
Get read/write access to fit parameter value at given index in buffer.
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.
JHashMap< key_type, value_type, evaluator_type > hashmap_type
Map string identifier to model parameters of string.
Model for fit to acoustics data.
void reset()
Reset parameters.
JMODEL::JEmission JEmission
void setOption(const int option)
Set fit option.
double & operator[](const size_t index)
Read/write access to fit parameter value by index.
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.
size_t getIndex(int id, double JString::*p) const
Get index of fit parameter for given string.
JModel & sub(const JModel &model)
Subtract model.
JACOUSTICS::JModel::string_type string
JModel & add(const JModel &model)
Add model.
JModel(T __begin, T __end)
Constructor.
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.
friend std::ostream & operator<<(std::ostream &out, const JModel &model)
Write model parameters to output stream.
JModel & mul(const double factor)
Scale model.
JModel & operator=(const JMATH::JZero &zero)
Reset parameters.
JModel & div(const double factor)
Scale model.
void clear()
Clear parameters.
JModel & negate()
Negate 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.