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/DDLSpecPar.h"
00015
00016 #include "DetectorDescription/Core/interface/DDName.h"
00017 #include "DetectorDescription/Core/interface/DDSpecifics.h"
00018 #include "DetectorDescription/Base/interface/DDdebug.h"
00019 #include "DetectorDescription/Core/interface/DDValue.h"
00020 #include "DetectorDescription/Core/interface/DDValuePair.h"
00021
00022 #include "DetectorDescription/ExprAlgo/interface/ExprEvalSingleton.h"
00023
00024 #include <sstream>
00025
00026 DDLSpecPar::DDLSpecPar( DDLElementRegistry* myreg )
00027 : DDXMLElement( myreg )
00028 {}
00029
00030 DDLSpecPar::~DDLSpecPar( void )
00031 {}
00032
00033
00034
00035 void
00036 DDLSpecPar::processElement( const std::string& name, const std::string& nmspace, DDCompactView& cpv )
00037 {
00038 DCOUT_V('P',"DDLSpecPar::processElement started");
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048 DDXMLElement* myParameter = myRegistry_->getElement("Parameter");
00049 DDXMLElement* myNumeric = myRegistry_->getElement("Numeric");
00050 DDXMLElement* myString = myRegistry_->getElement("String");
00051 DDXMLElement* myPartSelector = myRegistry_->getElement("PartSelector");
00052 DDXMLElement* mySpecParSection = myRegistry_->getElement("SpecParSection");
00053
00054
00055
00056
00057
00058
00059 std::string ns(nmspace);
00060 DDXMLAttribute spatts = getAttributeSet();
00061 std::string rn = spatts.find("name")->second;
00062 if ( ns == "!" ) {
00063 size_t foundColon= rn.find(':');
00064 if (foundColon != std::string::npos) {
00065 ns = rn.substr(0,foundColon);
00066
00067 }
00068 }
00069
00070
00071
00072 std::vector <std::string> partsels;
00073 size_t i;
00074
00075
00076
00077
00078
00079
00080
00081
00082
00083
00084
00085
00086
00087
00088
00089
00090
00091
00092
00093
00094
00095
00096
00097 for (i = 0; i < myPartSelector->size(); ++i)
00098 partsels.push_back((myPartSelector->getAttributeSet(i).find("path"))->second);
00099 DDsvalues_type svt;
00100
00101
00102
00103 typedef std::map<std::string, std::pair<bool,std::vector<DDValuePair> > > vvvpType;
00104
00105 vvvpType vvvp;
00106
00112 bool doNotEval = true;
00113 bool doRegex = true;
00114 {
00115
00116 const DDXMLAttribute & atts = mySpecParSection->getAttributeSet();
00117
00118 if (atts.find("eval") != atts.end() && atts.find("eval")->second == "true")
00119 doNotEval = false;
00120
00121 if (atts.find("regex") != atts.end() && atts.find("regex")->second == "false")
00122 doRegex = false;
00123 }
00124 {
00125
00126 const DDXMLAttribute & atts = getAttributeSet();
00127
00128 if (atts.find("eval") != atts.end() && atts.find("eval")->second == "true")
00129 doNotEval = false;
00130 else if (atts.find("eval") != atts.end())
00131 doNotEval = true;
00132
00133 if (atts.find("regex") != atts.end() && atts.find("regex")->second == "false")
00134 doRegex = false;
00135 else if (atts.find("regex") != atts.end())
00136 doRegex = true;
00137 }
00138 for (i = 0; i < myParameter->size(); ++i)
00139 {
00140 const DDXMLAttribute & atts = myParameter->getAttributeSet(i);
00141 std::vector <DDValuePair> vvp;
00142 vvvpType::iterator itv = vvvp.find((atts.find("name")->second));
00143 if (itv != vvvp.end())
00144 vvp = itv->second.second;
00145 double tval = 0.0;
00146 bool isEvaluated = false;
00147
00155
00156
00157
00158
00159
00160 std::string ts = "** no eval attribute **";
00161 if (atts.find("eval") != atts.end())
00162 ts = atts.find("eval")->second;
00163 DCOUT_V('P', std::string("about to process ") << atts.find("value")->second << std::string(" eval = ") << ts);
00164 if ((atts.find("eval") != atts.end() && atts.find("eval")->second !="false")
00165 || (atts.find("eval") == atts.end() && !doNotEval))
00166 {
00167 tval = ExprEvalSingleton::instance().eval(ns, atts.find("value")->second);
00168 isEvaluated=true;
00169 DCOUT_V('P', std::string("EVALUATED"));
00170 }
00171 else
00172 {
00173 DCOUT_V('P', std::string("NOT Evaluated"));
00174 }
00175
00176 DDValuePair vp(atts.find("value")->second, tval);
00177 vvp.push_back(vp);
00178 vvvp[atts.find("name")->second] = make_pair(isEvaluated,vvp);
00179 }
00180
00181
00182 for (i = 0; i < myString->size(); ++i)
00183 {
00184 const DDXMLAttribute & atts = myString->getAttributeSet(i);
00185 std::vector <DDValuePair> vvp;
00186 vvvpType::iterator itv = vvvp.find(atts.find("name")->second);
00187 if (itv != vvvp.end())
00188 vvp = itv->second.second;
00189 DCOUT_V('P', std::string("about to process String ") << (atts.find("name")->second) << " = " << (atts.find("value")->second));
00190 DDValuePair vp(atts.find("value")->second, 0.0);
00191 vvp.push_back(vp);
00192 vvvp[atts.find("name")->second] = make_pair(false,vvp);
00193 }
00194
00195
00196 for (i = 0; i < myNumeric->size(); ++i)
00197 {
00198 const DDXMLAttribute & atts = myNumeric->getAttributeSet(i);
00199 std::vector <DDValuePair> vvp;
00200 vvvpType::iterator itv = vvvp.find(atts.find("name")->second);
00201 if (itv != vvvp.end())
00202 vvp = itv->second.second;
00203 DCOUT_V('P', std::string("about to process String ") << (atts.find("name")->second) << " = " << (atts.find("value")->second));
00204 double tval = ExprEvalSingleton::instance().eval(ns, atts.find("value")->second);
00205 DCOUT_V('P', std::string("EVALUATED"));
00206 DDValuePair vp(atts.find("value")->second, tval);
00207 vvp.push_back(vp);
00208 vvvp[atts.find("name")->second] = make_pair(true,vvp);
00209 }
00210
00211 svt.reserve(vvvp.size());
00212 for (vvvpType::const_iterator it = vvvp.begin(); it != vvvp.end(); ++it)
00213 {
00214 DDValue val(it->first, it->second.second);
00215 bool isEvaluated = it->second.first;
00216 val.setEvalState(isEvaluated);
00217 svt.push_back(DDsvalues_Content_type(val,val));
00218 }
00219 std::sort(svt.begin(),svt.end());
00220
00221
00222 DCOUT_V('p', "DDLSpecPar::processElement\n\tname " << getDDName(nmspace) << "\n\tpartsels.size() = " << myPartSelector->size() << "\n\tsvt " << svt);
00223
00224 DDSpecifics ds(getDDName(nmspace),
00225 partsels,
00226 svt,
00227 doRegex);
00228
00229 myParameter->clear();
00230 myPartSelector->clear();
00231
00232
00233 clear();
00234
00235 DCOUT_V('P',"DDLSpecPar::processElement(...)");
00236 }
00237