CMS 3D CMS Logo

List of all members | Public Member Functions | Private Member Functions
DDLDivision Class Referencefinal

DDLDivision processes Division elements. More...

#include <DDLDivision.h>

Inheritance diagram for DDLDivision:
DDXMLElement

Public Member Functions

 DDLDivision (DDLElementRegistry *myreg)
 
void preProcessElement (const std::string &name, const std::string &nmspace, DDCompactView &cpv) override
 Called by loadAttributes AFTER attributes are loaded. More...
 
void processElement (const std::string &name, const std::string &nmspace, DDCompactView &cpv) override
 Processing the element. More...
 
- Public Member Functions inherited from DDXMLElement
void appendText (const std::string &inText)
 append to the current (i.e. most recently added) More...
 
virtual std::vector< DDXMLAttribute >::const_iterator begin (void)
 
virtual void clear (void)
 clear this element's contents. More...
 
 DDXMLElement (DDLElementRegistry *myreg)
 Constructor. More...
 
 DDXMLElement (DDLElementRegistry *myreg, const bool &clearme)
 Constructor for autoClear element. More...
 
virtual std::vector< DDXMLAttribute >::const_iterator end (void)
 
virtual const std::string & get (const std::string &name, size_t aIndex=0) const
 Returns a specific value from the aIndex set of attributes. More...
 
virtual const std::string & getAttribute (const std::string &name) const
 Access to attributes by name. More...
 
virtual const DDXMLAttributegetAttributeSet (size_t aIndex=0) const
 Get a "row" of attributes, i.e. one attribute set. More...
 
virtual const DDName getDDName (const std::string &defaultNS, const std::string &attname=std::string("name"), size_t aIndex=0)
 
const std::string getText (size_t tindex=0) const
 retrieve the text blob. More...
 
virtual std::vector< std::string > getVectorAttribute (const std::string &name)
 Returns a set of values as a std::vector of strings, given the attribute name. More...
 
virtual bool gotText (void) const
 gotText()? kind of like gotMilk? Yes = text has already been encountered. More...
 
virtual bool isEmpty (void) const
 Have any elements of this type been encountered but not processed? More...
 
void loadAttributes (const std::string &elemName, const std::vector< std::string > &names, const std::vector< std::string > &values, const std::string &nmspace, DDCompactView &cpv)
 Load the element attributes. More...
 
void loadText (const std::string &inText)
 Used to load both text and XML comments into this object. More...
 
std::vector< DDXMLAttribute >::const_iterator & operator++ (int inc)
 Allow the elements of this type to be iterated over using ++ operator. More...
 
const std::string & parent (void) const
 access to parent element name More...
 
void setParent (const std::string &pename)
 Set parent element name to central list of names. More...
 
void setSelf (const std::string &sename)
 Set self element name to central list of names. More...
 
virtual size_t size (void) const
 Number of elements accumulated. More...
 
virtual void stream (std::ostream &os) const
 Allow for the elements to have their own streaming method, but also provide a default. More...
 
void throwError (const std::string &keyMessage) const
 format std::string for throw an error. More...
 
virtual ~DDXMLElement (void)=default
 Destructor. More...
 

Private Member Functions

DDDividedGeometryObjectmakeDivider (const DDDivision &div, DDCompactView *cpv)
 

Additional Inherited Members

- Protected Attributes inherited from DDXMLElement
DDLElementRegistrymyRegistry_
 

Detailed Description

DDLDivision processes Division elements.

Author
Michael Case

DDLDivision.h - description

begin: Friday, April 23, 2004 email: case@.nosp@m.ucdh.nosp@m.ep.uc.nosp@m.davi.nosp@m.s.edu

Definition at line 27 of file DDLDivision.h.

Constructor & Destructor Documentation

◆ DDLDivision()

DDLDivision::DDLDivision ( DDLElementRegistry myreg)

Definition at line 26 of file DDLDivision.cc.

26 : DDXMLElement(myreg) {}
DDXMLElement(DDLElementRegistry *myreg)
Constructor.
Definition: DDXMLElement.cc:14

Member Function Documentation

◆ makeDivider()

DDDividedGeometryObject * DDLDivision::makeDivider ( const DDDivision div,
DDCompactView cpv 
)
private

Definition at line 83 of file DDLDivision.cc.

References DDDivision::axis(), dd_not_init, ddbox, ddcons, ddintersection, ddpolycone_rrz, ddpolycone_rz, ddpolyhedra_rrz, ddpolyhedra_rz, ddpseudotrap, ddshapeless, ddsubtraction, ddtrap, ddtrunctubs, ddtubs, ddunion, DDAxesNames::name(), DDSolidShapesName::name(), DDName::name(), DDBase< N, C >::name(), DDName::ns(), DDDivision::parent(), phi, rho, alignCSCRings::s, DDSolid::shape(), DDLogicalPart::solid(), AlCaHLTBitMon_QueryRunRegistry::string, DDXMLElement::throwError(), x, y, and z.

Referenced by processElement().

83  {
84  DDDividedGeometryObject* dg = nullptr;
85 
86  switch (div.parent().solid().shape()) {
88  if (div.axis() == DDAxes::x)
89  dg = new DDDividedBoxX(div, cpv);
90  else if (div.axis() == DDAxes::y)
91  dg = new DDDividedBoxY(div, cpv);
92  else if (div.axis() == DDAxes::z)
93  dg = new DDDividedBoxZ(div, cpv);
94  else {
95  std::string s = "DDLDivision can not divide a ";
97  s += " along axis " + DDAxesNames::name(div.axis());
98  s += ".";
99  s += "\n name= " + div.name().ns() + ":" + div.name().name();
100  s += "\n parent= " + div.parent().name().ns() + ":" + div.parent().name().name();
101  throwError(s);
102  }
103  break;
104 
106  if (div.axis() == DDAxes::rho)
107  dg = new DDDividedTubsRho(div, cpv);
108  else if (div.axis() == DDAxes::phi)
109  dg = new DDDividedTubsPhi(div, cpv);
110  else if (div.axis() == DDAxes::z)
111  dg = new DDDividedTubsZ(div, cpv);
112  else {
113  std::string s = "DDLDivision can not divide a ";
115  s += " along axis " + DDAxesNames::name(div.axis());
116  s += ".";
117  s += "\n name= " + div.name().ns() + ":" + div.name().name();
118  s += "\n parent= " + div.parent().name().ns() + ":" + div.parent().name().name();
119  throwError(s);
120  }
121  break;
122 
124  if (div.axis() == DDAxes::x)
125  dg = new DDDividedTrdX(div, cpv);
126  else if (div.axis() == DDAxes::y)
127  dg = new DDDividedTrdY(div, cpv);
128  else if (div.axis() == DDAxes::z)
129  dg = new DDDividedTrdZ(div, cpv);
130  else {
131  std::string s = "DDLDivision can not divide a ";
133  s += " along axis ";
134  s += DDAxesNames::name(div.axis());
135  s += ".";
136  s += "\n name= " + div.name().ns() + ":" + div.name().name();
137  s += "\n parent= " + div.parent().name().ns() + ":" + div.parent().name().name();
138  throwError(s);
139  }
140  break;
141 
143  if (div.axis() == DDAxes::rho)
144  dg = new DDDividedConsRho(div, cpv);
145  else if (div.axis() == DDAxes::phi)
146  dg = new DDDividedConsPhi(div, cpv);
147  else if (div.axis() == DDAxes::z)
148  dg = new DDDividedConsZ(div, cpv);
149  else {
150  std::string s = "DDLDivision can not divide a ";
152  s += " along axis " + DDAxesNames::name(div.axis());
153  s += ".";
154  s += "\n name= " + div.name().ns() + ":" + div.name().name();
155  s += "\n parent= " + div.parent().name().ns() + ":" + div.parent().name().name();
156  throwError(s);
157  }
158  break;
159 
161  if (div.axis() == DDAxes::rho)
162  dg = new DDDividedPolyconeRho(div, cpv);
163  else if (div.axis() == DDAxes::phi)
164  dg = new DDDividedPolyconePhi(div, cpv);
165  else if (div.axis() == DDAxes::z)
166  dg = new DDDividedPolyconeZ(div, cpv);
167  else {
168  std::string s = "DDLDivision can not divide a ";
170  s += " along axis ";
171  s += DDAxesNames::name(div.axis());
172  s += ".";
173  s += "\n name= " + div.name().ns() + ":" + div.name().name();
174  s += "\n parent= " + div.parent().name().ns() + ":" + div.parent().name().name();
175  throwError(s);
176  }
177  break;
178 
180  if (div.axis() == DDAxes::rho)
181  dg = new DDDividedPolyhedraRho(div, cpv);
182  else if (div.axis() == DDAxes::phi)
183  dg = new DDDividedPolyhedraPhi(div, cpv);
184  else if (div.axis() == DDAxes::z)
185  dg = new DDDividedPolyhedraZ(div, cpv);
186  else {
187  std::string s = "DDLDivision can not divide a ";
189  s += " along axis ";
190  s += DDAxesNames::name(div.axis());
191  s += ".";
192  s += "\n name= " + div.name().ns() + ":" + div.name().name();
193  s += "\n parent= " + div.parent().name().ns() + ":" + div.parent().name().name();
194  throwError(s);
195  }
196  break;
197 
200  std::string s = "ERROR: A Polycone or Polyhedra can not be divided on any axis if it's\n";
201  s += "original definition used r and z instead of ZSections. This has\n";
202  s += "not (yet) been implemented.";
203  s += "\n name= " + div.name().ns() + ":" + div.name().name();
204  s += "\n parent= " + div.parent().name().ns() + ":" + div.parent().name().name();
205  } break;
206 
214  std::string s = "DDLDivision can not divide a ";
216  s += " at all (yet?). Requested axis was ";
217  s += DDAxesNames::name(div.axis());
218  s += ".\n";
219  throwError(s);
220  } break;
221  default:
222  break;
223  }
224  return dg;
225 }
DDAxes axis() const
Definition: DDDivision.cc:49
const DDLogicalPart & parent() const
Definition: DDDivision.cc:57
static const char *const name(DDSolidShape s)
Definition: DDSolidShapes.h:33
const std::string & name() const
Returns the name.
Definition: DDName.cc:41
DDSolidShape shape(void) const
The type of the solid.
Definition: DDSolid.cc:123
const N & name() const
Definition: DDBase.h:58
const DDSolid & solid(void) const
Returns a reference object of the solid being the shape of this LogicalPart.
void throwError(const std::string &keyMessage) const
format std::string for throw an error.
static const std::string name(const DDAxes &s)
Definition: DDAxes.cc:24
const std::string & ns() const
Returns the namespace.
Definition: DDName.cc:52

◆ preProcessElement()

void DDLDivision::preProcessElement ( const std::string &  name,
const std::string &  nmspace,
DDCompactView cpv 
)
overridevirtual

Called by loadAttributes AFTER attributes are loaded.

The preProcessElement method can assume that the attributes are loaded and perform any code that is necessary at the start of an element.

This would allow users to call their own code to setup anything necessary for the continued processing of the child elements.

Reimplemented from DDXMLElement.

Definition at line 28 of file DDLDivision.cc.

28 {}

◆ processElement()

void DDLDivision::processElement ( const std::string &  name,
const std::string &  nmspace,
DDCompactView cpv 
)
overridevirtual

Processing the element.

The processElement method completes any necessary work to process the XML element.

For example, this can be used to call the DDCore to make the geometry in memory. There is a default for this so that if not declared in the inheriting class, no processing is done.

Reimplemented from DDXMLElement.

Definition at line 30 of file DDLDivision.cc.

References DDXMLElement::clear(), makeMEIFBenchmarkPlots::ev, DDLElementRegistry::evaluator(), DDDividedGeometryObject::execute(), DDXMLElement::getAttributeSet(), DDXMLElement::getDDName(), DDBase< N, C >::isDefined(), makeDivider(), DDXMLElement::myRegistry_, DDAxesNames::name(), DDName::name(), DDName::ns(), DDXMLElement::parent(), DDLogicalPart::solid(), AlCaHLTBitMon_QueryRunRegistry::string, and DDXMLElement::throwError().

30  {
32 
33  DDName parent = getDDName(nmspace, "parent");
35  size_t ax = 0;
36  while (DDAxesNames::name(DDAxes(ax)) != atts.find("axis")->second && DDAxesNames::name(DDAxes(ax)) != "undefined")
37  ++ax;
38 
40  if (!lp.isDefined().second || !lp.solid().isDefined().second) {
41  std::string em("DetectorDescription Parser DDLDivision::processElement(...) failed.");
42  em += " The solid of the parent logical part MUST be defined before the Division is made.";
43  em += "\n name= " + getDDName(nmspace).ns() + ":" + getDDName(nmspace).name();
44  em += "\n parent= " + parent.ns() + ":" + parent.name();
45  throwError(em);
46  }
47 
48  DDDivision div;
49 
50  if (atts.find("nReplicas") != atts.end() && atts.find("width") != atts.end() && atts.find("offset") != atts.end()) {
51  div = DDDivision(getDDName(nmspace),
52  parent,
53  DDAxes(ax),
54  int(ev.eval(nmspace, atts.find("nReplicas")->second)),
55  ev.eval(nmspace, atts.find("width")->second),
56  ev.eval(nmspace, atts.find("offset")->second));
57  } else if (atts.find("nReplicas") != atts.end() && atts.find("offset") != atts.end()) {
58  div = DDDivision(getDDName(nmspace),
59  parent,
60  DDAxes(ax),
61  int(ev.eval(nmspace, atts.find("nReplicas")->second)),
62  ev.eval(nmspace, atts.find("offset")->second));
63  } else if (atts.find("width") != atts.end() && atts.find("offset") != atts.end()) {
64  div = DDDivision(getDDName(nmspace),
65  parent,
66  DDAxes(ax),
67  ev.eval(nmspace, atts.find("width")->second),
68  ev.eval(nmspace, atts.find("offset")->second));
69  } else {
70  std::string em("DetectorDescription Parser DDLDivision::processElement(...) failed.");
71  em += " Allowed combinations are attributes width&offset OR nReplicas&offset OR nReplicas&width&offset.";
72  em += "\n name= " + getDDName(nmspace).ns() + ":" + getDDName(nmspace).name();
73  em += "\n parent= " + parent.ns() + ":" + parent.name();
74  throwError(em);
75  }
76  DDDividedGeometryObject* dg = makeDivider(div, &cpv);
77  dg->execute();
78  delete dg;
79 
80  clear();
81 }
DDLElementRegistry * myRegistry_
Definition: DDXMLElement.h:173
DDName is used to identify DDD entities uniquely.
Definition: DDName.h:17
std::map< std::string, std::string > DDXMLAttribute
Definition: DDXMLElement.h:45
DDDividedGeometryObject * makeDivider(const DDDivision &div, DDCompactView *cpv)
Definition: DDLDivision.cc:83
const std::string & name() const
Returns the name.
Definition: DDName.cc:41
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
A DDLogicalPart aggregates information concerning material, solid and sensitveness ...
Definition: DDLogicalPart.h:93
DDAxes
analagous to geant4/source/global/HEPGeometry/include/geomdefs.hh
Definition: DDAxes.h:11
const std::string & parent(void) const
access to parent element name
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.
static const std::string name(const DDAxes &s)
Definition: DDAxes.cc:24
virtual const DDName getDDName(const std::string &defaultNS, const std::string &attname=std::string("name"), size_t aIndex=0)
Definition: DDXMLElement.cc:56
const std::string & ns() const
Returns the namespace.
Definition: DDName.cc:52