23 #include "CLHEP/Units/GlobalSystemOfUnits.h"
38 DCOUT_V(
'P',
"DDLRotationAndReflection::processElement started " << name);
47 if ((name ==
"Rotation") &&
isLeftHanded(x, y, z, nmspace) == 0)
51 DCOUT_V (
'p',
"Rotation created: " << ddrot << std::endl);
53 else if ((name ==
"Rotation") &&
isLeftHanded(x, y, z, nmspace) == 1)
56 msg +=
" left-handed rotation with a Rotation element. If";
57 msg +=
" you meant to make a reflection, use ReflectionRotation";
58 msg +=
" elements, otherwise, please check your matrix. Other";
59 msg +=
" errors may follow. Rotation matrix not created.";
60 edm::LogError(
"DetectorDescription_Parser_Rotation_and_Reflection") << msg << std::endl;
62 else if (name ==
"ReflectionRotation" &&
isLeftHanded(x, y, z, nmspace) == 1)
67 , ev.
eval(nmspace, atts.find(
"thetaX")->second)
68 , ev.
eval(nmspace, atts.find(
"phiX")->second)
69 , ev.
eval(nmspace, atts.find(
"thetaY")->second)
70 , ev.
eval(nmspace, atts.find(
"phiY")->second)
71 , ev.
eval(nmspace, atts.find(
"thetaZ")->second)
72 , ev.
eval(nmspace, atts.find(
"phiZ")->second));
73 DCOUT_V (
'p',
"Rotation created: " << ddrot << std::endl);
75 else if (name ==
"ReflectionRotation" &&
isLeftHanded(x, y, z, nmspace) == 0)
78 msg +=
" rotation using a ReflectionRotation element. ";
79 msg +=
" If you meant to make a Rotation, use Rotation";
80 msg +=
" elements, otherwise, please check your matrix.";
81 msg +=
" Other errors may follow. ReflectionRotation";
82 msg +=
" matrix not created.";
83 edm::LogError(
"DetectorDescription_Parser_Rotation_and_Reflection") << msg << std::endl;
87 std::string msg =
"\nDDLRotationAndReflection::processElement tried to process wrong element.";
93 DCOUT_V(
'P',
"DDLRotationAndReflection::processElement completed");
112 DCOUT_V(
'P',
"DDLRotation::isLeftHanded started");
160 double check = (x.Cross(y)).Dot(z);
166 std::cout <<
"DDLRotationAndReflection Coordinate axes forming rotation matrix "
168 <<
" are not orthonormal.(tolerance=" << tol
169 <<
" check=" <<
std::abs(check) <<
")"
171 <<
" thetaX=" << (atts.find(
"thetaX")->second)
172 <<
' ' << ev.
eval(nmspace, atts.find(
"thetaX")->second)/deg << std::endl
173 <<
" phiX=" << (atts.find(
"phiX")->second)
174 <<
' ' << ev.
eval(nmspace, atts.find(
"phiX")->second)/deg << std::endl
175 <<
" thetaY=" << (atts.find(
"thetaY")->second)
176 <<
' ' << ev.
eval(nmspace, atts.find(
"thetaY")->second)/deg << std::endl
177 <<
" phiY=" << (atts.find(
"phiY")->second)
178 <<
' ' << ev.
eval(nmspace, atts.find(
"phiY")->second)/deg << std::endl
179 <<
" thetaZ=" << (atts.find(
"thetaZ")->second)
180 <<
' ' << ev.
eval(nmspace, atts.find(
"thetaZ")->second)/deg << std::endl
181 <<
" phiZ=" << (atts.find(
"phiZ")->second)
182 <<
' ' << ev.
eval(nmspace, atts.find(
"phiZ")->second)/deg
184 <<
" WAS NOT CREATED!" << std::endl;
187 else if (1.0+check<=tol) {
190 DCOUT_V(
'P',
"DDLRotation::isLeftHanded completed");
199 if (atts.find(
"thetaX") != atts.end())
202 double thetaX = ev.
eval(nmspace, atts.find(
"thetaX")->second.c_str());
203 double phiX = ev.
eval(nmspace, atts.find(
"phiX")->second.c_str());
205 x.SetX(
sin(thetaX) *
cos(phiX));
206 x.SetY(
sin(thetaX) *
sin(phiX));
217 if (atts.find(
"thetaY") != atts.end())
220 double thetaY = ev.
eval(nmspace, atts.find(
"thetaY")->second.c_str());
221 double phiY = ev.
eval(nmspace, atts.find(
"phiY")->second.c_str());
224 y.SetX(
sin(thetaY) *
cos(phiY));
225 y.SetY(
sin(thetaY) *
sin(phiY));
235 if (atts.find(
"thetaZ") != atts.end())
238 double thetaZ = ev.
eval(nmspace, atts.find(
"thetaZ")->second.c_str());
239 double phiZ = ev.
eval(nmspace, atts.find(
"phiZ")->second.c_str());
242 z.SetX(
sin(thetaZ) *
cos(phiZ));
243 z.SetY(
sin(thetaZ) *
sin(phiZ));
tuple ret
prodAgent to be discontinued
void processElement(const std::string &name, const std::string &nmspace, DDCompactView &cpv)
Processing the element.
DDLElementRegistry * myRegistry_
DD3Vector makeZ(std::string nmspace)
DD3Vector makeX(std::string nmspace)
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)
#define DCOUT_V(M_v_Y, M_v_S)
DDLRotationAndReflection(DDLElementRegistry *myreg)
Constructor.
This is a base class for processing XML elements in the DDD.
~DDLRotationAndReflection(void)
Destructor.
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.