CMS 3D CMS Logo

DDLPosPart Class Reference

DDLPosPart handles PosPart elements. More...

#include <DetectorDescription/Parser/src/DDLPosPart.h>

Inheritance diagram for DDLPosPart:

DDXMLElement

List of all members.

Public Member Functions

 DDLPosPart ()
 Constructor.
void preProcessElement (const std::string &name, const std::string &nmspace)
 Called by loadAttributes AFTER attributes are loaded.
void processElement (const std::string &name, const std::string &nmspace)
 Processing the element.
 ~DDLPosPart ()
 Destructor.


Detailed Description

DDLPosPart handles PosPart elements.

Author:
Michael Case
DDLPosPart.h - description ------------------- begin: Tue Oct 30 2001 email: case@ucdhep.ucdavis.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 (  ) 

Constructor.

Definition at line 33 of file DDLPosPart.cc.

00034 {
00035 }

DDLPosPart::~DDLPosPart (  ) 

Destructor.

Definition at line 38 of file DDLPosPart.cc.

00039 {
00040 }


Member Function Documentation

void DDLPosPart::preProcessElement ( const std::string &  name,
const std::string &  nmspace 
) [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 47 of file DDLPosPart.cc.

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

00048 {
00049   DCOUT_V('P', "DDLPosPart::preProcessElement started");
00050 
00051   // Clear out child elements.
00052   DDLElementRegistry::getElement("Rotation")->clear();
00053   DDLElementRegistry::getElement("ReflectionRotation")->clear();
00054 
00055   DCOUT_V('P', "DDLPosPart::preProcessElement completed");
00056 }

void DDLPosPart::processElement ( const std::string &  name,
const std::string &  nmspace 
) [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 61 of file DDLPosPart.cc.

References DDXMLElement::clear(), DCOUT_V, DDpos(), DDrot(), ExprEvalInterface::eval(), DDXMLElement::getAttributeSet(), DDXMLElement::getDDName(), DDLElementRegistry::getElement(), DDI::Singleton< I >::instance(), DDBase< N, C >::isValid(), DDName::name(), DDName::ns(), DDXMLElement::size(), pyDBSRunClass::temp, x, y, and z.

00062 {
00063   DCOUT_V('P', "DDLPosPart::processElement started");
00064   
00065   // get all internal elements.
00066   DDXMLElement* myParent     = DDLElementRegistry::getElement("rParent");
00067   DDXMLElement* myChild      = DDLElementRegistry::getElement("rChild");
00068   DDXMLElement* myTranslation= DDLElementRegistry::getElement("Translation");
00069   DDXMLElement* myDDLRotation= DDLElementRegistry::getElement("Rotation");
00070   DDXMLElement* myrRotation  = DDLElementRegistry::getElement("rRotation");
00071   DDXMLElement* myDDLRefl    = DDLElementRegistry::getElement("ReflectionRotation");
00072   DDXMLElement* myrRefl      = DDLElementRegistry::getElement("rReflectionRotation");
00073   // FIXME!!! add in the new RotationByAxis element...
00074 
00075   // At this time, PosPart is becoming the most complex of the elements.
00076   // For simply reflections/rotations we have 4 possible internal "components"
00077   // to the PosPart.  We take them in the following order of priority
00078   //     rRotation, Rotation, rReflectionRotation, ReflectionRotation.
00079   //
00080   // The idea in the following if-else-if is that no matter
00081   // what was used inside the PosPart element, the order in which we
00082   // will look for and use an internal element is:
00083   // rRotation, Rotation, ReflectionRotation, rReflectionRotation.
00084   // If it falls through here, a default call will result in a nameless 
00085   // "identity" rotation being passed to DDCore.
00086   DDName rotn;
00087   if (myrRotation->size() > 0){
00088     rotn = myrRotation->getDDName(nmspace);
00089   }
00090   else if (myDDLRotation->size() > 0) {
00091     // The assumption here is that the Rotation element created 
00092     // a DDRotation already, and so we can use this as an rRotation
00093     // just provide DDCore with the name of the one just added... 
00094     // How to handle name conflicts? OVERWRITTEN by DDCore for now.
00095     rotn = myDDLRotation->getDDName(nmspace);
00096   }
00097   else if (myDDLRefl->size() > 0) {
00098     // The assumption is that a ReflectionRotation has been created and therefore 
00099     // we can refer to it as the rotation associated with this PosPart.
00100     // we can further assume that the namespace is the same as this PosPart.
00101     rotn = myDDLRefl->getDDName(nmspace);
00102   }
00103   else if (myrRefl->size() > 0) {
00104     rotn = myrRefl->getDDName(nmspace);
00105   }
00106 
00107   DCOUT_V('P', "DDLPosPart::processElement:  Final Rotation info: " << rotn);
00108 
00109   ExprEvalInterface & ev = ExprEvalSingleton::instance();
00110 
00111   double x = 0.0, y = 0.0, z = 0.0;
00112   if (myTranslation->size() > 0)
00113     {
00114       const DDXMLAttribute & atts = myTranslation->getAttributeSet();
00115       x = ev.eval(nmspace, atts.find("x")->second);
00116       y = ev.eval(nmspace, atts.find("y")->second);
00117       z = ev.eval(nmspace, atts.find("z")->second);
00118     }
00119 
00120   DCOUT_V('P', "DDLPosPart::processElement:  Final Translation info x=" << x << " y=" << y << " z=" << z);
00121 
00122   DDRotation* myDDRotation;
00123   // if rotation is named ...
00124   if ( rotn.name() != "" && rotn.ns() != "" ) {
00125     DDRotation temp(rotn);
00126     myDDRotation = &temp;
00127   } else { 
00128     // rotn is not assigned a name anywhere therefore the DDPos assumes the identity matrix.
00129     DDRotation temp(DDName(std::string("identity"),std::string("generatedForDDD")));
00130     myDDRotation = &temp;
00131     // if the identity is not yet defined, then...
00132     if ( !myDDRotation->isValid() ) {
00133       DDRotationMatrix* dmr = new DDRotationMatrix;
00134       temp = DDrot(DDName(std::string("identity"),std::string("generatedForDDD")), dmr );
00135       myDDRotation = &temp;
00136     }
00137   }
00138 
00139 
00140   DDTranslation myDDTranslation(x, y, z);
00141 
00142   DCOUT_V('P', "about to make a PosPart ...");
00143   DCOUT_V('p', "  myDDRotation    : " << *myDDRotation);
00144   DCOUT_V('p', "  myDDTranslation : " << myDDTranslation);
00145   DCOUT_V('p', "  parentDDName    : " << myParent->getDDName(nmspace));
00146   DCOUT_V('p', "  selfDDName      : " << myChild->getDDName(nmspace));
00147 
00148   const DDXMLAttribute & atts = getAttributeSet();
00149   std::string copyno = "";
00150   if (atts.find("copyNumber") != atts.end())
00151     copyno = atts.find("copyNumber")->second;
00152     
00153   DDpos(DDLogicalPart(myChild->getDDName(nmspace))
00154         , DDLogicalPart(myParent->getDDName(nmspace))
00155         , copyno
00156         , myDDTranslation
00157         , *myDDRotation);
00158 
00159   // clear all "children" and attributes
00160   myParent->clear();
00161   myChild->clear();
00162   myTranslation->clear();
00163   myDDLRotation->clear();
00164   myrRotation->clear();
00165   myDDLRefl->clear();
00166   myrRefl->clear();
00167 
00168   // after a pos part is done, we know we can clear it.
00169   clear();
00170 
00171   DCOUT_V('P', "DDLPosPart::processElement completed");
00172 }


The documentation for this class was generated from the following files:
Generated on Tue Jun 9 18:18:03 2009 for CMSSW by  doxygen 1.5.4