00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019 #include "DDLCompositeMaterial.h"
00020 #include "DDLElementRegistry.h"
00021 #include "DDXMLElement.h"
00022
00023
00024 #include "DetectorDescription/Core/interface/DDLogicalPart.h"
00025 #include "DetectorDescription/Core/interface/DDName.h"
00026 #include "DetectorDescription/Base/interface/DDdebug.h"
00027 #include "DetectorDescription/Core/interface/DDMaterial.h"
00028 #include "DetectorDescription/Base/interface/DDException.h"
00029
00030 #include "DetectorDescription/ExprAlgo/interface/ExprEvalSingleton.h"
00031
00032
00033 #include <string>
00034
00035
00036 DDLCompositeMaterial::DDLCompositeMaterial()
00037 {
00038 }
00039
00040
00041 DDLCompositeMaterial::~DDLCompositeMaterial()
00042 {
00043 }
00044
00045
00046
00047 void DDLCompositeMaterial::preProcessElement (const std::string& type, const std::string& nmspace)
00048 {
00049
00050
00051 DDLElementRegistry::getElement("rMaterial")->clear();
00052 }
00053
00054 void DDLCompositeMaterial::processElement (const std::string& type, const std::string& nmspace)
00055 {
00056 DCOUT_V('P', "DDLCompositeMaterial::processElement started");
00057
00058
00059 ExprEvalInterface & ev = ExprEvalSingleton::instance();
00060 DDXMLAttribute atts = getAttributeSet();
00061
00062 DDName ddn = getDDName(nmspace);
00063 DDMaterial mat;
00064
00065 mat = DDMaterial(ddn, ev.eval(nmspace, atts.find("density")->second));
00066
00067
00068 DDXMLElement* myMF = DDLElementRegistry::getElement("MaterialFraction");
00069 DDXMLElement* myrMaterial = DDLElementRegistry::getElement("rMaterial");
00070
00071
00072
00073
00074
00075
00076
00077
00078
00079
00080
00081
00082
00083
00084 if (myMF->size() != myrMaterial->size())
00085 {
00086 std::string msg = "/nDDLCompositeMaterial::processElement found that the ";
00087 msg += "number of MaterialFractions does not match the number ";
00088 msg += "of rMaterial names for ";
00089 msg += ddn.ns() + ":" + ddn.name() + ".";
00090 throwError(msg);
00091 }
00092 for (size_t i = 0; i < myrMaterial->size(); ++i)
00093 {
00094 atts = myMF->getAttributeSet(i);
00095 mat.addMaterial(myrMaterial->getDDName(nmspace, "name", i)
00096 , ev.eval(nmspace, atts.find("fraction")->second));
00097 }
00098
00099
00100 DDLMaterial::setReference(nmspace);
00101 myMF->clear();
00102 clear();
00103
00104 DCOUT_V('P', "DDLCompositeMaterial::processElement completed " << mat);
00105 }