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/DDLCompositeMaterial.h"
00015 #include "DetectorDescription/Parser/src/DDXMLElement.h"
00016
00017 #include "DetectorDescription/Core/interface/DDName.h"
00018 #include "DetectorDescription/Base/interface/DDdebug.h"
00019 #include "DetectorDescription/Core/interface/DDMaterial.h"
00020
00021 #include "DetectorDescription/ExprAlgo/interface/ExprEvalSingleton.h"
00022
00023 DDLCompositeMaterial::DDLCompositeMaterial( DDLElementRegistry* myreg )
00024 : DDLMaterial( myreg )
00025 {}
00026
00027 DDLCompositeMaterial::~DDLCompositeMaterial( void )
00028 {}
00029
00030
00031
00032 void
00033 DDLCompositeMaterial::preProcessElement( const std::string& name, const std::string& nmspace, DDCompactView& cpv )
00034 {
00035
00036
00037 myRegistry_->getElement( "rMaterial" )->clear();
00038 }
00039
00040 void
00041 DDLCompositeMaterial::processElement( const std::string& name, const std::string& nmspace, DDCompactView& cpv )
00042 {
00043 DCOUT_V('P', "DDLCompositeMaterial::processElement started");
00044
00045 ExprEvalInterface & ev = ExprEvalSingleton::instance();
00046 DDXMLAttribute atts = getAttributeSet();
00047
00048 DDName ddn = getDDName( nmspace );
00049 DDMaterial mat;
00050
00051 mat = DDMaterial( ddn, ev.eval( nmspace, atts.find( "density" )->second ));
00052
00053
00054 DDXMLElement* myMF = myRegistry_->getElement( "MaterialFraction" );
00055 DDXMLElement* myrMaterial = myRegistry_->getElement( "rMaterial" );
00056
00057
00058
00059
00060
00061
00062
00063
00064
00065
00066
00067
00068
00069
00070 if( myMF->size() != myrMaterial->size())
00071 {
00072 std::string msg = "/nDDLCompositeMaterial::processElement found that the ";
00073 msg += "number of MaterialFractions does not match the number ";
00074 msg += "of rMaterial names for ";
00075 msg += ddn.ns() + ":" + ddn.name() + ".";
00076 throwError( msg );
00077 }
00078 for( size_t i = 0; i < myrMaterial->size(); ++i )
00079 {
00080 atts = myMF->getAttributeSet( i );
00081 mat.addMaterial( myrMaterial->getDDName( nmspace, "name", i ),
00082 ev.eval( nmspace, atts.find( "fraction" )->second ));
00083 }
00084
00085 DDLMaterial::setReference( nmspace, cpv );
00086 myMF->clear();
00087 clear();
00088
00089 DCOUT_V('P', "DDLCompositeMaterial::processElement completed " << mat);
00090 }