Jpp 20.0.0-195-g190c9e876
the software that should make you happy
Loading...
Searching...
No Matches
JMechanics_t.hh
Go to the documentation of this file.
1#ifndef __JACOUSTICS__JMECHANICS_T__
2#define __JACOUSTICS__JMECHANICS_T__
3
4#include <ostream>
5#include <iomanip>
6#include <map>
7#include <cmath>
8
9#include <TROOT.h>
10#include <TObject.h>
11
12#include "JLang/JException.hh"
13#include "JLang/JManip.hh"
14
15
16/**
17 * \file
18 *
19 * Mechanical modelling of string.
20 * \author mdejong
21 */
22namespace JACOUSTICS {}
23namespace JPP { using namespace JACOUSTICS; }
24
25namespace JACOUSTICS {
26
27 /**
28 * Auxiliary data structure for parameters of mechanical model.\n
29 * This data structure provides for the implementation of the effective height conform the mechanical model of string.
30 */
31 struct JMechanics {
32 /**
33 * Default constructor.
34 */
36 a(0.0),
37 b(0.0)
38 {}
39
40
41 /**
42 * Constructor.
43 *
44 * \param a logarithmic term
45 * \param b linear term
46 */
47 JMechanics(const double a,
48 const double b) :
49 a(a),
50 b(b)
51 {}
52
53
54 /**
55 * Get effective height for given actual height.
56 *
57 * \param height height
58 * \return height
59 */
60 double getHeight(const double height) const
61 {
62 return height + this->b * log(1.0 - this->a * height);
63 }
64
65
66 /**
67 * Read parameters from input stream.
68 *
69 * \param in input stream
70 * \param parameters parameters
71 * \return input stream
72 */
73 friend inline std::istream& operator>>(std::istream& in, JMechanics& parameters)
74 {
75 return in >> parameters.a >> parameters.b;
76 }
77
78
79 /**
80 * Write parameters to output stream.
81 *
82 * \param out output stream
83 * \param parameters parameters
84 * \return output stream
85 */
86 friend inline std::ostream& operator<<(std::ostream& out, const JMechanics& parameters)
87 {
88 return out << FIXED(7,5) << parameters.a << ' '
89 << FIXED(7,3) << parameters.b;
90 }
91
93
94 double a; ///< <tt>0 <= a < (maximal height)⁻1;</tt> [m^-1]
95 double b; ///< <tt>0 <= b;</tt> [m]
96 };
97
98
99 /**
100 * Auxiliary data structure for mechanical model parameters of strings in a given detector.
101 *
102 * Note that the JDetectorMechanics::WILDCARD acts as default value for the string number.
103 */
105 public std::map<int, JMechanics>,
106 public TObject
107 {
108 enum {
109 WILDCARD = -1 //!< wild card for string number.
110 };
111
112
113 /**
114 * Get mechanical parameters for given string.
115 *
116 * \param string string number
117 * \return mechanical parameters
118 */
119 const JMechanics& operator()(const int string) const
120 {
121 static const JMechanics mechanics;
122
123 const_iterator p;
124
125 if ((p = this->find(string)) != this->end())
126 return p->second;
127 else if ((p = this->find(WILDCARD)) != this->end())
128 return p->second;
129 else
130 return mechanics;
131 }
132
133
134 /**
135 * Write detector mechanics to output.
136 *
137 * \param out output stream
138 * \param object detector mechanics
139 * \return output stream
140 */
141 friend inline std::ostream& operator<<(std::ostream& out, const JDetectorMechanics_t& object)
142 {
143 using namespace std;
144
145 for (JDetectorMechanics_t::const_iterator i = object.begin(); i != object.end(); ++i) {
146 out << setw(4) << i->first << ' ' << i->second << endl;
147 }
148
149 return out;
150 }
151
153 };
154}
155
156#endif
Exceptions.
I/O manipulators.
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.
Definition JManip.hh:448
Auxiliary data structure for mechanical model parameters of strings in a given detector.
@ WILDCARD
wild card for string number.
ClassDef(JDetectorMechanics_t, 1)
friend std::ostream & operator<<(std::ostream &out, const JDetectorMechanics_t &object)
Write detector mechanics to output.
const JMechanics & operator()(const int string) const
Get mechanical parameters for given string.
Auxiliary data structure for parameters of mechanical model.
double a
0 <= a < (maximal height)⁻1; [m^-1]
double b
0 <= b; [m]
JMechanics(const double a, const double b)
Constructor.
friend std::istream & operator>>(std::istream &in, JMechanics &parameters)
Read parameters from input stream.
friend std::ostream & operator<<(std::ostream &out, const JMechanics &parameters)
Write parameters to output stream.
double getHeight(const double height) const
Get effective height for given actual height.
JMechanics()
Default constructor.
ClassDefNV(JMechanics, 1)