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, int count=0)
 
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 54 of file hierarchy.cc.

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

Referenced by hierarchy().

55 {
56  static DDCompactView cpv;
57  std::string name = v.back().name().name();
58  std::string ns = v.back().name().ns();
59  std::string fname = link(name,ns);
60  std::ofstream file(fname.c_str());
61 
62 
63  file << "<!DOCTYPE html PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\">" << std::endl;
64  file << "<html><head><title>DDD-part:" << ns << " " << name << "</title>";
65  file << "<body><h2>"
66  << "name=" << name << " namespace=" << ns << "</h2>" << std::endl;
67  file << "<br>weight = " << cpv.weight(v.back())/kg << "kg<br>" << std::endl;
68  //file << "volume = " << v.back().solid().volume()/m3 << "m3<br>" << std::endl;
69  //file << "solid = " << typeid(v.back().solid().rep()).name() << " ";
70  streamSolid(v.back().solid(),file);
71  file << "<br>" << std::endl;
72  std::string mname = v.back().material().name().name();
73  std::string mns = v.back().material().name().ns();
74  std::string lk = mns + ".html#" + mname;
75  file << "material = " << "<a href=\"" << lk << "\">"
76  << mname << "</a>" << std::endl;
77  file << "density = " << v.back().material().density()/g*cm3 << "g/cm3<br>" << std::endl;
78 
79  // link children
80  file << "<br>Children:<br>" << std::endl;
81  std::map<DDLogicalPart,int>::iterator cit = c.begin();
82  for (; cit != c.end(); ++cit) {
83  std::string nm, nsp;
84  nm = cit->first.name().name(); nsp = cit->first.name().ns();
85  file << "<a href=\"" << link(nm,nsp) << "\">"
86  << nm << "(" << cit->second << ")</a> " << std::endl;
87  }
88 
89  file << "<br><br>Ancestors:<br>";
90  int s = v.size();
91  --s; --s;
92  for (; s>=0; --s) {
93  std::string nm,nsp;
94  nm = v[s].name().name();
95  nsp = v[s].name().ns();
96  file << std::string(2*s,' ') << "<a href=\"" << link(nm,nsp) << "\">"
97  << nm << "</a><br> " << std::endl;
98  }
99  file << "<br>SpecPars:<br>" << std::endl;
100  file << "<table><tbody>" << std::endl;
101  typedef std::vector< std::pair<DDPartSelection*,DDsvalues_type*> > sv_type;
102  sv_type sv = v.back().attachedSpecifics();
103  sv_type::iterator sit = sv.begin();
104  for (; sit != sv.end(); ++sit) {
105  file << "<tr>" << std::endl
106  << " <td>" << *(sit->first) <<"</td>" << std::endl;
107  file << " <td>";
108  DDsvalues_type::iterator svit = sit->second->begin();
109  for(; svit != sit->second->end(); ++svit) {
110  file << svit->second << "<br>" <<std::endl;
111  }
112  file << "</td>" << std::endl
113  << "</tr>" << std::endl;
114 
115  }
116  file << "</table></tbody>" << std::endl;
117 
118  file << "<br></body></html>" <<std::endl;
119  file.close();
120 }
void streamSolid(DDSolid s, std::ostream &os)
Definition: hierarchy.cc:29
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:77
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:24
string fname
main script
void hierarchy ( const DDLogicalPart parent,
int  count = 0 
)

Definition at line 145 of file hierarchy.cc.

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

146 {
147  static DDCompactView cpv ;
148  static DDCompactView::graph_type g = cpv.graph();
149  static std::vector<DDLogicalPart> history;
150  static std::map<std::string,std::set<DDMaterial> > materials;
151  //DDCompactView::graph_type::adj_iterator it = g.begin();
152 
153  history.push_back(parent);
154  materials[parent.material().name().ns()].insert(parent.material());
155  std::cout << history.size() << std::string(2*count,' ') << " " << parent.ddname() << std::endl;
158  std::map<DDLogicalPart,int> children;
159  for (; eit != er.second; ++eit) {
160  children[g.nodeData(*eit)]++;
161  }
162 
163  generateHtml(history,children);
164 
165  std::map<DDLogicalPart,int>::iterator cit = children.begin();
166  for (; cit != children.end(); ++cit) {
167  ++count;
168  hierarchy(cit->first, count);
169  history.pop_back();
170  --count;
171  }
172 
173  writeMaterials(materials);
174 }
void writeMaterials(std::map< std::string, std::set< DDMaterial > > &m)
Definition: hierarchy.cc:122
const N & name() const
Definition: DDBase.h:82
std::pair< edge_iterator, edge_iterator > edge_range
Definition: adjgraph.h:138
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:317
type of data representation of DDCompactView
Definition: DDCompactView.h:77
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
void hierarchy(const DDLogicalPart &parent, int count=0)
Definition: hierarchy.cc:145
edge_range edges(index_type nodeIndex)
Definition: adjgraph.h:277
edge_list::iterator edge_iterator
Definition: adjgraph.h:134
void generateHtml(std::vector< DDLogicalPart > &v, std::map< DDLogicalPart, int > &c)
Definition: hierarchy.cc:54
tuple cout
Definition: gather_cfg.py:121
const DDMaterial & material(void) const
Returns a reference object of the material this LogicalPart is made of.
const N & ddname() const
Definition: DDBase.h:84
std::string link ( std::string &  nm,
std::string &  ns 
)
void streamSolid ( DDSolid  s,
std::ostream &  os 
)

Definition at line 29 of file hierarchy.cc.

References ddpolycone_rrz, ddpolyhedra_rrz, i, AlCaHLTBitMon_ParallelJobs::p, DDSolid::parameters(), alignCSCRings::s, and DDSolid::shape().

Referenced by generateHtml().

29  {
30  DDSolidShape sp = s.shape();
31  if ( (sp==ddpolycone_rrz) || (sp==ddpolyhedra_rrz) ) {
32  unsigned int i = 0;
33  const std::vector<double> & p = s.parameters();
34  if (sp==ddpolyhedra_rrz){
35  os << "numSides=" << p[0] << " ";
36  ++i;
37  }
38  os <<"startPhi[deg]=" << p[i]/deg << " deltaPhi[deg]" << p[i+1]/deg << std::endl;
39  i +=2;
40  os << "<table><tr><td>z[cm]</td><td>rMin[cm]</td><td>rMax[cm]</td></tr>";
41  while ( i+1 < p.size()) {
42  os << "<tr><td>" << p[i]/cm << "</td>";
43  os << "<td>" << p[i+1]/cm << "</td>";
44  os << "<td>" << p[i+2]/cm << "</td></tr>" << std::endl;
45  i = i+3;
46  }
47  os << "</table>" << std::endl;
48  } else
49  {
50  os << s;
51  }
52 }
int i
Definition: DBlmapReader.cc:9
const std::vector< double > & parameters(void) const
Give the parameters of the solid.
Definition: DDSolid.cc:150
DDSolidShape
Definition: DDSolidShapes.h:6
DDSolidShape shape(void) const
The type of the solid.
Definition: DDSolid.cc:144
void writeMaterials ( std::map< std::string, std::set< DDMaterial > > &  m)

Definition at line 122 of file hierarchy.cc.

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

Referenced by hierarchy().

123 {
124  std::map<std::string, std::set<DDMaterial> >::iterator it = m.begin();
125  for (; it != m.end(); ++it) {
126  std::string fname = it->first + ".html";
127  std::ofstream file(fname.c_str());
128  file << "<!DOCTYPE html PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\">" << std::endl;
129  file << "<html><head><title>DDD-Materials</title>";
130  file << "<body>";
131  std::set<DDMaterial>::iterator mit = it->second.begin();
132  for (; mit != it->second.end(); ++mit) {
133  file << "<a name=\"" << mit->name().name() << "\">";
134  file << mit->name().name() << " d=" << mit->density()/g*cm3
135  << "g/cm3";
136 
137  file << "</a><br>";
138  }
139  file << "</body></html>" << std::endl;
140  file.close();
141  }
142 
143 }
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