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.
4 #include "CLHEP/Units/GlobalSystemOfUnits.h"
5 
6 // Message logger.
8 
10  : root_(rootnodedata)
11 {
12  LogDebug("DDCompactViewImpl") << "Root node data = " << rootnodedata << std::endl;
13 }
14 
16 {
18  if ( graph_.size() == 0 ) {
19  LogDebug("DDCompactViewImpl") << "In destructor, graph is empty. Root:" << root_ << std::endl;
20  } else {
21  LogDebug("DDCompactViewImpl") << "In destructor, graph is NOT empty. Root:" << root_ << " graph_.size() = " << graph_.size() << std::endl;
22  for (; it < graph_.size() ; ++it) {
23  GraphNav::edge_range erange = graph_.edges(it); //it->second.begin();
24  for(; erange.first != erange.second; ++(erange.first)) {
25  DDPosData * pd = graph_.edgeData(erange.first->second);
26  delete pd;
27  pd=0;
28  }
29  }
30  }
31  edm::LogInfo("DDCompactViewImpl") << std::endl << "DDD transient representation has been destructed." << std::endl << std::endl;
32 }
33 
35 {
36  DCOUT('C',"DDCompactView::walker() root_=" << root_);
38 }
39 
40 // calculates the weight and caches it in LogicalPartImpl
41 //double DDCompactViewImpl::weight(DDLogicalPart & part)
44 double DDCompactViewImpl::weight(const DDLogicalPart & aPart) const
45 {
46  // return 0;
47 
48  if (!aPart)
49  return -1;
50  DDLogicalPart part = aPart;
51  //double result;
52  if (part.weight())
53  return part.weight();
54 
55  // weigth = (parent.vol - children.vol)*parent.density + weight(children)
56  double childrenVols=0;
57  double childrenWeights=0;
59  if(walker.firstChild()) {
60  bool doIt=true;
61  while(doIt) {
62  double a_vol;
63  DDLogicalPart child(walker.current().first);
64  a_vol=child.solid().volume();
65  if (a_vol <= 0.) {
66  edm::LogError("DDCompactViewImpl") << "DD-WARNING: volume of solid=" << aPart.solid()
67  << "is zero or negative, vol=" << a_vol/m3 << "m3" << std::endl;
68  }
69  DCOUT_V('C', "DC: weightcalc, currently=" << child.ddname().name()
70  << " vol=" << a_vol/cm3 << "cm3");
71  childrenVols += a_vol;
72  childrenWeights += weight(child); // recursive
73  doIt=walker.nextSibling();
74  }
75  }
76 
77  double dens = part.material().density();
78  if (dens <=0) {
79  edm::LogError("DDCompactViewImpl") << "DD-WARNING: density of material=" << part.material().ddname()
80  << " is negative or zero, rho=" << dens/g*cm3 << "g/cm3" << std::endl;
81  }
82  double p_vol = part.solid().volume();
83  double w = (p_vol - childrenVols)*dens + childrenWeights;
84  if ( (fabs(p_vol) - fabs(childrenVols))/fabs(p_vol) > 1.01 ) {
85  edm::LogError("DDCompactViewImpl") << "DD-WARNING: parent-volume smaller than children, parent="
86  << part.ddname() << " difference-vol="
87  << (p_vol - childrenVols)/m3 << "m3, this is "
88  << (childrenVols - p_vol)/p_vol << "% of the parent-vol." << std::endl;
89  }
90 
91  //part.rep().weight_=w;
92  part.weight() = w;
93  return w;
94 
95 }
96 
98  const DDLogicalPart & parent,
99  int copyno,
100  const DDTranslation & trans,
101  const DDRotation & rot,
102  const DDDivision * div)
103 {
104  DDPosData * pd = new DDPosData(trans,rot,copyno,div);
105  graph_.addEdge(parent,self,pd);
106 }
107 
108 
110  graph_.swap(implToSwap.graph_);
111 }
112 
#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:16
graphwalker< DDLogicalPart, DDPosData * > walker() const
list parent
Definition: dbtoconf.py:74
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:88
result_type nextSibling()
Definition: graphwalker.h:157
#define DCOUT_V(M_v_Y, M_v_S)
Definition: DDdebug.h:54
double density() const
returns the density
Definition: DDMaterial.cc:109
result_type firstChild()
Definition: graphwalker.h:143
part
Definition: HCALResponse.h:21
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
#define DCOUT(M_v_Y, M_v_S)
Definition: DDdebug.h:53
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:133
T w() const
void swap(graph< N, E > &)
Definition: adjgraph.h:442
const N & ddname() const
Definition: DDBase.h:84