Back to home page

Project CMSSW displayed by LXR

 
 

    


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

0001 #include "DetectorDescription/Parser/src/DDLTrapezoid.h"
0002 #include "DetectorDescription/Core/interface/DDSolid.h"
0003 #include "DetectorDescription/Core/interface/ClhepEvaluator.h"
0004 #include "DetectorDescription/Parser/interface/DDLElementRegistry.h"
0005 #include "DetectorDescription/Parser/src/DDLSolid.h"
0006 #include "DetectorDescription/Parser/src/DDXMLElement.h"
0007 
0008 #include <map>
0009 #include <utility>
0010 
0011 class DDCompactView;
0012 
0013 DDLTrapezoid::DDLTrapezoid(DDLElementRegistry* myreg) : DDLSolid(myreg) {}
0014 
0015 // Upon encountering an end of the tag, call DDCore's Trap.
0016 void DDLTrapezoid::processElement(const std::string& name, const std::string& nmspace, DDCompactView& cpv) {
0017   ClhepEvaluator& ev = myRegistry_->evaluator();
0018 
0019   DDXMLAttribute atts = getAttributeSet();
0020 
0021   double phi = 0.0;
0022   double theta = 0.0;
0023   double dy2 = 0.0;
0024 
0025   if (atts.find("phi") != atts.end())
0026     phi = ev.eval(nmspace, atts.find("phi")->second);
0027 
0028   if (atts.find("theta") != atts.end())
0029     theta = ev.eval(nmspace, atts.find("theta")->second);
0030 
0031   if (atts.find("dy2") != atts.end())
0032     dy2 = ev.eval(nmspace, atts.find("dy2")->second);
0033   else if (atts.find("dy1") != atts.end())
0034     dy2 = ev.eval(nmspace, atts.find("dy1")->second);
0035 
0036   if (name == "Trapezoid") {
0037     DDSolid myTrap = DDSolidFactory::trap(getDDName(nmspace),
0038                                           ev.eval(nmspace, atts.find("dz")->second),
0039                                           theta,
0040                                           phi,
0041                                           ev.eval(nmspace, atts.find("h1")->second),
0042                                           ev.eval(nmspace, atts.find("bl1")->second),
0043                                           ev.eval(nmspace, atts.find("tl1")->second),
0044                                           ev.eval(nmspace, atts.find("alp1")->second),
0045                                           ev.eval(nmspace, atts.find("h2")->second),
0046                                           ev.eval(nmspace, atts.find("bl2")->second),
0047                                           ev.eval(nmspace, atts.find("tl2")->second),
0048                                           ev.eval(nmspace, atts.find("alp2")->second));
0049   } else if (name == "Trd1") {
0050     DDSolid myTrd1 = DDSolidFactory::trap(getDDName(nmspace),
0051                                           ev.eval(nmspace, atts.find("dz")->second),
0052                                           0,
0053                                           0,
0054                                           ev.eval(nmspace, atts.find("dy1")->second),
0055                                           ev.eval(nmspace, atts.find("dx1")->second),
0056                                           ev.eval(nmspace, atts.find("dx1")->second),
0057                                           0,
0058                                           dy2,
0059                                           ev.eval(nmspace, atts.find("dx2")->second),
0060                                           ev.eval(nmspace, atts.find("dx2")->second),
0061                                           0);
0062   } else {
0063     std::string msg = "\nDDLTrapezoid::processElement failed to process element of name: " + name +
0064                       ".  It can only process Trapezoid and Trd1.";
0065     throwError(msg);
0066   }
0067 
0068   DDLSolid::setReference(nmspace, cpv);
0069 }