16 #include "CLHEP/Units/GlobalSystemOfUnits.h"
25 if ( sv1.size() < sv2.size() )
return true;
26 if ( sv2.size() < sv1.size() )
return false;
28 for (; ind < sv1.size(); ++ind) {
29 if ( sv1[ind].
first < sv2[ind].
first )
return true;
30 if ( sv2[ind].first < sv1[ind].first )
return false;
32 if ( sv2[ind].second < sv1[ind].second )
return false;
45 xos_ =
new std::ofstream(fname_.c_str());
47 (*xos_) <<
"<?xml version=\"1.0\"?>" << std::endl;
48 (*xos_) <<
"<DDDefinition xmlns=\"http://www.cern.ch/cms/DDL\"" << std::endl;
49 (*xos_) <<
" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"" << std::endl;
50 (*xos_) <<
"xsi:schemaLocation=\"http://www.cern.ch/cms/DDL ../../../DetectorDescription/Schema/DDLSchema.xsd\">" << std::endl;
51 (*xos_) << std::fixed << std::setprecision(18);
55 (*xos_) <<
"</DDDefinition>" << std::endl;
64 std::cout<<
"OutputDDToDDL::beginRun"<<std::endl;
70 DDCompactView::DDCompactView::graph_type gra = pDD->graph();
72 std::set<DDLogicalPart> lpStore;
73 std::set<DDMaterial> matStore;
74 std::set<DDSolid> solStore;
78 std::map<DDsvalues_type, std::set<DDPartSelection*>,
ddsvaluesCmp > specStore;
79 std::set<DDRotation> rotStore;
84 size_t foundLastDot= rn.find_last_of(
'.');
85 size_t foundLastSlash= rn.find_last_of(
'/');
86 if ( foundLastSlash > foundLastDot && foundLastSlash != std::string::npos) {
87 std::cout <<
"What? last . before last / in path for filename... this should die..." << std::endl;
89 if ( foundLastDot != std::string::npos && foundLastSlash != std::string::npos ) {
90 out.
ns_ = rn.substr(foundLastSlash,foundLastDot);
91 }
else if ( foundLastDot != std::string::npos ) {
92 out.
ns_ = rn.substr(0, foundLastDot);
94 std::cout <<
"What? no file name? Attempt at namespace =\"" << out.
ns_ <<
"\" filename was " <<
fname_ << std::endl;
97 std::string ns_ = out.
ns_;
99 (*xos_) << std::fixed << std::setprecision(18);
102 adjl_iterator git = gra.begin();
103 adjl_iterator gend = gra.end();
106 (*xos_) <<
"<PosPartSection label=\"" << ns_ <<
"\">" << std::endl;
108 for (; git != gend; ++git)
111 if ( lpStore.find(ddLP) != lpStore.end() ) {
114 lpStore.insert(ddLP);
121 DDCompactView::graph_type::edge_list::const_iterator cit = git->begin();
122 DDCompactView::graph_type::edge_list::const_iterator cend = git->end();
123 for (; cit != cend; ++cit)
126 if (lpStore.find(ddcurLP) != lpStore.end()) {
129 lpStore.insert(ddcurLP);
132 rotStore.insert(gra.edgeData(cit->second)->rot_);
139 (*xos_) <<
"</PosPartSection>" << std::endl;
141 (*xos_) << std::scientific << std::setprecision(18);
142 std::set<DDMaterial>::const_iterator it(matStore.begin()), ed(matStore.end());
143 (*xos_) <<
"<MaterialSection label=\"" << ns_ <<
"\">" << std::endl;
144 for (; it != ed; ++it) {
145 if (! it->isDefined().second)
continue;
148 (*xos_) <<
"</MaterialSection>" << std::endl;
150 (*xos_) <<
"<RotationSection label=\"" << ns_ <<
"\">" << std::endl;
151 (*xos_) << std::fixed << std::setprecision(18);
152 std::set<DDRotation>::iterator rit(rotStore.begin()),
red(rotStore.end());
153 for (; rit !=
red; ++rit) {
154 if (! rit->isDefined().second)
continue;
155 if ( rit->toString() !=
":" ) {
160 (*xos_) <<
"</RotationSection>" << std::endl;
162 (*xos_) << std::fixed << std::setprecision(18);
163 std::set<DDSolid>::const_iterator sit(solStore.begin()), sed(solStore.end());
164 (*xos_) <<
"<SolidSection label=\"" << ns_ <<
"\">" << std::endl;
165 for (; sit != sed; ++sit) {
166 if (! sit->isDefined().second)
continue;
169 (*xos_) <<
"</SolidSection>" << std::endl;
171 std::set<DDLogicalPart>::iterator lpit(lpStore.begin()), lped(lpStore.end());
172 (*xos_) <<
"<LogicalPartSection label=\"" << ns_ <<
"\">" << std::endl;
173 for (; lpit != lped; ++lpit) {
174 if (! lpit->isDefined().first)
continue;
178 (*xos_) <<
"</LogicalPartSection>" << std::endl;
180 (*xos_) << std::fixed << std::setprecision(18);
181 std::map<DDsvalues_type, std::set<DDPartSelection*> >::const_iterator mit(specStore.begin()), mend (specStore.end());
182 (*xos_) <<
"<SpecParSection label=\"" << ns_ <<
"\">" << std::endl;
183 for (; mit != mend; ++mit) {
186 (*xos_) <<
"</SpecParSection>" << std::endl;
191 matStore.insert(mat);
196 if ( matStore.find(mat.
constituent(findex).first) == matStore.end() ) {
205 solStore.insert(sol);
208 if ( solStore.find(bs.
solidA()) == solStore.end()) {
211 if ( solStore.find(bs.
solidB()) == solStore.end()) {
220 for ( ; spit != spend; ++spit ) {
221 specStore[*spit->second].insert(spit->first);
T getParameter(std::string const &) const
T getUntrackedParameter(std::string const &, T const &) const
void rotation(DDRotation &rotation, std::ostream &xos, const std::string &rotn="")
DDSolidShape shape() const
The type of the solid.
DDMaterial is used to define and access material information.
#define DEFINE_FWK_MODULE(type)
void addToMatStore(const DDMaterial &mat, std::set< DDMaterial > &matStore)
void addToSpecStore(const DDLogicalPart &lp, std::map< DDsvalues_type, std::set< DDPartSelection * >, ddsvaluesCmp > &specStore)
void specpar(const DDSpecifics &sp, std::ostream &xos)
Container::value_type value_type
std::vector< double >::size_type index_type
void addToSolStore(const DDSolid &sol, std::set< DDSolid > &solStore, std::set< DDRotation > &rotStore)
const DDMaterial & material() const
Returns a reference object of the material this LogicalPart is made of.
A DDSolid represents the shape of a part.
Represents a uniquely identifyable rotation matrix.
U second(std::pair< T, U > const &p)
const std::vector< std::pair< DDPartSelection *, DDsvalues_type * > > & attachedSpecifics() const
void position(const DDLogicalPart &parent, const DDLogicalPart &child, DDPosData *edgeToChild, int &rotNameSeed, std::ostream &xos)
bool operator()(const DDsvalues_type &sv1, const DDsvalues_type &sv2)
std::vector< std::pair< unsigned int, DDValue > > DDsvalues_type
std::maps an index to a DDValue. The index corresponds to the index assigned to the name of the std::...
FractionV::value_type constituent(int i) const
returns the i-th compound material and its fraction-mass
A DDLogicalPart aggregates information concerning material, solid and sensitveness ...
void logicalPart(const DDLogicalPart &lp, std::ostream &xos)
int noOfConstituents() const
returns the number of compound materials or 0 for elementary materials
OutputDDToDDL(const edm::ParameterSet &iConfig)
adj_list::const_iterator const_adj_iterator
const DDSolid & solid() const
Returns a reference object of the solid being the shape of this LogicalPart.
void material(const DDMaterial &material, std::ostream &xos)
DDRotation rotation() const
void solid(const DDSolid &solid, std::ostream &xos)
virtual void beginRun(const edm::Run &, edm::EventSetup const &)