#include <vector>
#include "DetectorDescription/Core/interface/DDMaterial.h"
Go to the source code of this file.
Functions | |
bool | DDCheckMaterial (DDMaterial &mip, std::pair< std::string, DDName > &result) |
bool | DDCheckMaterials (std::ostream &os, std::vector< std::pair< std::string, DDName > > *res) |
Checks all registered materials and sends a report /p os. |
bool DDCheckMaterial | ( | DDMaterial & | mip, | |
std::pair< std::string, DDName > & | result | |||
) |
Definition at line 8 of file DDCheckMaterials.cc.
References DDMaterial::a(), DDBase< N, C >::ddname(), DDMaterial::density(), err, DDBase< N, C >::isDefined(), python::cmstools::loop(), mp, DDName::name(), DDBase< N, C >::name(), DDMaterial::noOfConstituents(), DDName::ns(), res, and DDMaterial::z().
Referenced by DDCheckMaterials().
00009 { 00010 std::string no_composites = " NO-COMPOSITES "; 00011 std::string no_density = " NO-DENSITY "; 00012 std::string costit_nok = " CONSTITUENT NOK "; 00013 std::string no_z = " NO-Z "; 00014 std::string no_a = " NO-A "; 00015 static int rlevel = 0; 00016 00017 std::string curr_err = ""; 00018 bool err = false; 00019 00020 if (mip.isDefined().first == 0) { 00021 err=true; 00022 curr_err += "material not declared; unknown material!"; 00023 //edm::LogError("DDCheckMaterials") << "material not declared!" << std::endl; //exit(1); 00024 result.first = curr_err; 00025 return err; 00026 } 00027 00028 if (mip.isDefined().second == 0) { 00029 err=true; 00030 curr_err += "material name=" + mip.name().ns() + ":" + mip.name().name() 00031 + " is declared but not defined"; 00032 result.first = curr_err; 00033 return err; 00034 } 00035 /* 00036 else { 00037 edm::LogInfo << " material name=" << flush 00038 << *mip.isDefined().first << std::endl; 00039 } 00040 */ 00041 DDMaterial & mp = mip; 00042 result.second=mp.ddname(); 00043 00044 if (!mp.density()) { 00045 err=true; 00046 curr_err += no_density; 00047 } 00048 00049 if ( ( !mp.z() || !mp.a() ) && !mp.noOfConstituents() ) { 00050 err=true; 00051 curr_err += no_z; 00052 curr_err += "or"; 00053 curr_err += no_a; 00054 } 00055 00056 if ( ( !mp.z() && !mp.a() ) && !mp.noOfConstituents() ) { 00057 err=true; 00058 curr_err += no_composites; 00059 } 00060 00061 if ( !mp.z() && !mp.a() && !mp.density() && !mp.noOfConstituents() ){ 00062 err=true; 00063 curr_err = " NOT-DEFINED "; 00064 } 00065 00066 if (err) { 00067 result.first=curr_err; 00068 } 00069 00070 // recursive checking of constituents 00071 // the composite material is not ok if only one constituent is not ok 00072 int loop = mp.noOfConstituents() - 1; 00073 00074 for (; loop>=0; --loop) { 00075 std::pair<std::string,DDName> res("",""); 00076 DDMaterial mat(mp.ddname()); // bit slow but comfortable ... 00077 DDMaterial mimpl = mat.constituent(loop).first; 00078 ++rlevel; // recursion level 00079 bool c_err = DDCheckMaterial(mimpl,res); 00080 if (c_err) { 00081 err = err | c_err; 00082 curr_err = curr_err + std::string(" constituents have errors:\n") + std::string(4*rlevel,' ') 00083 //+ res.second.ns() + std::string(":") + res.second.name() 00084 + std::string(" ") + res.first; 00085 result.first=curr_err; 00086 } 00087 --rlevel; 00088 } 00089 00090 return err; 00091 }
Checks all registered materials and sends a report /p os.
Definition at line 95 of file DDCheckMaterials.cc.
References DDCheckMaterial(), lat::endl(), error, HLT_VtxMuL3::errors, i, j, res, HLT_VtxMuL3::result, and s.
Referenced by DDCheck(), and DDErrorDetection::ma().
00096 { 00097 bool result = false; 00098 std::vector<std::pair<std::string,DDName> > errors; 00099 00100 00101 //DDMaterialReg::instance_t& mr = DDMaterialReg::instance(); 00102 //DDMaterialReg::instance_t::iterator i = mr.begin(); 00103 typedef DDBase<DDName,DDI::Material*>::StoreT RegT; 00104 RegT::value_type& mr = RegT::instance(); 00105 RegT::value_type::iterator i = mr.begin(); 00106 //edm::LogError("DDCheckMaterials") << " material checking, registry access, exiting! " << std::endl; exit(1); 00107 for(; i != mr.end(); ++i) { 00108 std::pair<std::string,DDName> error("",""); 00109 DDMaterial tmat(i->first); 00110 //exit(1); 00111 if (DDCheckMaterial(tmat,error)) { 00112 errors.push_back(error); 00113 } 00114 } 00115 00116 std::string s(" "); 00117 os << "[DDCore:Report] Materials " << std::endl; 00118 os << s << mr.size() << " Materials declared" << std::endl; 00119 os << s << "detected errors:" << errors.size() << std::endl; 00120 std::vector<std::pair<std::string,DDName> >::iterator j = errors.begin(); 00121 for (;j!=errors.end();++j) { 00122 os << std::endl << s << j->second << " " << j->first << std::endl; 00123 result = true; 00124 } 00125 if(res) *res = errors; 00126 return result; 00127 }