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 }
DDXMLElement::clear
virtual void clear(void)
clear this element's contents.
Definition: DDXMLElement.cc:40
DDAxes::y
photonAnalyzer_cfi.rMax
rMax
Definition: photonAnalyzer_cfi.py:91
mps_fire.i
i
Definition: mps_fire.py:428
DDXMLElement::throwError
void throwError(const std::string &keyMessage) const
format std::string for throw an error.
Definition: DDXMLElement.cc:209
DDLSolid::setReference
void setReference(const std::string &nmspace, DDCompactView &cpv)
Definition: DDLSolid.cc:13
DDLSolid
DDLSolid processes Box elements.
Definition: DDLSolid.h:30
ClhepEvaluator.h
DDLElementRegistry
The main class for processing parsed elements.
Definition: DDLElementRegistry.h:23
ClhepEvaluator
Definition: ClhepEvaluator.h:8
mps_check.msg
tuple msg
Definition: mps_check.py:285
DDAxes::x
DDXMLElement::getAttributeSet
virtual const DDXMLAttribute & getAttributeSet(size_t aIndex=0) const
Get a "row" of attributes, i.e. one attribute set.
Definition: DDXMLElement.cc:54
DDLElementRegistry::evaluator
ClhepEvaluator & evaluator()
Definition: DDLElementRegistry.h:42
DDSolidFactory::polyhedra
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:551
DDCompactView
Compact representation of the geometrical detector hierarchy.
Definition: DDCompactView.h:81
DDAxes::z
DDSolid.h
DDXMLAttribute
std::map< std::string, std::string > DDXMLAttribute
Definition: DDXMLElement.h:45
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
DDLPolyGenerator.h
DDLPolyGenerator::processElement
void processElement(const std::string &name, const std::string &nmspace, DDCompactView &cpv) override
Processing the element.
Definition: DDLPolyGenerator.cc:25
DDSolidFactory::polycone
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:537
DDLElementRegistry.h
DDLPolyGenerator::preProcessElement
void preProcessElement(const std::string &name, const std::string &nmspace, DDCompactView &cpv) override
Called by loadAttributes AFTER attributes are loaded.
Definition: DDLPolyGenerator.cc:17
alignCSCRings.r
r
Definition: alignCSCRings.py:93
DDLSolid.h
DDLPolyGenerator::DDLPolyGenerator
DDLPolyGenerator(DDLElementRegistry *myreg)
Definition: DDLPolyGenerator.cc:15
DDXMLElement::getDDName
const virtual DDName getDDName(const std::string &defaultNS, const std::string &attname=std::string("name"), size_t aIndex=0)
Definition: DDXMLElement.cc:56
DDLElementRegistry::getElement
std::shared_ptr< DDXMLElement > getElement(const std::string &name)
THE most important part. Getting the pointer to a given element type.
Definition: DDLElementRegistry.cc:42
DDXMLElement.h
ev
bool ev
Definition: Hydjet2Hadronizer.cc:95
Skims_PA_cff.name
name
Definition: Skims_PA_cff.py:17
DDSolid
A DDSolid represents the shape of a part.
Definition: DDSolid.h:39
DDXMLElement::myRegistry_
DDLElementRegistry * myRegistry_
Definition: DDXMLElement.h:173