CMS 3D CMS Logo

DDLAlgoPosPart.cc

Go to the documentation of this file.
00001 /***************************************************************************
00002                           DDLAlgoPosPart.cc  -  description
00003                              -------------------
00004     begin                : Wed Apr 17 2002
00005     email                : case@ucdhep.ucdavis.edu
00006  ***************************************************************************/
00007 
00008 /***************************************************************************
00009  *                                                                         *
00010  *           DDDParser sub-component of DDD                                *
00011  *                                                                         *
00012  ***************************************************************************/
00013 
00014 
00015 
00016 // Parser parts
00017 #include "DDLAlgoPosPart.h"
00018 #include "DDLElementRegistry.h"
00019 #include "DDXMLElement.h"
00020 
00021 // DDCore dependencies
00022 #include "DetectorDescription/Core/interface/DDalgoPosPart.h"
00023 #include "DetectorDescription/Core/interface/DDName.h"
00024 #include "DetectorDescription/Core/interface/DDLogicalPart.h"
00025 #include "DetectorDescription/Core/interface/DDAlgo.h"
00026 #include "DetectorDescription/Base/interface/DDAlgoPar.h"
00027 #include "DetectorDescription/Base/interface/DDdebug.h"
00028 #include "DetectorDescription/Base/interface/DDException.h"
00029 
00030 #include "DetectorDescription/ExprAlgo/interface/ExprEvalSingleton.h"
00031 
00032 #include <string>
00033 #include <iostream>
00034 
00035 // Default constructor
00036 DDLAlgoPosPart::DDLAlgoPosPart()
00037 {
00038 }
00039 
00040 // Default desctructor
00041 DDLAlgoPosPart::~DDLAlgoPosPart()
00042 {
00043 }
00044 
00045 // Upon encountering the end tag of the AlgoPosPart we should have in the meantime
00046 // hit rParent, rChild, ParS and ParE.
00047 void DDLAlgoPosPart::processElement (const std::string& type, const std::string& nmspace)
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 }
00140 

Generated on Tue Jun 9 17:32:23 2009 for CMSSW by  doxygen 1.5.4