CMS 3D CMS Logo

DDLLogicalPart.cc
Go to the documentation of this file.
7 
8 #include <utility>
9 
10 class DDCompactView;
11 
13  : DDXMLElement( myreg )
14 {
15  // initialize category map
16  catMap_["sensitive"] = DDEnums::sensitive;
17  catMap_["cable"] = DDEnums::cable;
18  catMap_["cooling"] = DDEnums::cooling;
19  catMap_["support"] = DDEnums::support;
20  catMap_["envelope"] = DDEnums::envelope;
21  catMap_["unspecified"] = DDEnums::unspecified;
22 }
23 
24 // upon initialization, we want to clear rMaterial and rSolid.
25 void
27 {
28  myRegistry_->getElement( "rMaterial" )->clear();
29  myRegistry_->getElement( "rSolid" )->clear();
30 }
31 
32 // Upon encountering the end of the LogicalPart element, retrieve all
33 // relevant information from its sub-elements and put it all together to
34 // call the DDCore appropriately.
35 //
36 // History: Initially only rSolid and rMaterial elements worked. Now,
37 // a Material or a Solid element inside the LogicalPart also works but
38 // this is handled outside this class. Each Solid inherits from DDLSolid
39 // and in each Solid, the processElement method must call the setReference
40 // of the DDLSolid. The Material element also works similarly. Thus,
41 // by retrieving the rMaterial and the rSolid it actually will be handling
42 // Material and Solid subelements as well.
43 
44 void
46 {
47  // rMaterial and rSolid
48  auto myrMaterial = myRegistry_->getElement("rMaterial"); // get Material reference child
49  auto myrSolid = myRegistry_->getElement("rSolid"); // get Solid reference child
50 
52 
53  DDSolid mySolid = DDSolid(myrSolid->getDDName(nmspace));
54  DDMaterial myMaterial = DDMaterial(myrMaterial->getDDName(nmspace));
55 
57 
58  if (atts.find("category") != atts.end())
59  cat = catMap_[atts.find("category")->second];
60  else
61  cat = catMap_["unspecified"];
62 
63  DDLogicalPart lp( getDDName( nmspace ), myMaterial, mySolid, cat );
64 
65  // clear all "children" and attributes
66  myrMaterial->clear();
67  myrSolid->clear();
68 
69  // after each logical part is made, we can clear it
70  clear();
71 }
DDLElementRegistry * myRegistry_
Definition: DDXMLElement.h:172
DDMaterial is used to define and access material information.
Definition: DDMaterial.h:43
virtual const DDXMLAttribute & getAttributeSet(size_t aIndex=0) const
Get a "row" of attributes, i.e. one attribute set.
Definition: DDXMLElement.cc:72
Compact representation of the geometrical detector hierarchy.
Definition: DDCompactView.h:80
std::map< std::string, std::string > DDXMLAttribute
Definition: DDXMLElement.h:45
A DDSolid represents the shape of a part.
Definition: DDSolid.h:39
void processElement(const std::string &name, const std::string &nmspace, DDCompactView &cpv) override
Processing the element.
def cat(path)
Definition: eostools.py:401
std::shared_ptr< DDXMLElement > getElement(const std::string &name)
THE most important part. Getting the pointer to a given element type.
Category
Definition: DDEnums.h:7
A DDLogicalPart aggregates information concerning material, solid and sensitveness ...
Definition: DDLogicalPart.h:93
This is a base class for processing XML elements in the DDD.
Definition: DDXMLElement.h:48
void preProcessElement(const std::string &name, const std::string &nmspace, DDCompactView &cpv) override
Called by loadAttributes AFTER attributes are loaded.
std::map< std::string, DDEnums::Category > catMap_
The main class for processing parsed elements.
virtual void clear(void)
clear this element&#39;s contents.
Definition: DDXMLElement.cc:54
virtual const DDName getDDName(const std::string &defaultNS, const std::string &attname=std::string("name"), size_t aIndex=0)
Definition: DDXMLElement.cc:79
DDLLogicalPart(DDLElementRegistry *myreg)