#include <DetectorDescription/Parser/src/DDLCompositeMaterial.h>
Public Member Functions | |
DDLCompositeMaterial () | |
Constructor. | |
void | preProcessElement (const std::string &name, const std::string &nmspace) |
Called by loadAttributes AFTER attributes are loaded. | |
void | processElement (const std::string &name, const std::string &nmspace) |
Processing the element. | |
~DDLCompositeMaterial () | |
Destructor. |
DDLCompositeMaterial.h - description ------------------- begin: Wed Oct 31 2001 email: case@ucdhep.ucdavis.edu
This is the processor for CompositeMaterial DDL elements.
The CompositeMaterial is an element that contains other elements. In particular, it contains rMaterial elements which are references either to other Composite or Elementary materials.
Definition at line 28 of file DDLCompositeMaterial.h.
DDLCompositeMaterial::DDLCompositeMaterial | ( | ) |
DDLCompositeMaterial::~DDLCompositeMaterial | ( | ) |
void DDLCompositeMaterial::preProcessElement | ( | const std::string & | name, | |
const std::string & | nmspace | |||
) | [virtual] |
Called by loadAttributes AFTER attributes are loaded.
The preProcessElement method can assume that the attributes are loaded and perform any code that is necessary at the start of an element.
This would allow users to call their own code to setup anything necessary for the continued processing of the child elements.
Reimplemented from DDXMLElement.
Definition at line 47 of file DDLCompositeMaterial.cc.
References DDXMLElement::clear(), and DDLElementRegistry::getElement().
00048 { 00049 // fyi: no need to clear MaterialFraction because it is cleared at the end of each 00050 // CompositeMaterial 00051 DDLElementRegistry::getElement("rMaterial")->clear(); 00052 }
void DDLCompositeMaterial::processElement | ( | const std::string & | name, | |
const std::string & | nmspace | |||
) | [virtual] |
Processing the element.
The processElement method completes any necessary work to process the XML element.
For example, this can be used to call the DDCore to make the geometry in memory. There is a default for this so that if not declared in the inheriting class, no processing is done.
Reimplemented from DDXMLElement.
Definition at line 54 of file DDLCompositeMaterial.cc.
References DDMaterial::addMaterial(), DDXMLElement::clear(), DCOUT_V, ExprEvalInterface::eval(), DDXMLElement::getAttributeSet(), DDXMLElement::getDDName(), DDLElementRegistry::getElement(), i, DDI::Singleton< I >::instance(), alivecheck_mergeAndRegister::msg, DDName::name(), DDName::ns(), DDLMaterial::setReference(), DDXMLElement::size(), and DDXMLElement::throwError().
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 // Get references to relevant DDL elements that are needed. 00068 DDXMLElement* myMF = DDLElementRegistry::getElement("MaterialFraction"); 00069 DDXMLElement* myrMaterial = DDLElementRegistry::getElement("rMaterial"); 00070 00071 // Get the names from those elements and also the namespace for the reference element. 00072 // The parent element CompositeMaterial MUST be in the same namespace as this fraction. 00073 // additionally, because it is NOT a reference, we do not try to dis-entangle the namespace. 00074 // That is, we do not use the getName() which searches the name for a colon, but instead use 00075 // the "raw" name attribute. 00076 00077 // TO DO: sfractions assumes that the values are "mixture by weight" (I think) 00078 // we need to retrieve the fraction attributes and then check the method 00079 // attribute of the CompositeMaterial to determine if the numbers go straight 00080 // in to the DDCore or if the numbers need to be manipulated so that the 00081 // sfractions are really mixtures by weight going into the DDCore. Otherwise, 00082 // the DDCore has to know which are which and right now it does not. 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 // clears and sets new reference to THIS material. 00100 DDLMaterial::setReference(nmspace); 00101 myMF->clear(); 00102 clear(); 00103 // print it. 00104 DCOUT_V('P', "DDLCompositeMaterial::processElement completed " << mat); 00105 }