8 #include "CLHEP/Units/GlobalSystemOfUnits.h"
9 #include "CLHEP/Units/SystemOfUnits.h"
17 #include "Math/GenVector/Cartesian3D.h"
18 #include "Math/GenVector/DisplacementVector3D.h"
36 if ((name ==
"Rotation") &&
isLeftHanded(x, y, z, nmspace) == 0)
41 else if ((name ==
"Rotation") &&
isLeftHanded(x, y, z, nmspace) == 1)
44 msg +=
" left-handed rotation with a Rotation element. If";
45 msg +=
" you meant to make a reflection, use ReflectionRotation";
46 msg +=
" elements, otherwise, please check your matrix. Other";
47 msg +=
" errors may follow. Rotation matrix not created.";
48 edm::LogError(
"DetectorDescription_Parser_Rotation_and_Reflection") << msg << std::endl;
50 else if (name ==
"ReflectionRotation" &&
isLeftHanded(x, y, z, nmspace) == 1)
55 , ev.
eval(nmspace, atts.find(
"thetaX")->second)
56 , ev.
eval(nmspace, atts.find(
"phiX")->second)
57 , ev.
eval(nmspace, atts.find(
"thetaY")->second)
58 , ev.
eval(nmspace, atts.find(
"phiY")->second)
59 , ev.
eval(nmspace, atts.find(
"thetaZ")->second)
60 , ev.
eval(nmspace, atts.find(
"phiZ")->second));
62 else if (name ==
"ReflectionRotation" &&
isLeftHanded(x, y, z, nmspace) == 0)
65 msg +=
" rotation using a ReflectionRotation element. ";
66 msg +=
" If you meant to make a Rotation, use Rotation";
67 msg +=
" elements, otherwise, please check your matrix.";
68 msg +=
" Other errors may follow. ReflectionRotation";
69 msg +=
" matrix not created.";
70 edm::LogError(
"DetectorDescription_Parser_Rotation_and_Reflection") << msg << std::endl;
74 std::string msg =
"\nDDLRotationAndReflection::processElement tried to process wrong element.";
143 double check = (x.Cross(y)).Dot(z);
149 std::cout <<
"DDLRotationAndReflection Coordinate axes forming rotation matrix "
151 <<
" are not orthonormal.(tolerance=" << tol
152 <<
" check=" <<
std::abs(check) <<
")"
154 <<
" thetaX=" << (atts.find(
"thetaX")->second)
155 <<
' ' << ev.
eval(nmspace, atts.find(
"thetaX")->second)/deg << std::endl
156 <<
" phiX=" << (atts.find(
"phiX")->second)
157 <<
' ' << ev.
eval(nmspace, atts.find(
"phiX")->second)/deg << std::endl
158 <<
" thetaY=" << (atts.find(
"thetaY")->second)
159 <<
' ' << ev.
eval(nmspace, atts.find(
"thetaY")->second)/deg << std::endl
160 <<
" phiY=" << (atts.find(
"phiY")->second)
161 <<
' ' << ev.
eval(nmspace, atts.find(
"phiY")->second)/deg << std::endl
162 <<
" thetaZ=" << (atts.find(
"thetaZ")->second)
163 <<
' ' << ev.
eval(nmspace, atts.find(
"thetaZ")->second)/deg << std::endl
164 <<
" phiZ=" << (atts.find(
"phiZ")->second)
165 <<
' ' << ev.
eval(nmspace, atts.find(
"phiZ")->second)/deg
167 <<
" WAS NOT CREATED!" << std::endl;
170 else if (1.0+check<=tol) {
181 if (atts.find(
"thetaX") != atts.end())
184 double thetaX = ev.
eval(nmspace, atts.find(
"thetaX")->second.c_str());
185 double phiX = ev.
eval(nmspace, atts.find(
"phiX")->second.c_str());
187 x.SetX(
sin(thetaX) *
cos(phiX));
188 x.SetY(
sin(thetaX) *
sin(phiX));
199 if (atts.find(
"thetaY") != atts.end())
202 double thetaY = ev.
eval(nmspace, atts.find(
"thetaY")->second.c_str());
203 double phiY = ev.
eval(nmspace, atts.find(
"phiY")->second.c_str());
206 y.SetX(
sin(thetaY) *
cos(phiY));
207 y.SetY(
sin(thetaY) *
sin(phiY));
217 if (atts.find(
"thetaZ") != atts.end())
220 double thetaZ = ev.
eval(nmspace, atts.find(
"thetaZ")->second.c_str());
221 double phiZ = ev.
eval(nmspace, atts.find(
"phiZ")->second.c_str());
224 z.SetX(
sin(thetaZ) *
cos(phiZ));
225 z.SetY(
sin(thetaZ) *
sin(phiZ));
tuple ret
prodAgent to be discontinued
DDLElementRegistry * myRegistry_
DD3Vector makeZ(std::string nmspace)
DD3Vector makeX(std::string nmspace)
void processElement(const std::string &name, const std::string &nmspace, DDCompactView &cpv) override
Processing the element.
Sin< T >::type sin(const T &t)
virtual const DDXMLAttribute & getAttributeSet(size_t aIndex=0) const
Get a "row" of attributes, i.e. one attribute set.
void throwError(const std::string &keyMessage) const
format std::string for throw an error.
type of data representation of DDCompactView
std::map< std::string, std::string > DDXMLAttribute
Represents a uniquely identifyable rotation matrix.
T x() const
Cartesian x coordinate.
ClhepEvaluator & evaluator()
ROOT::Math::DisplacementVector3D< ROOT::Math::Cartesian3D< double > > DD3Vector
A DD Translation is currently implemented with Root Vector3D.
Cos< T >::type cos(const T &t)
DD3Vector makeY(std::string nmspace)
Abs< T >::type abs(const T &t)
DDLRotationAndReflection(DDLElementRegistry *myreg)
This is a base class for processing XML elements in the DDD.
double eval(const std::string &ns, const std::string &expr)
The main class for processing parsed elements.
virtual void clear(void)
clear this element's contents.
ROOT::Math::Rotation3D DDRotationMatrix
A DDRotationMatrix is currently implemented with a ROOT Rotation3D.
virtual const DDName getDDName(const std::string &defaultNS, const std::string &attname=std::string("name"), size_t aIndex=0)
int isLeftHanded(DD3Vector x, DD3Vector y, DD3Vector z, const std::string &nmspace)
returns 1 = left handed rotation matrix, 0 = right-handed, -1 = not orthonormal.