CMS 3D CMS Logo

List of all members | Public Member Functions | Protected Member Functions | Private Attributes
DDStreamer Class Reference

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 More...
 
 DDStreamer (std::istream &readFrom)
 creates a streamer object for reading More...
 
 DDStreamer (std::ostream &writeTo)
 creates a streamer object for writing More...
 
void read ()
 populate DDD transient objects from the std::istream refetrred to by member i_ More...
 
void read (std::istream &is)
 populate DDD transient objects from the given std::istream is More...
 
void setInput (std::istream &i)
 set the istream for DDStreamer::read() More...
 
void setOutput (std::ostream &o)
 set the std::ostream for DDStreamer::write() More...
 
void write ()
 stream all DDD transient objects to the std::ostream referred to by member o_ More...
 
void write (std::ostream &os)
 stream all DDD transient objects to the given std::ostream os More...
 
virtual ~DDStreamer ()
 does nothing; usefull only if another streamer derives from DDStreamer More...
 

Protected Member Functions

void materials_read ()
 read all instances of DDMaterial More...
 
void materials_write ()
 write all instances of DDMaterial More...
 
void names_read ()
 read all instances of DDName More...
 
void names_write ()
 write all instances of DDName More...
 
void parts_read ()
 read all instances of DDLogicalPart More...
 
void parts_write ()
 write all instances of DDLogicalPart More...
 
void pos_read ()
 read the graph structure for DDCompactView::graph() More...
 
void pos_write ()
 write the graph structure of DDCompactView::graph() More...
 
void rots_read ()
 read all instances of DDRotation More...
 
void rots_write ()
 write all instances of DDRotation More...
 
void solids_read ()
 read all instances of DDSolid More...
 
void solids_write ()
 write all instances of DDSolid More...
 
void specs_read ()
 read all instances of More...
 
void specs_write ()
 write all instances of DDSpecifics More...
 
void vars_read ()
 read the dictionlary of ClhepEvaluator More...
 
void vars_write ()
 write the dictionary of ClhepEvaluator More...
 

Private Attributes

std::istream * i_
 
std::ostream * o_
 

Detailed Description

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 42 of file DDStreamer.h.

Constructor & Destructor Documentation

DDStreamer::DDStreamer ( )

constructs a streamer object with yet undefined std::istream and std::ostream

Definition at line 37 of file DDStreamer.cc.

38  : o_(0), i_(0)
39  {
40  }
std::istream * i_
Definition: DDStreamer.h:126
std::ostream * o_
Definition: DDStreamer.h:125
DDStreamer::DDStreamer ( std::istream &  readFrom)

creates a streamer object for reading

Definition at line 53 of file DDStreamer.cc.

References Exception, and i_.

54  : o_(0), i_(0)
55 {
56  if (is) {
57  i_ = &is;
58  }
59  else {
60  throw cms::Exception("DDException") << "DDStreamer::DDStreamer(std::ostream&): not valid std::ostream";
61  }
62 }
std::istream * i_
Definition: DDStreamer.h:126
std::ostream * o_
Definition: DDStreamer.h:125
DDStreamer::DDStreamer ( std::ostream &  writeTo)

creates a streamer object for writing

Definition at line 42 of file DDStreamer.cc.

References Exception, and o_.

43  : o_(0), i_(0)
44 {
45  if (os) {
46  o_ = &os;
47  }
48  else {
49  throw cms::Exception("DDException") << "DDStreamer::DDStreamer(std::ostream&): not valid std::ostream";
50  }
51 }
std::istream * i_
Definition: DDStreamer.h:126
std::ostream * o_
Definition: DDStreamer.h:125
DDStreamer::~DDStreamer ( )
virtual

does nothing; usefull only if another streamer derives from DDStreamer

Definition at line 64 of file DDStreamer.cc.

64 {}

Member Function Documentation

void DDStreamer::materials_read ( )
protected

read all instances of DDMaterial

Definition at line 295 of file DDStreamer.cc.

References a, DDMaterial::addMaterial(), AlCaHLTBitMon_QueryRunRegistry::comp, edmIntegrityCheck::d, dd_get_name(), i, i_, j, funct::m, gen::n, and z.

Referenced by read(), and setOutput().

296 {
297  std::istream & is = *i_;
298  //DDMaterial::clear();
299  size_t n=0;
300  is >> n;
301  size_t i=0;
302  for (; i < n; ++i) { // Materials
303  is.ignore(1000,'@');
304  DDName dn = dd_get_name(is);
305  double z(0), a(0), d(0);
306  is >> z;
307  is >> a;
308  is >> d;
309  int comp(0);
310  is >> comp; // composites
311  if (comp) { // composite material
312  DDMaterial m(dn,d);
313  int j=0;
314  for(; j<comp; ++j) {
315  DDName cname(dd_get_name(is));
316  double fm(0);
317  is >> fm;
318  DDMaterial constituent(cname);
319  m.addMaterial(constituent,fm);
320  }
321  }
322  else { // elementary material
323  DDMaterial m(dn,z,a,d);
324  }
325  }
326 }
int i
Definition: DBlmapReader.cc:9
DDMaterial is used to define and access material information.
Definition: DDMaterial.h:41
DDName is used to identify DDD entities uniquely.
Definition: DDName.h:16
DDName dd_get_name(std::istream &is)
Definition: DDStreamer.cc:108
std::istream * i_
Definition: DDStreamer.h:126
int j
Definition: DBlmapReader.cc:9
double a
Definition: hdecay.h:121
void DDStreamer::materials_write ( )
protected

write all instances of DDMaterial

Definition at line 269 of file DDStreamer.cc.

References DDMaterial::a(), DDBase< DDName, DDI::Material * >::begin(), DDMaterial::constituent(), dd_count(), DDMaterial::density(), DDBase< DDName, DDI::Material * >::end(), j, funct::m, DDBase< N, C >::name(), nameout(), DDMaterial::noOfConstituents(), o_, and DDMaterial::z().

Referenced by setOutput(), and write().

270 {
271  std::ostream & os = *o_;
272  DDMaterial::iterator<DDMaterial> it(DDMaterial::begin()), ed(DDMaterial::end());
273  size_t no = dd_count(DDMaterial());
274  os << no << std::endl;
275  for (; it != ed; ++it) {
276  if (! it->isDefined().second) continue;
277  const DDMaterial & m = *it;
278  os << "--Material: " << m.name() << " @ " ;
279  nameout(os,m.name());
280  os << ' ' << m.z() << ' ' << m.a() << ' ' << m.density() << ' ';
281 
282  int noc = m.noOfConstituents();
283  os << noc;
284  int j=0;
285  for (; j<noc; ++j) {
286  os << ' ';
287  nameout(os,m.constituent(j).first.name());
288  os << ' ' << m.constituent(j).second;
289  }
290  os << std::endl;
291  }
292 }
double a() const
returns the atomic mass
Definition: DDMaterial.cc:97
const N & name() const
Definition: DDBase.h:78
DDMaterial is used to define and access material information.
Definition: DDMaterial.h:41
double z() const
retruns the atomic number
Definition: DDMaterial.cc:103
FractionV::value_type constituent(int i) const
returns the i-th compound material and its fraction-mass
Definition: DDMaterial.cc:91
int j
Definition: DBlmapReader.cc:9
size_t dd_count(const T &)
Definition: DDStreamer.cc:228
double density() const
returns the density
Definition: DDMaterial.cc:109
int noOfConstituents() const
returns the number of compound materials or 0 for elementary materials
Definition: DDMaterial.cc:85
std::ostream * o_
Definition: DDStreamer.h:125
void nameout(std::ostream &o, const DDName &n)
Definition: DDStreamer.cc:120
void DDStreamer::names_read ( )
protected

read all instances of DDName

Definition at line 204 of file DDStreamer.cc.

References dd_get_delimit(), DDName::defineId(), i, i_, hcalTTPDigis_cfi::id, DDI::Singleton< I >::instance(), alignCSCRings::s, and AlCaHLTBitMon_QueryRunRegistry::string.

Referenced by read(), and setOutput().

205 {
206  std::istream & is = *i_;
209 
210  size_t s;
211  is >> s;
212  ids.clear();
213  //ids.resize(s);
214  reg.clear();
215  size_t i(0);
216  //std::string nm; getline(is,nm);
217  for (; i<s; ++i) {
218  std::string nm(dd_get_delimit(is,'"'));
219  std::string ns(dd_get_delimit(is,'"'));
220  size_t id(0);
221  is >> id;
222  DDName::defineId(std::make_pair(nm,ns),id);
223  }
224 }
int i
Definition: DBlmapReader.cc:9
std::string dd_get_delimit(std::istream &is, char d)
Definition: DDStreamer.cc:81
std::map< std::pair< std::string, std::string >, id_type > Registry
Definition: DDName.h:24
static value_type & instance()
std::istream * i_
Definition: DDStreamer.h:126
static void defineId(const std::pair< std::string, std::string > &, id_type id)
register pre-defined ids
Definition: DDName.cc:66
std::vector< Registry::const_iterator > IdToName
Definition: DDName.h:25
void DDStreamer::names_write ( )
protected

write all instances of DDName

Definition at line 186 of file DDStreamer.cc.

References KineDebug3::count(), DDI::Singleton< I >::instance(), and o_.

Referenced by setOutput(), and write().

187 {
188  std::ostream & os = *o_;
190 
191  DDName::IdToName::const_iterator it(ids.begin()), ed(ids.end());
192  os << ids.size() << std::endl;
193  size_t count(0);
194  for (; it != ed; ++it) {
195  os << '"' << (*it)->first.first << '"' << ' '
196  << '"' << (*it)->first.second << '"' << ' '
197  << count << std::endl;
198  ++count;
199  }
200 
201 }
static value_type & instance()
std::vector< Registry::const_iterator > IdToName
Definition: DDName.h:25
std::ostream * o_
Definition: DDStreamer.h:125
void DDStreamer::parts_read ( )
protected

read all instances of DDLogicalPart

Definition at line 515 of file DDStreamer.cc.

References eostools::cat(), dd_get_name(), i, i_, and gen::n.

Referenced by read(), and setOutput().

516 {
517  std::istream & is = *i_;
518  //DDLogicalPart::clear();
519  size_t n=0;
520  is >> n;
521  size_t i=0;
522  for (; i < n; ++i) { // LogicalParts
523  is.ignore(1000,'@');
524  DDName dn = dd_get_name(is);
525  size_t cat(0);
526  is >> cat;
528  DDName mat = dd_get_name(is);
529  DDName sol = dd_get_name(is);
530  DDLogicalPart lp(dn,mat,sol,categ);
531  }
532 }
int i
Definition: DBlmapReader.cc:9
DDName is used to identify DDD entities uniquely.
Definition: DDName.h:16
DDName dd_get_name(std::istream &is)
Definition: DDStreamer.cc:108
std::istream * i_
Definition: DDStreamer.h:126
def cat(path)
Definition: eostools.py:400
Category
Definition: DDEnums.h:7
A DDLogicalPart aggregates information concerning material, solid and sensitveness ...
Definition: DDLogicalPart.h:92
void DDStreamer::parts_write ( )
protected

write all instances of DDLogicalPart

Definition at line 495 of file DDStreamer.cc.

References DDBase< DDName, DDI::LogicalPart * >::begin(), DDLogicalPart::category(), dd_count(), DDBase< DDName, DDI::LogicalPart * >::end(), DDLogicalPart::material(), DDBase< N, C >::name(), nameout(), o_, and DDLogicalPart::solid().

Referenced by setOutput(), and write().

496 {
497  std::ostream & os = *o_;
498  DDLogicalPart::iterator<DDLogicalPart> it(DDLogicalPart::begin()), ed(DDLogicalPart::end());
499  size_t no = dd_count(DDLogicalPart());
500  os << no << std::endl;
501  for (; it != ed; ++it) {
502  if (! it->isDefined().second) continue;
503  const DDLogicalPart & lp = *it;
504  os << "--Part: " << lp.name() << " @ ";
505  nameout(os,lp.name());
506  os << ' ' << lp.category() << ' ';
507  nameout(os,lp.material().name());
508  os << ' ';
509  nameout(os,lp.solid().name());
510  os << std::endl;
511  }
512 }
const N & name() const
Definition: DDBase.h:78
DDEnums::Category category(void) const
Returns the categorization of the DDLogicalPart (sensitive detector element, cable, ...)
const DDSolid & solid(void) const
Returns a reference object of the solid being the shape of this LogicalPart.
A DDLogicalPart aggregates information concerning material, solid and sensitveness ...
Definition: DDLogicalPart.h:92
size_t dd_count(const T &)
Definition: DDStreamer.cc:228
std::ostream * o_
Definition: DDStreamer.h:125
void nameout(std::ostream &o, const DDName &n)
Definition: DDStreamer.cc:120
const DDMaterial & material(void) const
Returns a reference object of the material this LogicalPart is made of.
void DDStreamer::pos_read ( )
protected

read the graph structure for DDCompactView::graph()

Definition at line 670 of file DDStreamer.cc.

References SimDataFormats::CaloAnalysis::cp, dd_get_name(), dd_rot_bin_in(), DDanonymousRot(), Exception, g, DDCompactView::graph(), i, i_, DDI::Singleton< I >::instance(), makeMuonMisalignmentScenario::matrix, python.rootplot.argparse::message, gen::n, DDCompactView::position(), pyrootRender::root, makeMuonMisalignmentScenario::rot, graph< N, E >::size(), AlCaHLTBitMon_QueryRunRegistry::string, lumiQTWidget::t, x, y, and z.

Referenced by read(), and setOutput().

671 {
672  std::istream & is = *i_;
673  is.ignore(1000,'@');
674  DDName rtname = dd_get_name(is);
675  DDLogicalPart root(rtname);
676  DDRootDef::instance().set(root);
677  size_t n=0;
678  is >> n;
679  size_t i=0;
680  DDCompactView cpv;
682  // DDPositioner pos_(&cpv);
683  //LogDebug << "===== GRAPH SIZE = " << g.size() << " ======" << std::endl << std::endl;
684  if (g.size()) {
685  edm::LogWarning("DDStreamer") << std::endl;
686  edm::LogWarning("DDStreamer") << "DDStreamer::pos_read(): The CompactView already contains some position information." << std::endl
687  << " It may cause an inconsistent geometry representation!" << std::endl << std::endl;
688  throw cms::Exception("DDException") << "DDStreamer::pos_read() failed; CompactView has already been populated by another data source";
689  }
690  for (; i < n; ++i) { // Positions
691  is.ignore(1000,'@');
692  DDName from(dd_get_name(is));
693  DDName to(dd_get_name(is));
694  std::string cp;
695  is >> cp;
696  char cr = is.get();
697  if (cr != ' ') throw cms::Exception("DDException") << "DDStreamer::pos_read(): inconsistent sequence! no blank delimiter found!";
698  //double x,y,z;
699  B x,y,z;
700  is >> x;
701  is >> y;
702  is >> z;
703  DDTranslation t(x.val_,y.val_,z.val_);
704  is.ignore();
705  char rottype = is.get();
707  //DDName rotname;
708  DDRotation rot;
709  switch(rottype) {
710  case 'a': // anonymous rotation
711  is.ignore();
712  matrix = new DDRotationMatrix;
713  dd_rot_bin_in(is,*matrix);
714  rot = DDanonymousRot(matrix);
715  break;
716  case 'u': // unit rotation
717  break;
718  case 'r': // regular (named) rotation
719  rot = DDRotation(dd_get_name(is));
720  break;
721  default:
722  std::string message = "DDStreamer::pos_read(): could not determine type of rotation\n";
723  throw cms::Exception("DDException") << message;
724  }
725  //DDName rot(dd_get_name(is));
726  cpv.position(DDLogicalPart(to),DDLogicalPart(from),cp,t,rot);
727  }
728 }
adj_list::size_type size() const
Definition: adjgraph.h:201
int i
Definition: DBlmapReader.cc:9
void dd_rot_bin_in(std::istream &is, DDRotationMatrix &r)
Definition: DDStreamer.cc:574
const graph_type & graph() const
Provides read-only access to the data structure of the compact-view.
void position(const DDLogicalPart &self, const DDLogicalPart &parent, std::string copyno, const DDTranslation &trans, const DDRotation &rot, const DDDivision *div=NULL)
DDName is used to identify DDD entities uniquely.
Definition: DDName.h:16
type of data representation of DDCompactView
Definition: DDCompactView.h:90
The Signals That Services Can Subscribe To This is based on ActivityRegistry and is current per Services can connect to the signals distributed by the ActivityRegistry in order to monitor the activity of the application Each possible callback has some defined which we here list in angle e g
Definition: Activities.doc:4
ROOT::Math::DisplacementVector3D< ROOT::Math::Cartesian3D< double > > DDTranslation
Definition: DDTranslation.h:7
DDRotation DDanonymousRot(DDRotationMatrix *rot)
Defines a anonymous rotation or rotation-reflection matrix.
Definition: DDRotation.cc:187
Represents a uniquely identifyable rotation matrix.
Definition: DDTransform.h:66
DDName dd_get_name(std::istream &is)
Definition: DDStreamer.cc:108
static value_type & instance()
std::istream * i_
Definition: DDStreamer.h:126
A DDLogicalPart aggregates information concerning material, solid and sensitveness ...
Definition: DDLogicalPart.h:92
ROOT::Math::Rotation3D DDRotationMatrix
A DDRotationMatrix is currently implemented with a ROOT Rotation3D.
void DDStreamer::pos_write ( )
protected

write the graph structure of DDCompactView::graph()

Definition at line 605 of file DDStreamer.cc.

References graph< N, E >::begin_iter(), KineDebug3::count(), dd_rot_bin_out(), graph< N, E >::end_iter(), g, DDCompactView::graph(), DDI::Singleton< I >::instance(), DDBase< N, C >::name(), nameout(), and o_.

Referenced by setOutput(), and write().

606 {
607  DDCompactView cpv;
608  const DDCompactView::graph_type & g = cpv.graph();
609  DDCompactView::graph_type::const_iterator it = g.begin_iter();
610  DDCompactView::graph_type::const_iterator ed = g.end_iter();
611  std::ostream & os = *o_;
612  // first the root
613  DDLogicalPart rt = DDRootDef::instance().root();
614  os << "--Root: @ ";
615  nameout(os,rt.name());
616  os << std::endl;
617  //os << g.edge_size() << std::endl;
618  DDCompactView::graph_type::const_iterator iit = g.begin_iter();
619  DDCompactView::graph_type::const_iterator eed = g.end_iter();
620  size_t count(0);
621  for(; iit != eed; ++iit) {
622  ++count;
623  }
624  os << count << std::endl;
625  count=0;
626  DDName unit_rot_name;
627  DDRotationMatrix unit_rot;
628  for(; it != ed; ++it) {
629  os << "--Pos[" << count << "]: @ "; ++count;
630  //const DDLogicalPart & fr = it->from();
631  nameout(os, it->from().name());
632  os << ' ';
633  nameout(os, it->to().name());
634  os << ' ' << it->edge()->copyno_;
635  const DDTranslation & tr = it->edge()->translation();
636  //os << ' ' << B(tr.x()) << ' ' << B(tr.y()) << ' ' << B(tr.z());
637  os << ' ' << B(tr.x()) << B(tr.y()) << B(tr.z());
638  const DDRotation & ro = it->edge()->rot_;
639  os << ' ';
640  /* if it's an anonymous rotation stemming from an AlgoPosPart
641  then it's id must be the one of a unit rotation AND
642  it must be defined at this point AND it must not be the
643  unit rotation.
644  A character identifier is issues to mark the type of the rotation:
645  a ... anonymous rotation, followed by the binary numbers of the matrix
646  u ... unit-rotation matrix, no values following
647  r ... regular defined rotation-matrix (named rotation matrix) followed by name-id
648  */
649  if (ro.name() == unit_rot_name) {
650  if(ro.isDefined().second) {
651  if(*(ro.rotation()) != unit_rot) {
652  os << "a ";
653  dd_rot_bin_out(os,*(ro.rotation()));
654  }
655  else {
656  os << "u ";
657  }
658  }
659  }
660  else {
661  os << "r ";
662  nameout(os, ro.name());
663  }
664  os << std::endl;
665  }
666 
667 }
const N & name() const
Definition: DDBase.h:78
double_binary B
Definition: DDStreamer.cc:248
const graph_type & graph() const
Provides read-only access to the data structure of the compact-view.
DDName is used to identify DDD entities uniquely.
Definition: DDName.h:16
void dd_rot_bin_out(std::ostream &os, const DDRotationMatrix &rm)
Definition: DDStreamer.cc:534
type of data representation of DDCompactView
Definition: DDCompactView.h:90
The Signals That Services Can Subscribe To This is based on ActivityRegistry and is current per Services can connect to the signals distributed by the ActivityRegistry in order to monitor the activity of the application Each possible callback has some defined which we here list in angle e g
Definition: Activities.doc:4
ROOT::Math::DisplacementVector3D< ROOT::Math::Cartesian3D< double > > DDTranslation
Definition: DDTranslation.h:7
Represents a uniquely identifyable rotation matrix.
Definition: DDTransform.h:66
static value_type & instance()
A DDLogicalPart aggregates information concerning material, solid and sensitveness ...
Definition: DDLogicalPart.h:92
const_iterator begin_iter() const
Definition: adjgraph.h:190
std::ostream * o_
Definition: DDStreamer.h:125
void nameout(std::ostream &o, const DDName &n)
Definition: DDStreamer.cc:120
ROOT::Math::Rotation3D DDRotationMatrix
A DDRotationMatrix is currently implemented with a ROOT Rotation3D.
const_iterator end_iter() const
Definition: adjgraph.h:192
void DDStreamer::read ( )

populate DDD transient objects from the std::istream refetrred to by member i_

Definition at line 136 of file DDStreamer.cc.

References Exception, and i_.

Referenced by edmIntegrityCheck.PublishToFileSystem::get(), Vispa.Plugins.EdmBrowser.EdmDataAccessor.EdmDataAccessor::goto(), and Vispa.Plugins.EdmBrowser.EdmDataAccessor.EdmDataAccessor::setFilterBranches().

137 {
138  if (i_ && *i_) {
139  read(*i_);
140  }
141  else {
142  throw cms::Exception("DDException") << "DDStreamer::read(): bad std::istream";
143  }
144 }
void read()
populate DDD transient objects from the std::istream refetrred to by member i_
Definition: DDStreamer.cc:136
std::istream * i_
Definition: DDStreamer.h:126
void DDStreamer::read ( std::istream &  is)

populate DDD transient objects from the given std::istream is

Definition at line 169 of file DDStreamer.cc.

References i_, materials_read(), names_read(), parts_read(), pos_read(), rots_read(), solids_read(), specs_read(), and vars_read().

Referenced by edmIntegrityCheck.PublishToFileSystem::get(), Vispa.Plugins.EdmBrowser.EdmDataAccessor.EdmDataAccessor::goto(), and Vispa.Plugins.EdmBrowser.EdmDataAccessor.EdmDataAccessor::setFilterBranches().

170 {
171 
172  i_=&is;
173  names_read();
174  vars_read();
175 
176  materials_read();
177  solids_read();
178  parts_read();
179 
180  pos_read();
181  specs_read();
182  rots_read();
183 }
void names_read()
read all instances of DDName
Definition: DDStreamer.cc:204
void vars_read()
read the dictionlary of ClhepEvaluator
Definition: DDStreamer.cc:898
void solids_read()
read all instances of DDSolid
Definition: DDStreamer.cc:409
std::istream * i_
Definition: DDStreamer.h:126
void specs_read()
read all instances of
Definition: DDStreamer.cc:813
void rots_read()
read all instances of DDRotation
Definition: DDStreamer.cc:584
void parts_read()
read all instances of DDLogicalPart
Definition: DDStreamer.cc:515
void pos_read()
read the graph structure for DDCompactView::graph()
Definition: DDStreamer.cc:670
void materials_read()
read all instances of DDMaterial
Definition: DDStreamer.cc:295
void DDStreamer::rots_read ( )
protected

read all instances of DDRotation

Definition at line 584 of file DDStreamer.cc.

References EnergyCorrector::c, dd_get_name(), dd_rot_bin_in(), Exception, i, i_, gen::n, and submit::rm.

Referenced by read(), and setOutput().

585 {
586  std::istream & is = *i_;
587  //DDRotation::clear();
588  size_t n=0;
589  is >> n;
590  size_t i=0;
591  for (; i < n; ++i) { // Rotations
592  is.ignore(1000,'@');
593  DDName dn = dd_get_name(is);
594  char c = is.get();
595  if (c != ' ') {
596  throw cms::Exception("DDException") << "DDStreamer::rots_read(): inconsitency! no blank separator found!";
597  }
598 
600  dd_rot_bin_in(is,*rm);
601  DDRotation ddr = DDRotation(dn,rm);
602  }
603 }
int i
Definition: DBlmapReader.cc:9
void dd_rot_bin_in(std::istream &is, DDRotationMatrix &r)
Definition: DDStreamer.cc:574
DDName is used to identify DDD entities uniquely.
Definition: DDName.h:16
Represents a uniquely identifyable rotation matrix.
Definition: DDTransform.h:66
DDName dd_get_name(std::istream &is)
Definition: DDStreamer.cc:108
std::istream * i_
Definition: DDStreamer.h:126
rm
Definition: submit.py:76
ROOT::Math::Rotation3D DDRotationMatrix
A DDRotationMatrix is currently implemented with a ROOT Rotation3D.
void DDStreamer::rots_write ( )
protected

write all instances of DDRotation

Definition at line 556 of file DDStreamer.cc.

References DDBase< DDName, DDRotationMatrix * >::begin(), dd_count(), dd_rot_out(), DDBase< DDName, DDRotationMatrix * >::end(), o_, and alignCSCRings::r.

Referenced by setOutput(), and write().

557 {
558  std::ostream & os = *o_;
559  DDRotation::iterator<DDRotation> it(DDRotation::begin()), ed(DDRotation::end());
560  size_t no = dd_count(DDRotation());
561  os << no << std::endl;
562  //DDName ano;
563  for (; it != ed; ++it) {
564  if (! it->isDefined().second) continue;
565  const DDRotation & r = *it;
566  //if (r.name().id() == ano.id()) {
567  // continue;
568  //}
569  dd_rot_out(os,r);
570  }
571 }
Represents a uniquely identifyable rotation matrix.
Definition: DDTransform.h:66
void dd_rot_out(std::ostream &os, const DDRotation &r)
Definition: DDStreamer.cc:542
size_t dd_count(const T &)
Definition: DDStreamer.cc:228
std::ostream * o_
Definition: DDStreamer.h:125
void DDStreamer::setInput ( std::istream &  i)
inline

set the istream for DDStreamer::read()

Definition at line 70 of file DDStreamer.h.

References i, and i_.

70 { i_ = &i; }
int i
Definition: DBlmapReader.cc:9
std::istream * i_
Definition: DDStreamer.h:126
void DDStreamer::setOutput ( std::ostream &  o)
inline
void DDStreamer::solids_read ( )
protected

read all instances of DDSolid

Definition at line 409 of file DDStreamer.cc.

References a, b, EnergyCorrector::c, dd_get_boolean_params(), dd_get_name(), ddbox, ddcons, ddcuttubs, ddintersection, ddpolycone_rrz, ddpolycone_rz, ddpolyhedra_rrz, ddpolyhedra_rz, ddpseudotrap, ddreflected, ddshapeless, ddsubtraction, ddtrap, ddtubs, ddunion, Exception, i, i_, DDSolidFactory::intersection(), gen::n, AlCaHLTBitMon_ParallelJobs::p, alignCSCRings::r, DDSolidFactory::reflection(), DDSolidFactory::subtraction(), lumiQTWidget::t, and DDSolidFactory::unionSolid().

Referenced by read(), and setOutput().

410 {
411  std::istream & is = *i_;
412  //DDSolid::clear();
413  size_t n=0;
414  is >> n;
415  size_t i=0;
416  for (; i < n; ++i) { // Solids
417  is.ignore(1000,'@');
418  DDName dn = dd_get_name(is);
419 
420  size_t sp(0);
421  is >> sp;
422  DDSolidShape shape = DDSolidShape(sp);
423 
424  // boolean solids
425  if ( (shape==ddunion) | (shape==ddsubtraction) || (shape==ddintersection) ) {
426  DDRotation r;
428  DDSolid a;
429  DDSolid b;
430  dd_get_boolean_params(is,r,t,a,b);
431  switch (shape) {
432  case ddunion:
433  DDSolidFactory::unionSolid(dn,a,b,t,r);
434  break;
435  case ddintersection:
436  DDSolidFactory::intersection(dn,a,b,t,r);
437  break;
438  case ddsubtraction:
439  DDSolidFactory::subtraction(dn,a,b,t,r);
440  break;
441  default:
442  throw cms::Exception("DDException") << "DDStreamer::solids_read(): messed up in boolean solid reading!";
443  }
444  }
445 
446  // reflection solids
447  else if (shape==ddreflected) {
448  DDName ref_nm = dd_get_name(is);
449  DDSolidFactory::reflection(dn,ref_nm);
450  }
451  else if ( (shape==ddbox ) ||
452  (shape==ddtrap) ||
453  (shape==ddcons) ||
454  (shape==ddtubs) ||
455  (shape==ddcuttubs) ||
456  (shape==ddpolycone_rz) ||
457  (shape==ddpolycone_rrz) ||
458  (shape==ddpolyhedra_rz) ||
459  (shape==ddpolyhedra_rrz) ||
460  (shape==ddpseudotrap) ||
461  (shape==ddshapeless) )
462  {
463  // read in the solid's parameters
464  size_t npars(0);
465  is >> npars;
466 
467  std::vector<double> p(npars);
468  if(npars) {
469  //edm::LogError("DDStreamer") << npars << flush << std::endl;
470  char c;
471  c = is.get();
472  if (c != ' ') {
473  edm::LogError("DDStreamer") << "delimiter: " << c << std::endl;
474  throw cms::Exception("DDException") << "DDStreamer::solids_read(): wrong separator in atomic for atomic solids parameters";
475  }
476  is.read((char*)&(*(p.begin())),npars*sizeof(double));
477  /*
478  size_t i(0);
479  for(; i< npars; ++i) {
480  double d(0);
481  is >> d;
482  p.push_back(d);
483  }
484  */
485  }
486  DDSolid so = DDSolid(dn,shape,p);
487  }
488  else {
489  edm::LogError("DDStreamer") << "wrong solid enum: " << shape << std::endl;
490  throw cms::Exception("DDException") << "Error in DDStreamer::solids_read(), wrong shape-enum!";
491  }
492  }
493 }
int i
Definition: DBlmapReader.cc:9
void dd_get_boolean_params(std::istream &is, DDRotation &r, DDTranslation &t, DDSolid &a, DDSolid &b)
Definition: DDStreamer.cc:390
DDSolidShape
Definition: DDSolidShapes.h:6
DDName is used to identify DDD entities uniquely.
Definition: DDName.h:16
A DDSolid represents the shape of a part.
Definition: DDSolid.h:37
ROOT::Math::DisplacementVector3D< ROOT::Math::Cartesian3D< double > > DDTranslation
Definition: DDTranslation.h:7
Represents a uniquely identifyable rotation matrix.
Definition: DDTransform.h:66
DDName dd_get_name(std::istream &is)
Definition: DDStreamer.cc:108
std::istream * i_
Definition: DDStreamer.h:126
static DDSolid intersection(const DDName &name, const DDSolid &a, const DDSolid &b, const DDTranslation &t, const DDRotation &r)
Definition: DDSolid.cc:749
static DDSolid subtraction(const DDName &name, const DDSolid &a, const DDSolid &b, const DDTranslation &t, const DDRotation &r)
Definition: DDSolid.cc:740
double b
Definition: hdecay.h:120
static DDSolid reflection(const DDName &name, const DDSolid &s)
Definition: DDSolid.cc:896
double a
Definition: hdecay.h:121
static DDSolid unionSolid(const DDName &name, const DDSolid &a, const DDSolid &b, const DDTranslation &t, const DDRotation &r)
Definition: DDSolid.cc:731
Definition: sp.h:21
void DDStreamer::solids_write ( )
protected

write all instances of DDSolid

Definition at line 352 of file DDStreamer.cc.

References DDBase< DDName, DDI::Solid * >::begin(), dd_count(), dd_stream_booleans(), dd_stream_reflected(), ddintersection, ddreflected, ddsubtraction, ddunion, DDBase< DDName, DDI::Solid * >::end(), DDSolidShapesName::name(), DDBase< N, C >::name(), nameout(), o_, AlCaHLTBitMon_ParallelJobs::p, DDSolid::parameters(), alignCSCRings::s, and DDSolid::shape().

Referenced by setOutput(), and write().

353 {
354  std::ostream & os = *o_;
355  DDSolid::iterator<DDSolid> it(DDSolid::begin()), ed(DDSolid::end());
356  size_t no = dd_count(DDSolid());
357  os << no << std::endl;
358  for (; it != ed; ++it) {
359  if (! it->isDefined().second) continue;
360  const DDSolid & s = *it;
361  os << "--Solid: " << s.name() << ' ' << DDSolidShapesName::name(s.shape()) << " @ ";
362  nameout(os,s.name());
363  os << ' ' << s.shape() << ' ';
364  switch (s.shape()) {
365  case ddunion: case ddsubtraction: case ddintersection:
366  dd_stream_booleans(os, s, s.shape());
367  break;
368  case ddreflected:
369  dd_stream_reflected(os, s);
370  break;
371  default:
372  size_t ps = s.parameters().size();
373  os << ps;
374  const std::vector<double> & p = s.parameters();
375  os << ' ';
376  os.write((char*)(&(*p.begin())),ps*sizeof(double));
377  /*
378  std::vector<double>::const_iterator it(p.begin()), ed(p.end());
379  for (; it != ed; ++it) {
380  os << ' ' << *it;
381  }
382  */
383  }
384  os << std::endl;
385  }
386 }
void dd_stream_reflected(std::ostream &os, DDSolid s)
Definition: DDStreamer.cc:346
const std::vector< double > & parameters(void) const
Give the parameters of the solid.
Definition: DDSolid.cc:157
const N & name() const
Definition: DDBase.h:78
A DDSolid represents the shape of a part.
Definition: DDSolid.h:37
static const char *const name(DDSolidShape s)
Definition: DDSolidShapes.h:21
void dd_stream_booleans(std::ostream &os, DDSolid s, DDSolidShape)
Definition: DDStreamer.cc:328
DDSolidShape shape(void) const
The type of the solid.
Definition: DDSolid.cc:151
size_t dd_count(const T &)
Definition: DDStreamer.cc:228
std::ostream * o_
Definition: DDStreamer.h:125
void nameout(std::ostream &o, const DDName &n)
Definition: DDStreamer.cc:120
void DDStreamer::specs_read ( )
protected

read all instances of

Definition at line 813 of file DDStreamer.cc.

References dd_get_delimit(), dd_get_name(), i, i_, cuy::ii, gen::n, dataset::name, mps_fire::result, alignCSCRings::s, DDValue::setEvalState(), and AlCaHLTBitMon_QueryRunRegistry::string.

Referenced by read(), and setOutput().

814 {
815  std::istream & is = *i_;
816  //DDSpecifics::clear();
817  size_t n=0;
818  is >> n;
819  size_t i=0;
820  for (; i < n; ++i) { // Specifics
821  is.ignore(1000,'@');
822  DDName sn(dd_get_name(is));
823  size_t nps(0);
824  is >> nps;
825  size_t ii=0;
826  std::vector<std::string> ps;
827  is.ignore(100,'\n');
828  for (; ii < nps; ++ii) {
829  std::string s;
830  getline(is,s);
831  ps.push_back(s);
832  }
833  is >> nps;
834  ii=0;
835  DDsvalues_type sv;
836  for(; ii<nps; ++ii) {
837  std::string name = dd_get_delimit(is,'"');
838  bool evl(false);
839  is >> evl;
840  size_t no(0);
841  is >> no;
842  std::vector<DDValuePair> valv;
843  DDValue result;
844  if (evl) {
845  size_t iii=0;
846  for(; iii<no; ++iii) {
847  std::string strv = dd_get_delimit(is,'"');
848  double dblv(0);
849  is >> dblv;
850  DDValuePair valp(strv,dblv);
851  valv.push_back(valp);
852  }
853  result = DDValue(name,valv);
854  result.setEvalState(true);
855  }
856  else {
857  size_t iii=0;
858  for(; iii<no; ++iii) {
859  std::string strv = dd_get_delimit(is,'"');
860  DDValuePair valp(strv,0);
861  valv.push_back(valp);
862  }
863  result = DDValue(name,valv);
864  result.setEvalState(false);
865  }
866  sv.push_back(DDsvalues_Content_type(result,result));
867  }
868  std::sort(sv.begin(),sv.end());
869  DDSpecifics sp(sn,ps,sv,false);
870  }
871 }
int i
Definition: DBlmapReader.cc:9
DDName is used to identify DDD entities uniquely.
Definition: DDName.h:16
void setEvalState(bool newState)
set to true, if the double-values (method DDValue::doubles()) make sense
Definition: DDValue.cc:195
std::string dd_get_delimit(std::istream &is, char d)
Definition: DDStreamer.cc:81
DDName dd_get_name(std::istream &is)
Definition: DDStreamer.cc:108
std::istream * i_
Definition: DDStreamer.h:126
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::...
Definition: DDsvalues.h:20
ii
Definition: cuy.py:588
Definition: sp.h:21
DDsvalues_type::value_type DDsvalues_Content_type
Definition: DDsvalues.h:21
Interface to attach user specific data to nodes in the expanded-view.
Definition: DDSpecifics.h:42
void DDStreamer::specs_write ( )
protected

write all instances of DDSpecifics

Definition at line 764 of file DDStreamer.cc.

References DDBase< DDName, DDI::Specific * >::begin(), 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 findQualityFiles::v.

Referenced by setOutput(), and write().

765 {
766  std::ostream & os = *o_;
767  DDSpecifics::iterator<DDSpecifics> it(DDSpecifics::begin()), ed(DDSpecifics::end());
768  size_t no = dd_count(DDSpecifics());
769  os << no << std::endl;
770  for (; it != ed; ++it) {
771  if (! it->isDefined().second) continue;
772  const DDSpecifics & sp = *it;
773  os << "--Spec: @ ";
774  nameout(os,sp.name());
775  os << ' ' << sp.selection().size() << std::endl;
776  std::vector<DDPartSelection>::const_iterator sit(sp.selection().begin()), sed(sp.selection().end());
777  for (; sit != sed; ++sit) {
778  os << *sit << std::endl;
779  }
780  os << sp.specifics().size() << std::endl;
781  DDsvalues_type::const_iterator vit(sp.specifics().begin()), ved(sp.specifics().end());
782  for (; vit != ved; ++vit) {
783  const DDValue & v = vit->second;
784  os << ' ' << '"' << v.name() << '"' << ' ';
785  if (v.isEvaluated()) {
786  os << 1 << ' ';
787  }
788  else {
789  os << 0 << ' ';
790  }
791  os << v.size() << ' ';
792  if (v.isEvaluated()) {
793  size_t s=v.size();
794  size_t i=0;
795  for (; i<s; ++i) {
796  os << '"' << v[i].first << '"' << ' ' << v[i].second << ' ';
797  }
798  }
799  else {
800  size_t s=v.size();
801  size_t i=0;
802  const std::vector<std::string> & vs = v.strings();
803  for (; i<s; ++i) {
804  os << '"' << vs[i] << '"' << ' ';
805  }
806  }
807  os << std::endl;
808 
809  }
810  }
811 }
const std::string & name(void) const
the name of the DDValue
Definition: DDValue.h:54
int i
Definition: DBlmapReader.cc:9
const N & name() const
Definition: DDBase.h:78
bool isEvaluated(void) const
true, if values are numerical evaluated; else false.
Definition: DDValue.cc:201
const std::vector< std::string > & strings() const
a reference to the std::string-valued values stored in the given instance of DDValue ...
Definition: DDValue.h:61
size_t dd_count(const T &)
Definition: DDStreamer.cc:228
const DDsvalues_type & specifics() const
Reference to the user-data attached to all nodes selected by the selections-strings given through sel...
Definition: DDSpecifics.cc:49
std::ostream * o_
Definition: DDStreamer.h:125
void nameout(std::ostream &o, const DDName &n)
Definition: DDStreamer.cc:120
unsigned int size() const
the size of the stored value-pairs (std::string,double)
Definition: DDValue.h:68
Definition: sp.h:21
Interface to attach user specific data to nodes in the expanded-view.
Definition: DDSpecifics.h:42
const std::vector< DDPartSelection > & selection() const
Gives a reference to the collection of part-selections.
Definition: DDSpecifics.cc:44
void DDStreamer::vars_read ( )
protected

read the dictionlary of ClhepEvaluator

Definition at line 898 of file DDStreamer.cc.

References DDConstant::createConstantsFromEvaluator(), dd_get_delimit(), ev, Exception, i, i_, DDI::Singleton< I >::instance(), gen::n, dataset::name, ClhepEvaluator::set(), AlCaHLTBitMon_QueryRunRegistry::string, and relativeConstraints::value.

Referenced by read(), and setOutput().

899 {
900  std::istream & is = *i_;
902  ClhepEvaluator * eval = dynamic_cast<ClhepEvaluator*>(&ev);
903  if (eval){
904  size_t n(0);
905  is >> n;
906  size_t i(0);
907 
908  for(; i<n; ++i) {
911  eval->set(name,value);
912  }
913  }
914  else {
915  throw cms::Exception("DDException") << "DDStreamer::vars_write(): expression-evaluator is not a ClhepEvaluator-implementation!";
916  }
918 }
int i
Definition: DBlmapReader.cc:9
bool ev
std::string dd_get_delimit(std::istream &is, char d)
Definition: DDStreamer.cc:81
static value_type & instance()
std::istream * i_
Definition: DDStreamer.h:126
Definition: value.py:1
static void createConstantsFromEvaluator()
creates all DDConstants from the variables of the ClhepEvaluator
Definition: DDConstant.cc:38
void set(const std::string &ns, const std::string &name, const std::string &exprValue)
void DDStreamer::vars_write ( )
protected

write the dictionary of ClhepEvaluator

Definition at line 874 of file DDStreamer.cc.

References ev, Exception, i, DDI::Singleton< I >::instance(), o_, alignCSCRings::s, create_public_pileup_plots::vals, ClhepEvaluator::values(), and ClhepEvaluator::variables().

Referenced by setOutput(), and write().

875 {
876  std::ostream & os = *o_;
878  ClhepEvaluator * eval = dynamic_cast<ClhepEvaluator*>(&ev);
879  if (eval){
880  const std::vector<std::string> & vars = eval->variables();
881  const std::vector<std::string> & vals = eval->values();
882  if (vars.size() != vals.size()) {
883  throw cms::Exception("DDException") << "DDStreamer::vars_write(): different size of variable names & values!";
884  }
885  size_t i(0), s(vars.size());
886  os << s << std::endl;
887  for (; i<s; ++i) {
888  os << '"' << vars[i] << '"' << ' '
889  << '"' << vals[i] << '"' << std::endl;
890  }
891  }
892  else {
893  throw cms::Exception("DDException") << "DDStreamer::vars_write(): expression-evaluator is not a ClhepEvaluator-implementation!";
894  }
895 }
int i
Definition: DBlmapReader.cc:9
bool ev
static value_type & instance()
const std::vector< std::string > & variables() const
access to the clhep-implementation of the dictionary variables
const std::vector< std::string > & values() const
std::ostream * o_
Definition: DDStreamer.h:125
void DDStreamer::write ( )

stream all DDD transient objects to the std::ostream referred to by member o_

Definition at line 126 of file DDStreamer.cc.

References Exception, and o_.

Referenced by pkg.AbstractPkg::generate().

127 {
128  if (o_ && *o_) {
129  write(*o_);
130  }
131  else {
132  throw cms::Exception("DDException") << "DDStreamer::write(): bad std::ostream";
133  }
134 }
void write()
stream all DDD transient objects to the std::ostream referred to by member o_
Definition: DDStreamer.cc:126
std::ostream * o_
Definition: DDStreamer.h:125
void DDStreamer::write ( std::ostream &  os)

stream all DDD transient objects to the given std::ostream os

Definition at line 146 of file DDStreamer.cc.

References materials_write(), names_write(), o_, parts_write(), pos_write(), rots_write(), solids_write(), specs_write(), and vars_write().

Referenced by pkg.AbstractPkg::generate().

147 {
148  o_=&os;
149  std::streamsize prec(os.precision());
150  os << std::setprecision(26) << std::scientific;
151  names_write();
152  vars_write();
153 
154  materials_write();
155  solids_write();
156  parts_write();
157 
158  pos_write();
159  specs_write();
160 
161  rots_write();
162  //os << DDI::Singleton<DDName::IdToName>::instance().size() << std::endl;
163  //names_write();
164  os << resetiosflags((std::ios_base::fmtflags)0);
165  os << std::setprecision(prec);
166 }
void materials_write()
write all instances of DDMaterial
Definition: DDStreamer.cc:269
void solids_write()
write all instances of DDSolid
Definition: DDStreamer.cc:352
void pos_write()
write the graph structure of DDCompactView::graph()
Definition: DDStreamer.cc:605
void vars_write()
write the dictionary of ClhepEvaluator
Definition: DDStreamer.cc:874
void specs_write()
write all instances of DDSpecifics
Definition: DDStreamer.cc:764
void parts_write()
write all instances of DDLogicalPart
Definition: DDStreamer.cc:495
void names_write()
write all instances of DDName
Definition: DDStreamer.cc:186
std::ostream * o_
Definition: DDStreamer.h:125
void rots_write()
write all instances of DDRotation
Definition: DDStreamer.cc:556

Member Data Documentation

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().