Jpp  19.1.0
the software that should make you happy
Public Member Functions | Public Attributes | Static Public Attributes | List of all members
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. More...
 
 JModel (const JQuaternion3D &Q0, const JQuaternion3D &Q1)
 Constructor. More...
 
template<class T >
 JModel (T __begin, T __end)
 Constructor. More...
 
JModeladd (const JModel &model)
 Add model. More...
 
JModelsub (const JModel &model)
 Subtract model. More...
 
JModelmul (const double factor)
 Scale model. More...
 
JQuaternion3D operator() (const double z) const
 Get quaternion at given z-position. More...
 
JFirst_t & mul (const JSecond_t &object)
 Multiply with object. More...
 

Public Attributes

JQuaternion3D Q0
 tilt More...
 
JQuaternion3D Q1
 twist More...
 

Static Public Attributes

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

Detailed Description

Model.

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

Constructor & Destructor Documentation

◆ JModel() [1/3]

JCOMPASS::JModel::JModel ( )
inline

Default constructor.

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

38  :
41  {}
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 50 of file JCompass/JModel.hh.

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

◆ JModel() [3/3]

template<class T >
JCOMPASS::JModel::JModel ( __begin,
__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 71 of file JCompass/JModel.hh.

72  :
75  {
76  using namespace std;
77  using namespace JPP;
78 
79  const int N = distance(__begin, __end);
80 
81  if (N >= NUMBER_OF_PARAMETERS) {
82 
83  vector<JQuaternion3D> buffer;
84 
85  for (T q = __begin, p = q++; q != __end; ++p, ++q) {
86 
87  const double dz = q->getZ() - p->getZ();
88 
89  if (dz != 0.0) {
90 
91  JQuaternion3D Q(p->getQuaternion());
92 
93  Q.conjugate();
94  Q.mul(q->getQuaternion());
95  Q.pow(1.0 / dz);
96 
97  buffer.push_back(Q);
98  }
99  }
100 
101  Q1 = getAverage(buffer.begin(), buffer.end());
103 
104  const double z1 = getAverage(make_array(__begin, __end, &JHit::getZ));
105 
106  Q0 = getAverage(make_array(__begin, __end, &JHit::getQuaternion));
107  Q0 = pow(Q1, -z1) * Q0;
108 
109  } else {
110  throw JValueOutOfRange("JModel: Not enough data points.");
111  }
112  }
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.
Definition: JException.hh:180
static const JVector3D JVector3Z_t(0, 0, 1)
unit z-vector
const array_type< JValue_t > & make_array(const JValue_t(&array)[N])
Method to create array of values.
Definition: JVectorize.hh:54
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).
Definition: JSTDTypes.hh:14
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 121 of file JCompass/JModel.hh.

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

◆ sub()

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

Subtract model.

Parameters
modelmodel
Returns
this model

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

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

◆ mul() [1/2]

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

Scale model.

Parameters
factormultiplication factor
Returns
this model

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

158  {
159  Q0.pow(factor);
160  Q1.pow(factor);
161 
162  return *this;
163  }
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 172 of file JCompass/JModel.hh.

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

◆ 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 179 of file JCompass/JModel.hh.

◆ Q0

JQuaternion3D JCOMPASS::JModel::Q0

tilt

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

◆ Q1

JQuaternion3D JCOMPASS::JModel::Q1

twist

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


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