DDLDivision processes Division elements. More...
#include <DDLDivision.h>
Public Member Functions | |
DDLDivision (DDLElementRegistry *myreg) | |
Constructor. | |
void | preProcessElement (const std::string &name, const std::string &nmspace, DDCompactView &cpv) |
Called by loadAttributes AFTER attributes are loaded. | |
void | processElement (const std::string &name, const std::string &nmspace, DDCompactView &cpv) |
Processing the element. | |
~DDLDivision (void) | |
Destructor. | |
Private Member Functions | |
DDDividedGeometryObject * | makeDivider (const DDDivision &div, DDCompactView *cpv) |
DDLDivision processes Division elements.
DDLDivision.h - description ------------------- begin: Friday, April 23, 2004 email: case@ucdhep.ucdavis.edu
Definition at line 23 of file DDLDivision.h.
DDLDivision::DDLDivision | ( | DDLElementRegistry * | myreg | ) |
DDLDivision::~DDLDivision | ( | void | ) |
DDDividedGeometryObject * DDLDivision::makeDivider | ( | const DDDivision & | div, |
DDCompactView * | cpv | ||
) | [private] |
Definition at line 114 of file DDLDivision.cc.
References DDDivision::axis(), dd_not_init, ddbox, ddcons, ddintersection, ddpolycone_rrz, ddpolycone_rz, ddpolyhedra_rrz, ddpolyhedra_rz, ddpseudotrap, ddreflected, ddshapeless, ddsubtraction, ddtrap, ddtrunctubs, ddtubs, ddunion, AlCaRecoCosmics_cfg::name, DDName::name(), DDBase< N, C >::name(), DDName::ns(), NULL, DDDivision::parent(), phi, rho, asciidump::s, DDSolid::shape(), DDLogicalPart::solid(), DDXMLElement::throwError(), ExpressReco_HICollisions_FallBack::x, ExpressReco_HICollisions_FallBack::y, and z.
Referenced by processElement().
{ DDDividedGeometryObject* dg = NULL; switch (div.parent().solid().shape()) { case ddbox: if (div.axis() == x) dg = new DDDividedBoxX(div,cpv); else if (div.axis() == y) dg = new DDDividedBoxY(div,cpv); else if (div.axis() == z) dg = new DDDividedBoxZ(div,cpv); else { std::string s = "DDLDivision can not divide a "; s += DDSolidShapesName::name(div.parent().solid().shape()); s += " along axis " + DDAxesNames::name(div.axis()); s += "."; s += "\n name= " + div.name().ns() + ":" + div.name().name() ; s += "\n parent= " + div.parent().name().ns() + ":" + div.parent().name().name(); throwError(s); } break; case ddtubs: if (div.axis() == rho) dg = new DDDividedTubsRho(div,cpv); else if (div.axis() == phi) dg = new DDDividedTubsPhi(div,cpv); else if (div.axis() == z) dg = new DDDividedTubsZ(div,cpv); else { std::string s = "DDLDivision can not divide a "; s += DDSolidShapesName::name(div.parent().solid().shape()); s += " along axis " + DDAxesNames::name(div.axis()); s += "."; s += "\n name= " + div.name().ns() + ":" + div.name().name() ; s += "\n parent= " + div.parent().name().ns() + ":" + div.parent().name().name(); throwError(s); } break; case ddtrap: if (div.axis() == x) dg = new DDDividedTrdX(div,cpv); else if (div.axis() == y ) dg = new DDDividedTrdY(div,cpv); else if (div.axis() == z ) dg = new DDDividedTrdZ(div,cpv); else { std::string s = "DDLDivision can not divide a "; s += DDSolidShapesName::name(div.parent().solid().shape()); s += " along axis "; s += DDAxesNames::name(div.axis()); s += "."; s += "\n name= " + div.name().ns() + ":" + div.name().name() ; s += "\n parent= " + div.parent().name().ns() + ":" + div.parent().name().name(); throwError(s); } break; case ddcons: if (div.axis() == rho) dg = new DDDividedConsRho(div,cpv); else if (div.axis() == phi) dg = new DDDividedConsPhi(div,cpv); else if (div.axis() == z) dg = new DDDividedConsZ(div,cpv); else { std::string s = "DDLDivision can not divide a "; s += DDSolidShapesName::name(div.parent().solid().shape()); s += " along axis " + DDAxesNames::name(div.axis()); s += "."; s += "\n name= " + div.name().ns() + ":" + div.name().name() ; s += "\n parent= " + div.parent().name().ns() + ":" + div.parent().name().name(); throwError(s); } break; case ddpolycone_rrz: if (div.axis() == rho) dg = new DDDividedPolyconeRho(div,cpv); else if (div.axis() == phi) dg = new DDDividedPolyconePhi(div,cpv); else if (div.axis() == z) dg = new DDDividedPolyconeZ(div,cpv); else { std::string s = "DDLDivision can not divide a "; s += DDSolidShapesName::name(div.parent().solid().shape()); s += " along axis "; s += DDAxesNames::name(div.axis()); s += "."; s += "\n name= " + div.name().ns() + ":" + div.name().name() ; s += "\n parent= " + div.parent().name().ns() + ":" + div.parent().name().name(); throwError(s); } break; case ddpolyhedra_rrz: if (div.axis() == rho) dg = new DDDividedPolyhedraRho(div,cpv); else if (div.axis() == phi) dg = new DDDividedPolyhedraPhi(div,cpv); else if (div.axis() == z) dg = new DDDividedPolyhedraZ(div,cpv); else { std::string s = "DDLDivision can not divide a "; s += DDSolidShapesName::name(div.parent().solid().shape()); s += " along axis "; s += DDAxesNames::name(div.axis()); s += "."; s += "\n name= " + div.name().ns() + ":" + div.name().name() ; s += "\n parent= " + div.parent().name().ns() + ":" + div.parent().name().name(); throwError(s); } break; case ddpolycone_rz: case ddpolyhedra_rz: { std::string s = "ERROR: A Polycone or Polyhedra can not be divided on any axis if it's\n"; s += "original definition used r and z instead of ZSections. This has\n"; s += "not (yet) been implemented."; s += "\n name= " + div.name().ns() + ":" + div.name().name() ; s += "\n parent= " + div.parent().name().ns() + ":" + div.parent().name().name(); } break; case ddunion: case ddsubtraction: case ddintersection: case ddreflected: case ddshapeless: case ddpseudotrap: case ddtrunctubs: case dd_not_init: { std::string s = "DDLDivision can not divide a "; s += DDSolidShapesName::name(div.parent().solid().shape()); s += " at all (yet?). Requested axis was "; s += DDAxesNames::name(div.axis()); s += ".\n"; throwError(s); } break; default: break; } return dg; }
void DDLDivision::preProcessElement | ( | const std::string & | name, |
const std::string & | nmspace, | ||
DDCompactView & | cpv | ||
) | [virtual] |
Called by loadAttributes AFTER attributes are loaded.
The preProcessElement method can assume that the attributes are loaded and perform any code that is necessary at the start of an element.
This would allow users to call their own code to setup anything necessary for the continued processing of the child elements.
Reimplemented from DDXMLElement.
Definition at line 39 of file DDLDivision.cc.
{}
void DDLDivision::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.
Reimplemented from DDXMLElement.
Definition at line 43 of file DDLDivision.cc.
References DDXMLElement::clear(), DCOUT_V, ExprEvalInterface::eval(), DDDividedGeometryObject::execute(), DDXMLElement::getAttributeSet(), DDXMLElement::getDDName(), DDI::Singleton< I >::instance(), DDBase< N, C >::isDefined(), makeDivider(), AlCaRecoCosmics_cfg::name, DDAxesNames::name(), DDName::name(), DDName::ns(), DDXMLElement::parent(), DDLogicalPart::solid(), and DDXMLElement::throwError().
{ DCOUT_V('P', "DDLDivision::processElement started"); DDXMLAttribute atts = getAttributeSet(); DDName parent = getDDName(nmspace, "parent"); ExprEvalInterface & ev = ExprEvalSingleton::instance(); size_t ax = 0; while (DDAxesNames::name(DDAxes(ax)) != atts.find("axis")->second && DDAxesNames::name(DDAxes(ax)) != "undefined") ++ax; DDLogicalPart lp(parent); if ( !lp.isDefined().second || !lp.solid().isDefined().second ) { std::string em("DetectorDescription Parser DDLDivision::processElement(...) failed."); em += " The solid of the parent logical part MUST be defined before the Division is made."; em += "\n name= " + getDDName(nmspace).ns() + ":" + getDDName(nmspace).name() ; em += "\n parent= " + parent.ns() + ":" + parent.name(); throwError (em); } DDDivision div; if (atts.find("nReplicas") != atts.end() && atts.find("width") != atts.end() && atts.find("offset") != atts.end()) { div = DDDivision(getDDName(nmspace) , parent , DDAxes(ax) , int(ev.eval(nmspace, atts.find("nReplicas")->second)) , ev.eval(nmspace, atts.find("width")->second) , ev.eval(nmspace, atts.find("offset")->second)); } else if (atts.find("nReplicas") != atts.end() && atts.find("offset") != atts.end()) { div = DDDivision(getDDName(nmspace) , parent , DDAxes(ax) , int(ev.eval(nmspace, atts.find("nReplicas")->second)) , ev.eval(nmspace, atts.find("offset")->second)); } else if (atts.find("width") != atts.end() && atts.find("offset") != atts.end()) { DCOUT_V ('D', " width = " << ev.eval(nmspace, atts.find("width")->second) << std::endl); DCOUT_V ('D', " offset = " << ev.eval(nmspace, atts.find("offset")->second) << std::endl); div = DDDivision(getDDName(nmspace) , parent , DDAxes(ax) , ev.eval(nmspace, atts.find("width")->second) , ev.eval(nmspace, atts.find("offset")->second)); } else { std::string em("DetectorDescription Parser DDLDivision::processElement(...) failed."); em += " Allowed combinations are attributes width&offset OR nReplicas&offset OR nReplicas&width&offset."; em += "\n name= " + getDDName(nmspace).ns() + ":" + getDDName(nmspace).name() ; em += "\n parent= " + parent.ns() + ":" + parent.name(); throwError (em); } DDDividedGeometryObject* dg = makeDivider(div, &cpv); dg->execute(); delete dg; clear(); DCOUT_V('P', "DDLDivision::processElement completed"); }