CMS 3D CMS Logo

DDLPolyGenerator.cc
Go to the documentation of this file.
2 
3 #include <stddef.h>
4 #include <map>
5 #include <utility>
6 #include <vector>
7 
13 
14 class DDCompactView;
15 
17  : DDLSolid( myreg )
18 {}
19 
20 void
22 {
23  myRegistry_->getElement("RZPoint")->clear();
24  myRegistry_->getElement("ZSection")->clear();
25 }
26 
27 // Upon encountering an end Polycone or Polyhedra tag, process the RZPoints
28 // element and extract the r and z std::vectors to feed into DDCore. Then, clear
29 // the RZPoints and clear this element.
30 void
32 {
33  auto myRZPoints = myRegistry_->getElement("RZPoint");
34  auto myZSection = myRegistry_->getElement("ZSection");
35 
37  DDXMLAttribute atts;
38 
39  // get z and r
40  std::vector<double> z, r, x, y;
41  for (size_t i = 0; i < myRZPoints->size(); ++i)
42  {
43  atts = myRZPoints->getAttributeSet(i);
44  z.push_back(ev.eval(nmspace, atts.find("z")->second));
45  r.push_back(ev.eval(nmspace, atts.find("r")->second));
46  }
47 
48  // if z is empty, then it better not have been a polycone defined
49  // by RZPoints, instead, it must be a ZSection defined polycone.
50  if (z.size() == 0 )
51  {
52  // get zSection information, note, we already have a z declared above
53  // and we will use r for rmin. In this case, no use "trying" because
54  // it better be there!
55  std::vector<double> rMax;
56 
57  for (size_t i = 0; i < myZSection->size(); ++i)
58  {
59  atts = myZSection->getAttributeSet(i);
60  z.push_back(ev.eval(nmspace, atts.find("z")->second));
61  r.push_back(ev.eval(nmspace, atts.find("rMin")->second));
62  rMax.push_back(ev.eval(nmspace, atts.find("rMax")->second));
63  }
64  atts = getAttributeSet();
65  if (name == "Polycone") // defined with ZSections
66  {
67  DDSolid ddpolycone =
69  , ev.eval(nmspace, atts.find("startPhi")->second)
70  , ev.eval(nmspace, atts.find("deltaPhi")->second)
71  , z
72  , r
73  , rMax);
74  }
75  else if (name == "Polyhedra") // defined with ZSections
76  {
77  DDSolid ddpolyhedra =
79  , int (ev.eval(nmspace, atts.find("numSide")->second))
80  , ev.eval(nmspace, atts.find("startPhi")->second)
81  , ev.eval(nmspace, atts.find("deltaPhi")->second)
82  , z
83  , r
84  , rMax);
85  }
86 
87  }
88  else if (name == "Polycone") // defined with RZPoints
89  {
90  atts = getAttributeSet();
91  DDSolid ddpolycone =
93  , ev.eval(nmspace, atts.find("startPhi")->second)
94  , ev.eval(nmspace, atts.find("deltaPhi")->second)
95  , z
96  , r);
97  }
98  else if (name == "Polyhedra") // defined with RZPoints
99  {
100  atts = getAttributeSet();
101  DDSolid ddpolyhedra =
103  , int (ev.eval(nmspace, atts.find("numSide")->second))
104  , ev.eval(nmspace, atts.find("startPhi")->second)
105  , ev.eval(nmspace, atts.find("deltaPhi")->second)
106  , z
107  , r);
108  } else
109  {
110  std::string msg = "\nDDLPolyGenerator::processElement was called with incorrect name of solid: " + name;
111  throwError(msg);
112  }
113  DDLSolid::setReference(nmspace, cpv);
114 
115  // clear out RZPoint element accumulator and ZSections
116  myRZPoints->clear();
117  myZSection->clear();
118  clear();
119 }
DDLElementRegistry * myRegistry_
Definition: DDXMLElement.h:172
void processElement(const std::string &name, const std::string &nmspace, DDCompactView &cpv) override
Processing the element.
void preProcessElement(const std::string &name, const std::string &nmspace, DDCompactView &cpv) override
Called by loadAttributes AFTER attributes are loaded.
DDLPolyGenerator(DDLElementRegistry *myreg)
static DDSolid polycone(const DDName &name, double startPhi, double deltaPhi, const std::vector< double > &z, const std::vector< double > &rmin, const std::vector< double > &rmax)
Creates a polycone (refere to Geant3 or Geant4 documentation)
Definition: DDSolid.cc:714
virtual const DDXMLAttribute & getAttributeSet(size_t aIndex=0) const
Get a "row" of attributes, i.e. one attribute set.
Definition: DDXMLElement.cc:73
void throwError(const std::string &keyMessage) const
format std::string for throw an error.
bool ev
type of data representation of DDCompactView
Definition: DDCompactView.h:90
std::map< std::string, std::string > DDXMLAttribute
Definition: DDXMLElement.h:45
A DDSolid represents the shape of a part.
Definition: DDSolid.h:37
ClhepEvaluator & evaluator()
std::shared_ptr< DDXMLElement > getElement(const std::string &name)
THE most important part. Getting the pointer to a given element type.
DDLSolid processes Box elements.
Definition: DDLSolid.h:30
double eval(const std::string &ns, const std::string &expr)
The main class for processing parsed elements.
virtual void clear(void)
clear this element&#39;s contents.
Definition: DDXMLElement.cc:55
virtual const DDName getDDName(const std::string &defaultNS, const std::string &attname=std::string("name"), size_t aIndex=0)
Definition: DDXMLElement.cc:80
void setReference(const std::string &nmspace, DDCompactView &cpv)
Definition: DDLSolid.cc:17
static DDSolid polyhedra(const DDName &name, int sides, double startPhi, double deltaPhi, const std::vector< double > &z, const std::vector< double > &rmin, const std::vector< double > &rmax)
Creates a polyhedra (refere to Geant3 or Geant4 documentation)
Definition: DDSolid.cc:732