Project
Loading...
Searching...
No Matches
FairGeoTransform.cxx
Go to the documentation of this file.
1/********************************************************************************
2 * Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH *
3 * *
4 * This software is distributed under the terms of the *
5 * GNU Lesser General Public Licence (LGPL) version 3, *
6 * copied verbatim in the file "LICENSE" *
7 ********************************************************************************/
8//*-- AUTHOR : Ilse Koenig
9//*-- Modified : 16/06/1999
10//*-- Modified : 21/06/2005 D.Bertini
11
13//
14// FairGeoTransform
15//
16// Class to hold the orientation (rotation matrix) and the position
17// (translation vector) of a coordinate system (system 2) relative to a
18// reference coordinate system (system 1)
19// It provides member functions to transform a vector or a point and an other
20// coordinate system from its own coordinate system into the reference
21// coordinate system and vice versa.
22// Instances of this class can e.g. hold the lab or detector transformation of
23// a geometry volume (see class FairGeoVolume)
24//
25// Inline functions:
26//
27// FairGeoTransform()
28// The default constructor creates an identity transformation
29// FairGeoTransform(FairGeoTransform& t)
30// copy constructor
31// void setTransform(const FairGeoTransform& t)
32// copies the given transformation
33// void setRotMatrix(const FairGeoRotation& r)
34// copies the given rotation matrix
35// void setRotMatrix(const Double_t* a)
36// creates a rotation matrix taking an Double_t array with 9 components
37// void setTransVector(const FairGeoVector& t)
38// copies the given translation vector
39// void setTransVector(const Double_t* a)
40// creates a translation vector taking an Double_t array with 6 components
41// const FairGeoRotation& getRotMatrix() const
42// returns the rotation matrix
43// const FairGeoVector& getTransVector() const
44// returns the translation vector
45//
47
48#include "FairGeoTransform.h"
49
50//#include <iostream>
51//#include <iomanip>
52//#include "math.h"
53
55
57 : TObject()
58 , rot(FairGeoRotation(0, 0, 0))
59 , trans(FairGeoVector(0, 0, 0))
60 , trans_cm(FairGeoVector(0, 0, 0))
61{}
62
64{
65 rot = t.getRotMatrix();
66 trans = t.getTransVector();
67
68 return *this;
69}
70
72{
73 // Transforms a vector (point) given in its own coordinate
74 // system (2) into the reference coordinate system (1)
75 // e.g. v2 is a vector (point) in the detector coordinate system;
76 // it can be transformed to a vector v2 the lab system with
77 // FairGeoVector v2=mo.transFrom(v1)
78 // where mo is the coordinate system of the mother
79 return rot * p + trans;
80}
81
83{
84 // Transforms a vector (point) given in the reference system (1)
85 // into the local coordinate system (2)
86 // e.g. v1 is a vector (point) in the lab system; it can be transformed to
87 // a vector v2 the detector coordinate system with
88 // FairGeoVector v2=mo.transTo(v1)
89 // where mo is the coordinate system of the mother
90 return rot.inverse() * (p - trans);
91}
92
94{
95 // Transforms the coordinate system into the coordinate system
96 // described by s. Both transformations must have the same reference
97 // system e.g. the lab system
98 // This function is e.g. used to transform a daughter coordinate system
99 // with a transformation relative to the lab into the detector coordinate
100 // system.
101 const FairGeoRotation& rm = s.getRotMatrix();
102 FairGeoRotation rt(rm.inverse());
103 if (rm.diff2(rot) < 0.000001) {
105 } else {
106 rot.transform(rt);
107 }
108 trans -= s.getTransVector();
109 trans = rt * trans;
110 // trans.round(3); // rounds to 3 digits (precision 1 micrometer)
111}
112
114{
115 // Transforms the coordinate system described by s into the local
116 // coordinate system
117 // This function is e.g. used to transform a daughter coordinate system
118 // with a transformation relative to its mother into the lab system.
119 // e.g. daughterDetTransform.transFrom(motherLabTransform)
120 const FairGeoRotation& r = s.getRotMatrix();
121 rot.transform(r);
122 trans = r * trans;
123 trans += s.getTransVector();
124}
125
127{
128 trans.clear();
130}
131
133{
134 rot.print();
135 trans.print();
136}
137
139{
140 rot.invert();
141 trans = rot * trans;
142 trans *= -1.;
143}
ClassImp(FairGeoTransform)
Timeframe settings Average distance in cm of events merged into Randomize distance around average distance of merged events Simulate correct bunch interactions instead of placing only the average number of events A value[n] sets TFlen for[n] collisions in Number of bunches per trainsort Number of bunch trains Instantaneous interaction rate Do not simulate border Total number of collisions to be placed in the interior of all time Do not select random but walk over array of events in stride steps h Event generator settings h configStandalone Use CPU for GPU Force usage of the specified GPU device no CPU fallback Continue processing after an error s
FairGeoRotation & invert()
FairGeoRotation inverse() const
FairGeoRotation & transform(const FairGeoRotation &)
void print() const
Double_t diff2(const FairGeoRotation &) const
FairGeoVector trans
FairGeoRotation rot
FairGeoVector transTo(const FairGeoVector &p) const
FairGeoVector transFrom(const FairGeoVector &p) const
FairGeoTransform & operator=(const FairGeoTransform &t)
void print() const