CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Member Functions
DDLSpecPar Class Reference

DDLSpecPar processes SpecPar elements. More...

#include <DDLSpecPar.h>

Inheritance diagram for DDLSpecPar:
DDXMLElement

Public Member Functions

 DDLSpecPar (DDLElementRegistry *myreg)
 Constructor. More...
 
void processElement (const std::string &name, const std::string &nmspace, DDCompactView &cpv)
 Processing the element. More...
 
 ~DDLSpecPar (void)
 Destructor. 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)
 Destructor. More...
 

Additional Inherited Members

- Static Public Member Functions inherited from DDXMLElement
static std::string itostr (int i)
 WARNING: abused by other classes in this system: yet another conversion from int to std::string... More...
 
- 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 23 of file DDLSpecPar.h.

Constructor & Destructor Documentation

DDLSpecPar::DDLSpecPar ( DDLElementRegistry myreg)

Constructor.

Definition at line 26 of file DDLSpecPar.cc.

27  : DDXMLElement( myreg )
28 {}
DDXMLElement(DDLElementRegistry *myreg)
Constructor.
Definition: DDXMLElement.cc:15
DDLSpecPar::~DDLSpecPar ( void  )

Destructor.

Definition at line 30 of file DDLSpecPar.cc.

31 {}

Member Function Documentation

void DDLSpecPar::processElement ( const std::string &  name,
const std::string &  nmspace,
DDCompactView cpv 
)
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.

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 36 of file DDLSpecPar.cc.

References DDXMLElement::clear(), DCOUT_V, DDXMLElement::getAttributeSet(), DDXMLElement::getDDName(), DDLElementRegistry::getElement(), i, reco::if(), DDI::Singleton< I >::instance(), DDXMLElement::myRegistry_, edm::second(), DDValue::setEvalState(), DDXMLElement::size(), python.multivaluedict::sort(), and AlCaHLTBitMon_QueryRunRegistry::string.

37 {
38  DCOUT_V('P',"DDLSpecPar::processElement started");
39 
40  // sends the call to the DDD Core OR does nothing if it is a sub-element
41 
42  // What I want to do here is the following:
43  // 1. output PartSelector information.
44  // 2. pass the Path and parameters to DDSpecifics
45  // for each of the above, use the name of the SpecPar, since DDL does not
46  // provide a name for a PartSelector.
47 
48  DDXMLElement* myParameter = myRegistry_->getElement("Parameter");
49  DDXMLElement* myNumeric = myRegistry_->getElement("Numeric");
50  DDXMLElement* myString = myRegistry_->getElement("String");
51  DDXMLElement* myPartSelector = myRegistry_->getElement("PartSelector");
52  DDXMLElement* mySpecParSection = myRegistry_->getElement("SpecParSection");
53 
54  // Because of namespace magic "!" means namespaces should be provided
55  // in the names of the XML elements for the DDD. So if this is
56  // the state/case then we need to force the expression evaluator to
57  // use the namespace of the SpecPar element being processed.
58  // -- Michael Case 2008-11-06
59  std::string ns(nmspace);
61  std::string rn = spatts.find("name")->second;
62  if ( ns == "!" ) {
63  size_t foundColon= rn.find(':');
64  if (foundColon != std::string::npos) {
65  ns = rn.substr(0,foundColon);
66  // rn = rn.substr(foundColon+1);
67  }
68  }
69 
70  // DDPartSelector name comes from DDLSpecPar (this class, there is no analogue to
71  // DDLSpecPar in DDCore)
72  std::vector <std::string> partsels;
73  size_t i;
74 
75  // if (getName("name") == "")
76  // {
77  // std::cout << "ERROR: no name for SpecPar" << std::endl;
78  // partsels = myPartSelector->getVectorAttribute("path");
79  // snames = myParameter->getVectorAttribute("name");
80  // std::cout << "\tParameter Names" << std::endl;
81  // size_t i;
82  // for (i = 0; i < snames.size(); ++i)
83  // {
84  // std::cout << "\t\t" << snames[i] << std::endl;
85  // }
86  // std::cout << "\tPart Selectors:" << std::endl;
87  // for (i = 0; i < partsels.size(); ++i)
88  // {
89  // std::cout << "\t\t" << partsels[i] << std::endl;
90  // }
91  // }
92  // else
93  // {
94 
95  //should i keep this? partsels = myPartSelector->getVectorAttribute("path");
96  //otherise I have to do this block...
97  for (i = 0; i < myPartSelector->size(); ++i)
98  partsels.push_back((myPartSelector->getAttributeSet(i).find("path"))->second);
99  DDsvalues_type svt;
100 
101  // boolean flag to indicate whether the std::vector<DDValuePair> has been evaluated
102  // using the Evaluator
103  typedef std::map<std::string, std::pair<bool,std::vector<DDValuePair> > > vvvpType;
104 
105  vvvpType vvvp;
106 
112  bool doNotEval = true;
113  bool doRegex = true;
114  {
115  // check parent level
116  const DDXMLAttribute & atts = mySpecParSection->getAttributeSet();
117 
118  if (atts.find("eval") != atts.end() && atts.find("eval")->second == "true")
119  doNotEval = false;
120 
121  if (atts.find("regex") != atts.end() && atts.find("regex")->second == "false")
122  doRegex = false;
123  }
124  {
125  // check this level
126  const DDXMLAttribute & atts = getAttributeSet();
127 
128  if (atts.find("eval") != atts.end() && atts.find("eval")->second == "true")
129  doNotEval = false;
130  else if (atts.find("eval") != atts.end())
131  doNotEval = true;
132 
133  if (atts.find("regex") != atts.end() && atts.find("regex")->second == "false")
134  doRegex = false;
135  else if (atts.find("regex") != atts.end())
136  doRegex = true;
137  }
138  for (i = 0; i < myParameter->size(); ++i)
139  {
140  const DDXMLAttribute & atts = myParameter->getAttributeSet(i);
141  std::vector <DDValuePair> vvp;
142  vvvpType::iterator itv = vvvp.find((atts.find("name")->second));
143  if (itv != vvvp.end())
144  vvp = itv->second.second;
145  double tval = 0.0;
146  bool isEvaluated = false;
147 
155  // bool notThis = doNotEval myParameter->get(std::string("eval"), i) != "true";
156 
157  // since eval is an optional attribute, we need to check if it exists for
158  // the debug statement. Unfortunately, I see no way to do this internal
159  // to the DCOUT_V statement... ts is a "wasted" variable.
160  std::string ts = "** no eval attribute **";
161  if (atts.find("eval") != atts.end())
162  ts = atts.find("eval")->second;
163  DCOUT_V('P', std::string("about to process ") << atts.find("value")->second << std::string(" eval = ") << ts);
164  if ((atts.find("eval") != atts.end() && atts.find("eval")->second !="false")
165  || (atts.find("eval") == atts.end() && !doNotEval))
166  {
167  tval = ExprEvalSingleton::instance().eval(ns, atts.find("value")->second);
168  isEvaluated=true;
169  DCOUT_V('P', std::string("EVALUATED"));
170  }
171  else
172  {
173  DCOUT_V('P', std::string("NOT Evaluated"));
174  }
175 
176  DDValuePair vp(atts.find("value")->second, tval);
177  vvp.push_back(vp);
178  vvvp[atts.find("name")->second] = make_pair(isEvaluated,vvp);
179  }
180 
181  // Process the String names and values.
182  for (i = 0; i < myString->size(); ++i)
183  {
184  const DDXMLAttribute & atts = myString->getAttributeSet(i);
185  std::vector <DDValuePair> vvp;
186  vvvpType::iterator itv = vvvp.find(atts.find("name")->second);
187  if (itv != vvvp.end())
188  vvp = itv->second.second;
189  DCOUT_V('P', std::string("about to process String ") << (atts.find("name")->second) << " = " << (atts.find("value")->second));
190  DDValuePair vp(atts.find("value")->second, 0.0);
191  vvp.push_back(vp);
192  vvvp[atts.find("name")->second] = make_pair(false,vvp);
193  }
194 
195  // Process the Numeric names and values.
196  for (i = 0; i < myNumeric->size(); ++i)
197  {
198  const DDXMLAttribute & atts = myNumeric->getAttributeSet(i);
199  std::vector <DDValuePair> vvp;
200  vvvpType::iterator itv = vvvp.find(atts.find("name")->second);
201  if (itv != vvvp.end())
202  vvp = itv->second.second;
203  DCOUT_V('P', std::string("about to process String ") << (atts.find("name")->second) << " = " << (atts.find("value")->second));
204  double tval = ExprEvalSingleton::instance().eval(ns, atts.find("value")->second);
205  DCOUT_V('P', std::string("EVALUATED"));
206  DDValuePair vp(atts.find("value")->second, tval);
207  vvp.push_back(vp);
208  vvvp[atts.find("name")->second] = make_pair(true,vvp);
209  }
210 
211  svt.reserve(vvvp.size());
212  for (vvvpType::const_iterator it = vvvp.begin(); it != vvvp.end(); ++it)
213  {
214  DDValue val(it->first, it->second.second);
215  bool isEvaluated = it->second.first;
216  val.setEvalState(isEvaluated);
217  svt.push_back(DDsvalues_Content_type(val,val));
218  }
219  std::sort(svt.begin(),svt.end());
220 
221 
222  DCOUT_V('p', "DDLSpecPar::processElement\n\tname " << getDDName(nmspace) << "\n\tpartsels.size() = " << myPartSelector->size() << "\n\tsvt " << svt);
223 
224  DDSpecifics ds(getDDName(nmspace),
225  partsels,
226  svt,
227  doRegex);
228 
229  myParameter->clear();
230  myPartSelector->clear();
231 
232  // after a SpecPar is done, we can clear
233  clear();
234 
235  DCOUT_V('P',"DDLSpecPar::processElement(...)");
236 }
int i
Definition: DBlmapReader.cc:9
DDLElementRegistry * myRegistry_
Definition: DDXMLElement.h:186
virtual const DDXMLAttribute & getAttributeSet(size_t aIndex=0) const
Get a &quot;row&quot; of attributes, i.e. one attribute set.
Definition: DDXMLElement.cc:79
std::map< std::string, std::string > DDXMLAttribute
Definition: DDXMLElement.h:55
U second(std::pair< T, U > const &p)
DDXMLElement * getElement(const std::string &name)
THE most important part. Getting the pointer to a given element type.
static value_type & instance()
virtual size_t size(void) const
Number of elements accumulated.
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:19
#define DCOUT_V(M_v_Y, M_v_S)
Definition: DDdebug.h:54
This is a base class for processing XML elements in the DDD.
Definition: DDXMLElement.h:58
if(dp >Float(M_PI)) dp-
virtual void clear(void)
clear this element&#39;s contents.
Definition: DDXMLElement.cc:61
virtual const DDName getDDName(const std::string &defaultNS, const std::string &attname=std::string("name"), size_t aIndex=0)
Definition: DDXMLElement.cc:86
DDsvalues_type::value_type DDsvalues_Content_type
Definition: DDsvalues.h:20
Interface to attach user specific data to nodes in the expanded-view.
Definition: DDSpecifics.h:40