CMS 3D CMS Logo

List of all members | Public Types | Public Member Functions | Protected Attributes
DDCompactViewImpl Class Reference

#include <DDCompactViewImpl.h>

Public Types

using GraphNav = math::Graph< DDLogicalPart, DDPosData * >
 
using WalkerType = math::GraphWalker< DDLogicalPart, DDPosData * >
 

Public Member Functions

DDLogicalPartcurrent () const
 
 DDCompactViewImpl ()
 
 DDCompactViewImpl (const DDLogicalPart &rootnodedata)
 
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 &)
 
math::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.

Definition at line 20 of file DDCompactViewImpl.h.

Constructor & Destructor Documentation

DDCompactViewImpl::DDCompactViewImpl ( )
explicit

Definition at line 119 of file DDCompactViewImpl.cc.

119 { }
DDCompactViewImpl::DDCompactViewImpl ( const DDLogicalPart rootnodedata)

Definition at line 15 of file DDCompactViewImpl.cc.

References LogDebug.

16  : root_(rootnodedata)
17 {
18  LogDebug("DDCompactViewImpl") << "Root node data = " << rootnodedata << std::endl;
19 }
#define LogDebug(id)
DDLogicalPart root_
DDCompactViewImpl::~DDCompactViewImpl ( )

Definition at line 21 of file DDCompactViewImpl.cc.

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

22 {
24  if ( graph_.size() == 0 ) {
25  LogDebug("DDCompactViewImpl") << "In destructor, graph is empty. Root:" << root_ << std::endl;
26  } else {
27  LogDebug("DDCompactViewImpl") << "In destructor, graph is NOT empty. Root:" << root_ << " graph_.size() = " << graph_.size() << std::endl;
28  for (; it < graph_.size() ; ++it) {
29  GraphNav::edge_range erange = graph_.edges(it); //it->second.begin();
30  for(; erange.first != erange.second; ++(erange.first)) {
31  DDPosData * pd = graph_.edgeData(erange.first->second);
32  delete pd;
33  pd=nullptr;
34  }
35  }
36  }
37  edm::LogInfo("DDCompactViewImpl") << std::endl << "DDD transient representation has been destructed." << std::endl << std::endl;
38 }
#define LogDebug(id)
Relative position of a child-volume inside a parent-volume.
Definition: DDPosData.h:13
edge_range edges(index_type nodeIndex)
Definition: Graph.h:272
DDLogicalPart root_
uint16_t size_type
std::pair< edge_iterator, edge_iterator > edge_range
Definition: Graph.h:135
const E & edgeData(index_type i) const
Definition: Graph.h:178
auto size() const -> adj_list::size_type
Definition: Graph.h:196

Member Function Documentation

DDLogicalPart& DDCompactViewImpl::current ( ) const

Referenced by root().

const GraphNav& DDCompactViewImpl::graph ( ) const
inline
void DDCompactViewImpl::position ( const DDLogicalPart self,
const DDLogicalPart parent,
int  copyno,
const DDTranslation trans,
const DDRotation rot,
const DDDivision div 
)

Definition at line 103 of file DDCompactViewImpl.cc.

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

Referenced by graph().

109 {
110  DDPosData * pd = new DDPosData(trans,rot,copyno,div);
111  graph_.addEdge(parent,self,pd);
112 }
Relative position of a child-volume inside a parent-volume.
Definition: DDPosData.h:13
void addEdge(const N &from, const N &to, const E &edge)
Definition: Graph.h:261
const DDLogicalPart& DDCompactViewImpl::root ( ) const
inline

Definition at line 29 of file DDCompactViewImpl.h.

References current(), and root_.

Referenced by setRoot().

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

Definition at line 27 of file DDCompactViewImpl.h.

References root(), and root_.

27 { root_=root; }
DDLogicalPart root_
const DDLogicalPart & root() const
void DDCompactViewImpl::swap ( DDCompactViewImpl implToSwap)

Definition at line 115 of file DDCompactViewImpl.cc.

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

Referenced by graph().

115  {
116  graph_.swap(implToSwap.graph_);
117 }
void swap(Graph< N, E > &)
Definition: Graph.h:413
math::GraphWalker< DDLogicalPart, DDPosData * > DDCompactViewImpl::walker ( ) const
double DDCompactViewImpl::weight ( const DDLogicalPart aPart) const

Definition at line 52 of file DDCompactViewImpl.cc.

References class-composition::child, math::GraphWalker< N, E >::current(), DDBase< N, C >::ddname(), DDMaterial::density(), math::GraphWalker< N, E >::firstChild(), g, graph_, DDLogicalPart::material(), math::GraphWalker< N, E >::nextSibling(), DDLogicalPart::solid(), DDSolid::volume(), w, walker(), and DDLogicalPart::weight().

Referenced by graph().

53 {
54  // return 0;
55 
56  if (!aPart)
57  return -1;
58  DDLogicalPart part = aPart;
59  //double result;
60  if (part.weight())
61  return part.weight();
62 
63  // weigth = (parent.vol - children.vol)*parent.density + weight(children)
64  double childrenVols=0;
65  double childrenWeights=0;
66  WalkerType walker(graph_,part);
67  if(walker.firstChild()) {
68  bool doIt=true;
69  while(doIt) {
70  double a_vol;
72  a_vol=child.solid().volume();
73  if (a_vol <= 0.) {
74  edm::LogError("DDCompactViewImpl") << "DD-WARNING: volume of solid=" << aPart.solid()
75  << "is zero or negative, vol=" << a_vol/m3 << "m3" << std::endl;
76  }
77  childrenVols += a_vol;
78  childrenWeights += weight(child); // recursive
79  doIt=walker.nextSibling();
80  }
81  }
82 
83  double dens = part.material().density();
84  if (dens <=0) {
85  edm::LogError("DDCompactViewImpl") << "DD-WARNING: density of material=" << part.material().ddname()
86  << " is negative or zero, rho=" << dens/g*cm3 << "g/cm3" << std::endl;
87  }
88  double p_vol = part.solid().volume();
89  double w = (p_vol - childrenVols)*dens + childrenWeights;
90  if ( (fabs(p_vol) - fabs(childrenVols))/fabs(p_vol) > 1.01 ) {
91  edm::LogError("DDCompactViewImpl") << "DD-WARNING: parent-volume smaller than children, parent="
92  << part.ddname() << " difference-vol="
93  << (p_vol - childrenVols)/m3 << "m3, this is "
94  << (childrenVols - p_vol)/p_vol << "% of the parent-vol." << std::endl;
95  }
96 
97  //part.rep().weight_=w;
98  part.weight() = w;
99  return w;
100 
101 }
const double w
Definition: UKUtility.cc:23
math::GraphWalker< DDLogicalPart, DDPosData * > WalkerType
const DDSolid & solid(void) const
Returns a reference object of the solid being the shape of this LogicalPart.
double & weight(void)
Weight of the LogicalPart viewed as a component, if cached, else -1.
The Signals That Services Can Subscribe To This is based on ActivityRegistry and is current per Services can connect to the signals distributed by the ActivityRegistry in order to monitor the activity of the application Each possible callback has some defined which we here list in angle e g
Definition: Activities.doc:4
math::GraphWalker< DDLogicalPart, DDPosData * > walker() const
A DDLogicalPart aggregates information concerning material, solid and sensitveness ...
Definition: DDLogicalPart.h:92
result_type firstChild()
Definition: GraphWalker.h:118
result_type nextSibling()
Definition: GraphWalker.h:131
double density() const
returns the density
Definition: DDMaterial.cc:108
part
Definition: HCALResponse.h:20
double weight(const DDLogicalPart &) const
value_type current() const
Definition: GraphWalker.h:93
const DDMaterial & material(void) const
Returns a reference object of the material this LogicalPart is made of.
double volume(void) const
Returns the volume of the given solid (does not work with boolean soids !)
Definition: DDSolid.cc:138
const N & ddname() const
Definition: DDBase.h:80

Member Data Documentation

GraphNav DDCompactViewImpl::graph_
protected

Definition at line 51 of file DDCompactViewImpl.h.

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

DDLogicalPart DDCompactViewImpl::root_
protected

Definition at line 50 of file DDCompactViewImpl.h.

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