CMS 3D CMS Logo

Functions
DDRotation.cc File Reference
#include <cstdio>
#include <atomic>
#include <cmath>
#include <sstream>
#include <string>
#include "CLHEP/Units/GlobalSystemOfUnits.h"
#include "CLHEP/Units/SystemOfUnits.h"
#include "DetectorDescription/Core/interface/DDRotationMatrix.h"
#include "DetectorDescription/Core/interface/DDTranslation.h"
#include "DetectorDescription/Core/interface/Store.h"
#include "DetectorDescription/Core/interface/DDBase.h"
#include "DetectorDescription/Core/interface/DDName.h"
#include "DetectorDescription/Core/interface/DDTransform.h"
#include "FWCore/MessageLogger/interface/MessageLogger.h"
#include "FWCore/Utilities/interface/Exception.h"
#include "Math/GenVector/AxisAngle.h"
#include "Math/GenVector/Cartesian3D.h"
#include "Math/GenVector/DisplacementVector3D.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...
 
std::unique_ptr< DDRotationDDrotPtr (const DDName &ddname, DDRotationMatrix *rot)
 
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 193 of file DDRotation.cc.

References DDRotation::DDRotation().

Referenced by DDTIBLayerAlgo::execute().

194 {
195  return DDRotation(rot);
196 }
Represents a uniquely identifyable rotation matrix.
Definition: DDTransform.h:67
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 164 of file DDRotation.cc.

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

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

167 {
168  // define 3 unit std::vectors forming the new left-handed axes
169  DD3Vector x(cos(phiX)*sin(thetaX), sin(phiX)*sin(thetaX), cos(thetaX));
170  DD3Vector y(cos(phiY)*sin(thetaY), sin(phiY)*sin(thetaY), cos(thetaY));
171  DD3Vector z(cos(phiZ)*sin(thetaZ), sin(phiZ)*sin(thetaZ), cos(thetaZ));
172 
173  double tol = 1.0e-3; // Geant4 compatible
174  double check = (x.Cross(y)).Dot(z);// in case of a LEFT-handed orthogonal system this must be -1, RIGHT-handed: +1
175  if ((1.-fabs(check))>tol) {
176  std::ostringstream o;
177  o << "matrix is not an (left or right handed) orthonormal matrix! (in deg)" << std::endl
178  << " thetaX=" << thetaX/deg << " phiX=" << phiX/deg << std::endl
179  << " thetaY=" << thetaY/deg << " phiY=" << phiY/deg << std::endl
180  << " thetaZ=" << thetaZ/deg << " phiZ=" << phiZ/deg << std::endl;
181  edm::LogError("DDRotation") << o.str() << std::endl;
182 
183 
184  throw cms::Exception("DDException") << o.str();
185  }
186 
187  return new DDRotationMatrix(x.x(),y.x(),z.x(),
188  x.y(),y.y(),z.y(),
189  x.z(),y.z(),z.z());
190 }
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
def check(config)
Definition: trackerTree.py:14
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.

References DDRotation::DDRotation().

Referenced by DDPixFwdBlades::computeNippleParameters(), DDHCalBarrelAlgo::constructGeneralVolume(), DDHCalEndcapAlgo::constructGeneralVolume(), DDHGCalNoTaperEndcap::createQuarter(), DDTIDModulePosAlgo::execute(), DDHCalAngular::execute(), DDPixFwdDiskAlgo::execute(), DDPixPhase1FwdDiskAlgo::execute(), DDTECOptoHybAlgo::execute(), DDHCalTBCableAlgo::execute(), DDTIBLayerAlgo::execute(), DDHCalTBZposAlgo::execute(), DDHCalTestBeamAlgo::execute(), DDHCalXtalAlgo::execute(), DDHGCalWafer::execute(), DDHGCalWaferAlgo::execute(), DDTIBLayerAlgo_MTCC::execute(), DDGEMAngular::execute(), DDMuonAngular::execute(), DDPixBarLayerAlgo::execute(), DDPixBarLayerUpgradeAlgo::execute(), DDTrackerAngularV1::execute(), DDTIDRingAlgo::execute(), DDHCalFibreBundle::execute(), DDTECPhiAlgo::execute(), DDTECAxialCableAlgo::execute(), DDTECPhiAltAlgo::execute(), DDTrackerPhiAltAlgo::execute(), DDTIDAxialCableAlgo::execute(), DDTrackerAngular::execute(), DDTrackerPhiAlgo::execute(), DDLinear::execute(), DDAngular::execute(), DDTrackerRingAlgo::execute(), DDPixFwdBlades::execute(), DDDividedTubsPhi::makeDDRotation(), DDDividedConsPhi::makeDDRotation(), DDDividedPolyconePhi::makeDDRotation(), DDDividedPolyhedraPhi::makeDDRotation(), DDTBH4Algo::myrot(), DDEcalBarrelAlgo::myrot(), DDEcalBarrelNewAlgo::myrot(), DDEcalEndcapAlgo::myrot(), DDLRotationSequence::processElement(), DDLRotationByAxis::processElement(), DDLRotationAndReflection::processElement(), regressionTest_first(), and regressionTest_setup().

91 {
92  // memory of rot goes sto DDRotationImpl!!
93  return DDRotation(ddname, rot);
94 }
Represents a uniquely identifyable rotation matrix.
Definition: DDTransform.h:67
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 103 of file DDRotation.cc.

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

107 {
108  // define 3 unit std::vectors
109  DD3Vector x(cos(phiX)*sin(thetaX), sin(phiX)*sin(thetaX), cos(thetaX));
110  DD3Vector y(cos(phiY)*sin(thetaY), sin(phiY)*sin(thetaY), cos(thetaY));
111  DD3Vector z(cos(phiZ)*sin(thetaZ), sin(phiZ)*sin(thetaZ), cos(thetaZ));
112 
113  double tol = 1.0e-3; // Geant4 compatible
114  double check = (x.Cross(y)).Dot(z); // in case of a LEFT-handed orthogonal system this must be -1
115  if (fabs(1.-check)>tol) {
116  edm::LogError("DDRotation") << ddname << " is not a RIGHT-handed orthonormal matrix!" << std::endl;
117  throw cms::Exception("DDException") << ddname.name() << " is not RIGHT-handed!";
118  }
119 
120  DDRotationMatrix* rot = new DDRotationMatrix(x.x(),y.x(),z.x(),
121  x.y(),y.y(),z.y(),
122  x.z(),y.z(),z.z());
123 
124  return DDRotation(ddname, rot);
125 
126 }
Sin< T >::type sin(const T &t)
Definition: Sin.h:22
float float float z
Represents a uniquely identifyable rotation matrix.
Definition: DDTransform.h:67
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
def check(config)
Definition: trackerTree.py:14
ROOT::Math::Rotation3D DDRotationMatrix
A DDRotationMatrix is currently implemented with a ROOT Rotation3D.
const std::string & name() const
Returns the name.
Definition: DDName.cc:90
std::unique_ptr<DDRotation> DDrotPtr ( const DDName ddname,
DDRotationMatrix rot 
)

Definition at line 96 of file DDRotation.cc.

References DDBase< DDName, DDRotationMatrix * >::ddname(), and makeMuonMisalignmentScenario::rot.

Referenced by DDLPosPart::processElement().

97 {
98  // memory of rot goes sto DDRotationImpl!!
99  return std::make_unique<DDRotation>(ddname, rot);
100 }
DDRotation DDrotReflect ( const DDName ddname,
DDRotationMatrix rot 
)

Definition at line 129 of file DDRotation.cc.

References DDRotation::DDRotation().

130 {
131  // memory of rot goes sto DDRotationImpl!!
132  return DDRotation(ddname, rot);
133 }
Represents a uniquely identifyable rotation matrix.
Definition: DDTransform.h:67
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 137 of file DDRotation.cc.

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

Referenced by DDLRotationAndReflection::processElement().

141 {
142 
143  // define 3 unit std::vectors forming the new left-handed axes
144  DD3Vector x(cos(phiX)*sin(thetaX), sin(phiX)*sin(thetaX), cos(thetaX));
145  DD3Vector y(cos(phiY)*sin(thetaY), sin(phiY)*sin(thetaY), cos(thetaY));
146  DD3Vector z(cos(phiZ)*sin(thetaZ), sin(phiZ)*sin(thetaZ), cos(thetaZ));
147 
148  double tol = 1.0e-3; // Geant4 compatible
149  double check = (x.Cross(y)).Dot(z); // in case of a LEFT-handed orthogonal system this must be -1
150  if (fabs(1.+check)>tol) {
151  edm::LogError("DDRotation") << ddname << " is not a LEFT-handed orthonormal matrix!" << std::endl;
152  throw cms::Exception("DDException") << ddname.name() << " is not LEFT-handed!";
153  }
154 
155  DDRotationMatrix* rot = new DDRotationMatrix(x.x(),y.x(),z.x(),
156  x.y(),y.y(),z.y(),
157  x.z(),y.z(),z.z());
158 
159  return DDRotation(ddname, rot);
160 }
Sin< T >::type sin(const T &t)
Definition: Sin.h:22
float float float z
Represents a uniquely identifyable rotation matrix.
Definition: DDTransform.h:67
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
def check(config)
Definition: trackerTree.py:14
ROOT::Math::Rotation3D DDRotationMatrix
A DDRotationMatrix is currently implemented with a ROOT Rotation3D.
const std::string & name() const
Returns the name.
Definition: DDName.cc:90
std::ostream& operator<< ( std::ostream &  os,
const DDRotation r 
)

Definition at line 21 of file DDRotation.cc.

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

22 {
24  if (defined.first) {
25  os << *(defined.first) << " ";
26  if (defined.second) {
27  const DDRotationMatrix & rm = *(r.rotation());
28  DDAxisAngle ra(rm);
29  os << "t=" << ra.Axis().Theta()/deg << "deg "
30  << "p=" << ra.Axis().Phi()/deg << "deg "
31  << "a=" << ra.Angle()/deg << "deg";
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:91
def_type isDefined() const
Definition: DDBase.h:110
rm
Definition: submit.py:76
ROOT::Math::AxisAngle DDAxisAngle
ROOT::Math::Rotation3D DDRotationMatrix
A DDRotationMatrix is currently implemented with a ROOT Rotation3D.