1 #ifndef __JACOUSTICS__JMODEL__
2 #define __JACOUSTICS__JMODEL__
26 namespace JACOUSTICS {}
27 namespace JPP {
using namespace JACOUSTICS; }
29 namespace JACOUSTICS {
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) &&
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>
int operator()(const long int key) const
Get hash value.
size_t getN() const
Get number of fit parameters.
JModel & negate()
Negate model.
void setOption(const int option)
Set fit option.
int operator()(const unsigned long long int key) const
Get hash value.
int operator()(const long long int key) const
Get hash value.
void evaluate(const hash_map &buffer, value_type &(value_type::*f1)(const value_type &))
Evaluate arithmetic operation.
JString & mul(const double factor)
Scale string.
JEmission()
Default constructor.
Auxiliary base class for aritmetic operations of derived class types.
void clear()
Clear parameters.
double getAngle() const
Get angle.
JEmission & operator[](const int counter)
Get value corresponding to event counter (i.e. second part of JEKey).
JModel & mul(const double factor)
Scale model.
General purpose class for hash map of unique elements.
bool equals(const JModel &model, const double precision=std::numeric_limits< double >::min()) const
Check equality.
double getParameter(const size_t index, const JMODEL::JOption_t option) const
Get read access to fit parameter value at given index in buffer.
JModel(T __begin, T __end)
Constructor.
fit times of emission of emitters and tilt angles of strings with second order correction ...
#define THROW(JException_t, A)
Marco for throwing exception with std::ostream compatible message.
then usage $script< detector file >< detectorfile > nIf the range of floors is the first detector file is aligned to the second before the comparison nIn this
double & getParameter(const size_t index, const JMODEL::JOption_t option)
Get read/write access to fit parameter value at given index in buffer.
static const JZero zero
Function object to assign zero value.
static size_t getN(const JMODEL::JOption_t option)
Get number of fit parameters.
friend std::istream & operator>>(std::istream &in, JString &string)
Read string parameters from input stream.
Auxiliary data structure for floating point format specification.
helper operator[](int id)
Get helper corresponding to emission identifier (i.e. first part of JEKey).
friend std::ostream & operator<<(std::ostream &out, const JString &string)
Write string parameters to output stream.
Definition of zero value for any class.
int operator()(const unsigned int key) const
Get hash value.
double operator[](const size_t index) const
Read 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.
JEmission & add(const JEmission &emission)
Add emission.
static size_t getN(const JMODEL::JOption_t option)
Get number of fit parameters.
friend std::ostream & operator<<(std::ostream &out, const JModel &model)
Write model parameters to output stream.
const JPolynome f1(1.0, 2.0, 3.0)
Function.
Model for fit to acoustics data.
Map emission key to model parameters of emission.
bool equals(const JString &string, const double precision=std::numeric_limits< double >::min()) const
Check equality.
JHashMap< key_type, value_type, evaluator_type > hashmap_type
int operator()(const unsigned char key) const
Get hash value.
JString & sub(const JString &string)
Subtract string.
int operator()(const unsigned long int key) const
Get hash value.
Auxiliary class to assign zero value.
JEmission & negate()
Negate emission.
fit times of emission of emitters and tilt angles of strings
JMODEL::JEmission JEmission
Auxiliary data structure for common fit parameters.
do set_variable OUTPUT_DIRECTORY $WORKDIR T
JString & add(const JString &string)
Add string.
Template definition of auxiliary base class for comparison of data structures.
bool equals(const hash_map &buffer) const
Check equality of hash map.
JString & negate()
Negate string.
JACOUSTICS::JModel::emission_type emission
JMODEL::JOption_t getOption() const
Get fit option.
fit only times of emission of emitters
double getLengthSquared() const
Get length squared.
int operator()(const unsigned short key) const
Get hash value.
JEmission & sub(const JEmission &emission)
Subtract emission.
friend std::ostream & operator<<(std::ostream &out, const JEmission &emission)
Write emission parameters to output stream.
bool equals(const JEmission &emission, const double precision=std::numeric_limits< double >::min()) const
Check equality.
size_t getIndex(int id, double JString::*p) const
Get index of fit parameter for given string.
bool equals(const hash_map &buffer, const double precision) const
Check equality of has map.
JEmission & mul(const double factor)
Scale emission.
JModel & sub(const JModel &model)
Subtract model.
JACOUSTICS::JModel::string_type string
JString & div(const double factor)
Scale string.
int operator()(const int key) const
Get hash value.
double & operator[](const size_t index)
Read/write access to fit parameter value by index.
JEmission & div(const double factor)
Scale emission.
JModel & div(const double factor)
Scale model.
hash_map< JEKey, JEmission > & map
then fatal The output file must have the wildcard in the e g root fi eval JPrintDetector a $DETECTOR O IDENTIFIER eval JPrintDetector a $DETECTOR O SUMMARY JAcoustics sh $DETECTOR_ID source JAcousticsToolkit sh CHECK_EXIT_CODE typeset A EMITTERS get_tripods $WORKDIR tripod txt EMITTERS get_transmitters $WORKDIR transmitter txt EMITTERS for EMITTER in
void evaluate(value_type &(value_type::*f1)(const double), const double factor)
Evaluate arithmetic operation.
JModel()
Default constructor.
JString(const double tx, const double ty, const double tx2=0.0, const double ty2=0.0, const double vs=0.0)
Constructor.
Auxiliary class for multiple associative map operators.
JModel & add(const JModel &model)
Add model.
Auxiliary data structure with extended functionality of hash-map.
size_t getIndex(const key_type key, double value_type::*p, const JMODEL::JOption_t option) const
Get index of parameter.
int operator()(const char key) const
Get hash value.
Base class for data structures with artithmetic capabilities.
JEmission(const double t1)
Constructor.
fit times of emission of emitters and tilt angles of strings with second order correction and stretch...
int operator()(const short key) const
Get hash value.
Exception for accessing a value in a collection that is outside of its range.
Exception for accessing an index in a collection that is outside of its range.
helper(hash_map< JEKey, JEmission > &map, int id)
Constructor.
void evaluate(value_type &(value_type::*f1)())
Evaluate arithmetic operation.
Auxiliary data structure for floating point format specification.
static bool singularity
Option for common fit parameters.
void reset()
Reset parameters.
JString()
Default constructor.
double getDot(const JString &string) const
Get dot product.
double getLength() const
Get length.
Map string identifier to model parameters of string.
JModel & operator=(const JMATH::JZero &zero)
Reset parameters.
size_t getN(const JMODEL::JOption_t option) const
Get number of fit parameters.