CMS 3D CMS Logo

List of all members | Public Member Functions
DDLPosPart Class Referencefinal

DDLPosPart handles PosPart elements. More...

#include <DDLPosPart.h>

Inheritance diagram for DDLPosPart:
DDXMLElement

Public Member Functions

 DDLPosPart (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...
 
const virtual 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...
 

Additional Inherited Members

- Protected Attributes inherited from DDXMLElement
DDLElementRegistrymyRegistry_
 

Detailed Description

DDLPosPart handles PosPart elements.

Author
Michael Case

DDLPosPart.h - description

begin: Tue Oct 30 2001 email: case@.nosp@m.ucdh.nosp@m.ep.uc.nosp@m.davi.nosp@m.s.edu

A PosPart (or Positioning Part or Part Positioner :-)) is used to position a LogicalPart somewhere inside it's parent. So, A PosPart needs two rLogicalParts (self and parent) on which to operate, a Translation and a Rotation.

Definition at line 27 of file DDLPosPart.h.

Constructor & Destructor Documentation

◆ DDLPosPart()

DDLPosPart::DDLPosPart ( DDLElementRegistry myreg)

Definition at line 16 of file DDLPosPart.cc.

16 : DDXMLElement(myreg) {}

Member Function Documentation

◆ preProcessElement()

void DDLPosPart::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 23 of file DDLPosPart.cc.

23  {
24  // Clear out child elements.
25  myRegistry_->getElement("Rotation")->clear();
26  myRegistry_->getElement("ReflectionRotation")->clear();
27 }

References DDLElementRegistry::getElement(), and DDXMLElement::myRegistry_.

◆ processElement()

void DDLPosPart::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 32 of file DDLPosPart.cc.

32  {
33  // get all internal elements.
34  auto myParent = myRegistry_->getElement("rParent");
35  auto myChild = myRegistry_->getElement("rChild");
36  auto myTranslation = myRegistry_->getElement("Translation");
37  auto myDDLRotation = myRegistry_->getElement("Rotation");
38  auto myrRotation = myRegistry_->getElement("rRotation");
39  auto myDDLRefl = myRegistry_->getElement("ReflectionRotation");
40  auto myrRefl = myRegistry_->getElement("rReflectionRotation");
41  // FIXME!!! add in the new RotationByAxis element...
42 
43  // At this time, PosPart is becoming the most complex of the elements.
44  // For simply reflections/rotations we have 4 possible internal "components"
45  // to the PosPart. We take them in the following order of priority
46  // rRotation, Rotation, rReflectionRotation, ReflectionRotation.
47  //
48  // The idea in the following if-else-if is that no matter
49  // what was used inside the PosPart element, the order in which we
50  // will look for and use an internal element is:
51  // rRotation, Rotation, ReflectionRotation, rReflectionRotation.
52  // If it falls through here, a default call will result in a nameless
53  // "identity" rotation being passed to DDCore.
54  DDName rotn(
55  (myrRotation->size() > 0)
56  ? myrRotation->getDDName(nmspace)
57  : ((myDDLRotation->size() > 0)
58  ? myDDLRotation->getDDName(nmspace)
59  : ((myDDLRefl->size() > 0) ? myDDLRefl->getDDName(nmspace)
60  : ((myrRefl->size() > 0) ? myrRefl->getDDName(nmspace) : DDName("")))));
61 
63 
64  double x = 0.0, y = 0.0, z = 0.0;
65  if (myTranslation->size() > 0) {
66  const DDXMLAttribute& atts = myTranslation->getAttributeSet();
67  x = ev.eval(nmspace, atts.find("x")->second);
68  y = ev.eval(nmspace, atts.find("y")->second);
69  z = ev.eval(nmspace, atts.find("z")->second);
70  }
71 
72  std::unique_ptr<DDRotation> myDDRotation;
73  // if rotation is named ...
74  if (!rotn.name().empty() && !rotn.ns().empty()) {
75  myDDRotation = std::make_unique<DDRotation>(rotn);
76  } else {
77  // rotn is not assigned a name anywhere therefore the DDPos assumes the identity matrix.
78  myDDRotation = std::make_unique<DDRotation>(DDName(std::string("identity"), std::string("generatedForDDD")));
79  // if the identity is not yet defined, then...
80  if (!myDDRotation->isValid()) {
81  myDDRotation = DDrotPtr(DDName(std::string("identity"), std::string("generatedForDDD")),
82  std::make_unique<DDRotationMatrix>());
83  }
84  }
85 
86  DDTranslation myDDTranslation(x, y, z);
87 
88  const DDXMLAttribute& atts = getAttributeSet();
89  std::string copyno = "";
90  if (atts.find("copyNumber") != atts.end())
91  copyno = atts.find("copyNumber")->second;
92 
93  cpv.position(DDLogicalPart(myChild->getDDName(nmspace)),
94  DDLogicalPart(myParent->getDDName(nmspace)),
95  copyno,
96  myDDTranslation,
97  *myDDRotation);
98 
99  // clear all "children" and attributes
100  myParent->clear();
101  myChild->clear();
102  myTranslation->clear();
103  myDDLRotation->clear();
104  myrRotation->clear();
105  myDDLRefl->clear();
106  myrRefl->clear();
107 
108  // after a pos part is done, we know we can clear it.
109  clear();
110 }

References DDXMLElement::clear(), DDrotPtr(), ev, DDLElementRegistry::evaluator(), DDXMLElement::getAttributeSet(), DDLElementRegistry::getElement(), DDXMLElement::myRegistry_, DDName::name(), DDName::ns(), DDCompactView::position(), AlCaHLTBitMon_QueryRunRegistry::string, x, y, and z.

DDXMLElement::clear
virtual void clear(void)
clear this element's contents.
Definition: DDXMLElement.cc:40
DDAxes::y
DDName
DDName is used to identify DDD entities uniquely.
Definition: DDName.h:15
ClhepEvaluator
Definition: ClhepEvaluator.h:8
DDAxes::x
DDrotPtr
std::unique_ptr< DDRotation > DDrotPtr(const DDName &name, std::unique_ptr< DDRotationMatrix > rot)
Definition: DDRotation.cc:72
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
DDTranslation
ROOT::Math::DisplacementVector3D< ROOT::Math::Cartesian3D< double > > DDTranslation
Definition: DDTranslation.h:7
DDAxes::z
DDXMLElement::DDXMLElement
DDXMLElement(DDLElementRegistry *myreg)
Constructor.
Definition: DDXMLElement.cc:14
DDXMLAttribute
std::map< std::string, std::string > DDXMLAttribute
Definition: DDXMLElement.h:45
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
DDLogicalPart
A DDLogicalPart aggregates information concerning material, solid and sensitveness ....
Definition: DDLogicalPart.h:93
DDLElementRegistry::getElement
std::shared_ptr< DDXMLElement > getElement(const std::string &name)
THE most important part. Getting the pointer to a given element type.
Definition: DDLElementRegistry.cc:42
ev
bool ev
Definition: Hydjet2Hadronizer.cc:95
DDXMLElement::myRegistry_
DDLElementRegistry * myRegistry_
Definition: DDXMLElement.h:173
DDCompactView::position
void position(const DDLogicalPart &self, const DDLogicalPart &parent, const std::string &copyno, const DDTranslation &trans, const DDRotation &rot, const DDDivision *div=nullptr)
Definition: DDCompactView.cc:76