CMS 3D CMS Logo

Public Member Functions

DDLCompositeMaterial Class Reference

DDLCompositeMaterial processes all CompositeMaterial elements. More...

#include <DDLCompositeMaterial.h>

Inheritance diagram for DDLCompositeMaterial:
DDLMaterial DDXMLElement

List of all members.

Public Member Functions

 DDLCompositeMaterial (DDLElementRegistry *myreg)
 Constructor.
void preProcessElement (const std::string &name, const std::string &nmspace, DDCompactView &cpv)
 Called by loadAttributes AFTER attributes are loaded.
void processElement (const std::string &name, const std::string &nmspace, DDCompactView &cpv)
 Processing the element.
 ~DDLCompositeMaterial ()
 Destructor.

Detailed Description

DDLCompositeMaterial processes all CompositeMaterial elements.

Author:
Michael Case

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.


Constructor & Destructor Documentation

DDLCompositeMaterial::DDLCompositeMaterial ( DDLElementRegistry myreg)

Constructor.

Definition at line 23 of file DDLCompositeMaterial.cc.

  : DDLMaterial( myreg )
{}
DDLCompositeMaterial::~DDLCompositeMaterial ( void  )

Destructor.

Definition at line 27 of file DDLCompositeMaterial.cc.

{}

Member Function Documentation

void DDLCompositeMaterial::preProcessElement ( const std::string &  name,
const std::string &  nmspace,
DDCompactView cpv 
) [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 33 of file DDLCompositeMaterial.cc.

References DDXMLElement::clear(), DDLElementRegistry::getElement(), and DDXMLElement::myRegistry_.

{
  // fyi: no need to clear MaterialFraction because it is cleared at the end of each
  // CompositeMaterial
  myRegistry_->getElement( "rMaterial" )->clear();
}
void DDLCompositeMaterial::processElement ( const std::string &  name,
const std::string &  nmspace,
DDCompactView cpv 
) [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 41 of file DDLCompositeMaterial.cc.

References DDMaterial::addMaterial(), DDXMLElement::clear(), DCOUT_V, ExprEvalInterface::eval(), DDXMLElement::getAttributeSet(), DDXMLElement::getDDName(), DDLElementRegistry::getElement(), i, instance, lumiQueryAPI::msg, DDXMLElement::myRegistry_, DDName::name(), DDName::ns(), DDLMaterial::setReference(), DDXMLElement::size(), and DDXMLElement::throwError().

{
  DCOUT_V('P', "DDLCompositeMaterial::processElement started");

  ExprEvalInterface & ev = ExprEvalSingleton::instance();
  DDXMLAttribute atts = getAttributeSet();

  DDName ddn = getDDName( nmspace );
  DDMaterial mat;

  mat = DDMaterial( ddn, ev.eval( nmspace, atts.find( "density" )->second ));
  
  // Get references to relevant DDL elements that are needed.
  DDXMLElement* myMF = myRegistry_->getElement( "MaterialFraction" );
  DDXMLElement* myrMaterial = myRegistry_->getElement( "rMaterial" );

  // Get the names from those elements and also the namespace for the reference element.
  // The parent element CompositeMaterial MUST be in the same namespace as this fraction.
  // additionally, because it is NOT a reference, we do not try to dis-entangle the namespace.
  // That is, we do not use the getName() which searches the name for a colon, but instead use
  // the "raw" name attribute.

  // TO DO:  sfractions assumes that the values are "mixture by weight" (I think)
  // we need to retrieve the fraction attributes and then check the method
  // attribute of the CompositeMaterial to determine if the numbers go straight
  // in to the DDCore or if the numbers need to be manipulated so that the 
  // sfractions are really mixtures by weight going into the DDCore.  Otherwise,
  // the DDCore has to know which are which and right now it does not.

  if( myMF->size() != myrMaterial->size())
  {
    std::string msg = "/nDDLCompositeMaterial::processElement found that the ";
    msg += "number of MaterialFractions does not match the number ";
    msg += "of rMaterial names for ";
    msg += ddn.ns() + ":" + ddn.name() + ".";
    throwError( msg );
  }
  for( size_t i = 0; i < myrMaterial->size(); ++i )
  {
    atts = myMF->getAttributeSet( i );
    mat.addMaterial( myrMaterial->getDDName( nmspace, "name", i ),
                     ev.eval( nmspace, atts.find( "fraction" )->second ));
  }
  // clears and sets new reference to THIS material.
  DDLMaterial::setReference( nmspace, cpv );
  myMF->clear();
  clear();
  // print it.
  DCOUT_V('P', "DDLCompositeMaterial::processElement completed " << mat);
}