#include <OutputDDToDDL.h>
Public Member Functions | |
virtual void | analyze (const edm::Event &, const edm::EventSetup &) |
virtual void | beginRun (const edm::Run &, edm::EventSetup const &) |
virtual void | endJob () |
OutputDDToDDL (const edm::ParameterSet &iConfig) | |
~OutputDDToDDL () | |
Private Member Functions | |
void | addToMatStore (const DDMaterial &mat, std::set< DDMaterial > &matStore) |
void | addToSolStore (const DDSolid &sol, std::set< DDSolid > &solStore, std::set< DDRotation > &rotStore) |
void | addToSpecStore (const DDLogicalPart &lp, std::map< DDsvalues_type, std::set< DDPartSelection * >, ddsvaluesCmp > &specStore) |
Private Attributes | |
std::string | fname_ |
int | rotNumSeed_ |
int | specNameCount_ |
std::ostream * | xos_ |
Definition at line 21 of file OutputDDToDDL.h.
OutputDDToDDL::OutputDDToDDL | ( | const edm::ParameterSet & | iConfig | ) | [explicit] |
Definition at line 30 of file OutputDDToDDL.cc.
References gather_cfg::cout, fname_, edm::ParameterSet::getParameter(), edm::ParameterSet::getUntrackedParameter(), rotNumSeed_, and xos_.
: fname_() { // std::cout<<"OutputDDToDDL::OutputDDToDDL"<<std::endl; rotNumSeed_ = iConfig.getParameter<int>("rotNumSeed"); fname_ = iConfig.getUntrackedParameter<std::string>("fileName"); if ( fname_ == "" ) { xos_ = &std::cout; } else { xos_ = new std::ofstream(fname_.c_str()); } (*xos_) << "<?xml version=\"1.0\"?>" << std::endl; (*xos_) << "<DDDefinition xmlns=\"https://www.cern.ch/cms/DDL\"" << std::endl; (*xos_) << " xmlns:xsi=\"https://www.w3.org/2001/XMLSchema-instance\"" << std::endl; (*xos_) << "xsi:schemaLocation=\"https://www.cern.ch/cms/DDL ../../../DetectorDescription/Schema/DDLSchema.xsd\">" << std::endl; (*xos_) << std::fixed << std::setprecision(18); }
OutputDDToDDL::~OutputDDToDDL | ( | ) |
Definition at line 46 of file OutputDDToDDL.cc.
References xos_.
{ (*xos_) << "</DDDefinition>" << std::endl; (*xos_) << std::endl; xos_->flush(); }
void OutputDDToDDL::addToMatStore | ( | const DDMaterial & | mat, |
std::set< DDMaterial > & | matStore | ||
) | [private] |
Definition at line 183 of file OutputDDToDDL.cc.
References DDMaterial::constituent(), cropTnPTrees::frac, and DDMaterial::noOfConstituents().
Referenced by beginRun().
{ matStore.insert(mat); if ( mat.noOfConstituents() != 0 ) { DDMaterial::FractionV::value_type frac; int findex(0); while ( findex < mat.noOfConstituents() ) { if ( matStore.find(mat.constituent(findex).first) == matStore.end() ) { addToMatStore( mat.constituent(findex).first, matStore ); } ++findex; } } }
void OutputDDToDDL::addToSolStore | ( | const DDSolid & | sol, |
std::set< DDSolid > & | solStore, | ||
std::set< DDRotation > & | rotStore | ||
) | [private] |
Definition at line 197 of file OutputDDToDDL.cc.
References ddintersection, ddsubtraction, ddunion, DDBooleanSolid::rotation(), DDSolid::shape(), DDBooleanSolid::solidA(), and DDBooleanSolid::solidB().
Referenced by beginRun().
{ solStore.insert(sol); if ( sol.shape() == ddunion || sol.shape() == ddsubtraction || sol.shape() == ddintersection ) { const DDBooleanSolid& bs (sol); if ( solStore.find(bs.solidA()) == solStore.end()) { addToSolStore(bs.solidA(), solStore, rotStore); } if ( solStore.find(bs.solidB()) == solStore.end()) { addToSolStore(bs.solidB(), solStore, rotStore); } rotStore.insert(bs.rotation()); } }
void OutputDDToDDL::addToSpecStore | ( | const DDLogicalPart & | lp, |
std::map< DDsvalues_type, std::set< DDPartSelection * >, ddsvaluesCmp > & | specStore | ||
) | [private] |
Definition at line 211 of file OutputDDToDDL.cc.
References DDLogicalPart::attachedSpecifics().
Referenced by beginRun().
{ std::vector<std::pair<DDPartSelection*, DDsvalues_type*> >::const_iterator spit(lp.attachedSpecifics().begin()), spend(lp.attachedSpecifics().end()); for ( ; spit != spend; ++spit ) { specStore[*spit->second].insert(spit->first); } }
virtual void OutputDDToDDL::analyze | ( | const edm::Event & | , |
const edm::EventSetup & | |||
) | [inline, virtual] |
void OutputDDToDDL::beginRun | ( | const edm::Run & | , |
edm::EventSetup const & | es | ||
) | [virtual] |
Reimplemented from edm::EDAnalyzer.
Definition at line 55 of file OutputDDToDDL.cc.
References addToMatStore(), addToSolStore(), addToSpecStore(), gather_cfg::cout, fname_, edm::EventSetup::get(), i, DDCoreToDDXMLOutput::logicalPart(), DDCoreToDDXMLOutput::material(), DDLogicalPart::material(), DDCoreToDDXMLOutput::ns_, dbtoconf::out, DDCoreToDDXMLOutput::position(), alignCSCRings::r, cmsRelvalreport::red(), DDCoreToDDXMLOutput::rotation(), rotNumSeed_, DDLogicalPart::solid(), DDCoreToDDXMLOutput::solid(), DDCoreToDDXMLOutput::specpar(), and xos_.
{ std::cout<<"OutputDDToDDL::beginRun"<<std::endl; edm::ESTransientHandle<DDCompactView> pDD; es.get<IdealGeometryRecord>().get( pDD ); DDCompactView::DDCompactView::graph_type gra = pDD->graph(); // temporary stores: std::set<DDLogicalPart> lpStore; std::set<DDMaterial> matStore; std::set<DDSolid> solStore; // 2009-08-19: MEC: I've tried this with set<DDPartSelection> and // had to write operator< for DDPartSelection and DDPartSelectionLevel // the output from such an effort is different than this one. std::map<DDsvalues_type, std::set<DDPartSelection*>, ddsvaluesCmp > specStore; std::set<DDRotation> rotStore; DDCoreToDDXMLOutput out; std::string rn = fname_; size_t foundLastDot= rn.find_last_of('.'); size_t foundLastSlash= rn.find_last_of('/'); if ( foundLastSlash > foundLastDot && foundLastSlash != std::string::npos) { std::cout << "What? last . before last / in path for filename... this should die..." << std::endl; } if ( foundLastDot != std::string::npos && foundLastSlash != std::string::npos ) { out.ns_ = rn.substr(foundLastSlash,foundLastDot); } else if ( foundLastDot != std::string::npos ) { out.ns_ = rn.substr(0, foundLastDot); } else { std::cout << "What? no file name? Attempt at namespace =\"" << out.ns_ << "\" filename was " << fname_ << std::endl; } std::cout << "fname_=" << fname_ << " namespace = " << out.ns_ << std::endl; std::string ns_ = out.ns_; (*xos_) << std::fixed << std::setprecision(18); typedef DDCompactView::graph_type::const_adj_iterator adjl_iterator; adjl_iterator git = gra.begin(); adjl_iterator gend = gra.end(); DDCompactView::graph_type::index_type i=0; (*xos_) << "<PosPartSection label=\"" << ns_ << "\">" << std::endl; git = gra.begin(); for (; git != gend; ++git) { const DDLogicalPart & ddLP = gra.nodeData(git); if ( lpStore.find(ddLP) != lpStore.end() ) { addToSpecStore(ddLP, specStore); } lpStore.insert(ddLP); addToMatStore( ddLP.material(), matStore ); addToSolStore( ddLP.solid(), solStore, rotStore ); ++i; if (git->size()) { // ask for children of ddLP DDCompactView::graph_type::edge_list::const_iterator cit = git->begin(); DDCompactView::graph_type::edge_list::const_iterator cend = git->end(); for (; cit != cend; ++cit) { const DDLogicalPart & ddcurLP = gra.nodeData(cit->first); if (lpStore.find(ddcurLP) != lpStore.end()) { addToSpecStore(ddcurLP, specStore); } lpStore.insert(ddcurLP); addToMatStore(ddcurLP.material(), matStore); addToSolStore(ddcurLP.solid(), solStore, rotStore); rotStore.insert(gra.edgeData(cit->second)->rot_); out.position(ddLP, ddcurLP, gra.edgeData(cit->second), rotNumSeed_, *xos_); } // iterate over children } // if (children) } // iterate over graph nodes // std::cout << "specStore.size() = " << specStore.size() << std::endl; (*xos_) << "</PosPartSection>" << std::endl; (*xos_) << std::scientific << std::setprecision(18); std::set<DDMaterial>::const_iterator it(matStore.begin()), ed(matStore.end()); (*xos_) << "<MaterialSection label=\"" << ns_ << "\">" << std::endl; for (; it != ed; ++it) { if (! it->isDefined().second) continue; out.material(*it, *xos_); } (*xos_) << "</MaterialSection>" << std::endl; (*xos_) << "<RotationSection label=\"" << ns_ << "\">" << std::endl; (*xos_) << std::fixed << std::setprecision(18); std::set<DDRotation>::iterator rit(rotStore.begin()), red(rotStore.end()); for (; rit != red; ++rit) { if (! rit->isDefined().second) continue; if ( rit->toString() != ":" ) { DDRotation r(*rit); out.rotation(r, *xos_); } } (*xos_) << "</RotationSection>" << std::endl; (*xos_) << std::fixed << std::setprecision(18); std::set<DDSolid>::const_iterator sit(solStore.begin()), sed(solStore.end()); (*xos_) << "<SolidSection label=\"" << ns_ << "\">" << std::endl; for (; sit != sed; ++sit) { if (! sit->isDefined().second) continue; out.solid(*sit, *xos_); } (*xos_) << "</SolidSection>" << std::endl; std::set<DDLogicalPart>::iterator lpit(lpStore.begin()), lped(lpStore.end()); (*xos_) << "<LogicalPartSection label=\"" << ns_ << "\">" << std::endl; for (; lpit != lped; ++lpit) { if (! lpit->isDefined().first) continue; const DDLogicalPart & lp = *lpit; out.logicalPart(lp, *xos_); } (*xos_) << "</LogicalPartSection>" << std::endl; (*xos_) << std::fixed << std::setprecision(18); std::map<DDsvalues_type, std::set<DDPartSelection*> >::const_iterator mit(specStore.begin()), mend (specStore.end()); (*xos_) << "<SpecParSection label=\"" << ns_ << "\">" << std::endl; for (; mit != mend; ++mit) { out.specpar ( *mit, *xos_ ); } (*xos_) << "</SpecParSection>" << std::endl; }
virtual void OutputDDToDDL::endJob | ( | void | ) | [inline, virtual] |
std::string OutputDDToDDL::fname_ [private] |
Definition at line 36 of file OutputDDToDDL.h.
Referenced by beginRun(), and OutputDDToDDL().
int OutputDDToDDL::rotNumSeed_ [private] |
Definition at line 35 of file OutputDDToDDL.h.
Referenced by beginRun(), and OutputDDToDDL().
int OutputDDToDDL::specNameCount_ [private] |
Definition at line 38 of file OutputDDToDDL.h.
std::ostream* OutputDDToDDL::xos_ [private] |
Definition at line 37 of file OutputDDToDDL.h.
Referenced by beginRun(), OutputDDToDDL(), and ~OutputDDToDDL().