Streaming the DDD transient store from/into a std::istream/std::ostream */. More...
#include <DDStreamer.h>
Public Member Functions | |
DDStreamer () | |
constructs a streamer object with yet undefined std::istream and std::ostream | |
DDStreamer (std::istream &readFrom) | |
creates a streamer object for reading | |
DDStreamer (std::ostream &writeTo) | |
creates a streamer object for writing | |
void | read (std::istream &is) |
populate DDD transient objects from the given std::istream is | |
void | read () |
populate DDD transient objects from the std::istream refetrred to by member i_ | |
void | setInput (std::istream &i) |
set the istream for DDStreamer::read() | |
void | setOutput (std::ostream &o) |
set the std::ostream for DDStreamer::write() | |
void | write () |
stream all DDD transient objects to the std::ostream referred to by member o_ | |
void | write (std::ostream &os) |
stream all DDD transient objects to the given std::ostream os | |
virtual | ~DDStreamer () |
does nothing; usefull only if another streamer derives from DDStreamer | |
Protected Member Functions | |
void | materials_read () |
read all instances of DDMaterial | |
void | materials_write () |
write all instances of DDMaterial | |
void | names_read () |
read all instances of DDName | |
void | names_write () |
write all instances of DDName | |
void | parts_read () |
read all instances of DDLogicalPart | |
void | parts_write () |
write all instances of DDLogicalPart | |
void | pos_read () |
read the graph structure for DDCompactView::graph() | |
void | pos_write () |
write the graph structure of DDCompactView::graph() | |
void | rots_read () |
read all instances of DDRotation | |
void | rots_write () |
write all instances of DDRotation | |
void | solids_read () |
read all instances of DDSolid | |
void | solids_write () |
write all instances of DDSolid | |
void | specs_read () |
read all instances of | |
void | specs_write () |
write all instances of DDSpecifics | |
void | vars_read () |
read the dictionlary of ClhepEvaluator | |
void | vars_write () |
write the dictionary of ClhepEvaluator | |
Private Attributes | |
const DDCompactView * | cpv_ |
std::istream * | i_ |
std::ostream * | o_ |
Streaming the DDD transient store from/into a std::istream/std::ostream */.
DDStreamer can be used to write the DDD transient object into a std::ostram and to retrieve them again via an std::istream.
The streamer can also be used together with DDLParser. Once possible usage scenario would be to load most of the geometrical DDD information via the streamer and parse some addional DDD XML documents containing SpecPar-information using DDLParser.
If DDStreamer is used together with DDLParser, the user has to ensure that reading in via DDStreamer::read() is done BEFORE invoking DDLParser to guarantee internal consistensies of the DDD objects.
// writing: #include<fstream> std::ofstream file("pers.txt"); DDStreamer streamer(file); streamer.write(); // reading: #include<fstream> std::ifstream file("pers.txt"); DDStreamer streamer(filer); streamer.read();
Definition at line 41 of file DDStreamer.h.
DDStreamer::DDStreamer | ( | ) |
constructs a streamer object with yet undefined std::istream and std::ostream
Definition at line 21 of file DDStreamer.cc.
DDStreamer::DDStreamer | ( | std::istream & | readFrom | ) |
creates a streamer object for reading
Definition at line 37 of file DDStreamer.cc.
: cpv_(0), o_(0), i_(0) { if (is) { i_ = &is; } else { throw cms::Exception("DDException") << "DDStreamer::DDStreamer(std::ostream&): not valid std::ostream"; } }
DDStreamer::DDStreamer | ( | std::ostream & | writeTo | ) |
creates a streamer object for writing
Definition at line 26 of file DDStreamer.cc.
: cpv_(0), o_(0), i_(0) { if (os) { o_ = &os; } else { throw cms::Exception("DDException") << "DDStreamer::DDStreamer(std::ostream&): not valid std::ostream"; } }
DDStreamer::~DDStreamer | ( | ) | [virtual] |
does nothing; usefull only if another streamer derives from DDStreamer
Definition at line 48 of file DDStreamer.cc.
{}
void DDStreamer::materials_read | ( | ) | [protected] |
read all instances of DDMaterial
Definition at line 284 of file DDStreamer.cc.
References a, DDMaterial::addMaterial(), DCOUT, dd_get_name(), i, i_, j, m, n, DDBase< N, C >::name(), and z.
Referenced by read().
{ DCOUT('Y', "DDStreamer::materials_read()"); std::istream & is = *i_; //DDMaterial::clear(); size_t n=0; is >> n; size_t i=0; for (; i < n; ++i) { // Materials is.ignore(1000,'@'); DDName dn = dd_get_name(is); double z(0), a(0), d(0); is >> z; is >> a; is >> d; int comp(0); is >> comp; // composites if (comp) { // composite material DDMaterial m(dn,d); DCOUT('y', "read-comp-material=" << m.name()); int j=0; for(; j<comp; ++j) { DDName cname(dd_get_name(is)); double fm(0); is >> fm; DDMaterial constituent(cname); DCOUT('y', " read-composite=" << constituent.name()); m.addMaterial(constituent,fm); } } else { // elementary material DDMaterial m(dn,z,a,d); DCOUT('y', "read-elem-material=" << m.name()); } } }
void DDStreamer::materials_write | ( | ) | [protected] |
write all instances of DDMaterial
Definition at line 255 of file DDStreamer.cc.
References DDMaterial::a(), DDBase< DDName, DDI::Material * >::begin(), DDMaterial::constituent(), DCOUT, dd_count(), DDMaterial::density(), DDBase< DDName, DDI::Material * >::end(), j, m, DDBase< N, C >::name(), nameout(), DDMaterial::noOfConstituents(), o_, and DDMaterial::z().
Referenced by write().
{ DCOUT('Y', "DDStreamer::materials_write()"); std::ostream & os = *o_; DDMaterial::iterator<DDMaterial> it(DDMaterial::begin()), ed(DDMaterial::end()); size_t no = dd_count(DDMaterial()); os << no << std::endl; for (; it != ed; ++it) { if (! it->isDefined().second) continue; const DDMaterial & m = *it; os << "--Material: " << m.name() << " @ " ; nameout(os,m.name()); DCOUT('y', "write-material=" << m.name()); os << ' ' << m.z() << ' ' << m.a() << ' ' << m.density() << ' '; int noc = m.noOfConstituents(); os << noc; int j=0; for (; j<noc; ++j) { DCOUT('y', " write-const-material=" << m.constituent(j).first.name()); os << ' '; nameout(os,m.constituent(j).first.name()); os << ' ' << m.constituent(j).second; } os << std::endl; } }
void DDStreamer::names_read | ( | ) | [protected] |
read all instances of DDName
Definition at line 189 of file DDStreamer.cc.
References DCOUT, dd_get_delimit(), DDName::defineId(), i, i_, errorMatrix2Lands_multiChannel::id, instance, and alignCSCRings::s.
Referenced by read().
{ DCOUT('Y', "DDStreamer::names_read()"); std::istream & is = *i_; DDName::IdToName & ids = DDI::Singleton<DDName::IdToName>::instance(); DDName::Registry & reg = DDI::Singleton<DDName::Registry>::instance(); size_t s; is >> s; ids.clear(); //ids.resize(s); reg.clear(); size_t i(0); //std::string nm; getline(is,nm); for (; i<s; ++i) { std::string nm(dd_get_delimit(is,'"')); std::string ns(dd_get_delimit(is,'"')); size_t id(0); is >> id; DDName::defineId(std::make_pair(nm,ns),id); } }
void DDStreamer::names_write | ( | ) | [protected] |
write all instances of DDName
Definition at line 170 of file DDStreamer.cc.
References prof2calltree::count, DCOUT, instance, and o_.
Referenced by write().
{ DCOUT('Y', "DDStreamer::names_write()"); std::ostream & os = *o_; DDName::IdToName & ids = DDI::Singleton<DDName::IdToName>::instance(); DDName::IdToName::const_iterator it(ids.begin()), ed(ids.end()); os << ids.size() << std::endl; size_t count(0); for (; it != ed; ++it) { os << '"' << (*it)->first.first << '"' << ' ' << '"' << (*it)->first.second << '"' << ' ' << count << std::endl; ++count; } }
void DDStreamer::parts_read | ( | ) | [protected] |
read all instances of DDLogicalPart
Definition at line 513 of file DDStreamer.cc.
References cmsDownloadME::cat, DCOUT, dd_get_name(), i, i_, and n.
Referenced by read().
{ DCOUT('Y', "DDStreamer::parts_read()"); std::istream & is = *i_; //DDLogicalPart::clear(); size_t n=0; is >> n; size_t i=0; for (; i < n; ++i) { // LogicalParts is.ignore(1000,'@'); DDName dn = dd_get_name(is); size_t cat(0); is >> cat; DDEnums::Category categ = DDEnums::Category(cat); DDName mat = dd_get_name(is); DDName sol = dd_get_name(is); DDLogicalPart lp(dn,mat,sol,categ); DCOUT('y', "read-lp=" << lp); } }
void DDStreamer::parts_write | ( | ) | [protected] |
write all instances of DDLogicalPart
Definition at line 492 of file DDStreamer.cc.
References DDBase< DDName, DDI::LogicalPart * >::begin(), DDLogicalPart::category(), DCOUT, dd_count(), DDBase< DDName, DDI::LogicalPart * >::end(), DDLogicalPart::material(), DDBase< N, C >::name(), nameout(), o_, and DDLogicalPart::solid().
Referenced by write().
{ DCOUT('Y', "DDStreamer::parts_write()"); std::ostream & os = *o_; DDLogicalPart::iterator<DDLogicalPart> it(DDLogicalPart::begin()), ed(DDLogicalPart::end()); size_t no = dd_count(DDLogicalPart()); os << no << std::endl; for (; it != ed; ++it) { if (! it->isDefined().second) continue; const DDLogicalPart & lp = *it; os << "--Part: " << lp.name() << " @ "; nameout(os,lp.name()); os << ' ' << lp.category() << ' '; nameout(os,lp.material().name()); os << ' '; nameout(os,lp.solid().name()); os << std::endl; } }
void DDStreamer::pos_read | ( | ) | [protected] |
read the graph structure for DDCompactView::graph()
Definition at line 675 of file DDStreamer.cc.
References CommonMethods::cp(), DCOUT, dd_get_name(), dd_rot_bin_in(), DDanonymousRot(), Exception, Capri::details::from(), g, DDCompactView::graph(), i, i_, instance, makeMuonMisalignmentScenario::matrix, python::rootplot::argparse::message, n, DDBase< N, C >::name(), DDCompactView::position(), dbtoconf::root, makeMuonMisalignmentScenario::rot, graph< N, E >::size(), lumiQTWidget::t, x, detailsBasic3DVector::y, and z.
Referenced by read().
{ DCOUT('Y', "DDStreamer::pos_read()"); std::istream & is = *i_; is.ignore(1000,'@'); DDName rtname = dd_get_name(is); DDLogicalPart root(rtname); DCOUT('y', "root is: " << root.name()); DDRootDef::instance().set(root); size_t n=0; is >> n; size_t i=0; DDCompactView cpv; DDCompactView::graph_type & g = const_cast<DDCompactView::graph_type&>(cpv.graph()); // DDPositioner pos_(&cpv); //LogDebug << "===== GRAPH SIZE = " << g.size() << " ======" << std::endl << std::endl; if (g.size()) { edm::LogWarning("DDStreamer") << std::endl; edm::LogWarning("DDStreamer") << "DDStreamer::pos_read(): The CompactView already contains some position information." << std::endl << " It may cause an inconsistent geometry representation!" << std::endl << std::endl; throw cms::Exception("DDException") << "DDStreamer::pos_read() failed; CompactView has already been populated by another data source"; } for (; i < n; ++i) { // Positions is.ignore(1000,'@'); DDName from(dd_get_name(is)); DDName to(dd_get_name(is)); std::string cp; is >> cp; char cr = is.get(); if (cr != ' ') throw cms::Exception("DDException") << "DDStreamer::pos_read(): inconsistent sequence! no blank delimiter found!"; //double x,y,z; B x,y,z; is >> x; is >> y; is >> z; DDTranslation t(x.val_,y.val_,z.val_); is.ignore(); char rottype = is.get(); DDRotationMatrix * matrix(0); //DDName rotname; DDRotation rot; switch(rottype) { case 'a': // anonymous rotation is.ignore(); matrix = new DDRotationMatrix; dd_rot_bin_in(is,*matrix); rot = DDanonymousRot(matrix); break; case 'u': // unit rotation break; case 'r': // regular (named) rotation rot = DDRotation(dd_get_name(is)); break; default: std::string message = "DDStreamer::pos_read(): could not determine type of rotation\n"; throw cms::Exception("DDException") << message; } //DDName rot(dd_get_name(is)); cpv.position(DDLogicalPart(to),DDLogicalPart(from),cp,t,rot); DCOUT('y', " pos-read: f=" << from << " to=" << to << " t=" << t << " r=" << rot); } }
void DDStreamer::pos_write | ( | ) | [protected] |
write the graph structure of DDCompactView::graph()
Definition at line 609 of file DDStreamer.cc.
References graph< N, E >::begin_iter(), prof2calltree::count, DCOUT, dd_rot_bin_out(), graph< N, E >::end_iter(), g, DDCompactView::graph(), instance, DDBase< N, C >::name(), nameout(), and o_.
Referenced by write().
{ DCOUT('Y', "DDStreamer::pos_write()"); DDCompactView cpv; const DDCompactView::graph_type & g = cpv.graph(); DDCompactView::graph_type::const_iterator it = g.begin_iter(); DDCompactView::graph_type::const_iterator ed = g.end_iter(); std::ostream & os = *o_; // first the root DDLogicalPart rt = DDRootDef::instance().root(); os << "--Root: @ "; nameout(os,rt.name()); os << std::endl; //os << g.edge_size() << std::endl; DDCompactView::graph_type::const_iterator iit = g.begin_iter(); DDCompactView::graph_type::const_iterator eed = g.end_iter(); size_t count(0); for(; iit != eed; ++iit) { ++count; } os << count << std::endl; count=0; DDName unit_rot_name; DDRotationMatrix unit_rot; for(; it != ed; ++it) { os << "--Pos[" << count << "]: @ "; ++count; //const DDLogicalPart & fr = it->from(); nameout(os, it->from().name()); os << ' '; nameout(os, it->to().name()); os << ' ' << it->edge()->copyno_; const DDTranslation & tr = it->edge()->translation(); //os << ' ' << B(tr.x()) << ' ' << B(tr.y()) << ' ' << B(tr.z()); os << ' ' << B(tr.x()) << B(tr.y()) << B(tr.z()); const DDRotation & ro = it->edge()->rot_; os << ' '; /* if it's an anonymous rotation stemming from an AlgoPosPart then it's id must be the one of a unit rotation AND it must be defined at this point AND it must not be the unit rotation. A character identifier is issues to mark the type of the rotation: a ... anonymous rotation, followed by the binary numbers of the matrix u ... unit-rotation matrix, no values following r ... regular defined rotation-matrix (named rotation matrix) followed by name-id */ if (ro.name() == unit_rot_name) { if(ro.isDefined().second) { if(*(ro.rotation()) != unit_rot) { os << "a "; dd_rot_bin_out(os,*(ro.rotation())); } else { os << "u "; } } } else { os << "r "; nameout(os, ro.name()); } os << std::endl; } }
void DDStreamer::read | ( | std::istream & | is | ) |
populate DDD transient objects from the given std::istream is
Definition at line 153 of file DDStreamer.cc.
References i_, materials_read(), names_read(), parts_read(), pos_read(), rots_read(), solids_read(), specs_read(), and vars_read().
{ i_=&is; names_read(); vars_read(); materials_read(); solids_read(); parts_read(); pos_read(); specs_read(); rots_read(); }
void DDStreamer::read | ( | ) |
populate DDD transient objects from the std::istream refetrred to by member i_
Definition at line 120 of file DDStreamer.cc.
{ if (i_ && *i_) { read(*i_); } else { throw cms::Exception("DDException") << "DDStreamer::read(): bad std::istream"; } }
void DDStreamer::rots_read | ( | ) | [protected] |
read all instances of DDRotation
Definition at line 586 of file DDStreamer.cc.
References trackerHits::c, DCOUT, dd_get_name(), dd_rot_bin_in(), Exception, i, i_, n, DDBase< N, C >::name(), and submit::rm.
Referenced by read().
{ DCOUT('Y', "DDStreamer::rots_read()"); std::istream & is = *i_; //DDRotation::clear(); size_t n=0; is >> n; size_t i=0; for (; i < n; ++i) { // Rotations is.ignore(1000,'@'); DDName dn = dd_get_name(is); char c = is.get(); if (c != ' ') { throw cms::Exception("DDException") << "DDStreamer::rots_read(): inconsitency! no blank separator found!"; } DDRotationMatrix * rm = new DDRotationMatrix(); dd_rot_bin_in(is,*rm); DDRotation ddr = DDRotation(dn,rm); DCOUT('y',"read-rots=" << ddr.name()); } }
void DDStreamer::rots_write | ( | ) | [protected] |
write all instances of DDRotation
Definition at line 557 of file DDStreamer.cc.
References DDBase< DDName, DDRotationMatrix * >::begin(), DCOUT, dd_count(), dd_rot_out(), DDBase< DDName, DDRotationMatrix * >::end(), o_, and alignCSCRings::r.
Referenced by write().
{ DCOUT('Y', "DDStreamer::rots_write()"); std::ostream & os = *o_; DDRotation::iterator<DDRotation> it(DDRotation::begin()), ed(DDRotation::end()); size_t no = dd_count(DDRotation()); os << no << std::endl; //DDName ano; for (; it != ed; ++it) { if (! it->isDefined().second) continue; const DDRotation & r = *it; //if (r.name().id() == ano.id()) { // continue; //} dd_rot_out(os,r); } }
void DDStreamer::setInput | ( | std::istream & | i | ) | [inline] |
set the istream for DDStreamer::read()
Definition at line 69 of file DDStreamer.h.
void DDStreamer::setOutput | ( | std::ostream & | o | ) | [inline] |
set the std::ostream for DDStreamer::write()
Definition at line 72 of file DDStreamer.h.
References python::connectstrParser::o, and o_.
void DDStreamer::solids_read | ( | ) | [protected] |
read all instances of DDSolid
Definition at line 405 of file DDStreamer.cc.
References a, b, trackerHits::c, DCOUT, dd_get_boolean_params(), dd_get_name(), ddbox, ddcons, ddintersection, ddpolycone_rrz, ddpolycone_rz, ddpolyhedra_rrz, ddpolyhedra_rz, ddpseudotrap, ddreflected, ddshapeless, ddsubtraction, ddtrap, ddtubs, ddunion, Exception, i, i_, reco::helper::VirtualJetProducerHelper::intersection(), n, AlCaHLTBitMon_ParallelJobs::p, alignCSCRings::r, DDSolidFactory::reflection(), DDSolidFactory::subtraction(), lumiQTWidget::t, and DDSolidFactory::unionSolid().
Referenced by read().
{ DCOUT('Y', "DDStreamer::solids_read()"); std::istream & is = *i_; //DDSolid::clear(); size_t n=0; is >> n; size_t i=0; for (; i < n; ++i) { // Solids is.ignore(1000,'@'); DDName dn = dd_get_name(is); size_t sp(0); is >> sp; DDSolidShape shape = DDSolidShape(sp); // boolean solids if ( (shape==ddunion) | (shape==ddsubtraction) || (shape==ddintersection) ) { DDRotation r; DDTranslation t; DDSolid a; DDSolid b; dd_get_boolean_params(is,r,t,a,b); switch (shape) { case ddunion: DDSolidFactory::unionSolid(dn,a,b,t,r); break; case ddintersection: DDSolidFactory::intersection(dn,a,b,t,r); break; case ddsubtraction: DDSolidFactory::subtraction(dn,a,b,t,r); break; default: throw cms::Exception("DDException") << "DDStreamer::solids_read(): messed up in boolean solid reading!"; } } // reflection solids else if (shape==ddreflected) { DDName ref_nm = dd_get_name(is); DDSolidFactory::reflection(dn,ref_nm); } else if ( (shape==ddbox ) || (shape==ddtrap) || (shape==ddcons) || (shape==ddtubs) || (shape==ddpolycone_rz) || (shape==ddpolycone_rrz) || (shape==ddpolyhedra_rz) || (shape==ddpolyhedra_rrz) || (shape==ddpseudotrap) || (shape==ddshapeless) ) { // read in the solid's parameters size_t npars(0); is >> npars; std::vector<double> p(npars); if(npars) { //edm::LogError("DDStreamer") << npars << flush << std::endl; char c; c = is.get(); if (c != ' ') { edm::LogError("DDStreamer") << "delimiter: " << c << std::endl; throw cms::Exception("DDException") << "DDStreamer::solids_read(): wrong separator in atomic for atomic solids parameters"; } is.read((char*)&(*(p.begin())),npars*sizeof(double)); /* size_t i(0); for(; i< npars; ++i) { double d(0); is >> d; p.push_back(d); } */ } DDSolid so = DDSolid(dn,shape,p); DCOUT('y', "read-solid=" << so); } else { edm::LogError("DDStreamer") << "wrong solid enum: " << shape << std::endl; throw cms::Exception("DDException") << "Error in DDStreamer::solids_read(), wrong shape-enum!"; } } }
void DDStreamer::solids_write | ( | ) | [protected] |
write all instances of DDSolid
Definition at line 345 of file DDStreamer.cc.
References DDBase< DDName, DDI::Solid * >::begin(), DCOUT, dd_count(), dd_stream_booleans(), dd_stream_reflected(), ddintersection, ddreflected, ddsubtraction, ddunion, DDBase< DDName, DDI::Solid * >::end(), mergeVDriftHistosByStation::name, DDBase< N, C >::name(), nameout(), o_, AlCaHLTBitMon_ParallelJobs::p, DDSolid::parameters(), alignCSCRings::s, and DDSolid::shape().
Referenced by write().
{ DCOUT('Y', "DDStreamer::solids_write()"); std::ostream & os = *o_; DDSolid::iterator<DDSolid> it(DDSolid::begin()), ed(DDSolid::end()); size_t no = dd_count(DDSolid()); os << no << std::endl; for (; it != ed; ++it) { if (! it->isDefined().second) continue; const DDSolid & s = *it; DCOUT('y', "write-solid=" << s << " enum=" << s.shape()); os << "--Solid: " << s.name() << ' ' << DDSolidShapesName::name(s.shape()) << " @ "; nameout(os,s.name()); os << ' ' << s.shape() << ' '; switch (s.shape()) { case ddunion: case ddsubtraction: case ddintersection: dd_stream_booleans(os, s, s.shape()); break; case ddreflected: dd_stream_reflected(os, s); break; default: size_t ps = s.parameters().size(); os << ps; const std::vector<double> & p = s.parameters(); os << ' '; os.write((char*)(&(*p.begin())),ps*sizeof(double)); /* std::vector<double>::const_iterator it(p.begin()), ed(p.end()); for (; it != ed; ++it) { os << ' ' << *it; } */ } os << std::endl; } }
void DDStreamer::specs_read | ( | ) | [protected] |
read all instances of
Definition at line 823 of file DDStreamer.cc.
References DCOUT, dd_get_delimit(), dd_get_name(), i, i_, n, mergeVDriftHistosByStation::name, query::result, alignCSCRings::s, DDValue::setEvalState(), and python::multivaluedict::sort().
Referenced by read().
{ DCOUT('Y', "DDStreamer::specs_read()"); std::istream & is = *i_; //DDSpecifics::clear(); size_t n=0; is >> n; size_t i=0; for (; i < n; ++i) { // Specifics is.ignore(1000,'@'); DDName sn(dd_get_name(is)); size_t nps(0); is >> nps; size_t ii=0; std::vector<std::string> ps; is.ignore(100,'\n'); for (; ii < nps; ++ii) { std::string s; getline(is,s); DCOUT('y', "specs-ps=" << s); ps.push_back(s); } is >> nps; ii=0; DDsvalues_type sv; for(; ii<nps; ++ii) { std::string name = dd_get_delimit(is,'"'); bool evl(false); is >> evl; size_t no(0); is >> no; std::vector<DDValuePair> valv; DDValue result; if (evl) { size_t iii=0; for(; iii<no; ++iii) { std::string strv = dd_get_delimit(is,'"'); double dblv(0); is >> dblv; DDValuePair valp(strv,dblv); valv.push_back(valp); } result = DDValue(name,valv); result.setEvalState(true); } else { size_t iii=0; for(; iii<no; ++iii) { std::string strv = dd_get_delimit(is,'"'); DDValuePair valp(strv,0); valv.push_back(valp); } result = DDValue(name,valv); result.setEvalState(false); } sv.push_back(DDsvalues_Content_type(result,result)); } std::sort(sv.begin(),sv.end()); DDSpecifics sp(sn,ps,sv,false); DCOUT('y', " specs-read: " << sp); } }
void DDStreamer::specs_write | ( | ) | [protected] |
write all instances of DDSpecifics
Definition at line 773 of file DDStreamer.cc.
References DDBase< DDName, DDI::Specific * >::begin(), DCOUT, dd_count(), DDBase< DDName, DDI::Specific * >::end(), i, DDValue::isEvaluated(), DDValue::name(), DDBase< N, C >::name(), nameout(), o_, alignCSCRings::s, DDSpecifics::selection(), DDValue::size(), DDSpecifics::specifics(), DDValue::strings(), and v.
Referenced by write().
{ DCOUT('Y', "DDStreamer::specs_write()"); std::ostream & os = *o_; DDSpecifics::iterator<DDSpecifics> it(DDSpecifics::begin()), ed(DDSpecifics::end()); size_t no = dd_count(DDSpecifics()); os << no << std::endl; for (; it != ed; ++it) { if (! it->isDefined().second) continue; const DDSpecifics & sp = *it; os << "--Spec: @ "; nameout(os,sp.name()); os << ' ' << sp.selection().size() << std::endl; std::vector<DDPartSelection>::const_iterator sit(sp.selection().begin()), sed(sp.selection().end()); for (; sit != sed; ++sit) { os << *sit << std::endl; } os << sp.specifics().size() << std::endl; DDsvalues_type::const_iterator vit(sp.specifics().begin()), ved(sp.specifics().end()); for (; vit != ved; ++vit) { const DDValue & v = vit->second; os << ' ' << '"' << v.name() << '"' << ' '; if (v.isEvaluated()) { os << 1 << ' '; } else { os << 0 << ' '; } os << v.size() << ' '; if (v.isEvaluated()) { size_t s=v.size(); size_t i=0; for (; i<s; ++i) { os << '"' << v[i].first << '"' << ' ' << v[i].second << ' '; } } else { size_t s=v.size(); size_t i=0; const std::vector<std::string> & vs = v.strings(); for (; i<s; ++i) { os << '"' << vs[i] << '"' << ' '; } } os << std::endl; } } }
void DDStreamer::vars_read | ( | ) | [protected] |
read the dictionlary of ClhepEvaluator
Definition at line 911 of file DDStreamer.cc.
References DDConstant::createConstantsFromEvaluator(), DCOUT, dd_get_delimit(), Exception, i, i_, instance, n, mergeVDriftHistosByStation::name, ClhepEvaluator::set(), and relativeConstraints::value.
Referenced by read().
{ DCOUT('Y', "DDStreamer::vars_read()"); std::istream & is = *i_; ExprEvalInterface & ev = ExprEvalSingleton::instance(); ClhepEvaluator * eval = dynamic_cast<ClhepEvaluator*>(&ev); if (eval){ size_t n(0); is >> n; size_t i(0); for(; i<n; ++i) { std::string name(dd_get_delimit(is,'"')); std::string value(dd_get_delimit(is,'"')); eval->set(name,value); } } else { throw cms::Exception("DDException") << "DDStreamer::vars_write(): expression-evaluator is not a ClhepEvaluator-implementation!"; } DDConstant::createConstantsFromEvaluator(); }
void DDStreamer::vars_write | ( | ) | [protected] |
write the dictionary of ClhepEvaluator
Definition at line 887 of file DDStreamer.cc.
References Exception, i, instance, o_, alignCSCRings::s, create_public_pileup_plots::vals, ClhepEvaluator::values(), and ClhepEvaluator::variables().
Referenced by write().
{ std::ostream & os = *o_; ExprEvalInterface & ev = ExprEvalSingleton::instance(); ClhepEvaluator * eval = dynamic_cast<ClhepEvaluator*>(&ev); if (eval){ const std::vector<std::string> & vars = eval->variables(); const std::vector<std::string> & vals = eval->values(); if (vars.size() != vals.size()) { throw cms::Exception("DDException") << "DDStreamer::vars_write(): different size of variable names & values!"; } size_t i(0), s(vars.size()); os << s << std::endl; for (; i<s; ++i) { os << '"' << vars[i] << '"' << ' ' << '"' << vals[i] << '"' << std::endl; } } else { throw cms::Exception("DDException") << "DDStreamer::vars_write(): expression-evaluator is not a ClhepEvaluator-implementation!"; } }
void DDStreamer::write | ( | void | ) |
stream all DDD transient objects to the std::ostream referred to by member o_
Definition at line 110 of file DDStreamer.cc.
{ if (o_ && *o_) { write(*o_); } else { throw cms::Exception("DDException") << "DDStreamer::write(): bad std::ostream"; } }
void DDStreamer::write | ( | std::ostream & | os | ) |
stream all DDD transient objects to the given std::ostream os
Definition at line 130 of file DDStreamer.cc.
References materials_write(), names_write(), o_, parts_write(), pos_write(), rots_write(), solids_write(), specs_write(), and vars_write().
{ o_=&os; std::streamsize prec(os.precision()); os << std::setprecision(26) << std::scientific; names_write(); vars_write(); materials_write(); solids_write(); parts_write(); pos_write(); specs_write(); rots_write(); //os << DDI::Singleton<DDName::IdToName>::instance().size() << std::endl; //names_write(); os << resetiosflags((std::ios_base::fmtflags)0); os << std::setprecision(prec); }
const DDCompactView* DDStreamer::cpv_ [private] |
not used
Definition at line 124 of file DDStreamer.h.
std::istream* DDStreamer::i_ [private] |
istream target for reading DDD objects
Definition at line 126 of file DDStreamer.h.
Referenced by DDStreamer(), materials_read(), names_read(), parts_read(), pos_read(), read(), rots_read(), setInput(), solids_read(), specs_read(), and vars_read().
std::ostream* DDStreamer::o_ [private] |
std::ostream target for writing DDD objects
Definition at line 125 of file DDStreamer.h.
Referenced by DDStreamer(), materials_write(), names_write(), parts_write(), pos_write(), rots_write(), setOutput(), solids_write(), specs_write(), vars_write(), and write().