CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
DDLPosPart.cc
Go to the documentation of this file.
1 /***************************************************************************
2  DDLPosPart.cc - description
3  -------------------
4  begin : Tue Oct 30 2001
5  email : case@ucdhep.ucdavis.edu
6  ***************************************************************************/
7 
8 /***************************************************************************
9  * *
10  * DDDParser sub-component of DDD *
11  * *
12  ***************************************************************************/
13 
15 
19 
21 
23  : DDXMLElement( myreg )
24 {}
25 
27 {}
28 
29 // Upon encountering a PosPart, store the label, simple.
30 // Just in case some left-over Rotation has not been cleared, make sure
31 // that it is cleared.
32 // I commented out the others because the last element
33 // that made use of them should have cleared them.
34 void
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 }
45 
46 // Upon encountering the end tag of the PosPart we should have in the meantime
47 // hit two rLogicalPart calls and one of Rotation or rRotation and a Translation.
48 // So, retrieve them and make the call to DDCore.
49 void
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
~DDLPosPart(void)
Destructor.
Definition: DDLPosPart.cc:26
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:18
bool ev
type of data representation of DDCompactView
Definition: DDCompactView.h:77
float float float z
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:124
ClhepEvaluator & evaluator()
virtual size_t size(void) const
Number of elements accumulated.
DDLPosPart(DDLElementRegistry *myreg)
Constructor.
Definition: DDLPosPart.cc:22
A DDLogicalPart aggregates information concerning material, solid and sensitveness ...
Definition: DDLogicalPart.h:88
void preProcessElement(const std::string &name, const std::string &nmspace, DDCompactView &cpv)
Called by loadAttributes AFTER attributes are loaded.
Definition: DDLPosPart.cc:35
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)
The main class for processing parsed elements.
virtual void clear(void)
clear this element&#39;s contents.
Definition: DDXMLElement.cc:61
void processElement(const std::string &name, const std::string &nmspace, DDCompactView &cpv)
Processing the element.
Definition: DDLPosPart.cc:50
Definition: DDAxes.h:10
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