CMS 3D CMS Logo

DDStreamer.cc File Reference

#include "DetectorDescription/Core/interface/DDStreamer.h"
#include "DetectorDescription/Base/interface/Singleton.h"
#include "DetectorDescription/Core/interface/DDMaterial.h"
#include "DetectorDescription/Core/interface/DDSolid.h"
#include "DetectorDescription/Core/interface/DDLogicalPart.h"
#include "DetectorDescription/Core/interface/DDTransform.h"
#include "DetectorDescription/Core/interface/DDRoot.h"
#include "DetectorDescription/Core/interface/DDSpecifics.h"
#include "DetectorDescription/Core/interface/DDValue.h"
#include "DetectorDescription/Base/interface/DDdebug.h"
#include "DetectorDescription/Core/interface/DDConstant.h"
#include "DetectorDescription/Core/interface/DDPosPart.h"
#include "DetectorDescription/Core/interface/DDPartSelection.h"
#include "DetectorDescription/ExprAlgo/interface/ExprEvalSingleton.h"
#include "FWCore/MessageLogger/interface/MessageLogger.h"
#include <iomanip>

Go to the source code of this file.

Classes

struct  double_binary

Typedefs

typedef double_binary B

Functions

template<class T>
size_t dd_count (const T &dummy)
void dd_get_boolean_params (std::istream &is, DDRotation &r, DDTranslation &t, DDSolid &a, DDSolid &b)
std::string dd_get_delimit (std::istream &is, char d)
DDName dd_get_name (std::istream &is)
DDName dd_get_name_string (std::istream &is)
void dd_rot_bin_in (std::istream &is, DDRotationMatrix &r)
void dd_rot_bin_out (std::ostream &os, const DDRotationMatrix &rm)
void dd_rot_out (std::ostream &os, const DDRotation &r)
void dd_stream_booleans (std::ostream &os, DDSolid s, DDSolidShape sh)
void dd_stream_reflected (std::ostream &os, DDSolid s)
void nameout (std::ostream &o, const DDName &n)
void nameout_strings (std::ostream &o, const DDName &n)
std::ostream & operator<< (std::ostream &os, double_binary b)
std::istream & operator>> (std::istream &is, double_binary &b)


Typedef Documentation

typedef double_binary B

Definition at line 236 of file DDStreamer.cc.


Function Documentation

template<class T>
size_t dd_count ( const T &  dummy  )  [inline]

Definition at line 216 of file DDStreamer.cc.

References begin, end, it, and HLT_VtxMuL3::result.

Referenced by DDStreamer::materials_write(), DDStreamer::parts_write(), DDStreamer::rots_write(), DDStreamer::solids_write(), and DDStreamer::specs_write().

00217 {
00218   size_t result(0);
00219   typename T::template iterator<T> it(T::begin()), ed(T::end());
00220   for (; it!=ed; ++it) {
00221     if (it->isDefined().second) {
00222       ++result;
00223     }
00224   }
00225   return result;
00226 }

void dd_get_boolean_params ( std::istream &  is,
DDRotation r,
DDTranslation t,
DDSolid a,
DDSolid b 
)

Definition at line 387 of file DDStreamer.cc.

References DCOUT, dd_get_name(), n, DDBase< N, C >::name(), x, y, and z.

Referenced by DDStreamer::solids_read().

00388 {
00389    DDName n = dd_get_name(is);
00390    r = DDRotation(n);
00391    //double x(0), y(0), z(0);
00392    B x,y,z;
00393    char cr = is.get();
00394    if(cr != ' ') 
00395       throw DDException("DDStreamer::get_boolean_param(): inconsistent sequence! no blank delimiter before trans!");
00396    is >> x;
00397    is >> y;
00398    is >> z;
00399    t = DDTranslation(x.val_,y.val_,z.val_);
00400    n = dd_get_name(is);
00401    a = DDSolid(n);
00402    n = dd_get_name(is);
00403    b = DDSolid(n);
00404    DCOUT('y', "boolean-par: rot=" << r.name() << " t=" << t << " a=" << a.name() << " b=" << b.name());
00405 }

std::string dd_get_delimit ( std::istream &  is,
char  d 
)

Definition at line 67 of file DDStreamer.cc.

References i.

Referenced by dd_get_name_string(), DDStreamer::names_read(), DDStreamer::specs_read(), and DDStreamer::vars_read().

00068 {
00069   std::string nm;
00070   char i;
00071   while ((i=is.get()) && i != d) ;
00072   while ((i=is.get()) && i != d) {
00073       nm = nm + i; 
00074    }
00075   return nm;
00076 }

DDName dd_get_name ( std::istream &  is  ) 

Definition at line 94 of file DDStreamer.cc.

References id.

Referenced by dd_get_boolean_params(), DDStreamer::materials_read(), DDStreamer::parts_read(), DDStreamer::pos_read(), DDStreamer::rots_read(), DDStreamer::solids_read(), and DDStreamer::specs_read().

00095 {
00096   size_t id(0);
00097   is >> id;
00098   return DDName(id);
00099 }

DDName dd_get_name_string ( std::istream &  is  ) 

Definition at line 78 of file DDStreamer.cc.

References dd_get_delimit().

00079 {  
00080    std::string nm(dd_get_delimit(is,'"'))  ;
00081    return DDName(nm,
00082                  dd_get_delimit(is,'"'));
00083 /*
00084    char i;
00085    while ((i=is.get()) && i != '"') ;
00086    while ((i=is.get()) && i != '"') {
00087       nm = nm + i; 
00088    }
00089    std::pair<std::string,std::string> p = DDSplit(nm);
00090    return DDName(p.first,p.second);
00091 */   
00092 }

void dd_rot_bin_in ( std::istream &  is,
DDRotationMatrix r 
)

Definition at line 578 of file DDStreamer.cc.

References i, v, double_binary::val_, and w.

Referenced by DDStreamer::pos_read(), and DDStreamer::rots_read().

00579 {
00580     double v[9];
00581     B w;
00582     for (int i=0; i<9;i++) {
00583       is >> w; v[i]=w.val_;
00584     }
00585     r.SetComponents(v,v+9);
00586 }

void dd_rot_bin_out ( std::ostream &  os,
const DDRotationMatrix rm 
)

Definition at line 536 of file DDStreamer.cc.

References i, and v.

Referenced by dd_rot_out(), and DDStreamer::pos_write().

00537 {
00538   double v[9]; 
00539   rm.GetComponents(v,v+9);
00540   for (int i=0;i<9;i++)
00541     os        << B(v[i]);
00542 }

void dd_rot_out ( std::ostream &  os,
const DDRotation r 
)

Definition at line 544 of file DDStreamer.cc.

References DCOUT, dd_rot_bin_out(), lat::endl(), DDBase< N, C >::name(), nameout(), and DDRotation::rotation().

Referenced by DDStreamer::rots_write().

00544                                                        {
00545     os << "--Rot: " << r.name() << " @ ";
00546     nameout(os,r.name());
00547     os << ' ';
00548     const DDRotationMatrix & rm = *(r.rotation());
00549     DCOUT('y', "write-rots=" << r.name());
00550 /*
00551     os << ' ' << B(rep.xx_) << ' ' << B(rep.xy_) << ' ' << B(rep.xz_) << ' '
00552               << B(rep.yx_) << ' ' << B(rep.yy_) << ' ' << B(rep.yz_) << ' '
00553               << B(rep.zx_) << ' ' << B(rep.zy_) << ' ' << B(rep.zz_) << std::endl; 
00554 */            
00555    dd_rot_bin_out(os,rm);             
00556    os << std::endl;
00557 }

void dd_stream_booleans ( std::ostream &  os,
DDSolid  s,
DDSolidShape  sh 
)

Definition at line 323 of file DDStreamer.cc.

References b, lat::endl(), DDBase< N, C >::isDefined(), DDBase< N, C >::name(), nameout(), DDBooleanSolid::rotation(), DDBooleanSolid::solidA(), DDBooleanSolid::solidB(), and DDBooleanSolid::translation().

Referenced by DDStreamer::solids_write().

00324 {
00325   DDBooleanSolid b(s);
00326   DDRotation temprot = b.rotation();
00327   if(!temprot.isDefined().second) {
00328     temprot = DDRotation();
00329     edm::LogError("DDStreamer") << "DDStreamer::dd_stream_booleans(): solid=" << s.name() << " has no rotation. Using unit-rot." << std::endl;
00330   }
00331   nameout(os,temprot.name()); 
00332   // binary output of the translation std::vector
00333   os << ' ' << B(b.translation().x()) // << ' '
00334      << B(b.translation().y()) // << ' '
00335      << B(b.translation().z()) << ' '; 
00336   nameout(os,b.solidA().name());
00337   os << ' ';
00338   nameout(os,b.solidB().name());            
00339 }

void dd_stream_reflected ( std::ostream &  os,
DDSolid  s 
)

Definition at line 341 of file DDStreamer.cc.

References DDBase< N, C >::name(), nameout(), and DDReflectionSolid::unreflected().

Referenced by DDStreamer::solids_write().

00342 {
00343       DDReflectionSolid ref(s);
00344       nameout(os,ref.unreflected().name());
00345 }

void nameout ( std::ostream &  o,
const DDName n 
)

Definition at line 106 of file DDStreamer.cc.

References DDName::id().

Referenced by dd_rot_out(), dd_stream_booleans(), dd_stream_reflected(), DDStreamer::materials_write(), DDStreamer::parts_write(), DDStreamer::pos_write(), DDStreamer::solids_write(), and DDStreamer::specs_write().

00107 {
00108   o << n.id();
00109 }

void nameout_strings ( std::ostream &  o,
const DDName n 
)

Definition at line 101 of file DDStreamer.cc.

References DDName::name(), and DDName::ns().

00102 {
00103   o << '"' << n.name() << '"' << ' ' << '"' << n.ns() << '"' ;
00104 }

std::ostream& operator<< ( std::ostream &  os,
double_binary  b 
)

Definition at line 238 of file DDStreamer.cc.

References d, and double_binary::val_.

00239 {
00240   const char * d = (const char *)(&(b.val_));
00241   //size_t s(sizeof(double)), i(0);
00242   //os << '(';
00243   os.write(d,sizeof(double));
00244   return os;
00245 }

std::istream& operator>> ( std::istream &  is,
double_binary b 
) [inline]

Definition at line 248 of file DDStreamer.cc.

References d, and double_binary::val_.

00249 {
00250   char * d = (char *)(&(b.val_));
00251   //size_t s(sizeof(double)), i(0);
00252   is.read(d,sizeof(double));
00253   return is;
00254 } 


Generated on Tue Jun 9 17:52:36 2009 for CMSSW by  doxygen 1.5.4