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