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 <atomic>
#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 194 of file DDRotation.cc.

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

195 {
196  return DDRotation(rot);
197 }
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 165 of file DDRotation.cc.

References trackerTree::check(), funct::cos(), Exception, connectstrParser::o, funct::sin(), x(), detailsBasic3DVector::y, and detailsBasic3DVector::z.

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

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

Referenced by DDPixFwdBlades::computeNippleParameters(), DDHCalBarrelAlgo::constructGeneralVolume(), DDHCalEndcapAlgo::constructGeneralVolume(), DDHGCalNoTaperEndcap::createQuarter(), DDLinear::execute(), DDAngular::execute(), DDTIDModulePosAlgo::execute(), DDPixBarTPGStackLayerAlgo::execute(), DDPixFwdDiskAlgo::execute(), DDTECOptoHybAlgo::execute(), DDHCalAngular::execute(), DDTIBLayerAlgo::execute(), DDHCalTBCableAlgo::execute(), DDHCalTBZposAlgo::execute(), DDHCalTestBeamAlgo::execute(), DDHCalXtalAlgo::execute(), DDPixBarLayerUpgradeAlgoCoverage::execute(), DDPixBarStackLayerAlgo::execute(), DDPixBarStackTrigLayerAlgo::execute(), DDHGCalWaferAlgo::execute(), DDTIBLayerAlgo_MTCC::execute(), DDPixBarLayerUpgradeAlgo::execute(), DDGEMAngular::execute(), DDMuonAngular::execute(), DDPixBarLayerAlgo::execute(), DDTrackerPhiAltAlgo::execute(), DDTECAxialCableAlgo::execute(), DDTrackerAngular::execute(), DDTECPhiAlgo::execute(), DDTECPhiAltAlgo::execute(), DDTrackerPhiAlgo::execute(), DDHCalFibreBundle::execute(), DDTIDAxialCableAlgo::execute(), DDTIDRingAlgo::execute(), DDTrackerAngularV1::execute(), DDTrackerRingAlgo::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().

91 {
92  // memory of rot goes sto DDRotationImpl!!
93  //DCOUT('c', "DDrot: new rotation " << ddname);
94  //if (rot) rot->invert();
95  return DDRotation(ddname, rot);
96 }
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 99 of file DDRotation.cc.

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

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

126 {
127  // memory of rot goes sto DDRotationImpl!!
128  //DCOUT('c', "DDrot: new rotation " << ddname);
129 // if (rot) rot->invert();
130  return DDRotation(ddname, rot);
131 }
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 135 of file DDRotation.cc.

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

Referenced by DDLRotationAndReflection::processElement().

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

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

21 {
23  if (defined.first) {
24  os << *(defined.first) << " ";
25  if (defined.second) {
26  const DDRotationMatrix & rm = *(r.rotation());
27  DDAxisAngle ra(rm);
28  os << "t=" << ra.Axis().Theta()/deg << "deg "
29  << "p=" << ra.Axis().Phi()/deg << "deg "
30  << "a=" << ra.Angle()/deg << "deg";
31  DCOUT_V('R', rm);
32  }
33  else {
34  os << "* rotation not defined * ";
35  }
36  }
37  else {
38  os << "* rotation not declared * ";
39  }
40  return os;
41 }
Definition: DDBase.h:10
const DDRotationMatrix * rotation() const
Returns the read-only rotation-matrix.
Definition: DDTransform.h:90
def_type isDefined() const
Definition: DDBase.h:110
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.