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 ( DDLElementRegistry myreg)

Definition at line 21 of file DDLSpecPar.cc.

22  : DDXMLElement( myreg )
23 {}
DDXMLElement(DDLElementRegistry *myreg)
Constructor.
Definition: DDXMLElement.cc:15

Member Function Documentation

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).
  2. Default is the closest specified eval attribute with any value other than "false".

Reimplemented from DDXMLElement.

Definition at line 28 of file DDLSpecPar.cc.

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

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