CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
Classes | Functions
DDTransform.h File Reference
#include "DetectorDescription/Core/interface/DDBase.h"
#include "DetectorDescription/Core/interface/DDName.h"
#include "DetectorDescription/Base/interface/DDRotationMatrix.h"

Go to the source code of this file.

Classes

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

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 &name, 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...
 
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 ( 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 DDCompactView::algoPosPart(), 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 DDVectorGetter::check(), funct::cos(), edm::hlt::Exception, python.connectstrParser::o, funct::sin(), x, detailsBasic3DVector::y, and detailsBasic3DVector::z.

Referenced by 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
ROOT::Math::DisplacementVector3D< ROOT::Math::Cartesian3D< double > > DD3Vector
A DD Translation is currently implemented with Root Vector3D.
Definition: DDTranslation.h:6
bool check(const std::string &)
Cos< T >::type cos(const T &t)
Definition: Cos.h:22
Definition: DDAxes.h:10
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 WriteOneGeometryFromXML::beginRun(), DDPixFwdBlades::computeNippleParameters(), DDHCalBarrelAlgo::constructGeneralVolume(), DDHCalEndcapAlgo::constructGeneralVolume(), DDLinear::execute(), DDAngular::execute(), DDTIDModulePosAlgo::execute(), DDTECOptoHybAlgo::execute(), DDPixBarStackTrigLayerAlgo::execute(), DDTIBLayerAlgo::execute(), DDHCalAngular::execute(), DDHCalTBCableAlgo::execute(), DDPixBarLayerUpgradeAlgo::execute(), DDPixBarLayerUpgradeAlgoCoverage::execute(), DDHCalTBZposAlgo::execute(), DDPixBarStackLayerAlgo::execute(), DDHCalTestBeamAlgo::execute(), DDHCalXtalAlgo::execute(), DDPixBarTPGStackLayerAlgo::execute(), DDTIBLayerAlgo_MTCC::execute(), DDGEMAngular::execute(), DDPixFwdDiskAlgo::execute(), DDPixBarLayerAlgo::execute(), DDMuonAngular::execute(), DDTrackerAngularV1::execute(), DDTECAxialCableAlgo::execute(), DDTECPhiAlgo::execute(), DDTECPhiAltAlgo::execute(), DDTIDAxialCableAlgo::execute(), DDTrackerPhiAlgo::execute(), DDTrackerPhiAltAlgo::execute(), DDHCalFibreBundle::execute(), DDTrackerAngular::execute(), DDTIDRingAlgo::execute(), DDPixFwdBlades::execute(), DDDividedConsPhi::makeDDRotation(), DDDividedTubsPhi::makeDDRotation(), DDDividedPolyconePhi::makeDDRotation(), DDDividedPolyhedraPhi::makeDDRotation(), DDTBH4Algo::myrot(), DDEcalBarrelNewAlgo::myrot(), DDEcalBarrelAlgo::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 DDVectorGetter::check(), funct::cos(), edm::hlt::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
ROOT::Math::DisplacementVector3D< ROOT::Math::Cartesian3D< double > > DD3Vector
A DD Translation is currently implemented with Root Vector3D.
Definition: DDTranslation.h:6
bool check(const std::string &)
Cos< T >::type cos(const T &t)
Definition: Cos.h:22
Definition: DDAxes.h:10
ROOT::Math::Rotation3D DDRotationMatrix
A DDRotationMatrix is currently implemented with a ROOT Rotation3D.
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 DDVectorGetter::check(), funct::cos(), edm::hlt::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
ROOT::Math::DisplacementVector3D< ROOT::Math::Cartesian3D< double > > DD3Vector
A DD Translation is currently implemented with Root Vector3D.
Definition: DDTranslation.h:6
bool check(const std::string &)
Cos< T >::type cos(const T &t)
Definition: Cos.h:22
Definition: DDAxes.h:10
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 name,
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
std::ostream& operator<< ( std::ostream &  ,
const DDRotation  
)

Definition at line 20 of file DDRotation.cc.

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

21 {
22  DDBase<DDName,DDRotationMatrix*>::def_type defined(r.isDefined());
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:14
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.