2 #include "CLHEP/Units/GlobalSystemOfUnits.h" 3 #include "CLHEP/Units/SystemOfUnits.h" 11 #include "Math/GenVector/Cartesian3D.h" 12 #include "Math/GenVector/DisplacementVector3D.h" 35 if ((name ==
"Rotation") &&
isLeftHanded(x, y, z, nmspace) == 0)
40 else if ((name ==
"Rotation") &&
isLeftHanded(x, y, z, nmspace) == 1)
43 msg +=
" left-handed rotation with a Rotation element. If";
44 msg +=
" you meant to make a reflection, use ReflectionRotation";
45 msg +=
" elements, otherwise, please check your matrix. Other";
46 msg +=
" errors may follow. Rotation matrix not created.";
47 edm::LogError(
"DetectorDescription_Parser_Rotation_and_Reflection") << msg << std::endl;
49 else if (name ==
"ReflectionRotation" &&
isLeftHanded(x, y, z, nmspace) == 1)
54 , ev.
eval(nmspace, atts.find(
"thetaX")->second)
55 , ev.
eval(nmspace, atts.find(
"phiX")->second)
56 , ev.
eval(nmspace, atts.find(
"thetaY")->second)
57 , ev.
eval(nmspace, atts.find(
"phiY")->second)
58 , ev.
eval(nmspace, atts.find(
"thetaZ")->second)
59 , ev.
eval(nmspace, atts.find(
"phiZ")->second));
61 else if (name ==
"ReflectionRotation" &&
isLeftHanded(x, y, z, nmspace) == 0)
64 msg +=
" rotation using a ReflectionRotation element. ";
65 msg +=
" If you meant to make a Rotation, use Rotation";
66 msg +=
" elements, otherwise, please check your matrix.";
67 msg +=
" Other errors may follow. ReflectionRotation";
68 msg +=
" matrix not created.";
69 edm::LogError(
"DetectorDescription_Parser_Rotation_and_Reflection") << msg << std::endl;
73 std::string msg =
"\nDDLRotationAndReflection::processElement tried to process wrong element.";
142 double check = (x.Cross(y)).Dot(z);
148 std::cout <<
"DDLRotationAndReflection Coordinate axes forming rotation matrix " 150 <<
" are not orthonormal.(tolerance=" << tol
151 <<
" check=" <<
std::abs(check) <<
")" 153 <<
" thetaX=" << (atts.find(
"thetaX")->second)
154 <<
' ' << ev.
eval(nmspace, atts.find(
"thetaX")->second)/deg << std::endl
155 <<
" phiX=" << (atts.find(
"phiX")->second)
156 <<
' ' << ev.
eval(nmspace, atts.find(
"phiX")->second)/deg << std::endl
157 <<
" thetaY=" << (atts.find(
"thetaY")->second)
158 <<
' ' << ev.
eval(nmspace, atts.find(
"thetaY")->second)/deg << std::endl
159 <<
" phiY=" << (atts.find(
"phiY")->second)
160 <<
' ' << ev.
eval(nmspace, atts.find(
"phiY")->second)/deg << std::endl
161 <<
" thetaZ=" << (atts.find(
"thetaZ")->second)
162 <<
' ' << ev.
eval(nmspace, atts.find(
"thetaZ")->second)/deg << std::endl
163 <<
" phiZ=" << (atts.find(
"phiZ")->second)
164 <<
' ' << ev.
eval(nmspace, atts.find(
"phiZ")->second)/deg
166 <<
" WAS NOT CREATED!" << std::endl;
169 else if (1.0+check<=tol) {
180 if (atts.find(
"thetaX") != atts.end())
183 double thetaX = ev.
eval(nmspace, atts.find(
"thetaX")->second);
184 double phiX = ev.
eval(nmspace, atts.find(
"phiX")->second);
186 x.SetX(
sin(thetaX) *
cos(phiX));
187 x.SetY(
sin(thetaX) *
sin(phiX));
198 if (atts.find(
"thetaY") != atts.end())
201 double thetaY = ev.
eval(nmspace, atts.find(
"thetaY")->second);
202 double phiY = ev.
eval(nmspace, atts.find(
"phiY")->second);
205 y.SetX(
sin(thetaY) *
cos(phiY));
206 y.SetY(
sin(thetaY) *
sin(phiY));
216 if (atts.find(
"thetaZ") != atts.end())
219 double thetaZ = ev.
eval(nmspace, atts.find(
"thetaZ")->second);
220 double phiZ = ev.
eval(nmspace, atts.find(
"phiZ")->second);
223 z.SetX(
sin(thetaZ) *
cos(phiZ));
224 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.
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.
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)
DD3Vector makeY(const std::string &nmspace)