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