CMS 3D CMS Logo

DDLPolyGenerator.cc

Go to the documentation of this file.
00001 /***************************************************************************
00002                           DDLPolyGenerator.cpp  -  description
00003                              -------------------
00004     begin                : Thu Oct 25 2001
00005     email                : case@ucdhep.ucdavis.edu
00006  ***************************************************************************/
00007 
00008 /***************************************************************************
00009  *                                                                         *
00010  *           DDDParser sub-component of DDD                                *
00011  *                                                                         *
00012  ***************************************************************************/
00013 
00014 
00015 
00016 // Parser parts needed by PolyGenerator.
00017 #include "DDLPolyGenerator.h"
00018 #include "DDLElementRegistry.h"
00019 
00020 // DDCore dependencies
00021 #include "DetectorDescription/Core/interface/DDName.h"
00022 #include "DetectorDescription/Core/interface/DDSolid.h"
00023 #include "DetectorDescription/Base/interface/DDdebug.h"
00024 #include "DetectorDescription/Base/interface/DDException.h"
00025 
00026 #include "DetectorDescription/ExprAlgo/interface/ExprEvalSingleton.h"
00027 
00028 #include <string>
00029 
00030 // Default constructor.
00031 DDLPolyGenerator::DDLPolyGenerator()
00032 {
00033 }
00034 
00035 // Default destructor
00036 DDLPolyGenerator::~DDLPolyGenerator()
00037 {
00038 }
00039 
00040 void DDLPolyGenerator::preProcessElement (const std::string& name, const std::string& nmspace)
00041 {
00042   DDLElementRegistry::getElement("RZPoint")->clear();
00043   DDLElementRegistry::getElement("ZSection")->clear();
00044 }
00045 
00046 // Upon encountering an end Polycone or Polyhedra tag, process the RZPoints
00047 // element and extract the r and z std::vectors to feed into DDCore.  Then, clear
00048 // the RZPoints and clear this element.
00049 void DDLPolyGenerator::processElement (const std::string& name, const std::string& nmspace)
00050 {
00051   DCOUT_V('P', "DDLPolyGenerator::processElement started");
00052 
00053   DDXMLElement* myRZPoints = DDLElementRegistry::getElement("RZPoint");
00054   DDXMLElement* myZSection = DDLElementRegistry::getElement("ZSection");
00055 
00056   ExprEvalInterface & ev = ExprEvalSingleton::instance();
00057   DDXMLAttribute atts;
00058 
00059   // get z and r
00060   std::vector<double> z, r;
00061   for (size_t i = 0; i < myRZPoints->size(); ++i)
00062     {
00063       atts = myRZPoints->getAttributeSet(i);
00064       z.push_back(ev.eval(nmspace, atts.find("z")->second));
00065       r.push_back(ev.eval(nmspace, atts.find("r")->second));
00066     }
00067 
00068   // if z is empty, then it better not have been a polycone defined
00069   // by RZPoints, instead, it must be a ZSection defined polycone.
00070   if (z.size() == 0 )
00071     {
00072       // get zSection information, note, we already have a z declared above
00073       // and we will use r for rmin.  In this case, no use "trying" because
00074       // it better be there!
00075       std::vector<double> rMax;
00076 
00077       for (size_t i = 0; i < myZSection->size(); ++i)
00078         {
00079           atts = myZSection->getAttributeSet(i);
00080           z.push_back(ev.eval(nmspace, atts.find("z")->second));
00081           r.push_back(ev.eval(nmspace, atts.find("rMin")->second));
00082           rMax.push_back(ev.eval(nmspace, atts.find("rMax")->second));
00083         }
00084       atts = getAttributeSet();
00085       if (name == "Polycone") // defined with ZSections 
00086         {
00087           DDSolid ddpolycone = 
00088             DDSolidFactory::polycone(getDDName(nmspace)
00089                                      , ev.eval(nmspace, atts.find("startPhi")->second)
00090                                      , ev.eval(nmspace, atts.find("deltaPhi")->second)
00091                                      , z
00092                                      , r
00093                                      , rMax);
00094         }
00095       else if (name == "Polyhedra")  // defined with ZSections
00096         {
00097           DDSolid ddpolyhedra = 
00098             DDSolidFactory::polyhedra(getDDName(nmspace)
00099                                       , int (ev.eval(nmspace, atts.find("numSide")->second))
00100                                       , ev.eval(nmspace, atts.find("startPhi")->second)
00101                                       , ev.eval(nmspace, atts.find("deltaPhi")->second)
00102                                       , z
00103                                       , r
00104                                       , rMax);
00105         }
00106 
00107     }
00108   else if (name == "Polycone") // defined with RZPoints
00109     {
00110       atts = getAttributeSet();
00111       DDSolid ddpolycone = 
00112         DDSolidFactory::polycone(getDDName(nmspace)
00113                                  , ev.eval(nmspace, atts.find("startPhi")->second)
00114                                  , ev.eval(nmspace, atts.find("deltaPhi")->second)
00115                                  , z
00116                                  , r);
00117     }
00118   else if (name == "Polyhedra") // defined with RZPoints
00119     {
00120       atts = getAttributeSet();
00121       DDSolid ddpolyhedra = 
00122         DDSolidFactory::polyhedra(getDDName(nmspace)
00123                                   , int (ev.eval(nmspace, atts.find("numSide")->second))
00124                                   , ev.eval(nmspace, atts.find("startPhi")->second)
00125                                   , ev.eval(nmspace, atts.find("deltaPhi")->second)
00126                                   , z
00127                                   , r);
00128     }
00129   else
00130     {
00131       std::string msg = "\nDDLPolyGenerator::processElement was called with incorrect name of solid: " + name;
00132       throwError(msg);
00133     }
00134   DDLSolid::setReference(nmspace);
00135 
00136   // clear out RZPoint element accumulator and ZSections
00137   myRZPoints->clear();
00138   myZSection->clear();
00139   clear();
00140 
00141   DCOUT_V('P', "DDLPolyGenerator::processElement completed");
00142 }

Generated on Tue Jun 9 17:32:24 2009 for CMSSW by  doxygen 1.5.4