CMS 3D CMS Logo

DDLAlgoPosPart Class Reference

DDLAlgoPosPart handles AlgoPosPart elements. More...

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

Inheritance diagram for DDLAlgoPosPart:

DDXMLElement

List of all members.

Public Member Functions

 DDLAlgoPosPart ()
 Constructor.
void processElement (const std::string &name, const std::string &nmspace)
 Processing the element.
 ~DDLAlgoPosPart ()
 Destructor.


Detailed Description

DDLAlgoPosPart handles AlgoPosPart elements.

Author:
Michael Case
DDLAlgoPosPart.h - description ------------------- begin: Wed Apr 17 2002 email: case@ucdhep.ucdavis.edu

An AlgoPosPart (or Algorithmic Positioning Part) is used to repeatedly position a LogicalPart somewhere inside it's parent. So, an AlgoPosPart needs two rLogicalParts (self and parent) on which to operate, an Algorithm and it's parameters.

Definition at line 26 of file DDLAlgoPosPart.h.


Constructor & Destructor Documentation

DDLAlgoPosPart::DDLAlgoPosPart (  ) 

Constructor.

Definition at line 36 of file DDLAlgoPosPart.cc.

00037 {
00038 }

DDLAlgoPosPart::~DDLAlgoPosPart (  ) 

Destructor.

Definition at line 41 of file DDLAlgoPosPart.cc.

00042 {
00043 }


Member Function Documentation

void DDLAlgoPosPart::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 47 of file DDLAlgoPosPart.cc.

References DDXMLElement::clear(), DCOUT_V, DDalgoPosPart(), ExprEvalInterface::eval(), DDXMLElement::getAttributeSet(), DDXMLElement::getDDName(), DDLElementRegistry::getElement(), i, DDI::Singleton< I >::instance(), DDBase< N, C >::isDefined(), alivecheck_mergeAndRegister::msg, DDXMLElement::parent(), DDAlgo::setParameters(), DDXMLElement::size(), st, and DDXMLElement::throwError().

00048 {
00049   DCOUT_V('P', "DDLAlgoPosPart::processElement started");
00050   
00051   // get all internal elements.
00052   DDXMLElement* myParent  = DDLElementRegistry::getElement("rParent");
00053   DDXMLElement* myChild   = DDLElementRegistry::getElement("rChild");
00054   DDXMLElement* myParS    = DDLElementRegistry::getElement("ParS");
00055   DDXMLElement* myParE    = DDLElementRegistry::getElement("ParE");
00056 
00057   ExprEvalInterface & ev = ExprEvalSingleton::instance();
00058   
00059   DDXMLAttribute atts = getAttributeSet();
00060 
00061   // these were doubles
00062   int st = static_cast<int> ((atts.find("start") == atts.end() ? 0.0 : ev.eval(nmspace, atts.find("start")->second)));
00063   int ic = static_cast<int> ((atts.find("incr") == atts.end() ? 0.0 : ev.eval(nmspace, atts.find("incr")->second)));
00064   int ed = static_cast<int> ((atts.find("end") == atts.end() ? 0.0 : ev.eval(nmspace, atts.find("end")->second)));
00065   
00066   // get actual DDLogicalPart objects.
00067   DDLogicalPart parent(DDName(myParent->getDDName(nmspace)));
00068   DDLogicalPart self(DDName(myChild->getDDName(nmspace)));
00069 
00070   // get the algorithm
00071   DDAlgo algo( getDDName(nmspace, "algo" ));
00072   if (!(algo.isDefined().second)) 
00073     {
00074       std::string  msg = std::string("\n\tDDLParser, algo requested is not defined.  Either AlgoInit() or check algo spelling.\n ")
00075         + "\n\t\talgo=" + std::string(getDDName(nmspace, "algo" ))
00076         + "\n\t\tparent=" + std::string(myParent->getDDName(nmspace))
00077         + "\n\t\tself=" + std::string(myChild->getDDName(nmspace));
00078       throwError(msg);
00079     }
00080 
00081   // set the parameters for the algorithm
00082 
00083   // First for ParE type
00084   parE_type parE;
00085   for (size_t i = 0; i < myParE->size(); ++i)
00086     {
00087       atts = myParE->getAttributeSet(i);
00088       // find vname in ParE.
00089       parE_type::iterator existingName=parE.find(atts.find("name")->second);
00090       
00091       // if found, get std::vector, then add this value to it.
00092       // if not found, add this var, then add a value to it.
00093       if (existingName != parE.end())
00094         existingName->second.push_back(ev.eval(nmspace,atts.find("value")->second));
00095       //        tvect = existingName->second;
00096       else
00097         {
00098           std::vector<double> tvect;
00099           tvect.push_back(ev.eval(nmspace,atts.find("value")->second));
00100           parE[atts.find("name")->second] = tvect;
00101         }
00102     }
00103 
00104   // Now for ParS type
00105   parS_type parS;
00106 
00107   for (size_t i = 0; i < myParS->size(); ++i)
00108     {
00109       atts = myParS->getAttributeSet(i);
00110 
00111       // find vname in ParS.
00112       parS_type::iterator existingName=parS.find(atts.find("name")->second);
00113       
00114       // if found, get std::vector, then add this value to it.
00115       // if not found, add this var, then add a value to it.
00116 
00117       if (existingName != parS.end())
00118         existingName->second.push_back(atts.find("value")->second);
00119       else
00120         {
00121           std::vector<std::string> tvect;
00122           tvect.push_back(atts.find("value")->second);
00123           parS[atts.find("name")->second] = tvect;
00124         }
00125     }
00126   
00127   algo.setParameters(st,ed,ic,parS,parE);
00128   DDalgoPosPart(self, parent, algo);
00129   
00130   // clear all "children" and attributes
00131   myChild->clear();
00132   myParent->clear();
00133   myParS->clear();
00134   myParE->clear();
00135   // after an AlgoPosPart, we are sure it can be cleared.
00136   clear();
00137   
00138   DCOUT_V('P', "DDLAlgoPosPart::processElement completed");
00139 }


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