CMS 3D CMS Logo

DDLPolyGenerator.cc
Go to the documentation of this file.
7 
8 #include <cstddef>
9 #include <map>
10 #include <utility>
11 #include <vector>
12 
13 class DDCompactView;
14 
16 
18  myRegistry_->getElement("RZPoint")->clear();
19  myRegistry_->getElement("ZSection")->clear();
20 }
21 
22 // Upon encountering an end Polycone or Polyhedra tag, process the RZPoints
23 // element and extract the r and z std::vectors to feed into DDCore. Then, clear
24 // the RZPoints and clear this element.
26  auto myRZPoints = myRegistry_->getElement("RZPoint");
27  auto myZSection = myRegistry_->getElement("ZSection");
28 
30  DDXMLAttribute atts;
31 
32  // get z and r
33  std::vector<double> z, r, x, y;
34  for (size_t i = 0; i < myRZPoints->size(); ++i) {
35  atts = myRZPoints->getAttributeSet(i);
36  z.emplace_back(ev.eval(nmspace, atts.find("z")->second));
37  r.emplace_back(ev.eval(nmspace, atts.find("r")->second));
38  }
39 
40  // if z is empty, then it better not have been a polycone defined
41  // by RZPoints, instead, it must be a ZSection defined polycone.
42  if (z.empty()) {
43  // get zSection information, note, we already have a z declared above
44  // and we will use r for rmin. In this case, no use "trying" because
45  // it better be there!
46  std::vector<double> rMax;
47 
48  for (size_t i = 0; i < myZSection->size(); ++i) {
49  atts = myZSection->getAttributeSet(i);
50  z.emplace_back(ev.eval(nmspace, atts.find("z")->second));
51  r.emplace_back(ev.eval(nmspace, atts.find("rMin")->second));
52  rMax.emplace_back(ev.eval(nmspace, atts.find("rMax")->second));
53  }
54  atts = getAttributeSet();
55  if (name == "Polycone") // defined with ZSections
56  {
57  DDSolid ddpolycone = DDSolidFactory::polycone(getDDName(nmspace),
58  ev.eval(nmspace, atts.find("startPhi")->second),
59  ev.eval(nmspace, atts.find("deltaPhi")->second),
60  z,
61  r,
62  rMax);
63  } else if (name == "Polyhedra") // defined with ZSections
64  {
65  DDSolid ddpolyhedra = DDSolidFactory::polyhedra(getDDName(nmspace),
66  int(ev.eval(nmspace, atts.find("numSide")->second)),
67  ev.eval(nmspace, atts.find("startPhi")->second),
68  ev.eval(nmspace, atts.find("deltaPhi")->second),
69  z,
70  r,
71  rMax);
72  }
73 
74  } else if (name == "Polycone") // defined with RZPoints
75  {
76  atts = getAttributeSet();
77  DDSolid ddpolycone = DDSolidFactory::polycone(getDDName(nmspace),
78  ev.eval(nmspace, atts.find("startPhi")->second),
79  ev.eval(nmspace, atts.find("deltaPhi")->second),
80  z,
81  r);
82  } else if (name == "Polyhedra") // defined with RZPoints
83  {
84  atts = getAttributeSet();
85  DDSolid ddpolyhedra = DDSolidFactory::polyhedra(getDDName(nmspace),
86  int(ev.eval(nmspace, atts.find("numSide")->second)),
87  ev.eval(nmspace, atts.find("startPhi")->second),
88  ev.eval(nmspace, atts.find("deltaPhi")->second),
89  z,
90  r);
91  } else {
92  std::string msg = "\nDDLPolyGenerator::processElement was called with incorrect name of solid: " + name;
93  throwError(msg);
94  }
95  DDLSolid::setReference(nmspace, cpv);
96 
97  // clear out RZPoint element accumulator and ZSections
98  myRZPoints->clear();
99  myZSection->clear();
100  clear();
101 }
DDLElementRegistry * myRegistry_
Definition: DDXMLElement.h:173
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:551
Compact representation of the geometrical detector hierarchy.
Definition: DDCompactView.h:81
std::map< std::string, std::string > DDXMLAttribute
Definition: DDXMLElement.h:45
A DDSolid represents the shape of a part.
Definition: DDSolid.h:39
ClhepEvaluator & evaluator()
virtual const DDXMLAttribute & getAttributeSet(size_t aIndex=0) const
Get a "row" of attributes, i.e. one attribute set.
Definition: DDXMLElement.cc:54
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
tuple msg
Definition: mps_check.py:286
The main class for processing parsed elements.
virtual void clear(void)
clear this element&#39;s contents.
Definition: DDXMLElement.cc:40
void throwError(const std::string &keyMessage) const
format std::string for throw an error.
virtual const DDName getDDName(const std::string &defaultNS, const std::string &attname=std::string("name"), size_t aIndex=0)
Definition: DDXMLElement.cc:56
void setReference(const std::string &nmspace, DDCompactView &cpv)
Definition: DDLSolid.cc:13
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:565