CMS 3D CMS Logo

DDCompactViewImpl Class Reference

#include <DetectorDescription/Core/interface/DDCompactViewImpl.h>

List of all members.

Public Types

typedef graph< DDLogicalPart,
DDPosData * > 
GraphNav

Public Member Functions

DDLogicalPartcurrent () const
 DDCompactViewImpl (const DDLogicalPart &rootnodedata)
 DDCompactViewImpl ()
const GraphNavgraph () const
void print (std::ostream &os)
const DDLogicalPartroot () const
void setRoot (const DDLogicalPart &root)
graphwalker< DDLogicalPart,
DDPosData * > 
walker () const
 returns a walker beginning at the root of the expanded-view FIXME: CompactView::walker: it is assumed, that the root of walker is FIXME: world volume (just 1 copy, unrotated, unpositioned)
double weight (const DDLogicalPart &) const
 ~DDCompactViewImpl ()

Protected Member Functions

void buildGraph ()
 will return a walker beginning at the node specified by the PartSelector
void buildPaths ()

Protected Attributes

GraphNav graph_
DDLogicalPart root_


Detailed Description

Definition at line 16 of file DDCompactViewImpl.h.


Member Typedef Documentation

typedef graph<DDLogicalPart, DDPosData* > DDCompactViewImpl::GraphNav

Definition at line 23 of file DDCompactViewImpl.h.


Constructor & Destructor Documentation

DDCompactViewImpl::DDCompactViewImpl (  )  [explicit]

Definition at line 18 of file DDCompactViewImpl.cc.

00019  : root_("")
00020 {
00021 
00022 }

DDCompactViewImpl::DDCompactViewImpl ( const DDLogicalPart rootnodedata  ) 

Definition at line 9 of file DDCompactViewImpl.cc.

00010   :  root_(rootnodedata)//, rootWalker_(0)
00011 {
00012   //  edm::LogInfo("DDCompactViewImpl") << "Root node data = " << rootnodedata << std::endl;
00013    //buildTree(rootnodedata,root_);
00014    //buildGraph();
00015 }

DDCompactViewImpl::~DDCompactViewImpl (  ) 

Definition at line 25 of file DDCompactViewImpl.cc.

References graph< N, E >::edgeData(), graph< N, E >::edges(), lat::endl(), graph_, it, and graph< N, E >::size().

00026 {  
00027    GraphNav::adj_list::size_type it = 0;
00028    for (; it < graph_.size() ; ++it) {
00029      GraphNav::edge_range erange = graph_.edges(it); //it->second.begin();
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 }


Member Function Documentation

void DDCompactViewImpl::buildGraph (  )  [protected]

will return a walker beginning at the node specified by the PartSelector

walker_t walker(const DDPartSelector&) const;

void DDCompactViewImpl::buildPaths (  )  [protected]

Definition at line 41 of file DDCompactViewImpl.cc.

00042 {
00043   //paths_ = new GraphNavPaths(graph_,root_); // good luck!
00044 }

DDLogicalPart& DDCompactViewImpl::current (  )  const

const GraphNav& DDCompactViewImpl::graph (  )  const [inline]

Definition at line 48 of file DDCompactViewImpl.h.

References graph_.

00048 { return graph_; }

void DDCompactViewImpl::print ( std::ostream &  os  )  [inline]

Definition at line 40 of file DDCompactViewImpl.h.

00040 { /*graph_.printHierarchy(os,root_);*/ }

const DDLogicalPart& DDCompactViewImpl::root (  )  const [inline]

Definition at line 37 of file DDCompactViewImpl.h.

References root_.

00037 { return root_; }

void DDCompactViewImpl::setRoot ( const DDLogicalPart root  )  [inline]

Definition at line 35 of file DDCompactViewImpl.h.

References root_.

Referenced by DDCompactView::global().

00035 { root_=root; }

graphwalker< DDLogicalPart, DDPosData * > DDCompactViewImpl::walker (  )  const

returns a walker beginning at the root of the expanded-view FIXME: CompactView::walker: it is assumed, that the root of walker is FIXME: world volume (just 1 copy, unrotated, unpositioned)

Definition at line 59 of file DDCompactViewImpl.cc.

References DCOUT, graph_, and root_.

Referenced by weight().

00060 {
00061    DCOUT('C',"DDCompactView::walker() root_=" << root_);
00062    return graphwalker<DDLogicalPart,DDPosData*>(graph_,root_);
00063 }

double DDCompactViewImpl::weight ( const DDLogicalPart aPart  )  const

Definition at line 69 of file DDCompactViewImpl.cc.

References graphwalker< N, E >::current(), DCOUT_V, DDBase< N, C >::ddname(), DDMaterial::density(), lat::endl(), graphwalker< N, E >::firstChild(), g, graph_, DDLogicalPart::material(), graphwalker< N, E >::nextSibling(), DDLogicalPart::solid(), DDSolid::volume(), w, walker(), and DDLogicalPart::weight().

00070 {
00071  // return 0;
00072 
00073    if (!aPart)
00074      return -1;
00075    DDLogicalPart part = aPart;
00076    //double result;  
00077    if (part.weight())
00078      return part.weight();
00079    
00080    // weigth = (parent.vol - children.vol)*parent.density + weight(children)
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); // recursive
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    //part.rep().weight_=w;
00117    part.weight() = w;
00118    return w;
00119    
00120 }


Member Data Documentation

GraphNav DDCompactViewImpl::graph_ [protected]

Definition at line 76 of file DDCompactViewImpl.h.

Referenced by graph(), walker(), weight(), and ~DDCompactViewImpl().

DDLogicalPart DDCompactViewImpl::root_ [protected]

Definition at line 74 of file DDCompactViewImpl.h.

Referenced by root(), setRoot(), and walker().


The documentation for this class was generated from the following files:
Generated on Tue Jun 9 18:17:49 2009 for CMSSW by  doxygen 1.5.4