CMS 3D CMS Logo

List of all members | Public Member Functions
DDLSpecPar Class Referencefinal

DDLSpecPar processes SpecPar elements. More...

#include <DDLSpecPar.h>

Inheritance diagram for DDLSpecPar:
DDXMLElement

Public Member Functions

 DDLSpecPar (DDLElementRegistry *myreg)
 
void processElement (const std::string &name, const std::string &nmspace, DDCompactView &cpv) override
 Processing the element. 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...
 
virtual void preProcessElement (const std::string &name, const std::string &nmspace, DDCompactView &cpv)
 Called by loadAttributes AFTER attributes are loaded. 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)=default
 Destructor. More...
 

Additional Inherited Members

- Protected Attributes inherited from DDXMLElement
DDLElementRegistrymyRegistry_
 

Detailed Description

DDLSpecPar processes SpecPar elements.

Author
Michael Case

DDLSpecPar.h - description

begin: Tue Nov 21 2001 email: case@.nosp@m.ucdh.nosp@m.ep.uc.nosp@m.davi.nosp@m.s.edu

This element is used to specify parameters for a part in the detector. PartSelector provides a way to associate Parameters with specific parts of the detector.

Definition at line 26 of file DDLSpecPar.h.

Constructor & Destructor Documentation

◆ DDLSpecPar()

DDLSpecPar::DDLSpecPar ( DDLElementRegistry myreg)

Definition at line 20 of file DDLSpecPar.cc.

20 : DDXMLElement(myreg) {}
DDXMLElement(DDLElementRegistry *myreg)
Constructor.
Definition: DDXMLElement.cc:14

Member Function Documentation

◆ processElement()

void DDLSpecPar::processElement ( const std::string &  name,
const std::string &  nmspace,
DDCompactView cpv 
)
overridevirtual

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.

08/13/03 doNotEval for Parameter is based on the value of the eval flag. For String it is always false and for Numeric it is always true. But for "legacy" Parameter, remember, we need to check eval. Default is NOT to evaluate.


1. Check eval flag of each level (SpecParSection, SpecPar and Parameter).

  1. Default is the closest specified eval attribute with any value other than "false".

Reimplemented from DDXMLElement.

Definition at line 24 of file DDLSpecPar.cc.

References DDXMLElement::clear(), ClhepEvaluator::eval(), DDLElementRegistry::evaluator(), DDXMLElement::getAttributeSet(), DDXMLElement::getDDName(), DDLElementRegistry::getElement(), mps_fire::i, if(), DDXMLElement::myRegistry_, edm::second(), jetUpdater_cfi::sort, AlCaHLTBitMon_QueryRunRegistry::string, and heppy_batch::val.

24  {
25  // sends the call to the DDD Core OR does nothing if it is a sub-element
26 
27  // What I want to do here is the following:
28  // 1. output PartSelector information.
29  // 2. pass the Path and parameters to DDSpecifics
30  // for each of the above, use the name of the SpecPar, since DDL does not
31  // provide a name for a PartSelector.
32 
33  auto myParameter = myRegistry_->getElement("Parameter");
34  auto myNumeric = myRegistry_->getElement("Numeric");
35  auto myString = myRegistry_->getElement("String");
36  auto myPartSelector = myRegistry_->getElement("PartSelector");
37  auto mySpecParSection = myRegistry_->getElement("SpecParSection");
38 
39  // Because of namespace magic "!" means namespaces should be provided
40  // in the names of the XML elements for the DDD. So if this is
41  // the state/case then we need to force the expression evaluator to
42  // use the namespace of the SpecPar element being processed.
43  // -- Michael Case 2008-11-06
44  std::string ns(nmspace);
46  std::string rn = spatts.find("name")->second;
47  if (ns == "!") {
48  size_t foundColon = rn.find(':');
49  if (foundColon != std::string::npos) {
50  ns = rn.substr(0, foundColon);
51  // rn = rn.substr(foundColon+1);
52  }
53  }
54 
55  // DDPartSelector name comes from DDLSpecPar (this class, there is no analogue to
56  // DDLSpecPar in DDCore)
57  std::vector<std::string> partsels;
58  size_t i;
59 
60  // if (getName("name") == "")
61  // {
62  // std::cout << "ERROR: no name for SpecPar" << std::endl;
63  // partsels = myPartSelector->getVectorAttribute("path");
64  // snames = myParameter->getVectorAttribute("name");
65  // std::cout << "\tParameter Names" << std::endl;
66  // size_t i;
67  // for (i = 0; i < snames.size(); ++i)
68  // {
69  // std::cout << "\t\t" << snames[i] << std::endl;
70  // }
71  // std::cout << "\tPart Selectors:" << std::endl;
72  // for (i = 0; i < partsels.size(); ++i)
73  // {
74  // std::cout << "\t\t" << partsels[i] << std::endl;
75  // }
76  // }
77  // else
78  // {
79 
80  //should i keep this? partsels = myPartSelector->getVectorAttribute("path");
81  //otherise I have to do this block...
82  for (i = 0; i < myPartSelector->size(); ++i)
83  partsels.emplace_back((myPartSelector->getAttributeSet(i).find("path"))->second);
84  DDsvalues_type svt;
85 
86  // boolean flag to indicate whether the std::vector<DDValuePair> has been evaluated
87  // using the Evaluator
88  typedef std::map<std::string, std::pair<bool, std::vector<DDValuePair> > > vvvpType;
89 
90  vvvpType vvvp;
91 
97  bool doNotEval = true;
98  bool doRegex = true;
99  {
100  // check parent level
101  const DDXMLAttribute& atts = mySpecParSection->getAttributeSet();
102 
103  if (atts.find("eval") != atts.end() && atts.find("eval")->second == "true")
104  doNotEval = false;
105 
106  if (atts.find("regex") != atts.end() && atts.find("regex")->second == "false")
107  doRegex = false;
108  }
109  {
110  // check this level
111  const DDXMLAttribute& atts = getAttributeSet();
112 
113  if (atts.find("eval") != atts.end() && atts.find("eval")->second == "true")
114  doNotEval = false;
115  else if (atts.find("eval") != atts.end())
116  doNotEval = true;
117 
118  if (atts.find("regex") != atts.end() && atts.find("regex")->second == "false")
119  doRegex = false;
120  else if (atts.find("regex") != atts.end())
121  doRegex = true;
122  }
123  for (i = 0; i < myParameter->size(); ++i) {
124  const DDXMLAttribute& atts = myParameter->getAttributeSet(i);
125  std::vector<DDValuePair> vvp;
126  vvvpType::iterator itv = vvvp.find((atts.find("name")->second));
127  if (itv != vvvp.end())
128  vvp = itv->second.second;
129  double tval = 0.0;
130  bool isEvaluated = false;
131 
139  // bool notThis = doNotEval myParameter->get(std::string("eval"), i) != "true";
140 
141  if ((atts.find("eval") != atts.end() && atts.find("eval")->second != "false") ||
142  (atts.find("eval") == atts.end() && !doNotEval)) {
143  tval = myRegistry_->evaluator().eval(ns, atts.find("value")->second);
144  isEvaluated = true;
145  }
146 
147  DDValuePair vp(atts.find("value")->second, tval);
148  vvp.emplace_back(vp);
149  vvvp[atts.find("name")->second] = make_pair(isEvaluated, vvp);
150  }
151 
152  // Process the String names and values.
153  for (i = 0; i < myString->size(); ++i) {
154  const DDXMLAttribute& atts = myString->getAttributeSet(i);
155  std::vector<DDValuePair> vvp;
156  vvvpType::iterator itv = vvvp.find(atts.find("name")->second);
157  if (itv != vvvp.end())
158  vvp = itv->second.second;
159 
160  DDValuePair vp(atts.find("value")->second, 0.0);
161  vvp.emplace_back(vp);
162  vvvp[atts.find("name")->second] = make_pair(false, vvp);
163  }
164 
165  // Process the Numeric names and values.
166  for (i = 0; i < myNumeric->size(); ++i) {
167  const DDXMLAttribute& atts = myNumeric->getAttributeSet(i);
168  std::vector<DDValuePair> vvp;
169  vvvpType::iterator itv = vvvp.find(atts.find("name")->second);
170  if (itv != vvvp.end())
171  vvp = itv->second.second;
172  double tval = myRegistry_->evaluator().eval(ns, atts.find("value")->second);
173  DDValuePair vp(atts.find("value")->second, tval);
174  vvp.emplace_back(vp);
175  vvvp[atts.find("name")->second] = make_pair(true, vvp);
176  }
177 
178  svt.reserve(vvvp.size());
179  for (vvvpType::const_iterator it = vvvp.begin(); it != vvvp.end(); ++it) {
180  DDValue val(it->first, it->second.second);
181  bool isEvaluated = it->second.first;
182  val.setEvalState(isEvaluated);
183  svt.emplace_back(DDsvalues_Content_type(val, val));
184  }
185  std::sort(svt.begin(), svt.end());
186 
187  DDSpecifics ds(getDDName(nmspace), partsels, svt, doRegex);
188 
189  myParameter->clear();
190  myPartSelector->clear();
191 
192  // after a SpecPar is done, we can clear
193  clear();
194 }
DDLElementRegistry * myRegistry_
Definition: DDXMLElement.h:173
DDsvalues_type::value_type DDsvalues_Content_type
Definition: DDsvalues.h:13
std::map< std::string, std::string > DDXMLAttribute
Definition: DDXMLElement.h:45
U second(std::pair< T, U > const &p)
std::vector< std::pair< unsigned int, DDValue > > DDsvalues_type
Definition: DDsvalues.h:12
ClhepEvaluator & evaluator()
virtual const DDXMLAttribute & getAttributeSet(size_t aIndex=0) const
Get a "row" of attributes, i.e. one attribute set.
Definition: DDXMLElement.cc:54
std::shared_ptr< DDXMLElement > getElement(const std::string &name)
THE most important part. Getting the pointer to a given element type.
double eval(const std::string &ns, const std::string &expr)
virtual void clear(void)
clear this element&#39;s contents.
Definition: DDXMLElement.cc:40
virtual const DDName getDDName(const std::string &defaultNS, const std::string &attname=std::string("name"), size_t aIndex=0)
Definition: DDXMLElement.cc:56
Interface to attach user specific data to nodes in the expanded-view.
Definition: DDSpecifics.h:41