00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017 #include "DDLAlgoPosPart.h"
00018 #include "DDLElementRegistry.h"
00019 #include "DDXMLElement.h"
00020
00021
00022 #include "DetectorDescription/Core/interface/DDalgoPosPart.h"
00023 #include "DetectorDescription/Core/interface/DDName.h"
00024 #include "DetectorDescription/Core/interface/DDLogicalPart.h"
00025 #include "DetectorDescription/Core/interface/DDAlgo.h"
00026 #include "DetectorDescription/Base/interface/DDAlgoPar.h"
00027 #include "DetectorDescription/Base/interface/DDdebug.h"
00028 #include "DetectorDescription/Base/interface/DDException.h"
00029
00030 #include "DetectorDescription/ExprAlgo/interface/ExprEvalSingleton.h"
00031
00032 #include <string>
00033 #include <iostream>
00034
00035
00036 DDLAlgoPosPart::DDLAlgoPosPart()
00037 {
00038 }
00039
00040
00041 DDLAlgoPosPart::~DDLAlgoPosPart()
00042 {
00043 }
00044
00045
00046
00047 void DDLAlgoPosPart::processElement (const std::string& type, const std::string& nmspace)
00048 {
00049 DCOUT_V('P', "DDLAlgoPosPart::processElement started");
00050
00051
00052 DDXMLElement* myParent = DDLElementRegistry::getElement("rParent");
00053 DDXMLElement* myChild = DDLElementRegistry::getElement("rChild");
00054 DDXMLElement* myParS = DDLElementRegistry::getElement("ParS");
00055 DDXMLElement* myParE = DDLElementRegistry::getElement("ParE");
00056
00057 ExprEvalInterface & ev = ExprEvalSingleton::instance();
00058
00059 DDXMLAttribute atts = getAttributeSet();
00060
00061
00062 int st = static_cast<int> ((atts.find("start") == atts.end() ? 0.0 : ev.eval(nmspace, atts.find("start")->second)));
00063 int ic = static_cast<int> ((atts.find("incr") == atts.end() ? 0.0 : ev.eval(nmspace, atts.find("incr")->second)));
00064 int ed = static_cast<int> ((atts.find("end") == atts.end() ? 0.0 : ev.eval(nmspace, atts.find("end")->second)));
00065
00066
00067 DDLogicalPart parent(DDName(myParent->getDDName(nmspace)));
00068 DDLogicalPart self(DDName(myChild->getDDName(nmspace)));
00069
00070
00071 DDAlgo algo( getDDName(nmspace, "algo" ));
00072 if (!(algo.isDefined().second))
00073 {
00074 std::string msg = std::string("\n\tDDLParser, algo requested is not defined. Either AlgoInit() or check algo spelling.\n ")
00075 + "\n\t\talgo=" + std::string(getDDName(nmspace, "algo" ))
00076 + "\n\t\tparent=" + std::string(myParent->getDDName(nmspace))
00077 + "\n\t\tself=" + std::string(myChild->getDDName(nmspace));
00078 throwError(msg);
00079 }
00080
00081
00082
00083
00084 parE_type parE;
00085 for (size_t i = 0; i < myParE->size(); ++i)
00086 {
00087 atts = myParE->getAttributeSet(i);
00088
00089 parE_type::iterator existingName=parE.find(atts.find("name")->second);
00090
00091
00092
00093 if (existingName != parE.end())
00094 existingName->second.push_back(ev.eval(nmspace,atts.find("value")->second));
00095
00096 else
00097 {
00098 std::vector<double> tvect;
00099 tvect.push_back(ev.eval(nmspace,atts.find("value")->second));
00100 parE[atts.find("name")->second] = tvect;
00101 }
00102 }
00103
00104
00105 parS_type parS;
00106
00107 for (size_t i = 0; i < myParS->size(); ++i)
00108 {
00109 atts = myParS->getAttributeSet(i);
00110
00111
00112 parS_type::iterator existingName=parS.find(atts.find("name")->second);
00113
00114
00115
00116
00117 if (existingName != parS.end())
00118 existingName->second.push_back(atts.find("value")->second);
00119 else
00120 {
00121 std::vector<std::string> tvect;
00122 tvect.push_back(atts.find("value")->second);
00123 parS[atts.find("name")->second] = tvect;
00124 }
00125 }
00126
00127 algo.setParameters(st,ed,ic,parS,parE);
00128 DDalgoPosPart(self, parent, algo);
00129
00130
00131 myChild->clear();
00132 myParent->clear();
00133 myParS->clear();
00134 myParE->clear();
00135
00136 clear();
00137
00138 DCOUT_V('P', "DDLAlgoPosPart::processElement completed");
00139 }
00140