CMS 3D CMS Logo

Classes | Functions
DDTransform.h File Reference
#include "DetectorDescription/Core/interface/DDBase.h"
#include "DetectorDescription/Core/interface/DDName.h"
#include "DetectorDescription/Core/interface/DDRotationMatrix.h"
#include <memory>

Go to the source code of this file.

Classes

class  DDRotation
 Represents a uniquely identifyable rotation matrix. More...
 

Functions

DDRotation DDanonymousRot (std::unique_ptr< DDRotationMatrix > rot)
 Defines a anonymous rotation or rotation-reflection matrix. More...
 
std::unique_ptr< 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 &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. More...
 
DDRotation DDrot (const DDName &name, std::unique_ptr< DDRotationMatrix > rot)
 Definition of a uniquely identifiable rotation matrix named by DDName name. More...
 
std::unique_ptr< DDRotationDDrotPtr (const DDName &name, std::unique_ptr< DDRotationMatrix > rot)
 
DDRotation DDrotReflect (const DDName &name, DDRotationMatrix *rot)
 
DDRotation DDrotReflect (const DDName &name, 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 &, const DDRotation &)
 

Function Documentation

◆ DDanonymousRot()

DDRotation DDanonymousRot ( std::unique_ptr< 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 143 of file DDRotation.cc.

143 { return DDRotation(std::move(rot)); }

References eostools::move(), and makeMuonMisalignmentScenario::rot.

Referenced by DDTIBLayerAlgo::execute().

◆ DDcreateRotationMatrix()

std::unique_ptr<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 120 of file DDRotation.cc.

121  {
122  // define 3 unit std::vectors forming the new left-handed axes
123  DD3Vector x(cos(phiX) * sin(thetaX), sin(phiX) * sin(thetaX), cos(thetaX));
124  DD3Vector y(cos(phiY) * sin(thetaY), sin(phiY) * sin(thetaY), cos(thetaY));
125  DD3Vector z(cos(phiZ) * sin(thetaZ), sin(phiZ) * sin(thetaZ), cos(thetaZ));
126 
127  double tol = 1.0e-3; // Geant4 compatible
128  double check = (x.Cross(y)).Dot(z); // in case of a LEFT-handed orthogonal system this must be -1, RIGHT-handed: +1
129  if ((1. - fabs(check)) > tol) {
130  std::ostringstream o;
131  o << "matrix is not an (left or right handed) orthonormal matrix! (in deg)" << std::endl
132  << " thetaX=" << convertRadToDeg(thetaX) << " phiX=" << convertRadToDeg(phiX) << std::endl
133  << " thetaY=" << convertRadToDeg(thetaY) << " phiY=" << convertRadToDeg(phiY) << std::endl
134  << " thetaZ=" << convertRadToDeg(thetaZ) << " phiZ=" << convertRadToDeg(phiZ) << std::endl;
135  edm::LogError("DDRotation") << o.str() << std::endl;
136 
137  throw cms::Exception("DDException") << o.str();
138  }
139 
140  return std::make_unique<DDRotationMatrix>(x.x(), y.x(), z.x(), x.y(), y.y(), z.y(), x.z(), y.z(), z.z());
141 }

References RPCNoise_example::check, angle_units::operators::convertRadToDeg(), funct::cos(), Exception, EcalTangentSkim_cfg::o, funct::sin(), DOFs::thetaX, DOFs::thetaY, DOFs::thetaZ, vertices_cff::x, detailsBasic3DVector::y, and detailsBasic3DVector::z.

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

◆ DDrot() [1/2]

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 78 of file DDRotation.cc.

79  {
80  // define 3 unit std::vectors
81  DD3Vector x(cos(phiX) * sin(thetaX), sin(phiX) * sin(thetaX), cos(thetaX));
82  DD3Vector y(cos(phiY) * sin(thetaY), sin(phiY) * sin(thetaY), cos(thetaY));
83  DD3Vector z(cos(phiZ) * sin(thetaZ), sin(phiZ) * sin(thetaZ), cos(thetaZ));
84 
85  double tol = 1.0e-3; // Geant4 compatible
86  double check = (x.Cross(y)).Dot(z); // in case of a LEFT-handed orthogonal system this must be -1
87  if (fabs(1. - check) > tol) {
88  edm::LogError("DDRotation") << ddname << " is not a RIGHT-handed orthonormal matrix!" << std::endl;
89  throw cms::Exception("DDException") << ddname.name() << " is not RIGHT-handed!";
90  }
91 
92  return DDRotation(ddname,
93  std::make_unique<DDRotationMatrix>(x.x(), y.x(), z.x(), x.y(), y.y(), z.y(), x.z(), y.z(), z.z()));
94 }

References RPCNoise_example::check, funct::cos(), Exception, DDName::name(), funct::sin(), DOFs::thetaX, DOFs::thetaY, DOFs::thetaZ, vertices_cff::x, detailsBasic3DVector::y, and detailsBasic3DVector::z.

◆ DDrot() [2/2]

DDRotation DDrot ( const DDName ddname,
std::unique_ptr< 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 67 of file DDRotation.cc.

67  {
68  // memory of rot goes sto DDRotationImpl!!
69  return DDRotation(ddname, std::move(rot));
70 }

References eostools::move(), and makeMuonMisalignmentScenario::rot.

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

◆ DDrotPtr()

std::unique_ptr<DDRotation> DDrotPtr ( const DDName name,
std::unique_ptr< DDRotationMatrix rot 
)

Definition at line 72 of file DDRotation.cc.

72  {
73  // memory of rot goes sto DDRotationImpl!!
74  return std::make_unique<DDRotation>(ddname, std::move(rot));
75 }

References eostools::move(), and makeMuonMisalignmentScenario::rot.

Referenced by DDLPosPart::processElement().

◆ DDrotReflect() [1/2]

DDRotation DDrotReflect ( const DDName name,
DDRotationMatrix rot 
)

◆ DDrotReflect() [2/2]

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 101 of file DDRotation.cc.

102  {
103  // define 3 unit std::vectors forming the new left-handed axes
104  DD3Vector x(cos(phiX) * sin(thetaX), sin(phiX) * sin(thetaX), cos(thetaX));
105  DD3Vector y(cos(phiY) * sin(thetaY), sin(phiY) * sin(thetaY), cos(thetaY));
106  DD3Vector z(cos(phiZ) * sin(thetaZ), sin(phiZ) * sin(thetaZ), cos(thetaZ));
107 
108  double tol = 1.0e-3; // Geant4 compatible
109  double check = (x.Cross(y)).Dot(z); // in case of a LEFT-handed orthogonal system this must be -1
110  if (fabs(1. + check) > tol) {
111  edm::LogError("DDRotation") << ddname << " is not a LEFT-handed orthonormal matrix!" << std::endl;
112  throw cms::Exception("DDException") << ddname.name() << " is not LEFT-handed!";
113  }
114 
115  return DDRotation(ddname,
116  std::make_unique<DDRotationMatrix>(x.x(), y.x(), z.x(), x.y(), y.y(), z.y(), x.z(), y.z(), z.z()));
117 }

References RPCNoise_example::check, funct::cos(), Exception, DDName::name(), funct::sin(), DOFs::thetaX, DOFs::thetaY, DOFs::thetaZ, vertices_cff::x, detailsBasic3DVector::y, and detailsBasic3DVector::z.

Referenced by DDLRotationAndReflection::processElement().

◆ operator<<()

std::ostream& operator<< ( std::ostream &  ,
const DDRotation  
)

Definition at line 21 of file DDRotation.cc.

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=" << convertRadToDeg(ra.Axis().Theta()) << "deg "
29  << "p=" << convertRadToDeg(ra.Axis().Phi()) << "deg "
30  << "a=" << convertRadToDeg(ra.Angle()) << "deg";
31  } else {
32  os << "* rotation not defined * ";
33  }
34  } else {
35  os << "* rotation not declared * ";
36  }
37  return os;
38 }

References angle_units::operators::convertRadToDeg(), alignCSCRings::r, and submit::rm.

DDBase::def_type
std::pair< const N *, bool > def_type
Definition: DDBase.h:51
detailsBasic3DVector::z
float float float z
Definition: extBasic3DVector.h:14
angle_units::operators::convertRadToDeg
constexpr NumType convertRadToDeg(NumType radians)
Definition: angle_units.h:21
DDRotationMatrix
ROOT::Math::Rotation3D DDRotationMatrix
A DDRotationMatrix is currently implemented with a ROOT Rotation3D.
Definition: DDRotationMatrix.h:8
DD3Vector
ROOT::Math::DisplacementVector3D< ROOT::Math::Cartesian3D< double > > DD3Vector
A DD Translation is currently implemented with Root Vector3D.
Definition: DDTranslation.h:6
EcalTangentSkim_cfg.o
o
Definition: EcalTangentSkim_cfg.py:36
funct::sin
Sin< T >::type sin(const T &t)
Definition: Sin.h:22
RPCNoise_example.check
check
Definition: RPCNoise_example.py:71
funct::cos
Cos< T >::type cos(const T &t)
Definition: Cos.h:22
vertices_cff.x
x
Definition: vertices_cff.py:29
submit.rm
rm
Definition: submit.py:77
edm::LogError
Definition: MessageLogger.h:183
DDName::name
const std::string & name() const
Returns the name.
Definition: DDName.cc:40
DDAxisAngle
ROOT::Math::AxisAngle DDAxisAngle
Definition: DDRotationMatrix.h:9
DOFs::thetaY
Definition: AlignPCLThresholdsWriter.cc:37
alignCSCRings.r
r
Definition: alignCSCRings.py:93
DOFs::thetaX
Definition: AlignPCLThresholdsWriter.cc:37
eostools.move
def move(src, dest)
Definition: eostools.py:511
DOFs::thetaZ
Definition: AlignPCLThresholdsWriter.cc:37
Exception
Definition: hltDiff.cc:246
detailsBasic3DVector::y
float float y
Definition: extBasic3DVector.h:14
makeMuonMisalignmentScenario.rot
rot
Definition: makeMuonMisalignmentScenario.py:322
DDRotation
ROOT::Math::Rotation3D DDRotation
Definition: DDEcalEndcapAlgo.cc:18