47 void addToMatStore(
const DDMaterial& mat, std::set<DDMaterial> & matStore );
48 void addToSolStore(
const DDSolid& sol, std::set<DDSolid> & solStore, std::set<DDRotation>& rotStore );
59 if( sv1.size() < sv2.size())
return true;
60 if( sv2.size() < sv1.size())
return false;
62 for( ; ind < sv1.size(); ++ind )
64 if( sv1[ ind ].
first < sv2[ ind ].
first )
return true;
65 if( sv2[ ind ].first < sv1[ ind ].first )
return false;
67 if( sv2[ ind ].second < sv1[ ind ].second )
return false;
83 m_xos =
new std::ofstream( m_fname.c_str());
86 ( *m_xos ) <<
"<?xml version=\"1.0\"?>\n";
87 ( *m_xos ) <<
"<DDDefinition xmlns=\"http://www.cern.ch/cms/DDL\"\n";
88 ( *m_xos ) <<
" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"\n";
89 ( *m_xos ) <<
"xsi:schemaLocation=\"http://www.cern.ch/cms/DDL ../../../DetectorDescription/Schema/DDLSchema.xsd\">\n";
90 ( *m_xos ) <<
std::fixed << std::setprecision( 18 );
95 ( *m_xos ) <<
"</DDDefinition>\n";
96 ( *m_xos ) << std::endl;
103 edm::LogInfo(
"OutputMagneticFieldDDToDDL" ) <<
"OutputMagneticFieldDDToDDL::beginRun";
108 const auto& gra = pDD->
graph();
111 std::set<DDLogicalPart> lpStore;
112 std::set<DDMaterial> matStore;
113 std::set<DDSolid> solStore;
115 std::map<const DDsvalues_type, std::set<const DDPartSelection*>, ddsvaluesCmp > specStore;
116 std::set<DDRotation> rotStore;
121 size_t foundLastDot= rn.find_last_of(
'.');
122 size_t foundLastSlash= rn.find_last_of(
'/');
124 if( foundLastSlash > foundLastDot && foundLastSlash != std::string::npos )
126 edm::LogError(
"OutputMagneticFieldDDToDDL" ) <<
"What? last . before last / in path for filename... this should die...";
128 if( foundLastDot != std::string::npos && foundLastSlash != std::string::npos )
130 out.
ns_ = rn.substr( foundLastSlash, foundLastDot );
132 else if ( foundLastDot != std::string::npos )
134 out.
ns_ = rn.substr(0, foundLastDot);
138 edm::LogError(
"OutputMagneticFieldDDToDDL" ) <<
"What? no file name? Attempt at namespace =\"" << out.
ns_ <<
"\" filename was " <<
m_fname;
144 ( *m_xos ) <<
std::fixed << std::setprecision( 18 );
153 ( *m_xos) <<
"<PosPartSection label=\"" << ns_ <<
"\">\n";
155 for( ; git != gend; ++git )
158 if( lpStore.find(ddLP) != lpStore.end())
162 lpStore.insert( ddLP );
169 auto cit = git->begin();
170 auto cend = git->end();
171 for( ; cit != cend; ++cit )
174 if( lpStore.find(ddcurLP) != lpStore.end())
178 lpStore.insert( ddcurLP );
181 rotStore.insert( gra.edgeData( cit->second )->ddrot() );
187 ( *m_xos ) <<
"</PosPartSection>\n";
189 ( *m_xos ) << std::scientific << std::setprecision( 18 );
190 std::set<DDMaterial>::const_iterator it( matStore.begin()), ed( matStore.end());
191 ( *m_xos) <<
"<MaterialSection label=\"" << ns_ <<
"\">\n";
192 for( ; it != ed; ++it )
194 if( ! it->isDefined().second )
continue;
197 ( *m_xos ) <<
"</MaterialSection>\n";
199 ( *m_xos ) <<
"<RotationSection label=\"" << ns_ <<
"\">\n";
200 ( *m_xos ) <<
std::fixed << std::setprecision( 18 );
201 std::set<DDRotation>::iterator rit( rotStore.begin()),
red( rotStore.end());
202 for( ; rit !=
red; ++rit )
204 if( ! rit->isDefined().second )
continue;
205 if( rit->toString() !=
":" )
211 ( *m_xos ) <<
"</RotationSection>\n";
213 ( *m_xos ) <<
std::fixed << std::setprecision( 18 );
214 std::set<DDSolid>::const_iterator sit( solStore.begin()), sed( solStore.end());
215 ( *m_xos ) <<
"<SolidSection label=\"" << ns_ <<
"\">\n";
216 for( ; sit != sed; ++sit)
218 if( ! sit->isDefined().second )
continue;
221 ( *m_xos ) <<
"</SolidSection>\n";
223 std::set<DDLogicalPart>::iterator lpit( lpStore.begin()), lped( lpStore.end());
224 ( *m_xos ) <<
"<LogicalPartSection label=\"" << ns_ <<
"\">\n";
225 for( ; lpit != lped; ++lpit )
227 if( ! lpit->isDefined().first )
continue;
231 ( *m_xos ) <<
"</LogicalPartSection>\n";
233 ( *m_xos ) <<
std::fixed << std::setprecision( 18 );
234 std::map<DDsvalues_type, std::set<const DDPartSelection*> >::const_iterator mit( specStore.begin()), mend( specStore.end());
235 ( *m_xos ) <<
"<SpecParSection label=\"" << ns_ <<
"\">\n";
236 for( ; mit != mend; ++mit )
240 ( *m_xos ) <<
"</SpecParSection>\n";
246 matStore.insert( mat );
253 if( matStore.find( mat.
constituent( findex ).first ) == matStore.end())
265 solStore.insert( sol );
269 if( solStore.find(bs.
solidA()) == solStore.end())
273 if( solStore.find( bs.
solidB()) == solStore.end())
286 for( ; spit != spend; ++spit )
288 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
std::vector< double >::size_type index_type
void beginRun(edm::Run const &iEvent, edm::EventSetup const &) override
DDMaterial is used to define and access material information.
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.
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)
void analyze(edm::Event const &iEvent, edm::EventSetup const &) override
#define DEFINE_FWK_MODULE(type)
Container::value_type value_type
DDRotation rotation(void) const
void position(const DDLogicalPart &parent, const DDLogicalPart &child, DDPosData *edgeToChild, int &rotNameSeed, std::ostream &xos)
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)
Graph::const_adj_iterator adjl_iterator
~OutputMagneticFieldDDToDDL(void) override
DDSolid solidA(void) const
const Graph & graph() const
Provides read-only access to the data structure of the compact-view.
int noOfConstituents() const
returns the number of compound materials or 0 for elementary materials
OutputMagneticFieldDDToDDL(const edm::ParameterSet &iConfig)
std::vector< std::pair< unsigned int, DDValue > > DDsvalues_type
void material(const DDMaterial &material, std::ostream &xos)
math::Graph< DDLogicalPart, DDPosData * > Graph
void endRun(edm::Run const &iEvent, edm::EventSetup const &) override
adj_list::const_iterator const_adj_iterator
void rotation(const DDRotation &rotation, std::ostream &xos, const std::string &rotn="")
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.