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