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/DDLPosPart.h"
00015
00016 #include "DetectorDescription/Core/interface/DDLogicalPart.h"
00017 #include "DetectorDescription/Core/interface/DDName.h"
00018 #include "DetectorDescription/Base/interface/DDdebug.h"
00019
00020 #include "DetectorDescription/ExprAlgo/interface/ExprEvalSingleton.h"
00021
00022 DDLPosPart::DDLPosPart( DDLElementRegistry* myreg )
00023 : DDXMLElement( myreg )
00024 {}
00025
00026 DDLPosPart::~DDLPosPart( void )
00027 {}
00028
00029
00030
00031
00032
00033
00034 void
00035 DDLPosPart::preProcessElement( const std::string& name, const std::string& nmspace, DDCompactView& cpv )
00036 {
00037 DCOUT_V('P', "DDLPosPart::preProcessElement started");
00038
00039
00040 myRegistry_->getElement("Rotation")->clear();
00041 myRegistry_->getElement("ReflectionRotation")->clear();
00042
00043 DCOUT_V('P', "DDLPosPart::preProcessElement completed");
00044 }
00045
00046
00047
00048
00049 void
00050 DDLPosPart::processElement( const std::string& name, const std::string& nmspace, DDCompactView& cpv )
00051 {
00052 DCOUT_V('P', "DDLPosPart::processElement started");
00053
00054
00055 DDXMLElement* myParent = myRegistry_->getElement("rParent");
00056 DDXMLElement* myChild = myRegistry_->getElement("rChild");
00057 DDXMLElement* myTranslation= myRegistry_->getElement("Translation");
00058 DDXMLElement* myDDLRotation= myRegistry_->getElement("Rotation");
00059 DDXMLElement* myrRotation = myRegistry_->getElement("rRotation");
00060 DDXMLElement* myDDLRefl = myRegistry_->getElement("ReflectionRotation");
00061 DDXMLElement* myrRefl = myRegistry_->getElement("rReflectionRotation");
00062
00063
00064
00065
00066
00067
00068
00069
00070
00071
00072
00073
00074
00075 DDName rotn;
00076 if (myrRotation->size() > 0){
00077 rotn = myrRotation->getDDName(nmspace);
00078 }
00079 else if (myDDLRotation->size() > 0) {
00080
00081
00082
00083
00084 rotn = myDDLRotation->getDDName(nmspace);
00085 }
00086 else if (myDDLRefl->size() > 0) {
00087
00088
00089
00090 rotn = myDDLRefl->getDDName(nmspace);
00091 }
00092 else if (myrRefl->size() > 0) {
00093 rotn = myrRefl->getDDName(nmspace);
00094 }
00095
00096 DCOUT_V('P', "DDLPosPart::processElement: Final Rotation info: " << rotn);
00097
00098 ExprEvalInterface & ev = ExprEvalSingleton::instance();
00099
00100 double x = 0.0, y = 0.0, z = 0.0;
00101 if (myTranslation->size() > 0)
00102 {
00103 const DDXMLAttribute & atts = myTranslation->getAttributeSet();
00104 x = ev.eval(nmspace, atts.find("x")->second);
00105 y = ev.eval(nmspace, atts.find("y")->second);
00106 z = ev.eval(nmspace, atts.find("z")->second);
00107 }
00108
00109 DCOUT_V('P', "DDLPosPart::processElement: Final Translation info x=" << x << " y=" << y << " z=" << z);
00110
00111 DDRotation* myDDRotation;
00112
00113 if ( rotn.name() != "" && rotn.ns() != "" ) {
00114 DDRotation temp(rotn);
00115 myDDRotation = &temp;
00116 } else {
00117
00118 DDRotation temp(DDName(std::string("identity"),std::string("generatedForDDD")));
00119 myDDRotation = &temp;
00120
00121 if ( !myDDRotation->isValid() ) {
00122 DDRotationMatrix* dmr = new DDRotationMatrix;
00123 temp = DDrot(DDName(std::string("identity"),std::string("generatedForDDD")), dmr );
00124 myDDRotation = &temp;
00125 }
00126 }
00127
00128
00129 DDTranslation myDDTranslation(x, y, z);
00130
00131 DCOUT_V('P', "about to make a PosPart ...");
00132 DCOUT_V('p', " myDDRotation : " << *myDDRotation);
00133 DCOUT_V('p', " myDDTranslation : " << myDDTranslation);
00134 DCOUT_V('p', " parentDDName : " << myParent->getDDName(nmspace));
00135 DCOUT_V('p', " selfDDName : " << myChild->getDDName(nmspace));
00136
00137 const DDXMLAttribute & atts = getAttributeSet();
00138 std::string copyno = "";
00139 if (atts.find("copyNumber") != atts.end())
00140 copyno = atts.find("copyNumber")->second;
00141
00142 cpv.position(DDLogicalPart(myChild->getDDName(nmspace))
00143 , DDLogicalPart(myParent->getDDName(nmspace))
00144 , copyno
00145 , myDDTranslation
00146 , *myDDRotation);
00147
00148
00149 myParent->clear();
00150 myChild->clear();
00151 myTranslation->clear();
00152 myDDLRotation->clear();
00153 myrRotation->clear();
00154 myDDLRefl->clear();
00155 myrRefl->clear();
00156
00157
00158 clear();
00159
00160 DCOUT_V('P', "DDLPosPart::processElement completed");
00161 }