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, std::unique_ptr< DDRotationMatrix > rot)
 Definition of a uniquely identifiable rotation matrix named by DDName name. 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...
 
std::unique_ptr< DDRotationDDrotPtr (const DDName &name, std::unique_ptr< 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...
 
DDRotation DDrotReflect (const DDName &name, DDRotationMatrix *rot)
 
std::ostream & operator<< (std::ostream &, const DDRotation &)
 

Function Documentation

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

References DDRotation::DDRotation(), and eostools::move().

Referenced by DDTIBLayerAlgo::execute().

178 {
179  return DDRotation( std::move( rot ));
180 }
Represents a uniquely identifyable rotation matrix.
Definition: DDTransform.h:68
def move(src, dest)
Definition: eostools.py:511
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 149 of file DDRotation.cc.

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

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

152 {
153  // define 3 unit std::vectors forming the new left-handed axes
154  DD3Vector x(cos(phiX)*sin(thetaX), sin(phiX)*sin(thetaX), cos(thetaX));
155  DD3Vector y(cos(phiY)*sin(thetaY), sin(phiY)*sin(thetaY), cos(thetaY));
156  DD3Vector z(cos(phiZ)*sin(thetaZ), sin(phiZ)*sin(thetaZ), cos(thetaZ));
157 
158  double tol = 1.0e-3; // Geant4 compatible
159  double check = (x.Cross(y)).Dot(z);// in case of a LEFT-handed orthogonal system this must be -1, RIGHT-handed: +1
160  if ((1.-fabs(check))>tol) {
161  std::ostringstream o;
162  o << "matrix is not an (left or right handed) orthonormal matrix! (in deg)" << std::endl
163  << " thetaX=" << CONVERT_TO( thetaX, deg ) << " phiX=" << CONVERT_TO( phiX, deg ) << std::endl
164  << " thetaY=" << CONVERT_TO( thetaY, deg ) << " phiY=" << CONVERT_TO( phiY, deg ) << std::endl
165  << " thetaZ=" << CONVERT_TO( thetaZ, deg ) << " phiZ=" << CONVERT_TO( phiZ, deg ) << std::endl;
166  edm::LogError("DDRotation") << o.str() << std::endl;
167 
168  throw cms::Exception("DDException") << o.str();
169  }
170 
171  return std::make_unique<DDRotationMatrix>(x.x(),y.x(),z.x(),
172  x.y(),y.y(),z.y(),
173  x.z(),y.z(),z.z());
174 }
Sin< T >::type sin(const T &t)
Definition: Sin.h:22
#define CONVERT_TO(_x, _y)
Definition: DDUnits.h:6
float float float z
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
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 80 of file DDRotation.cc.

References DDRotation::DDRotation(), and eostools::move().

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

81 {
82  // memory of rot goes sto DDRotationImpl!!
83  return DDRotation(ddname, std::move( rot ));
84 }
Represents a uniquely identifyable rotation matrix.
Definition: DDTransform.h:68
def move(src, dest)
Definition: eostools.py:511
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 94 of file DDRotation.cc.

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

98 {
99  // define 3 unit std::vectors
100  DD3Vector x(cos(phiX)*sin(thetaX), sin(phiX)*sin(thetaX), cos(thetaX));
101  DD3Vector y(cos(phiY)*sin(thetaY), sin(phiY)*sin(thetaY), cos(thetaY));
102  DD3Vector z(cos(phiZ)*sin(thetaZ), sin(phiZ)*sin(thetaZ), cos(thetaZ));
103 
104  double tol = 1.0e-3; // Geant4 compatible
105  double check = (x.Cross(y)).Dot(z); // in case of a LEFT-handed orthogonal system this must be -1
106  if (fabs(1.-check)>tol) {
107  edm::LogError("DDRotation") << ddname << " is not a RIGHT-handed orthonormal matrix!" << std::endl;
108  throw cms::Exception("DDException") << ddname.name() << " is not RIGHT-handed!";
109  }
110 
111  return DDRotation( ddname,
112  std::make_unique<DDRotationMatrix>(x.x(),y.x(),z.x(),
113  x.y(),y.y(),z.y(),
114  x.z(),y.z(),z.z()));
115 }
Sin< T >::type sin(const T &t)
Definition: Sin.h:22
float float float z
Represents a uniquely identifyable rotation matrix.
Definition: DDTransform.h:68
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
std::unique_ptr<DDRotation> DDrotPtr ( const DDName name,
std::unique_ptr< DDRotationMatrix rot 
)

Definition at line 87 of file DDRotation.cc.

References DDBase< DDName, std::unique_ptr< DDRotationMatrix > >::ddname(), and eostools::move().

Referenced by DDLPosPart::processElement().

88 {
89  // memory of rot goes sto DDRotationImpl!!
90  return std::make_unique<DDRotation>( ddname, std::move( rot ));
91 }
def move(src, dest)
Definition: eostools.py:511
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 124 of file DDRotation.cc.

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

Referenced by DDLRotationAndReflection::processElement().

128 {
129  // define 3 unit std::vectors forming the new left-handed axes
130  DD3Vector x(cos(phiX)*sin(thetaX), sin(phiX)*sin(thetaX), cos(thetaX));
131  DD3Vector y(cos(phiY)*sin(thetaY), sin(phiY)*sin(thetaY), cos(thetaY));
132  DD3Vector z(cos(phiZ)*sin(thetaZ), sin(phiZ)*sin(thetaZ), cos(thetaZ));
133 
134  double tol = 1.0e-3; // Geant4 compatible
135  double check = (x.Cross(y)).Dot(z); // in case of a LEFT-handed orthogonal system this must be -1
136  if (fabs(1.+check)>tol) {
137  edm::LogError("DDRotation") << ddname << " is not a LEFT-handed orthonormal matrix!" << std::endl;
138  throw cms::Exception("DDException") << ddname.name() << " is not LEFT-handed!";
139  }
140 
141  return DDRotation( ddname,
142  std::make_unique<DDRotationMatrix>(x.x(),y.x(),z.x(),
143  x.y(),y.y(),z.y(),
144  x.z(),y.z(),z.z()));
145 }
Sin< T >::type sin(const T &t)
Definition: Sin.h:22
float float float z
Represents a uniquely identifyable rotation matrix.
Definition: DDTransform.h:68
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
const std::string & name() const
Returns the name.
Definition: DDName.cc:53
DDRotation DDrotReflect ( const DDName name,
DDRotationMatrix rot 
)
std::ostream& operator<< ( std::ostream &  ,
const DDRotation  
)

Definition at line 21 of file DDRotation.cc.

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

22 {
23  DDBase<DDName,DDRotationMatrix*>::def_type defined(r.isDefined());
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=" << CONVERT_TO( ra.Axis().Theta(), deg ) << "deg "
30  << "p=" << CONVERT_TO( ra.Axis().Phi(), deg ) << "deg "
31  << "a=" << CONVERT_TO( 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 }
ROOT::Math::Rotation3D DDRotationMatrix
A DDRotationMatrix is currently implemented with a ROOT Rotation3D.
#define CONVERT_TO(_x, _y)
Definition: DDUnits.h:6
std::pair< const N *, bool > def_type
Definition: DDBase.h:66
rm
Definition: submit.py:77
ROOT::Math::AxisAngle DDAxisAngle