CMS 3D CMS Logo

hierarchy.cc File Reference

#include "CLHEP/Units/SystemOfUnits.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 lat::endl(), file, mergeAndRegister_online::fname, g, link(), name, s, streamSolid(), sv, and DDCompactView::weight().

Referenced by hierarchy().

00078 {
00079    static DDCompactView cpv;
00080    std::string name = v.back().name().name();
00081    std::string ns   = v.back().name().ns();
00082    std::string fname = link(name,ns);
00083    std::ofstream file(fname.c_str());
00084    
00085    
00086    file << "<!DOCTYPE html PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\">" << std::endl;
00087    file << "<html><head><title>DDD-part:" << ns << " " << name << "</title>";
00088    file << "<body><h2>"
00089         <<  "name=" << name << "  namespace=" << ns << "</h2>" << std::endl;
00090    file << "<br>weight = " << cpv.weight(v.back())/kg << "kg<br>" << std::endl;
00091    //file << "volume = " << v.back().solid().volume()/m3 << "m3<br>" << std::endl;
00092    //file << "solid  = " << typeid(v.back().solid().rep()).name() << "  ";
00093            streamSolid(v.back().solid(),file);
00094    file << "<br>" << std::endl;
00095    std::string mname = v.back().material().name().name();
00096    std::string mns   = v.back().material().name().ns();
00097    std::string lk = mns + ".html#" + mname;
00098    file << "material = " << "<a href=\""  << lk <<  "\">"  
00099                          << mname << "</a>" << std::endl;
00100    file << "density = "  << v.back().material().density()/g*cm3 << "g/cm3<br>" << std::endl;
00101                          
00102    // link children
00103    file << "<br>Children:<br>" << std::endl;
00104    std::map<DDLogicalPart,int>::iterator cit = c.begin();
00105    for (; cit != c.end(); ++cit) {
00106      std::string nm, nsp;
00107      nm = cit->first.name().name(); nsp = cit->first.name().ns();
00108      file << "<a href=\"" << link(nm,nsp) << "\">"
00109           << nm  << "(" << cit->second << ")</a> " << std::endl;
00110    }
00111    
00112    file << "<br><br>Ancestors:<br>";
00113    int s = v.size();
00114    --s; --s;
00115    for (; s>=0; --s) {
00116      std::string nm,nsp;
00117      nm = v[s].name().name();
00118      nsp = v[s].name().ns();
00119      file << std::string(2*s,' ') << "<a href=\"" << link(nm,nsp) << "\">"
00120               << nm << "</a><br> " << std::endl;
00121    }
00122    file << "<br>SpecPars:<br>" << std::endl;
00123    file << "<table><tbody>" << std::endl;
00124    typedef std::vector< std::pair<DDPartSelection*,DDsvalues_type*> > sv_type;
00125    sv_type sv = v.back().attachedSpecifics();
00126    sv_type::iterator sit = sv.begin();
00127    for (; sit != sv.end(); ++sit) {
00128      file << "<tr>" << std::endl
00129           << " <td>" << *(sit->first) <<"</td>" << std::endl;
00130      file << " <td>";     
00131      DDsvalues_type::iterator svit = sit->second->begin();
00132      for(; svit != sit->second->end(); ++svit) {
00133        file << svit->second << "<br>" <<std::endl;
00134      }
00135      file << "</td>" << std::endl
00136           << "</tr>" << std::endl;
00137      
00138    }
00139    file << "</table></tbody>" << std::endl;
00140    
00141    file << "<br></body></html>" <<std::endl;
00142    file.close();
00143 }

void hierarchy ( const DDLogicalPart parent  ) 

Definition at line 168 of file hierarchy.cc.

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

Referenced by hierarchy().

00169 {
00170   static  DDCompactView cpv ;
00171   static graph_type g = cpv.graph();
00172   static int count=0;
00173   static std::vector<DDLogicalPart> history;
00174   static std::map<std::string,std::set<DDMaterial> > materials;
00175   //graph_type::adj_iterator it = g.begin();
00176   
00177   history.push_back(parent);
00178   materials[parent.material().name().ns()].insert(parent.material());
00179   std::cout << history.size() << std::string(2*count,' ') << " " << parent.ddname() << std::endl;
00180   graph_type::edge_range er = g.edges(parent);
00181   graph_type::edge_iterator eit = er.first;
00182   std::map<DDLogicalPart,int> children;
00183   for (; eit != er.second; ++eit) {  
00184      children[g.nodeData(*eit)]++;
00185   }
00186   
00187   generateHtml(history,children);
00188   
00189   std::map<DDLogicalPart,int>::iterator cit = children.begin();
00190   for (; cit != children.end(); ++cit) {
00191      ++count;
00192      hierarchy(cit->first);
00193      history.pop_back();
00194      --count;
00195   }
00196   
00197   writeMaterials(materials);
00198 }

std::string link ( std::string &  nm,
std::string &  ns 
)

Definition at line 47 of file hierarchy.cc.

Referenced by TrackerHitAssociator::associateSimpleRecHit(), DTReadOutMapping::cacheMap(), DTHitAssociator::DTHitAssociator(), SiPixelInformationExtractor::findNoisyPixels(), generateHtml(), DTReadOutMapping::geometryToReadOut(), SiPixelFrameConverter::hasDetUnit(), evf::WebGUI::htmlHead(), RPCReadOutMappingWithFastSearch::init(), DTReadOutMapping::insertReadOutGeometryLink(), PFAlgo::isSatelliteCluster(), CSCSPRecord::LCT(), CSCSPRecord::LCTs(), PixelEndcapLinkMaker::links(), PixelBarrelLinkMaker::links(), SiPixelSCurveCalibrationAnalysis::makeThresholdSummary(), CgiWriter::output_head(), CSCTFUnpacker::produce(), RPCReadOutMapping::rawDataFrame(), DTReadOutMapping::readOutToGeometry(), SiPixelFrameConverter::toCabling(), SiPixelFrameConverter::toDetector(), CSCSPRecord::unpack(), CSCTFTBSPBlock::unpackData(), and CSCTFTBFrontBlock::unpackData().

00048 {
00049    return ns + nm + ".html";
00050 }

void streamSolid ( DDSolid  s,
std::ostream &  os 
)

Definition at line 52 of file hierarchy.cc.

References ddpolycone_rrz, ddpolyhedra_rrz, lat::endl(), i, p, DDSolid::parameters(), and DDSolid::shape().

Referenced by generateHtml().

00052                                              {
00053   DDSolidShape sp = s.shape();
00054   if ( (sp==ddpolycone_rrz) || (sp==ddpolyhedra_rrz) ) {
00055     unsigned int i = 0;
00056     const std::vector<double> & p = s.parameters();
00057     if (sp==ddpolyhedra_rrz){
00058       os << "numSides=" << p[0] << " ";
00059       ++i;
00060     }
00061     os <<"startPhi[deg]=" << p[i]/deg << " deltaPhi[deg]" << p[i+1]/deg << std::endl;
00062     i +=2;
00063     os << "<table><tr><td>z[cm]</td><td>rMin[cm]</td><td>rMax[cm]</td></tr>";
00064     while ( i+1 < p.size()) {
00065       os << "<tr><td>" << p[i]/cm << "</td>";
00066       os << "<td>" << p[i+1]/cm << "</td>";
00067       os << "<td>" << p[i+2]/cm << "</td></tr>" << std::endl;
00068       i = i+3;  
00069     }
00070     os << "</table>" << std::endl;
00071   } else
00072   {
00073     os << s;
00074   }
00075 }

void writeMaterials ( std::map< std::string, std::set< DDMaterial > > &  m  ) 

Definition at line 145 of file hierarchy.cc.

References lat::endl(), file, mergeAndRegister_online::fname, g, it, and m.

Referenced by hierarchy().

00146 {
00147    std::map<std::string, std::set<DDMaterial> >::iterator it = m.begin();
00148    for (; it != m.end(); ++it) {
00149      std::string fname = it->first + ".html"; 
00150      std::ofstream file(fname.c_str());
00151      file << "<!DOCTYPE html PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\">" << std::endl;
00152      file << "<html><head><title>DDD-Materials</title>";
00153      file << "<body>";
00154      std::set<DDMaterial>::iterator mit = it->second.begin();
00155      for (; mit != it->second.end(); ++mit) {
00156        file << "<a name=\"" << mit->name().name() << "\">";
00157        file << mit->name().name() << " d=" << mit->density()/g*cm3 
00158             << "g/cm3";
00159             
00160        file << "</a><br>";
00161      }      
00162      file << "</body></html>" << std::endl;
00163      file.close();
00164    }
00165 
00166 }


Generated on Tue Jun 9 17:52:37 2009 for CMSSW by  doxygen 1.5.4