00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019 #include "DDLRotationByAxis.h"
00020 #include "DDLElementRegistry.h"
00021
00022
00023 #include "DetectorDescription/Core/interface/DDTransform.h"
00024 #include "DetectorDescription/Base/interface/DDdebug.h"
00025 #include "DetectorDescription/Base/interface/DDException.h"
00026 #include "DetectorDescription/Base/interface/DDTranslation.h"
00027 #include "DetectorDescription/ExprAlgo/interface/ExprEvalSingleton.h"
00028
00029
00030 #include <Math/RotationX.h>
00031 #include <Math/RotationY.h>
00032 #include <Math/RotationZ.h>
00033
00034 #include <string>
00035
00036
00037 DDLRotationByAxis::DDLRotationByAxis()
00038 {
00039 }
00040
00041
00042 DDLRotationByAxis::~DDLRotationByAxis()
00043 {
00044 }
00045
00046 void DDLRotationByAxis::preProcessElement (const std::string& name
00047 , const std::string& nmspace)
00048 {
00049 pNameSpace = nmspace;
00050 pName = name;
00051 }
00052
00053 void DDLRotationByAxis::processElement (const std::string& name
00054 , const std::string& nmspace)
00055 {
00056 DCOUT_V('P', "DDLRotationByAxis::processElement started " << name);
00057
00058
00059 DDXMLAttribute atts = getAttributeSet();
00060 if (parent() != "RotationSequence")
00061 {
00062 std::string axis = atts.find("axis")->second;
00063 std::string angle = atts.find("angle")->second;
00064
00065 DDRotationMatrix R;
00066 R = processOne(R, axis, angle);
00067
00068 DDRotationMatrix* ddr = new DDRotationMatrix(R);
00069 if (atts.find("name") == atts.end())
00070 {
00071
00072 DDXMLElement * myRealParent = DDLElementRegistry::instance()->getElement(parent());
00073 DDName pName = myRealParent->getDDName(nmspace);
00074 std::string tn = pName.name() + std::string("Rotation");
00075 std::vector<std::string> names;
00076 names.push_back("name");
00077
00078
00079
00080 std::vector<std::string> values;
00081 values.push_back(tn);
00082
00083
00084 clear();
00085 loadAttributes(name, names, values, nmspace);
00086 }
00087 DDRotation rot = DDrot(getDDName(nmspace), ddr);
00088
00089 clear();
00090 }
00091 else { }
00092
00093 DCOUT_V('P', "DDLRotationByAxis::processElement completed");
00094 }
00095
00096 DDRotationMatrix DDLRotationByAxis::processOne (DDRotationMatrix R, std::string& axis, std::string& angle)
00097 {
00101 ExprEvalInterface & ev = ExprEvalSingleton::instance();
00102 double dAngle = ev.eval(pNameSpace, angle);
00103
00104
00105 if ( axis == "x") {
00106 R = ROOT::Math::RotationX(dAngle);
00107 }
00108 else if ( axis == "y" ) {
00109 R = ROOT::Math::RotationY(dAngle);
00110 }
00111 else if ( axis =="z" ) {
00112 R = ROOT::Math::RotationZ(dAngle);
00113 }
00114 else {
00115 std::string msg = "\nDDLRotationByAxis invalid axis... you must not have validated XML sources! Element is ";
00116 msg += pName;
00117 throwError(msg);
00118 }
00119
00120 return R;
00121 }
00122
00123