test
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 {
37 }
38 
39 // calculates the weight and caches it in LogicalPartImpl
40 //double DDCompactViewImpl::weight(DDLogicalPart & part)
43 double DDCompactViewImpl::weight(const DDLogicalPart & aPart) const
44 {
45  // return 0;
46 
47  if (!aPart)
48  return -1;
49  DDLogicalPart part = aPart;
50  //double result;
51  if (part.weight())
52  return part.weight();
53 
54  // weigth = (parent.vol - children.vol)*parent.density + weight(children)
55  double childrenVols=0;
56  double childrenWeights=0;
57  WalkerType walker(graph_,part);
58  if(walker.firstChild()) {
59  bool doIt=true;
60  while(doIt) {
61  double a_vol;
62  DDLogicalPart child(walker.current().first);
63  a_vol=child.solid().volume();
64  if (a_vol <= 0.) {
65  edm::LogError("DDCompactViewImpl") << "DD-WARNING: volume of solid=" << aPart.solid()
66  << "is zero or negative, vol=" << a_vol/m3 << "m3" << std::endl;
67  }
68  DCOUT_V('C', "DC: weightcalc, currently=" << child.ddname().name()
69  << " vol=" << a_vol/cm3 << "cm3");
70  childrenVols += a_vol;
71  childrenWeights += weight(child); // recursive
72  doIt=walker.nextSibling();
73  }
74  }
75 
76  double dens = part.material().density();
77  if (dens <=0) {
78  edm::LogError("DDCompactViewImpl") << "DD-WARNING: density of material=" << part.material().ddname()
79  << " is negative or zero, rho=" << dens/g*cm3 << "g/cm3" << std::endl;
80  }
81  double p_vol = part.solid().volume();
82  double w = (p_vol - childrenVols)*dens + childrenWeights;
83  if ( (fabs(p_vol) - fabs(childrenVols))/fabs(p_vol) > 1.01 ) {
84  edm::LogError("DDCompactViewImpl") << "DD-WARNING: parent-volume smaller than children, parent="
85  << part.ddname() << " difference-vol="
86  << (p_vol - childrenVols)/m3 << "m3, this is "
87  << (childrenVols - p_vol)/p_vol << "% of the parent-vol." << std::endl;
88  }
89 
90  //part.rep().weight_=w;
91  part.weight() = w;
92  return w;
93 
94 }
95 
97  const DDLogicalPart & parent,
98  int copyno,
99  const DDTranslation & trans,
100  const DDRotation & rot,
101  const DDDivision * div)
102 {
103  DDPosData * pd = new DDPosData(trans,rot,copyno,div);
104  graph_.addEdge(parent,self,pd);
105 }
106 
107 
109  graph_.swap(implToSwap.graph_);
110 }
111 
#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
list parent
Definition: dbtoconf.py:74
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: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: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:133
void swap(graph< N, E > &)
Definition: adjgraph.h:442
const N & ddname() const
Definition: DDBase.h:80