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