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 ( DDLElementRegistry myreg)

Definition at line 26 of file DDLDivision.cc.

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

Member Function Documentation

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

Definition at line 100 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, DDSolidShapesName::name(), DDAxesNames::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().

101 {
102  DDDividedGeometryObject* dg = nullptr;
103 
104  switch (div.parent().solid().shape())
105  {
106  case DDSolidShape::ddbox:
107  if (div.axis() == DDAxes::x)
108  dg = new DDDividedBoxX(div,cpv);
109  else if (div.axis() == DDAxes::y)
110  dg = new DDDividedBoxY(div,cpv);
111  else if (div.axis() == DDAxes::z)
112  dg = new DDDividedBoxZ(div,cpv);
113  else {
114  std::string s = "DDLDivision can not divide a ";
115  s += DDSolidShapesName::name(div.parent().solid().shape());
116  s += " along axis " + DDAxesNames::name(div.axis());
117  s += ".";
118  s += "\n name= " + div.name().ns() + ":" + div.name().name() ;
119  s += "\n parent= " + div.parent().name().ns() + ":" + div.parent().name().name();
120  throwError(s);
121  }
122  break;
123 
125  if (div.axis() == DDAxes::rho)
126  dg = new DDDividedTubsRho(div,cpv);
127  else if (div.axis() == DDAxes::phi)
128  dg = new DDDividedTubsPhi(div,cpv);
129  else if (div.axis() == DDAxes::z)
130  dg = new DDDividedTubsZ(div,cpv);
131  else {
132  std::string s = "DDLDivision can not divide a ";
133  s += DDSolidShapesName::name(div.parent().solid().shape());
134  s += " along axis " + 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::x)
144  dg = new DDDividedTrdX(div,cpv);
145  else if (div.axis() == DDAxes::y )
146  dg = new DDDividedTrdY(div,cpv);
147  else if (div.axis() == DDAxes::z )
148  dg = new DDDividedTrdZ(div,cpv);
149  else {
150  std::string s = "DDLDivision can not divide a ";
151  s += DDSolidShapesName::name(div.parent().solid().shape());
152  s += " along axis ";
153  s += DDAxesNames::name(div.axis());
154  s += ".";
155  s += "\n name= " + div.name().ns() + ":" + div.name().name() ;
156  s += "\n parent= " + div.parent().name().ns() + ":" + div.parent().name().name();
157  throwError(s);
158  }
159  break;
160 
162  if (div.axis() == DDAxes::rho)
163  dg = new DDDividedConsRho(div,cpv);
164  else if (div.axis() == DDAxes::phi)
165  dg = new DDDividedConsPhi(div,cpv);
166  else if (div.axis() == DDAxes::z)
167  dg = new DDDividedConsZ(div,cpv);
168  else {
169  std::string s = "DDLDivision can not divide a ";
170  s += DDSolidShapesName::name(div.parent().solid().shape());
171  s += " along axis " + 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 DDDividedPolyconeRho(div,cpv);
182  else if (div.axis() == DDAxes::phi)
183  dg = new DDDividedPolyconePhi(div,cpv);
184  else if (div.axis() == DDAxes::z)
185  dg = new DDDividedPolyconeZ(div,cpv);
186  else {
187  std::string s = "DDLDivision can not divide a ";
188  s += DDSolidShapesName::name(div.parent().solid().shape());
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 
199  if (div.axis() == DDAxes::rho)
200  dg = new DDDividedPolyhedraRho(div,cpv);
201  else if (div.axis() == DDAxes::phi)
202  dg = new DDDividedPolyhedraPhi(div,cpv);
203  else if (div.axis() == DDAxes::z)
204  dg = new DDDividedPolyhedraZ(div,cpv);
205  else {
206  std::string s = "DDLDivision can not divide a ";
207  s += DDSolidShapesName::name(div.parent().solid().shape());
208  s += " along axis ";
209  s += DDAxesNames::name(div.axis());
210  s += ".";
211  s += "\n name= " + div.name().ns() + ":" + div.name().name() ;
212  s += "\n parent= " + div.parent().name().ns() + ":" + div.parent().name().name();
213  throwError(s);
214  }
215  break;
216 
219  std::string s = "ERROR: A Polycone or Polyhedra can not be divided on any axis if it's\n";
220  s += "original definition used r and z instead of ZSections. This has\n";
221  s += "not (yet) been implemented.";
222  s += "\n name= " + div.name().ns() + ":" + div.name().name() ;
223  s += "\n parent= " + div.parent().name().ns() + ":" + div.parent().name().name();
224  }
225  break;
226 
227  case DDSolidShape::ddunion:
234  std::string s = "DDLDivision can not divide a ";
235  s += DDSolidShapesName::name(div.parent().solid().shape());
236  s += " at all (yet?). Requested axis was ";
237  s += DDAxesNames::name(div.axis());
238  s += ".\n";
239  throwError(s);
240  }
241  break;
242  default:
243  break;
244  }
245  return dg;
246 
247 }
const N & name() const
Definition: DDBase.h:74
void throwError(const std::string &keyMessage) const
format std::string for throw an error.
const std::string & ns() const
Returns the namespace.
Definition: DDName.cc:67
const DDSolid & solid(void) const
Returns a reference object of the solid being the shape of this LogicalPart.
static const char *const name(DDSolidShape s)
Definition: DDSolidShapes.h:23
DDSolidShape shape(void) const
The type of the solid.
Definition: DDSolid.cc:138
DDAxes axis() const
Definition: DDDivision.cc:69
const DDLogicalPart & parent() const
Definition: DDDivision.cc:93
static const std::string name(const DDAxes &s)
Definition: DDAxes.cc:29
const std::string & name() const
Returns the name.
Definition: DDName.cc:53
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 31 of file DDLDivision.cc.

32 {}
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 35 of file DDLDivision.cc.

References create_public_lumi_plots::ax, DDXMLElement::clear(), ev, ClhepEvaluator::eval(), 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().

36 {
38 
39  DDName parent = getDDName(nmspace, "parent");
41  size_t ax = 0;
42  while (DDAxesNames::name(DDAxes(ax)) != atts.find("axis")->second &&
43  DDAxesNames::name(DDAxes(ax)) != "undefined")
44  ++ax;
45 
46  DDLogicalPart lp(parent);
47  if ( !lp.isDefined().second || !lp.solid().isDefined().second ) {
48  std::string em("DetectorDescription Parser DDLDivision::processElement(...) failed.");
49  em += " The solid of the parent logical part MUST be defined before the Division is made.";
50  em += "\n name= " + getDDName(nmspace).ns() + ":" + getDDName(nmspace).name() ;
51  em += "\n parent= " + parent.ns() + ":" + parent.name();
52  throwError (em);
53  }
54 
55  DDDivision div;
56 
57  if (atts.find("nReplicas") != atts.end()
58  && atts.find("width") != atts.end()
59  && atts.find("offset") != atts.end())
60  {
61  div = DDDivision(getDDName(nmspace)
62  , parent
63  , DDAxes(ax)
64  , int(ev.eval(nmspace, atts.find("nReplicas")->second))
65  , ev.eval(nmspace, atts.find("width")->second)
66  , ev.eval(nmspace, atts.find("offset")->second));
67  }
68  else if (atts.find("nReplicas") != atts.end()
69  && atts.find("offset") != atts.end())
70  {
71  div = DDDivision(getDDName(nmspace)
72  , parent
73  , DDAxes(ax)
74  , int(ev.eval(nmspace, atts.find("nReplicas")->second))
75  , ev.eval(nmspace, atts.find("offset")->second));
76  }
77  else if (atts.find("width") != atts.end()
78  && atts.find("offset") != atts.end())
79  {
80  div = DDDivision(getDDName(nmspace)
81  , parent
82  , DDAxes(ax)
83  , ev.eval(nmspace, atts.find("width")->second)
84  , ev.eval(nmspace, atts.find("offset")->second));
85  } else {
86  std::string em("DetectorDescription Parser DDLDivision::processElement(...) failed.");
87  em += " Allowed combinations are attributes width&offset OR nReplicas&offset OR nReplicas&width&offset.";
88  em += "\n name= " + getDDName(nmspace).ns() + ":" + getDDName(nmspace).name() ;
89  em += "\n parent= " + parent.ns() + ":" + parent.name();
90  throwError (em);
91  }
92  DDDividedGeometryObject* dg = makeDivider(div, &cpv);
93  dg->execute();
94  delete dg;
95 
96  clear();
97 }
DDLElementRegistry * myRegistry_
Definition: DDXMLElement.h:172
virtual const DDXMLAttribute & getAttributeSet(size_t aIndex=0) const
Get a "row" of attributes, i.e. one attribute set.
Definition: DDXMLElement.cc:72
void throwError(const std::string &keyMessage) const
format std::string for throw an error.
const std::string & ns() const
Returns the namespace.
Definition: DDName.cc:67
DDName is used to identify DDD entities uniquely.
Definition: DDName.h:15
const std::string & parent(void) const
access to parent element name
bool ev
std::map< std::string, std::string > DDXMLAttribute
Definition: DDXMLElement.h:45
DDDividedGeometryObject * makeDivider(const DDDivision &div, DDCompactView *cpv)
Definition: DDLDivision.cc:100
ClhepEvaluator & evaluator()
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
double eval(const std::string &ns, const std::string &expr)
virtual void clear(void)
clear this element&#39;s contents.
Definition: DDXMLElement.cc:54
static const std::string name(const DDAxes &s)
Definition: DDAxes.cc:29
virtual const DDName getDDName(const std::string &defaultNS, const std::string &attname=std::string("name"), size_t aIndex=0)
Definition: DDXMLElement.cc:79
const std::string & name() const
Returns the name.
Definition: DDName.cc:53