Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 12:55:07

0001 #include "DetectorDescription/Parser/src/DDLLogicalPart.h"
0002 #include "DetectorDescription/Core/interface/DDLogicalPart.h"
0003 #include "DetectorDescription/Core/interface/DDMaterial.h"
0004 #include "DetectorDescription/Core/interface/DDSolid.h"
0005 #include "DetectorDescription/Parser/interface/DDLElementRegistry.h"
0006 #include "DetectorDescription/Parser/src/DDXMLElement.h"
0007 
0008 #include <utility>
0009 
0010 class DDCompactView;
0011 
0012 DDLLogicalPart::DDLLogicalPart(DDLElementRegistry* myreg) : DDXMLElement(myreg) {
0013   // initialize category map
0014   catMap_["sensitive"] = DDEnums::sensitive;
0015   catMap_["cable"] = DDEnums::cable;
0016   catMap_["cooling"] = DDEnums::cooling;
0017   catMap_["support"] = DDEnums::support;
0018   catMap_["envelope"] = DDEnums::envelope;
0019   catMap_["unspecified"] = DDEnums::unspecified;
0020 }
0021 
0022 // upon initialization, we want to clear rMaterial and rSolid.
0023 void DDLLogicalPart::preProcessElement(const std::string& name, const std::string& nmspace, DDCompactView& cpv) {
0024   myRegistry_->getElement("rMaterial")->clear();
0025   myRegistry_->getElement("rSolid")->clear();
0026 }
0027 
0028 // Upon encountering the end of the LogicalPart element, retrieve all
0029 // relevant information from its sub-elements and put it all together to
0030 // call the DDCore appropriately.
0031 //
0032 // History:  Initially only rSolid and rMaterial elements worked.  Now,
0033 // a Material or a Solid element inside the LogicalPart also works but
0034 // this is handled outside this class.  Each Solid inherits from DDLSolid
0035 // and in each Solid, the processElement method must call the setReference
0036 // of the DDLSolid.  The Material element also works similarly.  Thus,
0037 // by retrieving the rMaterial and the rSolid it actually will be handling
0038 // Material and Solid subelements as well.
0039 
0040 void DDLLogicalPart::processElement(const std::string& name, const std::string& nmspace, DDCompactView& cpv) {
0041   // rMaterial and rSolid
0042   auto myrMaterial = myRegistry_->getElement("rMaterial");  // get Material reference child
0043   auto myrSolid = myRegistry_->getElement("rSolid");        // get Solid reference child
0044 
0045   DDXMLAttribute atts = getAttributeSet();
0046 
0047   DDSolid mySolid = DDSolid(myrSolid->getDDName(nmspace));
0048   DDMaterial myMaterial = DDMaterial(myrMaterial->getDDName(nmspace));
0049 
0050   DDEnums::Category cat;
0051 
0052   if (atts.find("category") != atts.end())
0053     cat = catMap_[atts.find("category")->second];
0054   else
0055     cat = catMap_["unspecified"];
0056 
0057   DDLogicalPart lp(getDDName(nmspace), myMaterial, mySolid, cat);
0058 
0059   // clear all "children" and attributes
0060   myrMaterial->clear();
0061   myrSolid->clear();
0062 
0063   // after each logical part is made, we can clear it
0064   clear();
0065 }