Jpp
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Public Types | Public Member Functions | Protected Attributes | Private Attributes | Friends | List of all members
JDYNAMICS::JDynamics::JOrientation Struct Reference

Dynamic orientation calibration. More...

#include <JDynamics.hh>

Public Types

enum  { NUMBER_OF_POINTS = 20, NUMBER_OF_DEGREES = 1 }
 
typedef JTOOLS::JElement2D
< double,
JGEOMETRY3D::JQuaternion3D
element_type
 
typedef
JTOOLS::JPolfitFunction1D
< NUMBER_OF_POINTS,
NUMBER_OF_DEGREES,
element_type,
JTOOLS::JCollection
function_type
 
typedef
function_type::collection_type::container_type 
container_type
 
typedef JTOOLS::JHashMap< int,
JGEOMETRY3D::JQuaternion3D
buffer_type
 
typedef JTOOLS::JHashMap< int,
function_type
data_type
 
typedef data_type::const_iterator const_iterator
 
typedef
data_type::const_reverse_iterator 
const_reverse_iterator
 

Public Member Functions

 JOrientation (const JDetector &detector, const double Tmax_s)
 Constructor. More...
 
void load (JObjectIterator< JCOMPASS::JOrientation > &input)
 Load calibration data. More...
 
bool empty () const
 empty More...
 
const_iterator begin () const
 begin of calibration data More...
 
const_iterator end () const
 end of calibration data More...
 
const_reverse_iterator rbegin () const
 begin of reverse of calibration data More...
 
const_reverse_iterator rend () const
 begin of reverse of calibration data More...
 
double getTmax () const
 Get applicability period. More...
 
void setTmax (const double Tmax_s)
 Set applicability period. More...
 
void update (JDetector &detector, const double t1_s)
 Calibrate given detector at given time. More...
 
double getXmin () const
 Get minimal abscissa. More...
 
double getXmax () const
 Get maximal abscissa. More...
 

Protected Attributes

buffer_type buffer
 
data_type calibration
 
double Tmax_s
 

Private Attributes

double t0_s
 

Friends

std::ostream & operator<< (std::ostream &out, const JOrientation &calibration)
 Write calibration to output stream. More...
 

Detailed Description

Dynamic orientation calibration.

Definition at line 99 of file JDynamics.hh.

Member Typedef Documentation

Definition at line 106 of file JDynamics.hh.

Definition at line 109 of file JDynamics.hh.

typedef function_type::collection_type::container_type JDYNAMICS::JDynamics::JOrientation::container_type

Definition at line 110 of file JDynamics.hh.

Definition at line 112 of file JDynamics.hh.

Definition at line 113 of file JDynamics.hh.

Definition at line 115 of file JDynamics.hh.

Definition at line 116 of file JDynamics.hh.

Member Enumeration Documentation

anonymous enum
Enumerator
NUMBER_OF_POINTS 

number of points for interpolation

NUMBER_OF_DEGREES 

number of degrees for interpolation

Definition at line 101 of file JDynamics.hh.

101  {
102  NUMBER_OF_POINTS = 20, //!< number of points for interpolation
103  NUMBER_OF_DEGREES = 1 //!< number of degrees for interpolation
104  };
number of points for interpolation
Definition: JDynamics.hh:102
number of degrees for interpolation
Definition: JDynamics.hh:103

Constructor & Destructor Documentation

JDYNAMICS::JDynamics::JOrientation::JOrientation ( const JDetector detector,
const double  Tmax_s 
)
inline

Constructor.

Parameters
detectordetector
Tmax_sapplicability period of calibration [s]

Definition at line 125 of file JDynamics.hh.

126  :
127  Tmax_s(Tmax_s),
128  t0_s(std::numeric_limits<double>::lowest())
129  {
130  using namespace JPP;
131 
132  if (hasDetectorAddressMap(detector.getID())) {
133 
134  const JDetectorAddressMap& demo = getDetectorAddressMap(detector.getID());
135 
136  for (JDetector::const_iterator module = detector.begin(); module != detector.end(); ++module) {
137  if (module->getFloor() != 0) {
138  buffer[module->getID()] = getRotation(getModule(demo.get(module->getID())), *module);
139  }
140  }
141 
142  } else {
143 
144  THROW(JValueOutOfRange, "No detector address map for detector identier " << detector.getID());
145  }
146  }
#define THROW(JException_t, A)
Marco for throwing exception with std::ostream compatible message.
Definition: JException.hh:670
bool hasDetectorAddressMap(const int id)
Check if detector address map is available.
static JRotation getRotation
Function object to get rotation matrix to go from first to second module.
Lookup table for PMT addresses in detector.
const JModuleAddressMap & get(const int id) const
Get module address map.
int getID() const
Get identifier.
Definition: JObjectID.hh:50
JDetectorAddressMap & getDetectorAddressMap()
Get detector address map.
Exception for accessing a value in a collection that is outside of its range.
Definition: JException.hh:162
const JModule & getModule(const JDetector &detector, const JModuleLocation &location)
find module with a given string and floor number

Member Function Documentation

void JDYNAMICS::JDynamics::JOrientation::load ( JObjectIterator< JCOMPASS::JOrientation > &  input)
inline

Load calibration data.

Parameters
inputcalibration data

Definition at line 154 of file JDynamics.hh.

155  {
156  t0_s = std::numeric_limits<double>::lowest();
157 
158  while (input.hasNext()) {
159 
160  const JCOMPASS::JOrientation* orientation = input.next();
161 
162  static_cast<container_type&>(calibration[orientation->id]).push_back(element_type(orientation->t, getQuaternion(*orientation)));
163  }
164 
165  for (data_type::iterator i = calibration.begin(); i != calibration.end(); ++i) {
166  i->second.sort();
167  i->second.compile();
168  }
169  }
int id
module identifier
JQuaternion3D getQuaternion(const JQuaternion &Q)
Get quaternion.
function_type::collection_type::container_type container_type
Definition: JDynamics.hh:110
virtual const pointer_type & next()=0
Get next element.
virtual bool hasNext()=0
Check availability of next element.
JTOOLS::JElement2D< double, JGEOMETRY3D::JQuaternion3D > element_type
Definition: JDynamics.hh:106
Orientation of module.
container_type::iterator iterator
Definition: JHashMap.hh:87
bool JDYNAMICS::JDynamics::JOrientation::empty ( ) const
inline

empty

Definition at line 172 of file JDynamics.hh.

const_iterator JDYNAMICS::JDynamics::JOrientation::begin ( ) const
inline

begin of calibration data

Definition at line 173 of file JDynamics.hh.

const_iterator JDYNAMICS::JDynamics::JOrientation::end ( ) const
inline

end of calibration data

Definition at line 174 of file JDynamics.hh.

const_reverse_iterator JDYNAMICS::JDynamics::JOrientation::rbegin ( ) const
inline

begin of reverse of calibration data

Definition at line 175 of file JDynamics.hh.

const_reverse_iterator JDYNAMICS::JDynamics::JOrientation::rend ( ) const
inline

begin of reverse of calibration data

Definition at line 176 of file JDynamics.hh.

double JDYNAMICS::JDynamics::JOrientation::getTmax ( ) const
inline

Get applicability period.

Returns
applicability period [s]

Definition at line 184 of file JDynamics.hh.

185  {
186  return Tmax_s;
187  }
void JDYNAMICS::JDynamics::JOrientation::setTmax ( const double  Tmax_s)
inline

Set applicability period.

Parameters
Tmax_sapplicability period [s]

Definition at line 195 of file JDynamics.hh.

196  {
197  this->Tmax_s = Tmax_s;
198  }
void JDYNAMICS::JDynamics::JOrientation::update ( JDetector detector,
const double  t1_s 
)
inline

Calibrate given detector at given time.

Parameters
detectordetector (I/O)
t1_stime [s]

Definition at line 207 of file JDynamics.hh.

208  {
209  using namespace std;
210  using namespace JPP;
211 
212  if (!calibration.empty()) {
213 
214  if (fabs(t1_s - t0_s) > Tmax_s) {
215 
216  for (JDetector::iterator module = detector.begin(); module != detector.end(); ++module) {
217 
218  if (module->getFloor() != 0 && calibration.has(module->getID()) && buffer.has(module->getID())) {
219 
220  const function_type& f1 = calibration.get(module->getID());
221 
222  if (!f1.empty()) {
223 
224  if (t1_s >= f1.getXmin() && t1_s <= f1.getXmax()) {
225 
226  JQuaternion3D Q0 = buffer[module->getID()];
227  JQuaternion3D Q1 = f1(t1_s);
228 
229  const JPosition3D center = module->getPosition();
230 
231  module->sub(center);
232 
233  module->rotate(Q1 * Q0.conjugate());
234 
235  module->add(center);
236 
237  buffer[module->getID()] = Q1;
238  }
239  }
240  }
241  }
242 
243  t0_s = t1_s;
244  }
245  }
246  }
JTOOLS::JPolfitFunction1D< NUMBER_OF_POINTS, NUMBER_OF_DEGREES, element_type, JTOOLS::JCollection > function_type
Definition: JDynamics.hh:109
virtual mapped_type & get(typename JClass< key_type >::argument_type key) override
Get mapped value.
Definition: JHashMap.hh:118
JVector3D & sub(const JVector3D &vector)
Subtract vector.
Definition: JVector3D.hh:158
const JPosition3D & getPosition() const
Get position.
Definition: JPosition3D.hh:130
Data structure for unit quaternion in three dimensions.
Data structure for position in three dimensions.
Definition: JPosition3D.hh:36
bool has(const T &value) const
Test whether given value is present.
JVector3D & add(const JVector3D &vector)
Add vector.
Definition: JVector3D.hh:142
JQuaternion3D & conjugate()
Conjugate quaternion.
double JDYNAMICS::JDynamics::JOrientation::getXmin ( ) const
inline

Get minimal abscissa.

Returns
minimal abscissa

Definition at line 254 of file JDynamics.hh.

255  {
256  return JDynamics::getXmin(this->calibration);
257  }
static double getXmin(const JTOOLS::JHashMap< JKey_t, JValue_t, JEvaluator_t > &input)
Get minimal abscissa of mapped function objects.
Definition: JDynamics.hh:61
double JDYNAMICS::JDynamics::JOrientation::getXmax ( ) const
inline

Get maximal abscissa.

Returns
maximal abscissa

Definition at line 265 of file JDynamics.hh.

266  {
267  return JDynamics::getXmax(this->calibration);
268  }
static double getXmax(const JTOOLS::JHashMap< JKey_t, JValue_t, JEvaluator_t > &input)
Get maximal abscissa of mapped function objects.
Definition: JDynamics.hh:82

Friends And Related Function Documentation

std::ostream& operator<< ( std::ostream &  out,
const JOrientation calibration 
)
friend

Write calibration to output stream.

Parameters
outoutput stream
calibration
Returns
output stream

Definition at line 278 of file JDynamics.hh.

279  {
280  if (!calibration.empty())
281  return out << "[" << FIXED(15,0) << calibration.getXmin()
282  << "," << FIXED(15,0) << calibration.getXmax()
283  << "]";
284  else
285  return out << "[,]";
286  }
Auxiliary data structure for floating point format specification.
Definition: JManip.hh:445

Member Data Documentation

buffer_type JDYNAMICS::JDynamics::JOrientation::buffer
protected

Definition at line 289 of file JDynamics.hh.

data_type JDYNAMICS::JDynamics::JOrientation::calibration
protected

Definition at line 290 of file JDynamics.hh.

double JDYNAMICS::JDynamics::JOrientation::Tmax_s
protected

Definition at line 291 of file JDynamics.hh.

double JDYNAMICS::JDynamics::JOrientation::t0_s
private

Definition at line 294 of file JDynamics.hh.


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