test
CMS 3D CMS Logo

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

DDLPosPart handles PosPart elements. More...

#include <DDLPosPart.h>

Inheritance diagram for DDLPosPart:
DDXMLElement

Public Member Functions

 DDLPosPart (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...
 
 ~DDLPosPart (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...
 

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

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 24 of file DDLPosPart.h.

Constructor & Destructor Documentation

DDLPosPart::DDLPosPart ( DDLElementRegistry myreg)

Constructor.

Definition at line 22 of file DDLPosPart.cc.

23  : DDXMLElement( myreg )
24 {}
DDXMLElement(DDLElementRegistry *myreg)
Constructor.
Definition: DDXMLElement.cc:15
DDLPosPart::~DDLPosPart ( void  )

Destructor.

Definition at line 26 of file DDLPosPart.cc.

27 {}

Member Function Documentation

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

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

36 {
37  DCOUT_V('P', "DDLPosPart::preProcessElement started");
38 
39  // Clear out child elements.
40  myRegistry_->getElement("Rotation")->clear();
41  myRegistry_->getElement("ReflectionRotation")->clear();
42 
43  DCOUT_V('P', "DDLPosPart::preProcessElement completed");
44 }
DDLElementRegistry * myRegistry_
Definition: DDXMLElement.h:186
DDXMLElement * getElement(const std::string &name)
THE most important part. Getting the pointer to a given element type.
#define DCOUT_V(M_v_Y, M_v_S)
Definition: DDdebug.h:54
virtual void clear(void)
clear this element&#39;s contents.
Definition: DDXMLElement.cc:61
void DDLPosPart::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 50 of file DDLPosPart.cc.

References DDXMLElement::clear(), DCOUT_V, DDrot(), ev, ClhepEvaluator::eval(), DDLElementRegistry::evaluator(), DDXMLElement::getAttributeSet(), DDXMLElement::getDDName(), DDLElementRegistry::getElement(), DDBase< N, C >::isValid(), DDXMLElement::myRegistry_, DDName::name(), DDName::ns(), DDCompactView::position(), DDXMLElement::size(), AlCaHLTBitMon_QueryRunRegistry::string, groupFilesInBlocks::temp, x, y, and z.

51 {
52  DCOUT_V('P', "DDLPosPart::processElement started");
53 
54  // get all internal elements.
55  DDXMLElement* myParent = myRegistry_->getElement("rParent");
56  DDXMLElement* myChild = myRegistry_->getElement("rChild");
57  DDXMLElement* myTranslation= myRegistry_->getElement("Translation");
58  DDXMLElement* myDDLRotation= myRegistry_->getElement("Rotation");
59  DDXMLElement* myrRotation = myRegistry_->getElement("rRotation");
60  DDXMLElement* myDDLRefl = myRegistry_->getElement("ReflectionRotation");
61  DDXMLElement* myrRefl = myRegistry_->getElement("rReflectionRotation");
62  // FIXME!!! add in the new RotationByAxis element...
63 
64  // At this time, PosPart is becoming the most complex of the elements.
65  // For simply reflections/rotations we have 4 possible internal "components"
66  // to the PosPart. We take them in the following order of priority
67  // rRotation, Rotation, rReflectionRotation, ReflectionRotation.
68  //
69  // The idea in the following if-else-if is that no matter
70  // what was used inside the PosPart element, the order in which we
71  // will look for and use an internal element is:
72  // rRotation, Rotation, ReflectionRotation, rReflectionRotation.
73  // If it falls through here, a default call will result in a nameless
74  // "identity" rotation being passed to DDCore.
75  DDName rotn;
76  if (myrRotation->size() > 0){
77  rotn = myrRotation->getDDName(nmspace);
78  }
79  else if (myDDLRotation->size() > 0) {
80  // The assumption here is that the Rotation element created
81  // a DDRotation already, and so we can use this as an rRotation
82  // just provide DDCore with the name of the one just added...
83  // How to handle name conflicts? OVERWRITTEN by DDCore for now.
84  rotn = myDDLRotation->getDDName(nmspace);
85  }
86  else if (myDDLRefl->size() > 0) {
87  // The assumption is that a ReflectionRotation has been created and therefore
88  // we can refer to it as the rotation associated with this PosPart.
89  // we can further assume that the namespace is the same as this PosPart.
90  rotn = myDDLRefl->getDDName(nmspace);
91  }
92  else if (myrRefl->size() > 0) {
93  rotn = myrRefl->getDDName(nmspace);
94  }
95 
96  DCOUT_V('P', "DDLPosPart::processElement: Final Rotation info: " << rotn);
97 
99 
100  double x = 0.0, y = 0.0, z = 0.0;
101  if (myTranslation->size() > 0)
102  {
103  const DDXMLAttribute & atts = myTranslation->getAttributeSet();
104  x = ev.eval(nmspace, atts.find("x")->second);
105  y = ev.eval(nmspace, atts.find("y")->second);
106  z = ev.eval(nmspace, atts.find("z")->second);
107  }
108 
109  DCOUT_V('P', "DDLPosPart::processElement: Final Translation info x=" << x << " y=" << y << " z=" << z);
110 
111  DDRotation* myDDRotation;
112  // if rotation is named ...
113  if ( rotn.name() != "" && rotn.ns() != "" ) {
114  DDRotation temp(rotn);
115  myDDRotation = &temp;
116  } else {
117  // rotn is not assigned a name anywhere therefore the DDPos assumes the identity matrix.
118  DDRotation temp(DDName(std::string("identity"),std::string("generatedForDDD")));
119  myDDRotation = &temp;
120  // if the identity is not yet defined, then...
121  if ( !myDDRotation->isValid() ) {
123  temp = DDrot(DDName(std::string("identity"),std::string("generatedForDDD")), dmr );
124  myDDRotation = &temp;
125  }
126  }
127 
128 
129  DDTranslation myDDTranslation(x, y, z);
130 
131  DCOUT_V('P', "about to make a PosPart ...");
132  DCOUT_V('p', " myDDRotation : " << *myDDRotation);
133  DCOUT_V('p', " myDDTranslation : " << myDDTranslation);
134  DCOUT_V('p', " parentDDName : " << myParent->getDDName(nmspace));
135  DCOUT_V('p', " selfDDName : " << myChild->getDDName(nmspace));
136 
137  const DDXMLAttribute & atts = getAttributeSet();
138  std::string copyno = "";
139  if (atts.find("copyNumber") != atts.end())
140  copyno = atts.find("copyNumber")->second;
141 
142  cpv.position(DDLogicalPart(myChild->getDDName(nmspace))
143  , DDLogicalPart(myParent->getDDName(nmspace))
144  , copyno
145  , myDDTranslation
146  , *myDDRotation);
147 
148  // clear all "children" and attributes
149  myParent->clear();
150  myChild->clear();
151  myTranslation->clear();
152  myDDLRotation->clear();
153  myrRotation->clear();
154  myDDLRefl->clear();
155  myrRefl->clear();
156 
157  // after a pos part is done, we know we can clear it.
158  clear();
159 
160  DCOUT_V('P', "DDLPosPart::processElement completed");
161 }
DDLElementRegistry * myRegistry_
Definition: DDXMLElement.h:186
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 position(const DDLogicalPart &self, const DDLogicalPart &parent, std::string copyno, const DDTranslation &trans, const DDRotation &rot, const DDDivision *div=NULL)
const std::string & ns() const
Returns the namespace.
Definition: DDName.cc:101
DDName is used to identify DDD entities uniquely.
Definition: DDName.h:14
bool ev
std::map< std::string, std::string > DDXMLAttribute
Definition: DDXMLElement.h:55
ROOT::Math::DisplacementVector3D< ROOT::Math::Cartesian3D< double > > DDTranslation
Definition: DDTranslation.h:7
Represents a uniquely identifyable rotation matrix.
Definition: DDTransform.h:66
DDXMLElement * getElement(const std::string &name)
THE most important part. Getting the pointer to a given element type.
bool isValid() const
true, if the wrapped pointer is valid
Definition: DDBase.h:119
ClhepEvaluator & evaluator()
virtual size_t size(void) const
Number of elements accumulated.
A DDLogicalPart aggregates information concerning material, solid and sensitveness ...
Definition: DDLogicalPart.h:88
DDRotation DDrot(const DDName &name, DDRotationMatrix *rot)
Definition of a uniquely identifiable rotation matrix named by DDName name.
Definition: DDRotation.cc:90
#define DCOUT_V(M_v_Y, M_v_S)
Definition: DDdebug.h:54
This is a base class for processing XML elements in the DDD.
Definition: DDXMLElement.h:58
double eval(const std::string &ns, const std::string &expr)
virtual void clear(void)
clear this element&#39;s contents.
Definition: DDXMLElement.cc:61
ROOT::Math::Rotation3D DDRotationMatrix
A DDRotationMatrix is currently implemented with a ROOT Rotation3D.
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