CMS 3D CMS Logo

DDLDivision.cc
Go to the documentation of this file.
18 
19 #include <cstddef>
20 #include <map>
21 #include <ostream>
22 #include <utility>
23 
24 class DDCompactView;
25 
27 
29 
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 }
82 
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 }
DDSolidShapes.h
DDXMLElement::parent
const std::string & parent(void) const
access to parent element name
Definition: DDXMLElement.cc:201
DDXMLElement::clear
virtual void clear(void)
clear this element's contents.
Definition: DDXMLElement.cc:40
DDAxes::y
MessageLogger.h
DDDividedTrd.h
DDSolidShape::ddtrap
DDXMLElement::throwError
void throwError(const std::string &keyMessage) const
format std::string for throw an error.
Definition: DDXMLElement.cc:209
DDName
DDName is used to identify DDD entities uniquely.
Definition: DDName.h:15
DDBase::isDefined
def_type isDefined() const
Definition: DDBase.h:90
ClhepEvaluator.h
DDSolidShape::ddpseudotrap
DDSolidShape::ddpolyhedra_rrz
DDDividedPolyconePhi
Definition: DDDividedPolycone.h:23
DDLElementRegistry
The main class for processing parsed elements.
Definition: DDLElementRegistry.h:23
ClhepEvaluator
Definition: ClhepEvaluator.h:8
DDAxes.h
DDDividedTubs.h
DDAxes::x
DDDividedTrdY
Definition: DDDividedTrd.h:23
DDDividedGeometryObject
Definition: DDDividedGeometryObject.h:20
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
DDDividedGeometryObject::execute
virtual void execute(void)
Definition: DDDividedGeometryObject.cc:85
DDDividedBoxX
Definition: DDDividedBox.h:12
DDDividedPolyconeZ
Definition: DDDividedPolycone.h:34
DDSolid::shape
DDSolidShape shape(void) const
The type of the solid.
Definition: DDSolid.cc:119
alignCSCRings.s
s
Definition: alignCSCRings.py:92
DDDividedTubsRho
Definition: DDDividedTubs.h:12
DDSolidShape::ddtubs
DDCompactView
Compact representation of the geometrical detector hierarchy.
Definition: DDCompactView.h:81
DDDividedCons.h
DDSolidShape::ddtrunctubs
DDSolidShape::ddpolyhedra_rz
DDLDivision::makeDivider
DDDividedGeometryObject * makeDivider(const DDDivision &div, DDCompactView *cpv)
Definition: DDLDivision.cc:83
DDBase::name
const N & name() const
Definition: DDBase.h:59
DDAxes::z
DDSolid.h
DDDividedTrdZ
Definition: DDDividedTrd.h:34
DDDividedTubsZ
Definition: DDDividedTubs.h:32
DDDividedPolyhedraPhi
Definition: DDDividedPolyhedra.h:23
DDAxes::rho
DDXMLAttribute
std::map< std::string, std::string > DDXMLAttribute
Definition: DDXMLElement.h:45
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
DDSolidShapesName::name
static const char *const name(DDSolidShape s)
Definition: DDSolidShapes.h:32
DDDividedConsZ
Definition: DDDividedCons.h:32
DDDividedTubsPhi
Definition: DDDividedTubs.h:22
DDDividedPolycone.h
DDAxes
DDAxes
analagous to geant4/source/global/HEPGeometry/include/geomdefs.hh
Definition: DDAxes.h:11
DDLDivision.h
DDSolidShape::ddcons
DDLogicalPart
A DDLogicalPart aggregates information concerning material, solid and sensitveness ....
Definition: DDLogicalPart.h:93
DDXMLElement
This is a base class for processing XML elements in the DDD.
Definition: DDXMLElement.h:48
DDDividedGeometryObject.h
DDDividedPolyhedra.h
DDName::name
const std::string & name() const
Returns the name.
Definition: DDName.cc:41
DDLElementRegistry.h
DDLogicalPart.h
DDSolidShape::dd_not_init
DDDivision::axis
DDAxes axis() const
Definition: DDDivision.cc:49
DDDividedBoxY
Definition: DDDividedBox.h:22
DDDivision
Definition: DDDivision.h:78
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
DDAxes::phi
DDSolidShape::ddbox
DDName::ns
const std::string & ns() const
Returns the namespace.
Definition: DDName.cc:52
DDXMLElement.h
DDDividedBox.h
DDName.h
ev
bool ev
Definition: Hydjet2Hadronizer.cc:95
DDDividedConsPhi
Definition: DDDividedCons.h:22
Skims_PA_cff.name
name
Definition: Skims_PA_cff.py:17
DDSolidShape::ddshapeless
DDXMLElement::myRegistry_
DDLElementRegistry * myRegistry_
Definition: DDXMLElement.h:173
DDDividedPolyhedraRho
Definition: DDDividedPolyhedra.h:12
DDLDivision::DDLDivision
DDLDivision(DDLElementRegistry *myreg)
Definition: DDLDivision.cc:26
DDDividedPolyconeRho
Definition: DDDividedPolycone.h:12
DDSolidShape::ddpolycone_rrz
DDLDivision::processElement
void processElement(const std::string &name, const std::string &nmspace, DDCompactView &cpv) override
Processing the element.
Definition: DDLDivision.cc:30
DDDividedPolyhedraZ
Definition: DDDividedPolyhedra.h:34
DDDividedConsRho
Definition: DDDividedCons.h:12
DDDividedTrdX
Definition: DDDividedTrd.h:12
DDDividedBoxZ
Definition: DDDividedBox.h:32
DDLDivision::preProcessElement
void preProcessElement(const std::string &name, const std::string &nmspace, DDCompactView &cpv) override
Called by loadAttributes AFTER attributes are loaded.
Definition: DDLDivision.cc:28
DDSolidShape::ddsubtraction
DDSolidShape::ddintersection
DDAxesNames::name
static const std::string name(const DDAxes &s)
Definition: DDAxes.cc:24
DDLogicalPart::solid
const DDSolid & solid(void) const
Returns a reference object of the solid being the shape of this LogicalPart.
Definition: DDLogicalPart.cc:120
DDSolidShape::ddunion
DDSolidShape::ddpolycone_rz
DDDivision::parent
const DDLogicalPart & parent() const
Definition: DDDivision.cc:57