CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
DDCompactViewImpl.cc
Go to the documentation of this file.
2 
3 #include <math.h>
4 #include <ostream>
5 #include <utility>
6 #include <vector>
7 
8 #include "CLHEP/Units/GlobalSystemOfUnits.h"
9 #include "CLHEP/Units/SystemOfUnits.h"
14 
16  : root_(rootnodedata)
17 {
18  LogDebug("DDCompactViewImpl") << "Root node data = " << rootnodedata << std::endl;
19 }
20 
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=0;
34  }
35  }
36  }
37  edm::LogInfo("DDCompactViewImpl") << std::endl << "DDD transient representation has been destructed." << std::endl << std::endl;
38 }
39 
41 {
43 }
44 
46 // calculates the weight and caches it in LogicalPartImpl
47 //double DDCompactViewImpl::weight(DDLogicalPart & part)
49 
50 class DDDivision;
51 
52 double DDCompactViewImpl::weight(const DDLogicalPart & aPart) const
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;
71  DDLogicalPart child(walker.current().first);
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 }
102 
104  const DDLogicalPart & parent,
105  int copyno,
106  const DDTranslation & trans,
107  const DDRotation & rot,
108  const DDDivision * div)
109 {
110  DDPosData * pd = new DDPosData(trans,rot,copyno,div);
111  graph_.addEdge(parent,self,pd);
112 }
113 
114 
116  graph_.swap(implToSwap.graph_);
117 }
118 
#define LogDebug(id)
adj_list::size_type size() const
Definition: adjgraph.h:201
void position(const DDLogicalPart &self, const DDLogicalPart &parent, int copyno, const DDTranslation &trans, const DDRotation &rot, const DDDivision *div)
Relative position of a child-volume inside a parent-volume.
Definition: DDPosData.h:13
graphwalker< DDLogicalPart, DDPosData * > walker() const
const double w
Definition: UKUtility.cc:23
std::pair< edge_iterator, edge_iterator > edge_range
Definition: adjgraph.h:138
DDLogicalPart root_
const E & edgeData(index_type i) const
Definition: adjgraph.h:183
const DDSolid & solid(void) const
Returns a reference object of the solid being the shape of this LogicalPart.
uint16_t size_type
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
ROOT::Math::DisplacementVector3D< ROOT::Math::Cartesian3D< double > > DDTranslation
Definition: DDTranslation.h:7
Represents a uniquely identifyable rotation matrix.
Definition: DDTransform.h:66
edge_range edges(index_type nodeIndex)
Definition: adjgraph.h:277
A DDLogicalPart aggregates information concerning material, solid and sensitveness ...
Definition: DDLogicalPart.h:92
result_type nextSibling()
Definition: graphwalker.h:157
double density() const
returns the density
Definition: DDMaterial.cc:109
result_type firstChild()
Definition: graphwalker.h:143
part
Definition: HCALResponse.h:20
value_type current() const
Definition: graphwalker.h:109
void swap(DDCompactViewImpl &)
static const char root_[]
void addEdge(const N &from, const N &to, const E &edge)
Definition: adjgraph.h:266
double weight(const DDLogicalPart &) const
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:140
void swap(graph< N, E > &)
Definition: adjgraph.h:442
const N & ddname() const
Definition: DDBase.h:80