CMS 3D CMS Logo

DDLCompositeMaterial.cc
Go to the documentation of this file.
9 
10 #include <cstddef>
11 #include <map>
12 #include <utility>
13 
14 class DDCompactView;
15 
17 
18 // to initialize the CompositeMaterial, clear all rMaterials in case some other
19 // rMaterial was used for some other element.
21  // fyi: no need to clear MaterialFraction because it is cleared at the end of each
22  // CompositeMaterial
23  myRegistry_->getElement("rMaterial")->clear();
24 }
25 
29 
30  DDName ddn = getDDName(nmspace);
31  DDMaterial mat;
32 
33  mat = DDMaterial(ddn, ev.eval(nmspace, atts.find("density")->second));
34 
35  // Get references to relevant DDL elements that are needed.
36  auto myMF = myRegistry_->getElement("MaterialFraction");
37  auto myrMaterial = myRegistry_->getElement("rMaterial");
38 
39  // Get the names from those elements and also the namespace for the reference element.
40  // The parent element CompositeMaterial MUST be in the same namespace as this fraction.
41  // additionally, because it is NOT a reference, we do not try to dis-entangle the namespace.
42  // That is, we do not use the getName() which searches the name for a colon, but instead use
43  // the "raw" name attribute.
44 
45  // TO DO: sfractions assumes that the values are "mixture by weight" (I think)
46  // we need to retrieve the fraction attributes and then check the method
47  // attribute of the CompositeMaterial to determine if the numbers go straight
48  // in to the DDCore or if the numbers need to be manipulated so that the
49  // sfractions are really mixtures by weight going into the DDCore. Otherwise,
50  // the DDCore has to know which are which and right now it does not.
51 
52  if (myMF->size() != myrMaterial->size()) {
53  std::string msg = "/nDDLCompositeMaterial::processElement found that the ";
54  msg += "number of MaterialFractions does not match the number ";
55  msg += "of rMaterial names for ";
56  msg += ddn.ns() + ":" + ddn.name() + ".";
57  throwError(msg);
58  }
59  for (size_t i = 0; i < myrMaterial->size(); ++i) {
60  atts = myMF->getAttributeSet(i);
61  mat.addMaterial(myrMaterial->getDDName(nmspace, "name", i), ev.eval(nmspace, atts.find("fraction")->second));
62  }
63  // clears and sets new reference to THIS material.
64  DDLMaterial::setReference(nmspace, cpv);
65  myMF->clear();
66  clear();
67 }
DDXMLElement::clear
virtual void clear(void)
clear this element's contents.
Definition: DDXMLElement.cc:40
DDLCompositeMaterial.h
mps_fire.i
i
Definition: mps_fire.py:428
MessageLogger.h
DDXMLElement::throwError
void throwError(const std::string &keyMessage) const
format std::string for throw an error.
Definition: DDXMLElement.cc:209
DDName
DDName is used to identify DDD entities uniquely.
Definition: DDName.h:15
ClhepEvaluator.h
DDLElementRegistry
The main class for processing parsed elements.
Definition: DDLElementRegistry.h:23
ClhepEvaluator
Definition: ClhepEvaluator.h:8
mps_check.msg
tuple msg
Definition: mps_check.py:285
DDLCompositeMaterial::preProcessElement
void preProcessElement(const std::string &name, const std::string &nmspace, DDCompactView &cpv) override
Called by loadAttributes AFTER attributes are loaded.
Definition: DDLCompositeMaterial.cc:20
DDXMLElement::getAttributeSet
virtual const DDXMLAttribute & getAttributeSet(size_t aIndex=0) const
Get a "row" of attributes, i.e. one attribute set.
Definition: DDXMLElement.cc:54
DDLElementRegistry::evaluator
ClhepEvaluator & evaluator()
Definition: DDLElementRegistry.h:42
DDMaterial
DDMaterial is used to define and access material information.
Definition: DDMaterial.h:45
DDCompactView
Compact representation of the geometrical detector hierarchy.
Definition: DDCompactView.h:81
DDXMLAttribute
std::map< std::string, std::string > DDXMLAttribute
Definition: DDXMLElement.h:45
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
DDMaterial.h
DDName::name
const std::string & name() const
Returns the name.
Definition: DDName.cc:41
DDLMaterial::setReference
virtual void setReference(const std::string &nmspace, DDCompactView &cpv)
Definition: DDLMaterial.cc:13
DDLElementRegistry.h
DDLMaterial.h
DDXMLElement::getDDName
const virtual DDName getDDName(const std::string &defaultNS, const std::string &attname=std::string("name"), size_t aIndex=0)
Definition: DDXMLElement.cc:56
DDLElementRegistry::getElement
std::shared_ptr< DDXMLElement > getElement(const std::string &name)
THE most important part. Getting the pointer to a given element type.
Definition: DDLElementRegistry.cc:42
DDName::ns
const std::string & ns() const
Returns the namespace.
Definition: DDName.cc:52
DDXMLElement.h
DDName.h
ev
bool ev
Definition: Hydjet2Hadronizer.cc:95
DDLCompositeMaterial::DDLCompositeMaterial
DDLCompositeMaterial(DDLElementRegistry *myreg)
Definition: DDLCompositeMaterial.cc:16
DDLCompositeMaterial::processElement
void processElement(const std::string &name, const std::string &nmspace, DDCompactView &cpv) override
Processing the element.
Definition: DDLCompositeMaterial.cc:26
Skims_PA_cff.name
name
Definition: Skims_PA_cff.py:17
DDXMLElement::myRegistry_
DDLElementRegistry * myRegistry_
Definition: DDXMLElement.h:173
DDMaterial::addMaterial
int addMaterial(const DDMaterial &m, double fm)
adds a material to the mixture proportional to its fraction-mass fm.
Definition: DDMaterial.cc:63
DDLMaterial
DDLMaterial processes Box elements.
Definition: DDLMaterial.h:29