00001 #include "DetectorDescription/Core/interface/DDCompactViewImpl.h"
00002 #include "DetectorDescription/Core/interface/DDCompactView.h"
00003 #include "DetectorDescription/Base/interface/DDdebug.h"
00004 #include "CLHEP/Units/SystemOfUnits.h"
00005
00006
00007 #include "FWCore/MessageLogger/interface/MessageLogger.h"
00008
00009 DDCompactViewImpl::DDCompactViewImpl(const DDLogicalPart & rootnodedata)
00010 : root_(rootnodedata)
00011 {
00012
00013
00014
00015 }
00016
00017
00018 DDCompactViewImpl::DDCompactViewImpl()
00019 : root_("")
00020 {
00021
00022 }
00023
00024
00025 DDCompactViewImpl::~DDCompactViewImpl()
00026 {
00027 GraphNav::adj_list::size_type it = 0;
00028 for (; it < graph_.size() ; ++it) {
00029 GraphNav::edge_range erange = graph_.edges(it);
00030 for(; erange.first != erange.second; ++(erange.first)) {
00031 DDPosData * pd = graph_.edgeData(erange.first->second);
00032 delete pd;
00033 pd=0;
00034 }
00035 }
00036 edm::LogInfo("DDCompactViewImpl") << std::endl << "DDD transient representation has been destructed." << std::endl << std::endl;
00037 }
00038
00039
00040
00041 void DDCompactViewImpl::buildPaths()
00042 {
00043
00044 }
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059 graphwalker<DDLogicalPart,DDPosData*> DDCompactViewImpl::walker() const
00060 {
00061 DCOUT('C',"DDCompactView::walker() root_=" << root_);
00062 return graphwalker<DDLogicalPart,DDPosData*>(graph_,root_);
00063 }
00064
00065
00066
00067 #include "DetectorDescription/Core/interface/DDSolid.h"
00068 #include "DetectorDescription/Core/interface/DDMaterial.h"
00069 double DDCompactViewImpl::weight(const DDLogicalPart & aPart) const
00070 {
00071
00072
00073 if (!aPart)
00074 return -1;
00075 DDLogicalPart part = aPart;
00076
00077 if (part.weight())
00078 return part.weight();
00079
00080
00081 double childrenVols=0;
00082 double childrenWeights=0;
00083 walker_type walker(graph_,part);
00084 if(walker.firstChild()) {
00085 bool doIt=true;
00086 while(doIt) {
00087 double a_vol;
00088 DDLogicalPart child(walker.current().first);
00089 a_vol=child.solid().volume();
00090 if (a_vol <= 0.) {
00091 edm::LogError("DDCompactViewImpl") << "DD-WARNING: volume of solid=" << aPart.solid()
00092 << "is zero or negative, vol=" << a_vol/m3 << "m3" << std::endl;
00093 }
00094 DCOUT_V('C', "DC: weightcalc, currently=" << child.ddname().name()
00095 << " vol=" << a_vol/cm3 << "cm3");
00096 childrenVols += a_vol;
00097 childrenWeights += weight(child);
00098 doIt=walker.nextSibling();
00099 }
00100 }
00101
00102 double dens = part.material().density();
00103 if (dens <=0) {
00104 edm::LogError("DDCompactViewImpl") << "DD-WARNING: density of material=" << part.material().ddname()
00105 << " is negative or zero, rho=" << dens/g*cm3 << "g/cm3" << std::endl;
00106 }
00107 double p_vol = part.solid().volume();
00108 double w = (p_vol - childrenVols)*dens + childrenWeights;
00109 if ( (fabs(p_vol) - fabs(childrenVols))/fabs(p_vol) > 1.01 ) {
00110 edm::LogError("DDCompactViewImpl") << "DD-WARNING: parent-volume smaller than children, parent="
00111 << part.ddname() << " difference-vol="
00112 << (p_vol - childrenVols)/m3 << "m3, this is "
00113 << (childrenVols - p_vol)/p_vol << "% of the parent-vol." << std::endl;
00114 }
00115
00116
00117 part.weight() = w;
00118 return w;
00119
00120 }
00121
00122
00123
00124
00125
00126
00127
00128
00129
00130
00131