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 27 of file DDLDivision.cc.

28  : DDXMLElement( myreg )
29 {}
DDXMLElement(DDLElementRegistry *myreg)
Constructor.
Definition: DDXMLElement.cc:15

Member Function Documentation

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

Definition at line 101 of file DDLDivision.cc.

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

Referenced by processElement().

102 {
104 
105  switch (div.parent().solid().shape())
106  {
107  case ddbox:
108  if (div.axis() == DDAxes::x)
109  dg = new DDDividedBoxX(div,cpv);
110  else if (div.axis() == DDAxes::y)
111  dg = new DDDividedBoxY(div,cpv);
112  else if (div.axis() == DDAxes::z)
113  dg = new DDDividedBoxZ(div,cpv);
114  else {
115  std::string s = "DDLDivision can not divide a ";
116  s += DDSolidShapesName::name(div.parent().solid().shape());
117  s += " along axis " + DDAxesNames::name(div.axis());
118  s += ".";
119  s += "\n name= " + div.name().ns() + ":" + div.name().name() ;
120  s += "\n parent= " + div.parent().name().ns() + ":" + div.parent().name().name();
121  throwError(s);
122  }
123  break;
124 
125  case ddtubs:
126  if (div.axis() == DDAxes::rho)
127  dg = new DDDividedTubsRho(div,cpv);
128  else if (div.axis() == DDAxes::phi)
129  dg = new DDDividedTubsPhi(div,cpv);
130  else if (div.axis() == DDAxes::z)
131  dg = new DDDividedTubsZ(div,cpv);
132  else {
133  std::string s = "DDLDivision can not divide a ";
134  s += DDSolidShapesName::name(div.parent().solid().shape());
135  s += " along axis " + DDAxesNames::name(div.axis());
136  s += ".";
137  s += "\n name= " + div.name().ns() + ":" + div.name().name() ;
138  s += "\n parent= " + div.parent().name().ns() + ":" + div.parent().name().name();
139  throwError(s);
140  }
141  break;
142 
143  case ddtrap:
144  if (div.axis() == DDAxes::x)
145  dg = new DDDividedTrdX(div,cpv);
146  else if (div.axis() == DDAxes::y )
147  dg = new DDDividedTrdY(div,cpv);
148  else if (div.axis() == DDAxes::z )
149  dg = new DDDividedTrdZ(div,cpv);
150  else {
151  std::string s = "DDLDivision can not divide a ";
152  s += DDSolidShapesName::name(div.parent().solid().shape());
153  s += " along axis ";
154  s += DDAxesNames::name(div.axis());
155  s += ".";
156  s += "\n name= " + div.name().ns() + ":" + div.name().name() ;
157  s += "\n parent= " + div.parent().name().ns() + ":" + div.parent().name().name();
158  throwError(s);
159  }
160  break;
161 
162  case ddcons:
163  if (div.axis() == DDAxes::rho)
164  dg = new DDDividedConsRho(div,cpv);
165  else if (div.axis() == DDAxes::phi)
166  dg = new DDDividedConsPhi(div,cpv);
167  else if (div.axis() == DDAxes::z)
168  dg = new DDDividedConsZ(div,cpv);
169  else {
170  std::string s = "DDLDivision can not divide a ";
171  s += DDSolidShapesName::name(div.parent().solid().shape());
172  s += " along axis " + DDAxesNames::name(div.axis());
173  s += ".";
174  s += "\n name= " + div.name().ns() + ":" + div.name().name() ;
175  s += "\n parent= " + div.parent().name().ns() + ":" + div.parent().name().name();
176  throwError(s);
177  }
178  break;
179 
180  case ddpolycone_rrz:
181  if (div.axis() == DDAxes::rho)
182  dg = new DDDividedPolyconeRho(div,cpv);
183  else if (div.axis() == DDAxes::phi)
184  dg = new DDDividedPolyconePhi(div,cpv);
185  else if (div.axis() == DDAxes::z)
186  dg = new DDDividedPolyconeZ(div,cpv);
187  else {
188  std::string s = "DDLDivision can not divide a ";
189  s += DDSolidShapesName::name(div.parent().solid().shape());
190  s += " along axis ";
191  s += DDAxesNames::name(div.axis());
192  s += ".";
193  s += "\n name= " + div.name().ns() + ":" + div.name().name() ;
194  s += "\n parent= " + div.parent().name().ns() + ":" + div.parent().name().name();
195  throwError(s);
196  }
197  break;
198 
199  case ddpolyhedra_rrz:
200  if (div.axis() == DDAxes::rho)
201  dg = new DDDividedPolyhedraRho(div,cpv);
202  else if (div.axis() == DDAxes::phi)
203  dg = new DDDividedPolyhedraPhi(div,cpv);
204  else if (div.axis() == DDAxes::z)
205  dg = new DDDividedPolyhedraZ(div,cpv);
206  else {
207  std::string s = "DDLDivision can not divide a ";
208  s += DDSolidShapesName::name(div.parent().solid().shape());
209  s += " along axis ";
210  s += DDAxesNames::name(div.axis());
211  s += ".";
212  s += "\n name= " + div.name().ns() + ":" + div.name().name() ;
213  s += "\n parent= " + div.parent().name().ns() + ":" + div.parent().name().name();
214  throwError(s);
215  }
216  break;
217 
218  case ddpolycone_rz:
219  case ddpolyhedra_rz: {
220  std::string s = "ERROR: A Polycone or Polyhedra can not be divided on any axis if it's\n";
221  s += "original definition used r and z instead of ZSections. This has\n";
222  s += "not (yet) been implemented.";
223  s += "\n name= " + div.name().ns() + ":" + div.name().name() ;
224  s += "\n parent= " + div.parent().name().ns() + ":" + div.parent().name().name();
225  }
226  break;
227 
228  case ddunion:
229  case ddsubtraction:
230  case ddintersection:
231  case ddreflected:
232  case ddshapeless:
233  case ddpseudotrap:
234  case ddtrunctubs:
235  case dd_not_init: {
236  std::string s = "DDLDivision can not divide a ";
237  s += DDSolidShapesName::name(div.parent().solid().shape());
238  s += " at all (yet?). Requested axis was ";
239  s += DDAxesNames::name(div.axis());
240  s += ".\n";
241  throwError(s);
242  }
243  break;
244  default:
245  break;
246  }
247  return dg;
248 
249 }
const N & name() const
Definition: DDBase.h:78
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:104
#define NULL
Definition: scimark2.h:8
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:22
DDSolidShape shape(void) const
The type of the solid.
Definition: DDSolid.cc:140
DDAxes axis() const
Definition: DDDivision.cc:66
const DDLogicalPart & parent() const
Definition: DDDivision.cc:86
static const std::string name(const DDAxes &s)
Definition: DDAxes.cc:23
const std::string & name() const
Returns the name.
Definition: DDName.cc:90
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 32 of file DDLDivision.cc.

33 {}
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 36 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().

37 {
39 
40  DDName parent = getDDName(nmspace, "parent");
42  size_t ax = 0;
43  while (DDAxesNames::name(DDAxes(ax)) != atts.find("axis")->second &&
44  DDAxesNames::name(DDAxes(ax)) != "undefined")
45  ++ax;
46 
47  DDLogicalPart lp(parent);
48  if ( !lp.isDefined().second || !lp.solid().isDefined().second ) {
49  std::string em("DetectorDescription Parser DDLDivision::processElement(...) failed.");
50  em += " The solid of the parent logical part MUST be defined before the Division is made.";
51  em += "\n name= " + getDDName(nmspace).ns() + ":" + getDDName(nmspace).name() ;
52  em += "\n parent= " + parent.ns() + ":" + parent.name();
53  throwError (em);
54  }
55 
56  DDDivision div;
57 
58  if (atts.find("nReplicas") != atts.end()
59  && atts.find("width") != atts.end()
60  && atts.find("offset") != atts.end())
61  {
62  div = DDDivision(getDDName(nmspace)
63  , parent
64  , DDAxes(ax)
65  , int(ev.eval(nmspace, atts.find("nReplicas")->second))
66  , ev.eval(nmspace, atts.find("width")->second)
67  , ev.eval(nmspace, atts.find("offset")->second));
68  }
69  else if (atts.find("nReplicas") != atts.end()
70  && atts.find("offset") != atts.end())
71  {
72  div = DDDivision(getDDName(nmspace)
73  , parent
74  , DDAxes(ax)
75  , int(ev.eval(nmspace, atts.find("nReplicas")->second))
76  , ev.eval(nmspace, atts.find("offset")->second));
77  }
78  else if (atts.find("width") != atts.end()
79  && atts.find("offset") != atts.end())
80  {
81  div = DDDivision(getDDName(nmspace)
82  , parent
83  , DDAxes(ax)
84  , ev.eval(nmspace, atts.find("width")->second)
85  , ev.eval(nmspace, atts.find("offset")->second));
86  } else {
87  std::string em("DetectorDescription Parser DDLDivision::processElement(...) failed.");
88  em += " Allowed combinations are attributes width&offset OR nReplicas&offset OR nReplicas&width&offset.";
89  em += "\n name= " + getDDName(nmspace).ns() + ":" + getDDName(nmspace).name() ;
90  em += "\n parent= " + parent.ns() + ":" + parent.name();
91  throwError (em);
92  }
93  DDDividedGeometryObject* dg = makeDivider(div, &cpv);
94  dg->execute();
95  delete dg;
96 
97  clear();
98 }
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:73
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:104
DDName is used to identify DDD entities uniquely.
Definition: DDName.h:16
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:101
ClhepEvaluator & evaluator()
A DDLogicalPart aggregates information concerning material, solid and sensitveness ...
Definition: DDLogicalPart.h:92
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:55
static const std::string name(const DDAxes &s)
Definition: DDAxes.cc:23
virtual const DDName getDDName(const std::string &defaultNS, const std::string &attname=std::string("name"), size_t aIndex=0)
Definition: DDXMLElement.cc:80
const std::string & name() const
Returns the name.
Definition: DDName.cc:90