CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
Functions
DDRotation.cc File Reference
#include <cmath>
#include "DetectorDescription/Core/interface/DDTransform.h"
#include "DetectorDescription/Base/interface/DDTranslation.h"
#include "DetectorDescription/Base/interface/DDdebug.h"
#include "CLHEP/Units/GlobalSystemOfUnits.h"
#include <Math/AxisAngle.h>
#include <sstream>
#include <cstdlib>
#include "FWCore/MessageLogger/interface/MessageLogger.h"

Go to the source code of this file.

Functions

DDRotation DDanonymousRot (DDRotationMatrix *rot)
 Defines a anonymous rotation or rotation-reflection matrix. More...
 
DDRotationMatrixDDcreateRotationMatrix (double thetaX, double phiX, double thetaY, double phiY, double thetaZ, double phiZ)
 create a new DDRotationMatrix in the GEANT3 style. More...
 
DDRotation DDrot (const DDName &ddname, DDRotationMatrix *rot)
 Definition of a uniquely identifiable rotation matrix named by DDName name. More...
 
DDRotation DDrot (const DDName &ddname, double thetaX, double phiX, double thetaY, double phiY, double thetaZ, double phiZ)
 Definition of a uniquely identifiable rotation matrix named by DDName name in the GEANT3 style. More...
 
DDRotation DDrotReflect (const DDName &ddname, DDRotationMatrix *rot)
 
DDRotation DDrotReflect (const DDName &ddname, double thetaX, double phiX, double thetaY, double phiY, double thetaZ, double phiZ)
 Defines a rotation-reflection in the Geant3 way. More...
 
std::ostream & operator<< (std::ostream &os, const DDRotation &r)
 

Function Documentation

DDRotation DDanonymousRot ( DDRotationMatrix rot)

Defines a anonymous rotation or rotation-reflection matrix.

It can't be addressed by a unique DDName. Once created, it's the users responsibility to keep the reference object DDRotation! Will be mostly used by algorithmic positioning.

Definition at line 197 of file DDRotation.cc.

Referenced by DDCompactView::algoPosPart(), DDTIBLayerAlgo::execute(), and DDStreamer::pos_read().

198 {
199  return DDRotation(rot);
200 }
Represents a uniquely identifyable rotation matrix.
Definition: DDTransform.h:66
DDRotationMatrix* DDcreateRotationMatrix ( double  thetaX,
double  phiX,
double  thetaY,
double  phiY,
double  thetaZ,
double  phiZ 
)

create a new DDRotationMatrix in the GEANT3 style.

The Matrix must be orthonormal - left or right handed - otherwise a DDException is thrown; memory of the returned pointer belongs to the caller

Definition at line 168 of file DDRotation.cc.

References CastorDataFrameFilter_impl::check(), funct::cos(), edm::hlt::Exception, python.connectstrParser::o, funct::sin(), vdt::x, detailsBasic3DVector::y, and detailsBasic3DVector::z.

Referenced by DDAngular::execute(), and DDTIBLayerAlgo::execute().

171 {
172  // define 3 unit std::vectors forming the new left-handed axes
173  DD3Vector x(cos(phiX)*sin(thetaX), sin(phiX)*sin(thetaX), cos(thetaX));
174  DD3Vector y(cos(phiY)*sin(thetaY), sin(phiY)*sin(thetaY), cos(thetaY));
175  DD3Vector z(cos(phiZ)*sin(thetaZ), sin(phiZ)*sin(thetaZ), cos(thetaZ));
176 
177  double tol = 1.0e-3; // Geant4 compatible
178  double check = (x.Cross(y)).Dot(z);// in case of a LEFT-handed orthogonal system this must be -1, RIGHT-handed: +1
179  if ((1.-fabs(check))>tol) {
180  std::ostringstream o;
181  o << "matrix is not an (left or right handed) orthonormal matrix! (in deg)" << std::endl
182  << " thetaX=" << thetaX/deg << " phiX=" << phiX/deg << std::endl
183  << " thetaY=" << thetaY/deg << " phiY=" << phiY/deg << std::endl
184  << " thetaZ=" << thetaZ/deg << " phiZ=" << phiZ/deg << std::endl;
185  edm::LogError("DDRotation") << o.str() << std::endl;
186 
187 
188  throw cms::Exception("DDException") << o.str();
189  }
190 
191  return new DDRotationMatrix(x.x(),y.x(),z.x(),
192  x.y(),y.y(),z.y(),
193  x.z(),y.z(),z.z());
194 }
Sin< T >::type sin(const T &t)
Definition: Sin.h:22
double double double z
ROOT::Math::DisplacementVector3D< ROOT::Math::Cartesian3D< double > > DD3Vector
A DD Translation is currently implemented with Root Vector3D.
Definition: DDTranslation.h:6
bool check(const DataFrame &df, bool capcheck, bool dvercheck)
Cos< T >::type cos(const T &t)
Definition: Cos.h:22
x
Definition: VDTMath.h:216
ROOT::Math::Rotation3D DDRotationMatrix
A DDRotationMatrix is currently implemented with a ROOT Rotation3D.
DDRotation DDrot ( const DDName ddname,
DDRotationMatrix rot 
)

Definition of a uniquely identifiable rotation matrix named by DDName name.

DDrot() returns a reference-object DDRotation representing the rotation matrix rot.

The user must not free memory allocated for rot!

Definition at line 93 of file DDRotation.cc.

Referenced by WriteOneGeometryFromXML::beginRun(), DDPixFwdBlades::computeNippleParameters(), DDHCalBarrelAlgo::constructGeneralVolume(), DDHCalEndcapAlgo::constructGeneralVolume(), DDLinear::execute(), DDAngular::execute(), DDTIDModulePosAlgo::execute(), DDTIBLayerAlgo::execute(), DDHCalAngular::execute(), DDHCalTBCableAlgo::execute(), DDHCalTBZposAlgo::execute(), DDHCalTestBeamAlgo::execute(), DDHCalXtalAlgo::execute(), DDTIBLayerAlgo_MTCC::execute(), DDPixBarLayerAlgo::execute(), DDTECOptoHybAlgo::execute(), DDTECPhiAltAlgo::execute(), DDTECPhiAlgo::execute(), DDTIDAxialCableAlgo::execute(), DDTIDRingAlgo::execute(), DDTrackerAngular::execute(), DDHCalFibreBundle::execute(), DDTrackerPhiAltAlgo::execute(), DDTrackerPhiAlgo::execute(), DDTECAxialCableAlgo::execute(), DDPixFwdBlades::execute(), DDDividedConsPhi::makeDDRotation(), DDDividedTubsPhi::makeDDRotation(), DDDividedPolyconePhi::makeDDRotation(), DDDividedPolyhedraPhi::makeDDRotation(), DDTBH4Algo::myrot(), DDEcalBarrelAlgo::myrot(), DDEcalBarrelNewAlgo::myrot(), DDEcalEndcapAlgo::myrot(), DDLPosPart::processElement(), DDLRotationSequence::processElement(), DDLRotationAndReflection::processElement(), DDLRotationByAxis::processElement(), regressionTest_first(), and regressionTest_setup().

94 {
95  // memory of rot goes sto DDRotationImpl!!
96  //DCOUT('c', "DDrot: new rotation " << ddname);
97  //if (rot) rot->invert();
98  return DDRotation(ddname, rot);
99 }
Represents a uniquely identifyable rotation matrix.
Definition: DDTransform.h:66
DDRotation DDrot ( const DDName name,
double  thetaX,
double  phiX,
double  thetaY,
double  phiY,
double  thetaZ,
double  phiZ 
)

Definition of a uniquely identifiable rotation matrix named by DDName name in the GEANT3 style.

DDrot() returns a reference-object DDRotation representing the rotation matrix.

Definition at line 102 of file DDRotation.cc.

References CastorDataFrameFilter_impl::check(), funct::cos(), edm::hlt::Exception, DDName::name(), makeMuonMisalignmentScenario::rot, funct::sin(), vdt::x, detailsBasic3DVector::y, and detailsBasic3DVector::z.

106 {
107  // define 3 unit std::vectors
108  DD3Vector x(cos(phiX)*sin(thetaX), sin(phiX)*sin(thetaX), cos(thetaX));
109  DD3Vector y(cos(phiY)*sin(thetaY), sin(phiY)*sin(thetaY), cos(thetaY));
110  DD3Vector z(cos(phiZ)*sin(thetaZ), sin(phiZ)*sin(thetaZ), cos(thetaZ));
111 
112  double tol = 1.0e-3; // Geant4 compatible
113  double check = (x.Cross(y)).Dot(z); // in case of a LEFT-handed orthogonal system this must be -1
114  if (fabs(1.-check)>tol) {
115  edm::LogError("DDRotation") << ddname << " is not a RIGHT-handed orthonormal matrix!" << std::endl;
116  throw cms::Exception("DDException") << ddname.name() << " is not RIGHT-handed!";
117  }
118 
119  DDRotationMatrix* rot = new DDRotationMatrix(x.x(),y.x(),z.x(),
120  x.y(),y.y(),z.y(),
121  x.z(),y.z(),z.z());
122 
123  return DDRotation(ddname, rot);
124 
125 }
Sin< T >::type sin(const T &t)
Definition: Sin.h:22
double double double z
Represents a uniquely identifyable rotation matrix.
Definition: DDTransform.h:66
ROOT::Math::DisplacementVector3D< ROOT::Math::Cartesian3D< double > > DD3Vector
A DD Translation is currently implemented with Root Vector3D.
Definition: DDTranslation.h:6
bool check(const DataFrame &df, bool capcheck, bool dvercheck)
Cos< T >::type cos(const T &t)
Definition: Cos.h:22
x
Definition: VDTMath.h:216
ROOT::Math::Rotation3D DDRotationMatrix
A DDRotationMatrix is currently implemented with a ROOT Rotation3D.
const std::string & name() const
Returns the name.
Definition: DDName.cc:87
DDRotation DDrotReflect ( const DDName ddname,
DDRotationMatrix rot 
)

Definition at line 128 of file DDRotation.cc.

129 {
130  // memory of rot goes sto DDRotationImpl!!
131  //DCOUT('c', "DDrot: new rotation " << ddname);
132 // if (rot) rot->invert();
133  return DDRotation(ddname, rot);
134 }
Represents a uniquely identifyable rotation matrix.
Definition: DDTransform.h:66
DDRotation DDrotReflect ( const DDName ddname,
double  thetaX,
double  phiX,
double  thetaY,
double  phiY,
double  thetaZ,
double  phiZ 
)

Defines a rotation-reflection in the Geant3 way.

The resulting matrix MUST be a LEFThanded orthonormal system, otherwise a DDException will be thrown!

Definition at line 138 of file DDRotation.cc.

References CastorDataFrameFilter_impl::check(), funct::cos(), edm::hlt::Exception, DDName::name(), makeMuonMisalignmentScenario::rot, funct::sin(), vdt::x, detailsBasic3DVector::y, and detailsBasic3DVector::z.

Referenced by DDLRotationAndReflection::processElement().

142 {
143 
144  // define 3 unit std::vectors forming the new left-handed axes
145  DD3Vector x(cos(phiX)*sin(thetaX), sin(phiX)*sin(thetaX), cos(thetaX));
146  DD3Vector y(cos(phiY)*sin(thetaY), sin(phiY)*sin(thetaY), cos(thetaY));
147  DD3Vector z(cos(phiZ)*sin(thetaZ), sin(phiZ)*sin(thetaZ), cos(thetaZ));
148 
149  double tol = 1.0e-3; // Geant4 compatible
150  double check = (x.Cross(y)).Dot(z); // in case of a LEFT-handed orthogonal system this must be -1
151  if (fabs(1.+check)>tol) {
152  edm::LogError("DDRotation") << ddname << " is not a LEFT-handed orthonormal matrix!" << std::endl;
153  throw cms::Exception("DDException") << ddname.name() << " is not LEFT-handed!";
154  }
155 
156  DDRotationMatrix* rot = new DDRotationMatrix(x.x(),y.x(),z.x(),
157  x.y(),y.y(),z.y(),
158  x.z(),y.z(),z.z());
159 
160  //DCOUT('c', "DDrotReflect: new reflection " << ddname);
161  //rot->invert();
162  return DDRotation(ddname, rot);
163 
164 }
Sin< T >::type sin(const T &t)
Definition: Sin.h:22
double double double z
Represents a uniquely identifyable rotation matrix.
Definition: DDTransform.h:66
ROOT::Math::DisplacementVector3D< ROOT::Math::Cartesian3D< double > > DD3Vector
A DD Translation is currently implemented with Root Vector3D.
Definition: DDTranslation.h:6
bool check(const DataFrame &df, bool capcheck, bool dvercheck)
Cos< T >::type cos(const T &t)
Definition: Cos.h:22
x
Definition: VDTMath.h:216
ROOT::Math::Rotation3D DDRotationMatrix
A DDRotationMatrix is currently implemented with a ROOT Rotation3D.
const std::string & name() const
Returns the name.
Definition: DDName.cc:87
std::ostream& operator<< ( std::ostream &  os,
const DDRotation r 
)

Definition at line 19 of file DDRotation.cc.

References DCOUT_V, DDBase< N, C >::isDefined(), submit::rm, and DDRotation::rotation().

20 {
22  if (defined.first) {
23  os << *(defined.first) << " ";
24  if (defined.second) {
25  const DDRotationMatrix & rm = *(r.rotation());
26  DDAxisAngle ra(rm);
27  os << "t=" << ra.Axis().Theta()/deg << "deg "
28  << "p=" << ra.Axis().Phi()/deg << "deg "
29  << "a=" << ra.Angle()/deg << "deg";
30  DCOUT_V('R', rm);
31  }
32  else {
33  os << "* rotation not defined * ";
34  }
35  }
36  else {
37  os << "* rotation not declared * ";
38  }
39  return os;
40 }
Definition: DDBase.h:14
const DDRotationMatrix * rotation() const
Returns the read-only rotation-matrix.
Definition: DDTransform.h:90
def_type isDefined() const
Definition: DDBase.h:115
string rm
Definition: submit.py:76
#define DCOUT_V(M_v_Y, M_v_S)
Definition: DDdebug.h:54
ROOT::Math::AxisAngle DDAxisAngle
ROOT::Math::Rotation3D DDRotationMatrix
A DDRotationMatrix is currently implemented with a ROOT Rotation3D.