20 if( sv1.size() < sv2.size())
return true;
21 if( sv2.size() < sv1.size())
return false;
23 for( ; ind < sv1.size(); ++ind )
25 if( sv1[ ind ].
first < sv2[ ind ].
first )
return true;
26 if( sv2[ ind ].first < sv1[ ind ].first )
return false;
28 if( sv2[ ind ].second < sv1[ ind ].second )
return false;
44 m_xos =
new std::ofstream( m_fname.c_str());
47 ( *m_xos ) <<
"<?xml version=\"1.0\"?>\n";
48 ( *m_xos ) <<
"<DDDefinition xmlns=\"http://www.cern.ch/cms/DDL\"\n";
49 ( *m_xos ) <<
" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"\n";
50 ( *m_xos ) <<
"xsi:schemaLocation=\"http://www.cern.ch/cms/DDL ../../../DetectorDescription/Schema/DDLSchema.xsd\">\n";
51 ( *m_xos ) << std::fixed << std::setprecision( 18 );
56 ( *m_xos ) <<
"</DDDefinition>\n";
57 ( *m_xos ) << std::endl;
64 edm::LogInfo(
"OutputMagneticFieldDDToDDL" ) <<
"OutputMagneticFieldDDToDDL::beginRun";
69 DDCompactView::DDCompactView::graph_type gra = pDD->graph();
72 std::set<DDLogicalPart> lpStore;
73 std::set<DDMaterial> matStore;
74 std::set<DDSolid> solStore;
76 std::map<const DDsvalues_type, std::set<const DDPartSelection*>, ddsvaluesCmp > specStore;
77 std::set<DDRotation> rotStore;
82 size_t foundLastDot= rn.find_last_of(
'.');
83 size_t foundLastSlash= rn.find_last_of(
'/');
85 if( foundLastSlash > foundLastDot && foundLastSlash != std::string::npos )
87 edm::LogError(
"OutputMagneticFieldDDToDDL" ) <<
"What? last . before last / in path for filename... this should die...";
89 if( foundLastDot != std::string::npos && foundLastSlash != std::string::npos )
91 out.
ns_ = rn.substr( foundLastSlash, foundLastDot );
93 else if ( foundLastDot != std::string::npos )
95 out.
ns_ = rn.substr(0, foundLastDot);
99 edm::LogError(
"OutputMagneticFieldDDToDDL" ) <<
"What? no file name? Attempt at namespace =\"" << out.
ns_ <<
"\" filename was " <<
m_fname;
105 ( *m_xos ) << std::fixed << std::setprecision( 18 );
109 adjl_iterator git = gra.begin();
110 adjl_iterator gend = gra.end();
113 ( *m_xos) <<
"<PosPartSection label=\"" << ns_ <<
"\">\n";
115 for( ; git != gend; ++git )
118 if( lpStore.find(ddLP) != lpStore.end())
122 lpStore.insert( ddLP );
129 DDCompactView::graph_type::edge_list::const_iterator cit = git->begin();
130 DDCompactView::graph_type::edge_list::const_iterator cend = git->end();
131 for( ; cit != cend; ++cit )
134 if( lpStore.find(ddcurLP) != lpStore.end())
138 lpStore.insert( ddcurLP );
141 rotStore.insert( gra.edgeData( cit->second )->rot_ );
147 ( *m_xos ) <<
"</PosPartSection>\n";
149 ( *m_xos ) << std::scientific << std::setprecision( 18 );
150 std::set<DDMaterial>::const_iterator it( matStore.begin()), ed( matStore.end());
151 ( *m_xos) <<
"<MaterialSection label=\"" << ns_ <<
"\">\n";
152 for( ; it != ed; ++it )
154 if( ! it->isDefined().second )
continue;
157 ( *m_xos ) <<
"</MaterialSection>\n";
159 ( *m_xos ) <<
"<RotationSection label=\"" << ns_ <<
"\">\n";
160 ( *m_xos ) << std::fixed << std::setprecision( 18 );
161 std::set<DDRotation>::iterator rit( rotStore.begin()),
red( rotStore.end());
162 for( ; rit !=
red; ++rit )
164 if( ! rit->isDefined().second )
continue;
165 if( rit->toString() !=
":" )
171 ( *m_xos ) <<
"</RotationSection>\n";
173 ( *m_xos ) << std::fixed << std::setprecision( 18 );
174 std::set<DDSolid>::const_iterator sit( solStore.begin()), sed( solStore.end());
175 ( *m_xos ) <<
"<SolidSection label=\"" << ns_ <<
"\">\n";
176 for( ; sit != sed; ++sit)
178 if( ! sit->isDefined().second )
continue;
181 ( *m_xos ) <<
"</SolidSection>\n";
183 std::set<DDLogicalPart>::iterator lpit( lpStore.begin()), lped( lpStore.end());
184 ( *m_xos ) <<
"<LogicalPartSection label=\"" << ns_ <<
"\">\n";
185 for( ; lpit != lped; ++lpit )
187 if( ! lpit->isDefined().first )
continue;
191 ( *m_xos ) <<
"</LogicalPartSection>\n";
193 ( *m_xos ) << std::fixed << std::setprecision( 18 );
194 std::map<DDsvalues_type, std::set<const DDPartSelection*> >::const_iterator mit( specStore.begin()), mend( specStore.end());
195 ( *m_xos ) <<
"<SpecParSection label=\"" << ns_ <<
"\">\n";
196 for( ; mit != mend; ++mit )
200 ( *m_xos ) <<
"</SpecParSection>\n";
206 matStore.insert( mat );
213 if( matStore.find( mat.
constituent( findex ).first ) == matStore.end())
225 solStore.insert( sol );
229 if( solStore.find(bs.
solidA()) == solStore.end())
233 if( solStore.find( bs.
solidB()) == solStore.end())
245 for( ; spit != spend; ++spit )
247 specStore[ *spit->second ].insert( spit->first );
T getParameter(std::string const &) const
void addToSpecStore(const DDLogicalPart &lp, std::map< const DDsvalues_type, std::set< const DDPartSelection * >, ddsvaluesCmp > &specStore)
T getUntrackedParameter(std::string const &, T const &) const
void rotation(DDRotation &rotation, std::ostream &xos, const std::string &rotn="")
void beginRun(edm::Run const &iEvent, edm::EventSetup const &) override
DDMaterial is used to define and access material information.
#define DEFINE_FWK_MODULE(type)
void specpar(const DDSpecifics &sp, std::ostream &xos)
void addToMatStore(const DDMaterial &mat, std::set< DDMaterial > &matStore)
const DDSolid & solid(void) const
Returns a reference object of the solid being the shape of this LogicalPart.
std::vector< double >::size_type index_type
~OutputMagneticFieldDDToDDL(void)
A DDSolid represents the shape of a part.
DDSolid solidB(void) const
Represents a uniquely identifyable rotation matrix.
U second(std::pair< T, U > const &p)
DDRotation rotation(void) const
void position(const DDLogicalPart &parent, const DDLogicalPart &child, DDPosData *edgeToChild, int &rotNameSeed, std::ostream &xos)
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 ...
DDSolidShape shape(void) const
The type of the solid.
void addToSolStore(const DDSolid &sol, std::set< DDSolid > &solStore, std::set< DDRotation > &rotStore)
void logicalPart(const DDLogicalPart &lp, std::ostream &xos)
Container::value_type value_type
DDSolid solidA(void) const
int noOfConstituents() const
returns the number of compound materials or 0 for elementary materials
OutputMagneticFieldDDToDDL(const edm::ParameterSet &iConfig)
adj_list::const_iterator const_adj_iterator
void material(const DDMaterial &material, std::ostream &xos)
void solid(const DDSolid &solid, std::ostream &xos)
const std::vector< std::pair< const DDPartSelection *, const DDsvalues_type * > > & attachedSpecifics(void) const
const DDMaterial & material(void) const
Returns a reference object of the material this LogicalPart is made of.