CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
Functions
hierarchy.cc File Reference
#include "CLHEP/Units/GlobalSystemOfUnits.h"
#include "DetectorDescription/Core/interface/DDLogicalPart.h"
#include "DetectorDescription/Core/interface/DDSolid.h"
#include "DetectorDescription/Core/interface/DDMaterial.h"
#include "DetectorDescription/Core/interface/DDCompactView.h"
#include "DetectorDescription/Core/interface/DDPartSelection.h"
#include "DetectorDescription/Core/interface/DDName.h"
#include <fstream>
#include <string>
#include <set>
#include <iostream>
#include <map>

Go to the source code of this file.

Functions

void generateHtml (std::vector< DDLogicalPart > &v, std::map< DDLogicalPart, int > &c)
 
void hierarchy (const DDLogicalPart &parent)
 
std::string link (std::string &nm, std::string &ns)
 
void streamSolid (DDSolid s, std::ostream &os)
 
void writeMaterials (std::map< std::string, std::set< DDMaterial > > &m)
 

Function Documentation

void generateHtml ( std::vector< DDLogicalPart > &  v,
std::map< DDLogicalPart, int > &  c 
)

Definition at line 77 of file hierarchy.cc.

References mergeVDriftHistosByStation::file, alignmentValidation::fname, g, link(), mergeVDriftHistosByStation::name, asciidump::s, streamSolid(), and DDCompactView::weight().

Referenced by hierarchy().

78 {
79  static DDCompactView cpv;
80  std::string name = v.back().name().name();
81  std::string ns = v.back().name().ns();
82  std::string fname = link(name,ns);
83  std::ofstream file(fname.c_str());
84 
85 
86  file << "<!DOCTYPE html PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\">" << std::endl;
87  file << "<html><head><title>DDD-part:" << ns << " " << name << "</title>";
88  file << "<body><h2>"
89  << "name=" << name << " namespace=" << ns << "</h2>" << std::endl;
90  file << "<br>weight = " << cpv.weight(v.back())/kg << "kg<br>" << std::endl;
91  //file << "volume = " << v.back().solid().volume()/m3 << "m3<br>" << std::endl;
92  //file << "solid = " << typeid(v.back().solid().rep()).name() << " ";
93  streamSolid(v.back().solid(),file);
94  file << "<br>" << std::endl;
95  std::string mname = v.back().material().name().name();
96  std::string mns = v.back().material().name().ns();
97  std::string lk = mns + ".html#" + mname;
98  file << "material = " << "<a href=\"" << lk << "\">"
99  << mname << "</a>" << std::endl;
100  file << "density = " << v.back().material().density()/g*cm3 << "g/cm3<br>" << std::endl;
101 
102  // link children
103  file << "<br>Children:<br>" << std::endl;
104  std::map<DDLogicalPart,int>::iterator cit = c.begin();
105  for (; cit != c.end(); ++cit) {
106  std::string nm, nsp;
107  nm = cit->first.name().name(); nsp = cit->first.name().ns();
108  file << "<a href=\"" << link(nm,nsp) << "\">"
109  << nm << "(" << cit->second << ")</a> " << std::endl;
110  }
111 
112  file << "<br><br>Ancestors:<br>";
113  int s = v.size();
114  --s; --s;
115  for (; s>=0; --s) {
116  std::string nm,nsp;
117  nm = v[s].name().name();
118  nsp = v[s].name().ns();
119  file << std::string(2*s,' ') << "<a href=\"" << link(nm,nsp) << "\">"
120  << nm << "</a><br> " << std::endl;
121  }
122  file << "<br>SpecPars:<br>" << std::endl;
123  file << "<table><tbody>" << std::endl;
124  typedef std::vector< std::pair<DDPartSelection*,DDsvalues_type*> > sv_type;
125  sv_type sv = v.back().attachedSpecifics();
126  sv_type::iterator sit = sv.begin();
127  for (; sit != sv.end(); ++sit) {
128  file << "<tr>" << std::endl
129  << " <td>" << *(sit->first) <<"</td>" << std::endl;
130  file << " <td>";
131  DDsvalues_type::iterator svit = sit->second->begin();
132  for(; svit != sit->second->end(); ++svit) {
133  file << svit->second << "<br>" <<std::endl;
134  }
135  file << "</td>" << std::endl
136  << "</tr>" << std::endl;
137 
138  }
139  file << "</table></tbody>" << std::endl;
140 
141  file << "<br></body></html>" <<std::endl;
142  file.close();
143 }
void streamSolid(DDSolid s, std::ostream &os)
Definition: hierarchy.cc:52
double weight(const DDLogicalPart &p) const
Prototype version of calculating the weight of a detector component.
type of data representation of DDCompactView
Definition: DDCompactView.h:81
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
std::string link(std::string &nm, std::string &ns)
Definition: hierarchy.cc:47
string fname
main script
string s
Definition: asciidump.py:422
mathSSE::Vec4< T > v
void hierarchy ( const DDLogicalPart parent)

Definition at line 168 of file hierarchy.cc.

References prof2calltree::count, gather_cfg::cout, DDBase< N, C >::ddname(), graph< N, E >::edges(), g, generateHtml(), DDCompactView::graph(), hierarchy(), DDLogicalPart::material(), DDBase< N, C >::name(), graph< N, E >::nodeData(), DDName::ns(), and writeMaterials().

Referenced by hierarchy().

169 {
170  static DDCompactView cpv ;
171  static DDCompactView::graph_type g = cpv.graph();
172  static int count=0;
173  static std::vector<DDLogicalPart> history;
174  static std::map<std::string,std::set<DDMaterial> > materials;
175  //DDCompactView::graph_type::adj_iterator it = g.begin();
176 
177  history.push_back(parent);
178  materials[parent.material().name().ns()].insert(parent.material());
179  std::cout << history.size() << std::string(2*count,' ') << " " << parent.ddname() << std::endl;
182  std::map<DDLogicalPart,int> children;
183  for (; eit != er.second; ++eit) {
184  children[g.nodeData(*eit)]++;
185  }
186 
187  generateHtml(history,children);
188 
189  std::map<DDLogicalPart,int>::iterator cit = children.begin();
190  for (; cit != children.end(); ++cit) {
191  ++count;
192  hierarchy(cit->first);
193  history.pop_back();
194  --count;
195  }
196 
197  writeMaterials(materials);
198 }
void writeMaterials(std::map< std::string, std::set< DDMaterial > > &m)
Definition: hierarchy.cc:145
const N & name() const
Definition: DDBase.h:88
std::pair< edge_iterator, edge_iterator > edge_range
Definition: adjgraph.h:139
const graph_type & graph() const
Provides read-only access to the data structure of the compact-view.
const std::string & ns() const
Returns the namespace.
Definition: DDName.cc:101
const N & nodeData(const edge_type &) const
Definition: adjgraph.h:318
type of data representation of DDCompactView
Definition: DDCompactView.h:81
const DDMaterial & material() const
Returns a reference object of the material this LogicalPart is made of.
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
edge_range edges(index_type nodeIndex)
Definition: adjgraph.h:278
void hierarchy(const DDLogicalPart &parent)
Definition: hierarchy.cc:168
edge_list::iterator edge_iterator
Definition: adjgraph.h:135
void generateHtml(std::vector< DDLogicalPart > &v, std::map< DDLogicalPart, int > &c)
Definition: hierarchy.cc:77
tuple cout
Definition: gather_cfg.py:41
const N & ddname() const
Definition: DDBase.h:90
std::string link ( std::string &  nm,
std::string &  ns 
)
void streamSolid ( DDSolid  s,
std::ostream &  os 
)

Definition at line 52 of file hierarchy.cc.

References ddpolycone_rrz, ddpolyhedra_rrz, i, L1TEmulatorMonitor_cff::p, DDSolid::parameters(), asciidump::s, and DDSolid::shape().

Referenced by generateHtml().

52  {
53  DDSolidShape sp = s.shape();
54  if ( (sp==ddpolycone_rrz) || (sp==ddpolyhedra_rrz) ) {
55  unsigned int i = 0;
56  const std::vector<double> & p = s.parameters();
57  if (sp==ddpolyhedra_rrz){
58  os << "numSides=" << p[0] << " ";
59  ++i;
60  }
61  os <<"startPhi[deg]=" << p[i]/deg << " deltaPhi[deg]" << p[i+1]/deg << std::endl;
62  i +=2;
63  os << "<table><tr><td>z[cm]</td><td>rMin[cm]</td><td>rMax[cm]</td></tr>";
64  while ( i+1 < p.size()) {
65  os << "<tr><td>" << p[i]/cm << "</td>";
66  os << "<td>" << p[i+1]/cm << "</td>";
67  os << "<td>" << p[i+2]/cm << "</td></tr>" << std::endl;
68  i = i+3;
69  }
70  os << "</table>" << std::endl;
71  } else
72  {
73  os << s;
74  }
75 }
const std::vector< double > & parameters() const
Don&#39;t use (only meant to be used by DDbox(), DDtub(), ...)
Definition: DDSolid.cc:153
int i
Definition: DBlmapReader.cc:9
DDSolidShape shape() const
The type of the solid.
Definition: DDSolid.cc:147
DDSolidShape
Definition: DDSolidShapes.h:5
string s
Definition: asciidump.py:422
void writeMaterials ( std::map< std::string, std::set< DDMaterial > > &  m)

Definition at line 145 of file hierarchy.cc.

References mergeVDriftHistosByStation::file, alignmentValidation::fname, g, and m.

Referenced by hierarchy().

146 {
147  std::map<std::string, std::set<DDMaterial> >::iterator it = m.begin();
148  for (; it != m.end(); ++it) {
149  std::string fname = it->first + ".html";
150  std::ofstream file(fname.c_str());
151  file << "<!DOCTYPE html PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\">" << std::endl;
152  file << "<html><head><title>DDD-Materials</title>";
153  file << "<body>";
154  std::set<DDMaterial>::iterator mit = it->second.begin();
155  for (; mit != it->second.end(); ++mit) {
156  file << "<a name=\"" << mit->name().name() << "\">";
157  file << mit->name().name() << " d=" << mit->density()/g*cm3
158  << "g/cm3";
159 
160  file << "</a><br>";
161  }
162  file << "</body></html>" << std::endl;
163  file.close();
164  }
165 
166 }
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
string fname
main script