CMS 3D CMS Logo

Functions
DDRotation.cc File Reference
#include <cstdio>
#include <atomic>
#include <cmath>
#include <sstream>
#include <string>
#include "DetectorDescription/Core/interface/DDRotationMatrix.h"
#include "DetectorDescription/Core/interface/DDTranslation.h"
#include "DetectorDescription/Core/interface/DDBase.h"
#include "DetectorDescription/Core/interface/DDName.h"
#include "DetectorDescription/Core/interface/DDTransform.h"
#include "DataFormats/Math/interface/GeantUnits.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 (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 &ddname, std::unique_ptr< 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, std::unique_ptr< DDRotationMatrix > rot)
 
DDRotation DDrotReflect (const DDName &ddname, std::unique_ptr< 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

◆ 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.

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

Referenced by DDTIBLayerAlgo::execute().

143 { return DDRotation(std::move(rot)); }
Represents a uniquely identifyable rotation matrix.
Definition: DDTransform.h:57
def move(src, dest)
Definition: eostools.py:511

◆ 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.

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

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

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 }
constexpr NumType convertRadToDeg(NumType radians)
Definition: angle_units.h:21
Sin< T >::type sin(const T &t)
Definition: Sin.h:22
Log< level::Error, false > LogError
ROOT::Math::DisplacementVector3D< ROOT::Math::Cartesian3D< double > > DD3Vector
Cos< T >::type cos(const T &t)
Definition: Cos.h:22
float x

◆ DDrot() [1/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.

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

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

67  {
68  // memory of rot goes sto DDRotationImpl!!
69  return DDRotation(ddname, std::move(rot));
70 }
Represents a uniquely identifyable rotation matrix.
Definition: DDTransform.h:57
def move(src, dest)
Definition: eostools.py:511

◆ DDrot() [2/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.

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

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 }
Sin< T >::type sin(const T &t)
Definition: Sin.h:22
Log< level::Error, false > LogError
Represents a uniquely identifyable rotation matrix.
Definition: DDTransform.h:57
ROOT::Math::DisplacementVector3D< ROOT::Math::Cartesian3D< double > > DD3Vector
const std::string & name() const
Returns the name.
Definition: DDName.cc:41
Cos< T >::type cos(const T &t)
Definition: Cos.h:22
float x

◆ DDrotPtr()

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

Definition at line 72 of file DDRotation.cc.

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

Referenced by DDLPosPart::processElement().

72  {
73  // memory of rot goes sto DDRotationImpl!!
74  return std::make_unique<DDRotation>(ddname, std::move(rot));
75 }
def move(src, dest)
Definition: eostools.py:511

◆ DDrotReflect() [1/2]

DDRotation DDrotReflect ( const DDName ddname,
std::unique_ptr< DDRotationMatrix rot 
)

Definition at line 96 of file DDRotation.cc.

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

96  {
97  return DDRotation(ddname, std::move(rot));
98 }
Represents a uniquely identifyable rotation matrix.
Definition: DDTransform.h:57
def move(src, dest)
Definition: eostools.py:511

◆ 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.

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

Referenced by DDLRotationAndReflection::processElement().

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 }
Sin< T >::type sin(const T &t)
Definition: Sin.h:22
Log< level::Error, false > LogError
Represents a uniquely identifyable rotation matrix.
Definition: DDTransform.h:57
ROOT::Math::DisplacementVector3D< ROOT::Math::Cartesian3D< double > > DD3Vector
const std::string & name() const
Returns the name.
Definition: DDName.cc:41
Cos< T >::type cos(const T &t)
Definition: Cos.h:22
float x

◆ operator<<()

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

Definition at line 21 of file DDRotation.cc.

References angle_units::operators::convertRadToDeg(), l1tGTMenu_BTagSeeds_cff::os, and eostools::rm().

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 }
def rm(path, rec=False)
Definition: eostools.py:363
ROOT::Math::AxisAngle DDAxisAngle
constexpr NumType convertRadToDeg(NumType radians)
Definition: angle_units.h:21
ROOT::Math::Rotation3D DDRotationMatrix
A DDRotationMatrix is currently implemented with a ROOT Rotation3D.
std::pair< const N *, bool > def_type
Definition: DDBase.h:51