diff --git a/GeoModelTools/GeoModelXML/GeoModelXml/GeoModelXml/createdomdocument.h b/GeoModelTools/GeoModelXML/GeoModelXml/GeoModelXml/createdomdocument.h index bc7772436d8bc2b82967cd4b747fe7fdba93c7fb..66889180426d52f8d9edac24b37b92c3214389fe 100644 --- a/GeoModelTools/GeoModelXML/GeoModelXml/GeoModelXml/createdomdocument.h +++ b/GeoModelTools/GeoModelXML/GeoModelXml/GeoModelXml/createdomdocument.h @@ -8,9 +8,6 @@ #include <xercesc/dom/DOMLSParser.hpp> #include <iostream> -using namespace std; -using namespace xercesc; - -DOMDocument *createDOMDocument(string xmlFile, DOMLSParser *parser, unsigned int flags = 0); +xercesc::DOMDocument *createDOMDocument(std::string xmlFile, xercesc::DOMLSParser *parser, unsigned int flags = 0); #endif // CREATEDOMDOCUMENT_H diff --git a/GeoModelTools/GeoModelXML/GeoModelXml/data/geomodel.dtd b/GeoModelTools/GeoModelXML/GeoModelXml/data/geomodel.dtd index a38db9b61bfaec21fd3b1005461167d70a79c9a6..bca714ee6daf87fe4dbcfa9ec9e5f01559052307 100644 --- a/GeoModelTools/GeoModelXML/GeoModelXml/data/geomodel.dtd +++ b/GeoModelTools/GeoModelXML/GeoModelXml/data/geomodel.dtd @@ -65,7 +65,7 @@ <!ELEMENT addindex EMPTY> <!ATTLIST addindex name ID #REQUIRED> - <!ELEMENT shapes ((box|cons|generictrap|para|pcon|pgon|trap|tube|tubs|trd|intersection|subtraction|union)+)> + <!ELEMENT shapes ((box|cons|generictrap|para|pcon|pgon|trap|tube|tubs|trd|intersection|subtraction|union|simplepolygonbrep)+)> <!-- All shapes allowed in GeoModel manual. Same name, parameters, parameter order, but always lower case --> <!ELEMENT box EMPTY> @@ -118,7 +118,7 @@ <!ATTLIST addplane zplane CDATA #REQUIRED rminplane CDATA #REQUIRED rmaxplane CDATA #REQUIRED> - + <!ATTLIST pcon name ID #REQUIRED sphi CDATA #REQUIRED dphi CDATA #REQUIRED> @@ -174,6 +174,12 @@ <!ELEMENT union (shaperef, (transformation|transformationref), shaperef)> <!ATTLIST union name ID #REQUIRED> + <!ELEMENT simplepolygonbrep EMPTY> + <!ATTLIST simplepolygonbrep name ID #REQUIRED + xpoints CDATA #REQUIRED + ypoints CDATA #REQUIRED + zhalflength CDATA #REQUIRED> + <!ELEMENT shaperef EMPTY> <!ATTLIST shaperef ref IDREF #REQUIRED> @@ -200,7 +206,7 @@ z CDATA "0.0"> <!ATTLIST transformation name ID #REQUIRED> - <!ATTLIST transformation alignable (true|false) "false"> + <!ATTLIST transformation alignable (true|false) "false"> <!ELEMENT transformationref EMPTY> <!ATTLIST transformationref ref IDREF #REQUIRED> @@ -211,7 +217,8 @@ shape IDREF #REQUIRED material IDREF #REQUIRED sensitive IDREF #IMPLIED - alignable (true|false) "false"> + alignable (true|false) "false" + splitLevel CDATA #IMPLIED> <!ELEMENT index EMPTY> <!ATTLIST index ref IDREF #REQUIRED @@ -223,15 +230,15 @@ <!ELEMENT assembly (transform|logvol|logvolref|assembly|assemblyref|multicopy|replicaX|replicaY|replicaZ|replicaRPhi|replicaXYarrays|index)+> <!ATTLIST assembly name ID #REQUIRED - alignable (true|false) "false"> + alignable (true|false) "false"> <!ELEMENT assemblyref EMPTY> <!ATTLIST assemblyref ref IDREF #REQUIRED zeroid (true|false) "false"> <!ELEMENT multicopy (transformation, (transform|logvolref|assemblyref))> - <!-- Removed logvol and assembly from multicopy content. There is no particular reason - why they shouldn't be allowed there. But in practice one uses refs, and forbidding them simplifies coding + <!-- Removed logvol and assembly from multicopy content. There is no particular reason + why they shouldn't be allowed there. But in practice one uses refs, and forbidding them simplifies coding the index stuff. If you need them, put them back. Got rid of transformref; never used. --> <!-- loopvar: Set to a vector variable name or omit; see manual --> <!-- alignable: Value is the alignment level-number --> diff --git a/GeoModelTools/GeoModelXML/GeoModelXml/src/Gmx2Geo.cxx b/GeoModelTools/GeoModelXML/GeoModelXml/src/Gmx2Geo.cxx index a6f28adb549d7080cb6781b942c2f3bedf76f89c..2e03038f570423eddc01e1c217a81c62bf0d3d33 100644 --- a/GeoModelTools/GeoModelXML/GeoModelXml/src/Gmx2Geo.cxx +++ b/GeoModelTools/GeoModelXML/GeoModelXml/src/Gmx2Geo.cxx @@ -28,6 +28,7 @@ #include "GeoModelXml/MaterialManager.h" using namespace std; +using namespace xercesc; Gmx2Geo::Gmx2Geo(const string xmlFile, GeoPhysVol *addHere, GmxInterface &gmxInterface, unsigned int flags, bool useMatManager) { // diff --git a/GeoModelTools/GeoModelXML/GeoModelXml/src/LogvolProcessor.cxx b/GeoModelTools/GeoModelXML/GeoModelXml/src/LogvolProcessor.cxx deleted file mode 100644 index c6a6736bcd58943748eb83314adce64fba913121..0000000000000000000000000000000000000000 --- a/GeoModelTools/GeoModelXML/GeoModelXml/src/LogvolProcessor.cxx +++ /dev/null @@ -1,235 +0,0 @@ -/* - Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration -*/ - -// -// Processor for logvol elements -// -// Add name to list. -// Create a physvol using my logvol; add it to list. -// Process children and get list of things to be added to the physvol. -// Add them to the physvol. -// -#include "GeoModelXml/LogvolProcessor.h" -#include "OutputDirector.h" - -#include <map> - -#include <xercesc/dom/DOM.hpp> -#include "GeoModelKernel/GeoNameTag.h" -#include "GeoModelKernel/GeoIdentifierTag.h" -#include "GeoModelKernel/GeoLogVol.h" -#include "GeoModelKernel/GeoPhysVol.h" -#include "GeoModelKernel/GeoFullPhysVol.h" -#include "GeoModelKernel/GeoVFullPhysVol.h" -#include "GeoModelXml/GmxUtil.h" -#include "GeoModelXml/GeoNodeList.h" -#include "xercesc/util/XMLString.hpp" - -// using namespace CLHEP; - -using namespace std; -using namespace xercesc; - -void LogvolProcessor::process(const DOMElement *element, GmxUtil &gmxUtil, GeoNodeList &toAdd) { - GeoLogVol *lv; - GeoNameTag *physVolName; - - gmxUtil.positionIndex.incrementLevel(); - - XMLCh * name_tmp = XMLString::transcode("name"); - char *name2release = XMLString::transcode(element->getAttribute(name_tmp)); - string name(name2release); - XMLString::release(&name2release); - XMLString::release(&name_tmp); -// -// Look for the logvol in the map; if not yet there, add it -// - map<string, LogVolStore>::iterator entry; - if ((entry = m_map.find(name)) == m_map.end()) { // Not in registry; make a new item -// -// Name -// - m_map[name] = LogVolStore(); - LogVolStore *store = &m_map[name]; - physVolName = new GeoNameTag(name); - store->name = physVolName; - store->id = 0; -// -// Get the shape. -// - DOMDocument *doc = element->getOwnerDocument(); - XMLCh * shape_tmp = XMLString::transcode("shape"); - const XMLCh *shape = element->getAttribute(shape_tmp); - DOMElement *refShape = doc->getElementById(shape); - // Check it is a shape... its parent should be a <shapes>. DTD cannot do this for us. - DOMNode *parent = refShape->getParentNode(); - if (XMLString::compareIString(parent->getNodeName(), XMLString::transcode("shapes")) != 0) { - - msglog << MSG::FATAL << "Processing logvol " << name << - ". Error in gmx file. An IDREF for a logvol shape did not refer to a shape.\n" << - "Shape ref was " << shape << "; exiting" << endmsg; - exit (1); // Need to improve... - } -// -// What sort of shape? -// - name2release = XMLString::transcode(refShape->getNodeName()); - string shapeType(name2release); - XMLString::release(&name2release); - XMLString::release(&shape_tmp); - - GeoShape *s = (GeoShape *) gmxUtil.geoItemRegistry.find(shapeType)->process(refShape, gmxUtil); -// -// Get the material -// - XMLCh * material_tmp = XMLString::transcode("material"); - const XMLCh *material = element->getAttribute(material_tmp); - DOMElement *refMaterial = doc->getElementById(material); - // Check it is a material... its parent should be a <materials>. DTD cannot do this for us. - parent = refMaterial->getParentNode(); - XMLCh * materials_tmp = XMLString::transcode("materials"); - if (XMLString::compareIString(parent->getNodeName(), materials_tmp) != 0) { - msglog << MSG::FATAL << "Processing logvol " << name << - ". Error in gmx file. An IDREF for a logvol material did not refer to a material.\n" << - "Material ref was " << material << "; exiting" << endmsg; - exit (1); // Need to improve... - } - std::string nam_mat=XMLString::transcode(material); - - GeoMaterial* m=0; - - if (gmxUtil.matManager) - { - if (!gmxUtil.matManager->isMaterialDefined(nam_mat)) - { - GeoMaterial* tempMat=(GeoMaterial *) gmxUtil.tagHandler.material.process(refMaterial, gmxUtil); - // we let GMX create the material and store it in the MM - - gmxUtil.matManager->addMaterial(tempMat); - } - m=const_cast<GeoMaterial*>(gmxUtil.matManager->getMaterial(nam_mat)); - } - else - m=(GeoMaterial *) gmxUtil.tagHandler.material.process(refMaterial, gmxUtil); - -// -// Make the LogVol and add it to the map ready for next time -// - lv = new GeoLogVol(name, s, m); - store->logVol = lv; - - XMLString::release(&material_tmp); - XMLString::release(&materials_tmp); - } - else { // Already in the registry; use it. - physVolName = entry->second.name; - lv = entry->second.logVol; - } - - -// -// Process the logvol children (side effect: sets formulae for indexes before calculating them) -// - GeoNodeList childrenAdd; - for (DOMNode *child = element->getFirstChild(); child != 0; child = child->getNextSibling()) { - if (child->getNodeType() == DOMNode::ELEMENT_NODE) { - DOMElement *el = dynamic_cast<DOMElement *> (child); - name2release = XMLString::transcode(el->getNodeName()); - string name(name2release); - XMLString::release(&name2release); - gmxUtil.processorRegistry.find(name)->process(el, gmxUtil, childrenAdd); - } - } -// -// Make a list of things to be added -// - toAdd.push_back(physVolName); - XMLCh * sensitive_tmp = XMLString::transcode("sensitive"); - bool sensitive = element->hasAttribute(sensitive_tmp); - int sensId = 0; - //std::vector<int> extraSensIds;//extra Identfiers to be used in case we split this volume into multiple DetectorElements - map<string, int> index; - //map<string, int> updatedIndex;//extra indices to be used in case we split this volume - if (sensitive) { - gmxUtil.positionIndex.setCopyNo(m_map[name].id++); - gmxUtil.positionIndex.indices(index, gmxUtil.eval); - sensId = gmxUtil.gmxInterface()->sensorId(index); - // toAdd.push_back(new GeoIdentifierTag(m_map[name].id)); // Normal copy number - toAdd.push_back(new GeoIdentifierTag(sensId)); - } - else { - toAdd.push_back(new GeoIdentifierTag(m_map[name].id)); // Normal copy number - gmxUtil.positionIndex.setCopyNo(m_map[name].id++); - } - XMLString::release(&sensitive_tmp); - // - // Make a new PhysVol and add everything to it, then add it to the list of things for my caller to add - // - XMLCh * alignable_tmp = XMLString::transcode("alignable"); - char *toRelease = XMLString::transcode(element->getAttribute(alignable_tmp)); - string alignable(toRelease); - XMLString::release(&toRelease); - XMLString::release(&alignable_tmp); - if (sensitive || (alignable.compare(string("true")) == 0)) { - GeoFullPhysVol *pv = new GeoFullPhysVol(lv); - for (GeoNodeList::iterator node = childrenAdd.begin(); node != childrenAdd.end(); ++node) { - pv->add(*node); - } - toAdd.push_back(pv); // NB: the *PV is third item added, so reference as toAdd[2]. - // - // Add sensitive volumes to detector manager via GmxInterface - // - if (sensitive) { - XMLCh * sensitive_tmp = XMLString::transcode("sensitive"); - name2release = XMLString::transcode(element->getAttribute(sensitive_tmp)); - string sensitiveName(name2release); - XMLString::release(&name2release); - XMLString::release(&sensitive_tmp); - //splitting sensors where we would like multiple DetectorElements per GeoVFullPhysVol (e.g.ITk Strips) - XMLCh * splitLevel_tmp = XMLString::transcode("splitLevel"); - bool split = element->hasAttribute(splitLevel_tmp); - char* splitString; - int splitLevel = 1; - if (split) { - splitString = XMLString::transcode(element->getAttribute(splitLevel_tmp)); - splitLevel = gmxUtil.evaluate(splitString); - XMLString::release(&splitString); - XMLString::release(&splitLevel_tmp); - for(int i=0;i<splitLevel;i++){ - std::string field = "eta_module";//eventually specify in Xml the field to split in? - std::pair<std::string,int> extraIndex(field,i); - gmxUtil.gmxInterface()->addSplitSensor(sensitiveName, index,extraIndex, sensId, dynamic_cast<GeoVFullPhysVol *> (pv)); - } - } - else gmxUtil.gmxInterface()->addSensor(sensitiveName, index, sensId, dynamic_cast<GeoVFullPhysVol *> (pv)); - } - } - else { - GeoPhysVol *pv = new GeoPhysVol(lv); - for (GeoNodeList::iterator node = childrenAdd.begin(); node != childrenAdd.end(); ++node) { - pv->add(*node); - } - toAdd.push_back(pv); - } - - gmxUtil.positionIndex.decrementLevel(); - return; -} - -void LogvolProcessor::zeroId(const xercesc::DOMElement *element) { - - XMLCh * name_tmp = XMLString::transcode("name"); - char *name2release = XMLString::transcode(element->getAttribute(name_tmp)); - string name(name2release); - XMLString::release(&name2release); - XMLString::release(&name_tmp); - // - // Look for the logvol in the map; if not yet there, add it - // - map<string, LogVolStore>::iterator entry; - if ((entry = m_map.find(name)) != m_map.end()) { - entry->second.id = 0; - } - /* else: Not an error: it is usually just about to be made with id = 0; no action needed. */ -} diff --git a/GeoModelTools/GeoModelXML/GeoModelXml/src/MakeShaperef.cxx b/GeoModelTools/GeoModelXML/GeoModelXml/src/MakeShaperef.cxx index 4f7621903d96bfd1b177990ce89058be881cd220..86aa0d39f8b5289602191afeb099551b99057301 100644 --- a/GeoModelTools/GeoModelXML/GeoModelXml/src/MakeShaperef.cxx +++ b/GeoModelTools/GeoModelXML/GeoModelXml/src/MakeShaperef.cxx @@ -31,9 +31,11 @@ const RCBase *MakeShaperef::process(const DOMElement *element, GmxUtil &gmxUtil) // DOMNode *parent = shape->getParentNode(); if (XMLString::compareIString(parent->getNodeName(), shapes_tmp) != 0) { - msglog << MSG::FATAL << "Error processing <shaperef> tag: An IDREF for a shape did not refer to a shape.\nShape ref was " << - idref << "; exiting" << endmsg; - exit (1); // Need to improve... + char* idref_s = XMLString::transcode (idref); + msglog << MSG::FATAL << "Error processing <shaperef> tag: An IDREF for a shape did not refer to a shape.\nShape ref was " << + idref_s << "; exiting" << endmsg; + XMLString::release (&idref_s); + exit (1); // Need to improve... } // // Get what sort of shape