CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Member Functions | Private Member Functions
DDLDivision Class Reference

DDLDivision processes Division elements. More...

#include <DDLDivision.h>

Inheritance diagram for DDLDivision:
DDXMLElement

Public Member Functions

 DDLDivision (DDLElementRegistry *myreg)
 Constructor. More...
 
void preProcessElement (const std::string &name, const std::string &nmspace, DDCompactView &cpv)
 Called by loadAttributes AFTER attributes are loaded. More...
 
void processElement (const std::string &name, const std::string &nmspace, DDCompactView &cpv)
 Processing the element. More...
 
 ~DDLDivision (void)
 Destructor. 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)
 Destructor. More...
 

Private Member Functions

DDDividedGeometryObjectmakeDivider (const DDDivision &div, DDCompactView *cpv)
 

Additional Inherited Members

- Static Public Member Functions inherited from DDXMLElement
static std::string itostr (int i)
 WARNING: abused by other classes in this system: yet another conversion from int to std::string... More...
 
- 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 23 of file DDLDivision.h.

Constructor & Destructor Documentation

DDLDivision::DDLDivision ( DDLElementRegistry myreg)

Constructor.

Definition at line 31 of file DDLDivision.cc.

32  : DDXMLElement( myreg )
33 {}
DDXMLElement(DDLElementRegistry *myreg)
Constructor.
Definition: DDXMLElement.cc:15
DDLDivision::~DDLDivision ( void  )

Destructor.

Definition at line 35 of file DDLDivision.cc.

36 {}

Member Function Documentation

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

Definition at line 114 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(), DDXMLElement::throwError(), vdt::x, detailsBasic3DVector::y, and detailsBasic3DVector::z.

Referenced by processElement().

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

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

40 {}
void DDLDivision::processElement ( const std::string &  name,
const std::string &  nmspace,
DDCompactView cpv 
)
virtual

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

References create_public_lumi_plots::ax, DDXMLElement::clear(), DCOUT_V, ExprEvalInterface::eval(), DDDividedGeometryObject::execute(), DDXMLElement::getAttributeSet(), DDXMLElement::getDDName(), DDI::Singleton< I >::instance(), DDBase< N, C >::isDefined(), makeDivider(), DDAxesNames::name(), DDName::name(), DDName::ns(), DDXMLElement::parent(), DDLogicalPart::solid(), and DDXMLElement::throwError().

44 {
45  DCOUT_V('P', "DDLDivision::processElement started");
46 
48 
49  DDName parent = getDDName(nmspace, "parent");
51  size_t ax = 0;
52  while (DDAxesNames::name(DDAxes(ax)) != atts.find("axis")->second &&
53  DDAxesNames::name(DDAxes(ax)) != "undefined")
54  ++ax;
55 
56  DDLogicalPart lp(parent);
57  if ( !lp.isDefined().second || !lp.solid().isDefined().second ) {
58  std::string em("DetectorDescription Parser DDLDivision::processElement(...) failed.");
59  em += " The solid of the parent logical part MUST be defined before the Division is made.";
60  em += "\n name= " + getDDName(nmspace).ns() + ":" + getDDName(nmspace).name() ;
61  em += "\n parent= " + parent.ns() + ":" + parent.name();
62  throwError (em);
63  }
64 
65  DDDivision div;
66 
67  if (atts.find("nReplicas") != atts.end()
68  && atts.find("width") != 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("width")->second)
76  , ev.eval(nmspace, atts.find("offset")->second));
77  }
78  else if (atts.find("nReplicas") != atts.end()
79  && atts.find("offset") != atts.end())
80  {
81  div = DDDivision(getDDName(nmspace)
82  , parent
83  , DDAxes(ax)
84  , int(ev.eval(nmspace, atts.find("nReplicas")->second))
85  , ev.eval(nmspace, atts.find("offset")->second));
86  }
87  else if (atts.find("width") != atts.end()
88  && atts.find("offset") != atts.end())
89  {
90  DCOUT_V ('D', " width = " << ev.eval(nmspace, atts.find("width")->second) << std::endl);
91  DCOUT_V ('D', " offset = " << ev.eval(nmspace, atts.find("offset")->second) << std::endl);
92  div = DDDivision(getDDName(nmspace)
93  , parent
94  , DDAxes(ax)
95  , ev.eval(nmspace, atts.find("width")->second)
96  , ev.eval(nmspace, atts.find("offset")->second));
97  } else {
98  std::string em("DetectorDescription Parser DDLDivision::processElement(...) failed.");
99  em += " Allowed combinations are attributes width&offset OR nReplicas&offset OR nReplicas&width&offset.";
100  em += "\n name= " + getDDName(nmspace).ns() + ":" + getDDName(nmspace).name() ;
101  em += "\n parent= " + parent.ns() + ":" + parent.name();
102  throwError (em);
103  }
104  DDDividedGeometryObject* dg = makeDivider(div, &cpv);
105  dg->execute();
106  delete dg;
107 
108  clear();
109 
110  DCOUT_V('P', "DDLDivision::processElement completed");
111 }
virtual const DDXMLAttribute & getAttributeSet(size_t aIndex=0) const
Get a &quot;row&quot; of attributes, i.e. one attribute set.
Definition: DDXMLElement.cc:79
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:101
DDName is used to identify DDD entities uniquely.
Definition: DDName.h:18
const std::string & parent(void) const
access to parent element name
std::map< std::string, std::string > DDXMLAttribute
Definition: DDXMLElement.h:55
DDDividedGeometryObject * makeDivider(const DDDivision &div, DDCompactView *cpv)
Definition: DDLDivision.cc:114
static value_type & instance()
Interface of an Expression Evaluator.
A DDLogicalPart aggregates information concerning material, solid and sensitveness ...
Definition: DDLogicalPart.h:88
#define DCOUT_V(M_v_Y, M_v_S)
Definition: DDdebug.h:54
virtual double eval(const std::string &ns, const std::string &expr)=0
evaluate an expression expr inside the local namespace
DDAxes
analagous to geant4/source/global/HEPGeometry/include/geomdefs.hh
Definition: DDAxes.h:10
virtual void clear(void)
clear this element&#39;s contents.
Definition: DDXMLElement.cc:61
static const std::string name(const DDAxes &s)
Definition: DDAxes.cc:37
virtual const DDName getDDName(const std::string &defaultNS, const std::string &attname=std::string("name"), size_t aIndex=0)
Definition: DDXMLElement.cc:86
const std::string & name() const
Returns the name.
Definition: DDName.cc:87