Jpp
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Public Types | Public Member Functions | Protected Attributes | Private Attributes | 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...
 
double getCoverage (const JDetector &detector, const double t1_s) const
 Get coverage. 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
 

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  }
double JDYNAMICS::JDynamics::JOrientation::getCoverage ( const JDetector detector,
const double  t1_s 
) const
inline

Get coverage.

Parameters
detectordetector
t1_stime [s]
Returns
coverage

Definition at line 208 of file JDynamics.hh.

209  {
210  int n0 = 0;
211  int n1 = 0;
212 
213  for (JDetector::const_iterator module = detector.begin(); module != detector.end(); ++module) {
214 
215  if (module->getFloor() != 0) {
216 
217  ++n0;
218 
219  if (calibration.has(module->getID()) && !calibration.get(module->getID()).empty()) {
220  if (calibration[module->getID()].getXmin() <= t1_s &&
221  calibration[module->getID()].getXmax() >= t1_s) {
222  ++n1;
223  }
224  }
225  }
226  }
227 
228  return (double) n1 / (double) n0;
229  }
virtual mapped_type & get(typename JClass< key_type >::argument_type key) override
Get mapped value.
Definition: JHashMap.hh:118
bool has(const T &value) const
Test whether given value is present.
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 238 of file JDynamics.hh.

239  {
240  using namespace std;
241  using namespace JPP;
242 
243  if (!calibration.empty()) {
244 
245  if (fabs(t1_s - t0_s) > Tmax_s) {
246 
247  for (JDetector::iterator module = detector.begin(); module != detector.end(); ++module) {
248 
249  if (module->getFloor() != 0 && calibration.has(module->getID()) && buffer.has(module->getID())) {
250 
251  const function_type& f1 = calibration.get(module->getID());
252 
253  if (!f1.empty()) {
254 
255  if (t1_s >= f1.getXmin() && t1_s <= f1.getXmax()) {
256 
257  JQuaternion3D Q0 = buffer[module->getID()];
258  JQuaternion3D Q1 = f1(t1_s);
259 
260  const JPosition3D center = module->getPosition();
261 
262  module->sub(center);
263 
264  module->rotate(Q1 * Q0.conjugate());
265 
266  module->add(center);
267 
268  buffer[module->getID()] = Q1;
269  }
270  }
271  }
272  }
273 
274  t0_s = t1_s;
275  }
276  }
277  }
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 285 of file JDynamics.hh.

286  {
287  return JDynamics::getXmin(this->calibration);
288  }
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 296 of file JDynamics.hh.

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

Member Data Documentation

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

Definition at line 302 of file JDynamics.hh.

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

Definition at line 303 of file JDynamics.hh.

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

Definition at line 304 of file JDynamics.hh.

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

Definition at line 307 of file JDynamics.hh.


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