10 #include "Math/GenVector/Cartesian3D.h" 11 #include "Math/GenVector/DisplacementVector3D.h" 35 if ((name ==
"Rotation") &&
isLeftHanded(x, y, z, nmspace) == 0)
39 else if ((name ==
"Rotation") &&
isLeftHanded(x, y, z, nmspace) == 1)
42 msg +=
" left-handed rotation with a Rotation element. If";
43 msg +=
" you meant to make a reflection, use ReflectionRotation";
44 msg +=
" elements, otherwise, please check your matrix. Other";
45 msg +=
" errors may follow. Rotation matrix not created.";
46 edm::LogError(
"DetectorDescription_Parser_Rotation_and_Reflection") << msg << std::endl;
48 else if (name ==
"ReflectionRotation" &&
isLeftHanded(x, y, z, nmspace) == 1)
53 , ev.
eval(nmspace, atts.find(
"thetaX")->second)
54 , ev.
eval(nmspace, atts.find(
"phiX")->second)
55 , ev.
eval(nmspace, atts.find(
"thetaY")->second)
56 , ev.
eval(nmspace, atts.find(
"phiY")->second)
57 , ev.
eval(nmspace, atts.find(
"thetaZ")->second)
58 , ev.
eval(nmspace, atts.find(
"phiZ")->second));
60 else if (name ==
"ReflectionRotation" &&
isLeftHanded(x, y, z, nmspace) == 0)
63 msg +=
" rotation using a ReflectionRotation element. ";
64 msg +=
" If you meant to make a Rotation, use Rotation";
65 msg +=
" elements, otherwise, please check your matrix.";
66 msg +=
" Other errors may follow. ReflectionRotation";
67 msg +=
" matrix not created.";
68 edm::LogError(
"DetectorDescription_Parser_Rotation_and_Reflection") << msg << std::endl;
72 std::string msg =
"\nDDLRotationAndReflection::processElement tried to process wrong element.";
99 double check = (x.Cross(y)).Dot(z);
105 std::cout <<
"DDLRotationAndReflection Coordinate axes forming rotation matrix " 107 <<
" are not orthonormal.(tolerance=" << tol
108 <<
" check=" <<
std::abs(check) <<
")" 110 <<
" thetaX=" << (atts.find(
"thetaX")->second)
111 <<
' ' <<
CONVERT_TO( ev.
eval(nmspace, atts.find(
"thetaX")->second), deg ) << std::endl
112 <<
" phiX=" << (atts.find(
"phiX")->second)
113 <<
' ' <<
CONVERT_TO( ev.
eval(nmspace, atts.find(
"phiX")->second), deg ) << std::endl
114 <<
" thetaY=" << (atts.find(
"thetaY")->second)
115 <<
' ' <<
CONVERT_TO( ev.
eval(nmspace, atts.find(
"thetaY")->second), deg ) << std::endl
116 <<
" phiY=" << (atts.find(
"phiY")->second)
117 <<
' ' <<
CONVERT_TO( ev.
eval(nmspace, atts.find(
"phiY")->second), deg ) << std::endl
118 <<
" thetaZ=" << (atts.find(
"thetaZ")->second)
119 <<
' ' <<
CONVERT_TO( ev.
eval(nmspace, atts.find(
"thetaZ")->second), deg ) << std::endl
120 <<
" phiZ=" << (atts.find(
"phiZ")->second)
121 <<
' ' <<
CONVERT_TO( ev.
eval(nmspace, atts.find(
"phiZ")->second), deg )
123 <<
" WAS NOT CREATED!" << std::endl;
126 else if (1.0+check<=tol) {
137 if (atts.find(
"thetaX") != atts.end())
140 double thetaX = ev.
eval(nmspace, atts.find(
"thetaX")->second);
141 double phiX = ev.
eval(nmspace, atts.find(
"phiX")->second);
143 x.SetX(
sin(thetaX) *
cos(phiX));
144 x.SetY(
sin(thetaX) *
sin(phiX));
155 if (atts.find(
"thetaY") != atts.end())
158 double thetaY = ev.
eval(nmspace, atts.find(
"thetaY")->second);
159 double phiY = ev.
eval(nmspace, atts.find(
"phiY")->second);
162 y.SetX(
sin(thetaY) *
cos(phiY));
163 y.SetY(
sin(thetaY) *
sin(phiY));
174 if (atts.find(
"thetaZ") != atts.end())
177 double thetaZ = ev.
eval(nmspace, atts.find(
"thetaZ")->second);
178 double phiZ = ev.
eval(nmspace, atts.find(
"phiZ")->second);
181 z.SetX(
sin(thetaZ) *
cos(phiZ));
182 z.SetY(
sin(thetaZ) *
sin(phiZ));
DDLElementRegistry * myRegistry_
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.
#define CONVERT_TO(_x, _y)
void throwError(const std::string &keyMessage) const
format std::string for throw an error.
Compact representation of the geometrical detector hierarchy.
DD3Vector makeZ(const std::string &nmspace)
std::map< std::string, std::string > DDXMLAttribute
Represents a uniquely identifyable rotation matrix.
DD3Vector makeX(const std::string &nmspace)
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)
Abs< T >::type abs(const T &t)
int isLeftHanded(const DD3Vector &x, const DD3Vector &y, const DD3Vector &z, const std::string &nmspace)
returns 1 = left handed rotation matrix, 0 = right-handed, -1 = not orthonormal.
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.
virtual const DDName getDDName(const std::string &defaultNS, const std::string &attname=std::string("name"), size_t aIndex=0)
DD3Vector makeY(const std::string &nmspace)