CMS 3D CMS Logo

Public Types | Public Member Functions | Protected Attributes

DDCompactViewImpl Class Reference

#include <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 position (const DDLogicalPart &self, const DDLogicalPart &parent, int copyno, const DDTranslation &trans, const DDRotation &rot, const DDDivision *div)
const DDLogicalPartroot () const
void setRoot (const DDLogicalPart &root)
void swap (DDCompactViewImpl &)
graphwalker< DDLogicalPart,
DDPosData * > 
walker () const
double weight (const DDLogicalPart &) const
 ~DDCompactViewImpl ()

Protected Attributes

GraphNav graph_
DDLogicalPart root_

Detailed Description

Definition at line 15 of file DDCompactViewImpl.h.


Member Typedef Documentation

Definition at line 19 of file DDCompactViewImpl.h.


Constructor & Destructor Documentation

DDCompactViewImpl::DDCompactViewImpl ( ) [explicit]

Definition at line 113 of file DDCompactViewImpl.cc.

{ }
DDCompactViewImpl::DDCompactViewImpl ( const DDLogicalPart rootnodedata)

Definition at line 9 of file DDCompactViewImpl.cc.

References LogDebug.

  :  root_(rootnodedata)
{
  LogDebug("DDCompactViewImpl") << "Root node data = " << rootnodedata << std::endl;
}
DDCompactViewImpl::~DDCompactViewImpl ( )

Definition at line 15 of file DDCompactViewImpl.cc.

References graph< N, E >::edgeData(), graph< N, E >::edges(), graph_, LogDebug, root_, and graph< N, E >::size().

{  
   GraphNav::adj_list::size_type it = 0;
   if ( graph_.size() == 0 ) {
     LogDebug("DDCompactViewImpl") << "In destructor, graph is empty.  Root:" << root_ << std::endl;
   } else {
     LogDebug("DDCompactViewImpl") << "In destructor, graph is NOT empty.  Root:" << root_ << " graph_.size() = " << graph_.size() << std::endl;
     for (; it < graph_.size() ; ++it) {
       GraphNav::edge_range erange = graph_.edges(it); //it->second.begin();
       for(; erange.first != erange.second; ++(erange.first)) {
         DDPosData * pd = graph_.edgeData(erange.first->second);
         delete pd;
         pd=0;
       }  
     }
   }
   edm::LogInfo("DDCompactViewImpl") << std::endl << "DDD transient representation has been destructed." << std::endl << std::endl;   
}

Member Function Documentation

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

Definition at line 35 of file DDCompactViewImpl.h.

References graph_.

Referenced by DDCompactView::graph(), and DDCompactView::writeableGraph().

{ return graph_; }
void DDCompactViewImpl::position ( const DDLogicalPart self,
const DDLogicalPart parent,
int  copyno,
const DDTranslation trans,
const DDRotation rot,
const DDDivision div 
)

Definition at line 97 of file DDCompactViewImpl.cc.

References graph< N, E >::addEdge(), and graph_.

Referenced by DDCompactView::position().

{
  DDPosData * pd = new DDPosData(trans,rot,copyno,div);
  graph_.addEdge(parent,self,pd);
}
const DDLogicalPart& DDCompactViewImpl::root ( ) const [inline]

Definition at line 27 of file DDCompactViewImpl.h.

References root_.

Referenced by DDCompactView::root(), and setRoot().

{ return root_; }
void DDCompactViewImpl::setRoot ( const DDLogicalPart root) [inline]

Definition at line 25 of file DDCompactViewImpl.h.

References root(), and root_.

Referenced by DDCompactView::setRoot().

{ root_=root; }
void DDCompactViewImpl::swap ( DDCompactViewImpl implToSwap)

Definition at line 109 of file DDCompactViewImpl.cc.

References graph_, and graph< N, E >::swap().

Referenced by DDCompactView::swap().

                                                            {
  graph_.swap(implToSwap.graph_);
}
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 34 of file DDCompactViewImpl.cc.

References DCOUT, graph_, and root_.

Referenced by DDCompactView::walker(), and weight().

{
   DCOUT('C',"DDCompactView::walker() root_=" << root_);
   return graphwalker<DDLogicalPart,DDPosData*>(graph_,root_);
}
double DDCompactViewImpl::weight ( const DDLogicalPart aPart) const

Definition at line 44 of file DDCompactViewImpl.cc.

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

Referenced by DDCompactView::weight().

{
 // return 0;

   if (!aPart)
     return -1;
   DDLogicalPart part = aPart;
   //double result;  
   if (part.weight())
     return part.weight();
   
   // weigth = (parent.vol - children.vol)*parent.density + weight(children)
   double childrenVols=0;
   double childrenWeights=0;
   walker_type walker(graph_,part);
   if(walker.firstChild()) {
     bool doIt=true;
     while(doIt) {
       double a_vol;
       DDLogicalPart child(walker.current().first);
       a_vol=child.solid().volume();
       if (a_vol <= 0.) {
         edm::LogError("DDCompactViewImpl")  << "DD-WARNING: volume of solid=" << aPart.solid() 
               << "is zero or negative, vol=" << a_vol/m3 << "m3" << std::endl;
       }
       DCOUT_V('C', "DC: weightcalc, currently=" << child.ddname().name()
            << " vol=" << a_vol/cm3 << "cm3");
       childrenVols += a_vol;
       childrenWeights += weight(child); // recursive
       doIt=walker.nextSibling();
     }
   }
   
   double dens = part.material().density();
   if (dens <=0) {
     edm::LogError("DDCompactViewImpl")  << "DD-WARNING: density of material=" << part.material().ddname() 
           << " is negative or zero, rho=" << dens/g*cm3 << "g/cm3" << std::endl;
   }
   double p_vol  = part.solid().volume();
   double w =   (p_vol - childrenVols)*dens + childrenWeights; 
   if (  (fabs(p_vol) - fabs(childrenVols))/fabs(p_vol) > 1.01 ) {
     edm::LogError("DDCompactViewImpl")  << "DD-WARNING: parent-volume smaller than children, parent=" 
          << part.ddname() << " difference-vol=" 
           << (p_vol - childrenVols)/m3 << "m3, this is " 
           << (childrenVols - p_vol)/p_vol << "% of the parent-vol." << std::endl;
   }
  
   //part.rep().weight_=w;
   part.weight() = w;
   return w;
   
}

Member Data Documentation

Definition at line 63 of file DDCompactViewImpl.h.

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

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

walker_t walker(const DDPartSelector&) const;

Definition at line 62 of file DDCompactViewImpl.h.

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