Jpp 21.0.0-rc.3
the software that should make you happy
Loading...
Searching...
No Matches
JCOMPASS::JModel Struct Reference

Model. More...

#include <JModel.hh>

Inheritance diagram for JCOMPASS::JModel:
JMATH::JMath< JFirst_t, JSecond_t >

Public Member Functions

 JModel ()
 Default constructor.
 
 JModel (const JQuaternion3D &Q0, const JQuaternion3D &Q1)
 Constructor.
 
template<class T >
 JModel (T __begin, T __end)
 Constructor.
 
JModeladd (const JModel &model)
 Add model.
 
JModelsub (const JModel &model)
 Subtract model.
 
JModelmul (const double factor)
 Scale model.
 
JQuaternion3D operator() (const double z) const
 Get quaternion at given z-position.
 
JFirst_t & mul (const JSecond_t &object)
 Multiply with object.
 

Public Attributes

JQuaternion3D Q0
 tilt
 
JQuaternion3D Q1
 twist
 

Static Public Attributes

static const int NUMBER_OF_PARAMETERS = 4
 number of parameters of fit per quaternion
 

Detailed Description

Model.

Definition at line 33 of file JCompass/JModel.hh.

Constructor & Destructor Documentation

◆ JModel() [1/3]

JCOMPASS::JModel::JModel ( )
inline

Default constructor.

Definition at line 39 of file JCompass/JModel.hh.

39 :
42 {}
static const JQuaternion3D & getIdentity()
Get identity quaternion.
JQuaternion3D Q0
tilt
JQuaternion3D Q1
twist

◆ JModel() [2/3]

JCOMPASS::JModel::JModel ( const JQuaternion3D & Q0,
const JQuaternion3D & Q1 )
inline

Constructor.

Parameters
Q0tilt
Q1twist

Definition at line 51 of file JCompass/JModel.hh.

52 :
53 Q0(Q0),
54 Q1(Q1)
55 {}

◆ JModel() [3/3]

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

Constructor.

The data type corresponding to the hits should provide for the following policy methods.

   double        getZ();             // get z-position
   JQuaternion3D getQuaternion();    // get quaternion

Note that the input data should be ordered with increasing z-positions.

Parameters
__beginbegin of data
__endend of data

Definition at line 72 of file JCompass/JModel.hh.

73 :
76 {
77 using namespace std;
78 using namespace JPP;
79
80 const int N = distance(__begin, __end);
81
82 if (N >= NUMBER_OF_PARAMETERS) {
83
85
86 for (T q = __begin, p = q++; q != __end; ++p, ++q) {
87
88 const double dz = q->getZ() - p->getZ();
89
90 if (dz != 0.0) {
91
92 JQuaternion3D Q(p->getQuaternion());
93
94 Q.conjugate();
95 Q.mul(q->getQuaternion());
96 Q.pow(1.0 / dz);
97
98 buffer.push_back(Q);
99 }
100 }
101
102 Q1 = getAverage(buffer.begin(), buffer.end());
103 Q1 = JQuaternion3D::decomposition(Q1, JVector3Z_t).twist;
104
105 const double z1 = getAverage(make_array(__begin, __end, &JHit::getZ));
106
107 Q0 = getAverage(make_array(__begin, __end, &JHit::getQuaternion));
108 Q0 = pow(Q1, -z1) * Q0;
109
110 } else {
111 THROW(JValueOutOfRange, "JModel: Not enough data points " << N);
112 }
113 }
#define THROW(JException_t, A)
Marco for throwing exception with std::ostream compatible message.
std::vector< T >::difference_type distance(typename std::vector< T >::const_iterator first, typename PhysicsEvent::const_iterator< T > second)
Specialisation of STL distance.
Data structure for unit quaternion in three dimensions.
const JQuaternion3D & getQuaternion() const
Get quaternion.
Exception for accessing a value in a collection that is outside of its range.
T pow(const T &x, const double y)
Power .
Definition JMath.hh:97
std::iterator_traits< T >::value_type getAverage(T __begin, T __end)
Get average.
Definition JMath.hh:494
This name space includes all other name spaces (except KM3NETDAQ, KM3NET and ANTARES).
double getZ() const
Get z-position.
static const int NUMBER_OF_PARAMETERS
number of parameters of fit per quaternion
Auxiliary data structure for decomposition of quaternion in twist and swing quaternions.
JQuaternion3D twist
rotation around parallel axis

Member Function Documentation

◆ add()

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

Add model.

Parameters
modelmodel
Returns
this model

Definition at line 122 of file JCompass/JModel.hh.

123 {
124 Q0 *= model.Q0;
125 Q1 *= model.Q1;
126
127 Q0.normalise();
128 Q1.normalise();
129
130 return *this;
131 }
JQuaternion3D & normalise()
Normalise quaternion.

◆ sub()

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

Subtract model.

Parameters
modelmodel
Returns
this model

Definition at line 140 of file JCompass/JModel.hh.

141 {
142 Q0 *= model.Q0.getConjugate();
143 Q1 *= model.Q1.getConjugate();
144
145 Q0.normalise();
146 Q1.normalise();
147
148 return *this;
149 }

◆ mul() [1/2]

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

Scale model.

Parameters
factormultiplication factor
Returns
this model

Definition at line 158 of file JCompass/JModel.hh.

159 {
160 Q0.pow(factor);
161 Q1.pow(factor);
162
163 return *this;
164 }
JQuaternion3D & pow(const double y)
Raise quaternion to given power.

◆ operator()()

JQuaternion3D JCOMPASS::JModel::operator() ( const double z) const
inline

Get quaternion at given z-position.

Parameters
zz-position.
Returns
quaternion

Definition at line 173 of file JCompass/JModel.hh.

174 {
175 using namespace JPP;
176
177 return pow(Q1, z) * Q0;
178 }

◆ 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 }

Member Data Documentation

◆ NUMBER_OF_PARAMETERS

const int JCOMPASS::JModel::NUMBER_OF_PARAMETERS = 4
static

number of parameters of fit per quaternion

Definition at line 180 of file JCompass/JModel.hh.

◆ Q0

JQuaternion3D JCOMPASS::JModel::Q0

tilt

Definition at line 182 of file JCompass/JModel.hh.

◆ Q1

JQuaternion3D JCOMPASS::JModel::Q1

twist

Definition at line 183 of file JCompass/JModel.hh.


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