Mantid
|
Creates an instrument data from a XML instrument description file. More...
#include <InstrumentDefinitionParser.h>
Classes | |
struct | IdList |
Structure for holding detector IDs. More... | |
struct | SphVec |
Stripped down vector that holds position in terms of spherical coordinates, Needed when processing instrument definition files that use the 'Ariel format'. More... | |
Public Types | |
enum | CachingOption { NoneApplied , ReadGeomCache , ReadFallBack , WroteGeomCache , WroteCacheTemp } |
Caching. More... | |
Public Member Functions | |
const std::string | createVTPFileName () |
creates a vtp filename from a given xml filename More... | |
Kernel::V3D | getAbsolutPositionInCompCoorSys (Geometry::ICompAssembly *comp, Kernel::V3D) |
return absolute position of point which is set relative to the coordinate system of the input component More... | |
CachingOption | getAppliedCachingOption () const |
Getter the the applied caching option. More... | |
std::string | getMangledName () |
Handle used in the singleton constructor for instrument file should append the value file sha-1 checksum to determine if it is already in memory so that changes to the instrument file will cause file to be reloaded. More... | |
InstrumentDefinitionParser () | |
Default Constructor - not very functional in this state. More... | |
InstrumentDefinitionParser (const IDFObject_const_sptr &xmlFile, const IDFObject_const_sptr &expectedCacheFile, const std::string &instName, const std::string &xmlText) | |
Construct the XML parser based on an IDF xml and cached vtp file objects. More... | |
InstrumentDefinitionParser (const std::string &filename, const std::string &instName, const std::string &xmlText) | |
Constructor. More... | |
std::shared_ptr< Instrument > | parseXML (Kernel::ProgressBase *progressReporter) |
Parse XML contents. More... | |
void | saveDOM_Tree (std::string &outFilename) |
Save DOM tree to xml file. More... | |
void | setComponentLinks (std::shared_ptr< Geometry::Instrument > &instrument, Poco::XML::Element *pRootElem, Kernel::ProgressBase *progress=nullptr, const std::string &requestedDate=std::string()) |
Add/overwrite any parameters specified in instrument with param values specified in <component-link> XML elements. More... | |
~InstrumentDefinitionParser ()=default | |
Static Public Member Functions | |
static std::string | getNameOfLocationElement (const Poco::XML::Element *pElem, const Poco::XML::Element *pCompElem) |
get name of location element More... | |
static Poco::XML::Element * | getParentComponent (const Poco::XML::Element *pLocElem) |
Get parent component element of location element. More... | |
Private Member Functions | |
void | adjust (Poco::XML::Element *pElem, std::map< std::string, bool > &isTypeAssembly, std::map< std::string, Poco::XML::Element * > &getTypeElement) |
Takes as input a <type> element containing a <combine-components-into-one-shape>, and adjust the <type> element by replacing its containing <component> elements with <cuboid>'s (note for now this will only work for <cuboid>'s and when necessary this can be extended). More... | |
void | adjustTypesContainingCombineComponentsElement (ShapeFactory &shapeCreator, const std::string &filename, const std::vector< Poco::XML::Element * > &typeElems, size_t numberOfTypes) |
Adjust each type which contains a <combine-components-into-one-shape> element. More... | |
void | appendAssembly (Geometry::ICompAssembly *parent, const Poco::XML::Element *pLocElem, const Poco::XML::Element *pCompElem, IdList &idList) |
Add XML element to parent assuming the element contains other component elements. More... | |
void | appendLeaf (Geometry::ICompAssembly *parent, const Poco::XML::Element *pLocElem, const Poco::XML::Element *pCompElem, IdList &idList) |
Add XML element to parent assuming the element contains no other component elements. More... | |
void | appendLocations (Geometry::ICompAssembly *parent, const Poco::XML::Element *pLocElems, const Poco::XML::Element *pCompElem, IdList &idList) |
Append <locations> in a locations element. More... | |
void | applyCache (const IDFObject_const_sptr &cacheToApply) |
Reads from a cache file. More... | |
double | attrToDouble (const Poco::XML::Element *pElem, const std::string &name) |
return 0 if the attribute doesn't exist. More... | |
std::vector< std::string > | buildExcludeList (const Poco::XML::Element *const location) |
void | checkComponentContainsLocationElement (Poco::XML::Element *pElem, const std::string &filename) const |
Check component has a <location> or <locations> element. More... | |
void | checkIdListExistsAndDefinesEnoughIDs (const IdList &idList, Poco::XML::Element *pElem, const std::string &filename) const |
Check IdList. More... | |
void | collateTypeInformation (const std::string &filename, const std::vector< Poco::XML::Element * > &typeElems, ShapeFactory &shapeCreator) |
Collect some information about types for later use. More... | |
Poco::AutoPtr< Poco::XML::Document > | convertLocationsElement (const Poco::XML::Element *pElem) |
Take as input a <locations> element. More... | |
void | createDetectorOrMonitor (Geometry::ICompAssembly *parent, const Poco::XML::Element *pLocElem, const Poco::XML::Element *pCompElem, const std::string &filename, IdList &idList, const std::string &category) |
void | createGridDetector (Geometry::ICompAssembly *parent, const Poco::XML::Element *pLocElem, const Poco::XML::Element *pCompElem, const std::string &filename, const Poco::XML::Element *pType) |
void | createNeutronicInstrument () |
If appropriate, creates a second instrument containing neutronic detector positions. More... | |
void | createRectangularDetector (Geometry::ICompAssembly *parent, const Poco::XML::Element *pLocElem, const Poco::XML::Element *pCompElem, const std::string &filename, const Poco::XML::Element *pType) |
void | createShapeIfTypeIsNotAnAssembly (Mantid::Geometry::ShapeFactory &shapeCreator, size_t iType, Poco::XML::Element *pTypeElem, const std::string &typeName) |
Record type as an assembly if it contains a component, otherwise create a shape for it. More... | |
void | createStructuredDetector (Geometry::ICompAssembly *parent, const Poco::XML::Element *pLocElem, const Poco::XML::Element *pCompElem, const std::string &filename, const Poco::XML::Element *pType) |
void | createVectorOfElementsContainingAParameterElement (Poco::XML::Element *pRootElem) |
Create a vector of elements which contain a <parameter> More... | |
Poco::AutoPtr< Poco::XML::Document > | getDocument () |
lazy loads the document and returns a pointer More... | |
Kernel::V3D | getRelativeTranslation (const Geometry::IComponent *comp, const Poco::XML::Element *pElem, const double angleConvertConst, const bool deltaOffsets=false) |
Calculate the position of comp relative to its parent from info provided by <location> element. More... | |
std::string | getShapeCoorSysComp (Geometry::ICompAssembly *parent, Poco::XML::Element *pLocElem, std::map< std::string, Poco::XML::Element * > &getTypeElement, Geometry::ICompAssembly *&endAssembly) |
This method returns the parent appended which its child components and also name of type of the last child component. More... | |
Poco::XML::Element * | getShapeElement (const Poco::XML::Element *pElem, const std::string &name) |
Return a subelement of an XML element. More... | |
void | getTypeAndComponentPointers (const Poco::XML::Element *pRootElem, std::vector< Poco::XML::Element * > &typeElems, std::vector< Poco::XML::Element * > &compElems) const |
Populate vectors of pointers to type and component xml elements. More... | |
void | initialise (const std::string &filename, const std::string &instName, const std::string &xmlText, const std::string &vtpFilename) |
shared Constructor logic More... | |
bool | isAssembly (const std::string &) const |
Return true if assembly, false if not assembly and throws exception if string not in assembly. More... | |
void | makeXYplaneFaceComponent (Geometry::IComponent *&in, const Geometry::ObjComponent *facing) |
Make the shape defined in 1st argument face the component in the second argument. More... | |
void | makeXYplaneFaceComponent (Geometry::IComponent *&in, const Kernel::V3D &facingPoint) |
Make the shape defined in 1st argument face the position in the second argument. More... | |
Kernel::V3D | parseFacingElementToV3D (Poco::XML::Element *pElem) |
Parse position of facing element to V3D. More... | |
void | parseLocationsForEachTopLevelComponent (Kernel::ProgressBase *progressReporter, const std::string &filename, const std::vector< Poco::XML::Element * > &compElems) |
Aggregate locations and IDs for components. More... | |
Kernel::V3D | parsePosition (Poco::XML::Element *pElem) |
Get position coordinates from XML element. More... | |
void | populateIdList (Poco::XML::Element *pE, IdList &idList) |
Method for populating IdList. More... | |
void | readDefaults (Poco::XML::Element *defaults) |
Reads the contents of the <defaults> element to set member variables,. More... | |
void | setFacing (Geometry::IComponent *comp, const Poco::XML::Element *pElem) |
Set facing of comp as specified in XML facing element. More... | |
void | setLocation (Geometry::IComponent *comp, const Poco::XML::Element *pElem, const double angleConvertConst, const bool deltaOffsets=false) |
Set location (position) of comp as specified in XML location element. More... | |
void | setLogfile (const Geometry::IComponent *comp, const Poco::XML::Element *pElem, InstrumentParameterCache &logfileCache, const std::string &requestedDate=std::string()) |
Set parameter/logfile info (if any) associated with component. More... | |
CachingOption | setupGeometryCache () |
Reads in or creates the geometry cache ('vtp') file. More... | |
void | setValidityRange (const Poco::XML::Element *pRootElem) |
Check the validity range and add it to the instrument object. More... | |
void | throwIfTypeNameNotUnique (const std::string &filename, const std::string &typeName) const |
Throw exception if type name is not unique in the IDF. More... | |
std::string | translateRotateXMLcuboid (Geometry::ICompAssembly *comp, const Poco::XML::Element *cuboidEle, const std::string &cuboidName) |
Returns a translated and rotated <cuboid> element. More... | |
std::string | translateRotateXMLcuboid (Geometry::ICompAssembly *comp, const std::string &cuboidXML, const std::string &cuboidName) |
Returns a translated and rotated <cuboid> element. More... | |
CachingOption | writeAndApplyCache (IDFObject_const_sptr firstChoiceCache, IDFObject_const_sptr fallBackCache) |
Write out a cache file. More... | |
Private Attributes | |
std::map< std::string, Poco::XML::Element * > | getTypeElement |
map which holds names of types and pointers to these type for fast retrieval in code More... | |
std::map< std::string, bool > | isTypeAssembly |
map which holds names of types and whether or not they are categorized as being assemblies, which means whether the type element contains component elements More... | |
double | m_angleConvertConst |
when this const equals 1 it means that angle=degree (default) is set in IDF otherwise if this const equals 180/pi it means that angle=radian is set in IDF More... | |
IDFObject_const_sptr | m_cacheFile |
Input vtp file. More... | |
CachingOption | m_cachingOption |
Caching applied. More... | |
Kernel::V3D | m_defaultFacing |
Hold default facing position. More... | |
bool | m_deltaOffsets |
Flag to indicate whether offsets given in spherical coordinates are to be added to the current position (true) or are a vector from the current position (false, default) More... | |
std::vector< Geometry::ObjComponent * > | m_facingComponent |
Container to hold all detectors and monitors added to the instrument. More... | |
std::vector< Poco::XML::Element * > | m_hasParameterElement |
Holds all the xml elements that have a <parameter> child element. More... | |
bool | m_hasParameterElement_beenSet |
has m_hasParameterElement been set - used when public method setComponentLinks is used More... | |
bool | m_haveDefaultFacing |
True if defaults->components-are-facing is set in instrument def. file. More... | |
bool | m_indirectPositions |
Flag to indicate whether IDF contains physical & neutronic positions. More... | |
std::string | m_instName |
Name of the instrument. More... | |
std::shared_ptr< Geometry::Instrument > | m_instrument |
For convenience added pointer to instrument here. More... | |
std::map< Geometry::IComponent *, Poco::XML::Element * > | m_neutronicPos |
A map containing the neutronic position for each detector. More... | |
Poco::AutoPtr< Poco::XML::Document > | m_pDoc |
XML document is lazy loaded. More... | |
std::map< const Geometry::IComponent *, SphVec > | m_tempPosHolder |
Map to store positions of parent components in spherical coordinates. More... | |
IDFObject_const_sptr | m_xmlFile |
Input xml file. More... | |
std::map< std::string, std::shared_ptr< Geometry::IObject > > | mapTypeNameToShape |
map which maps the type name to a shared pointer to a geometric shape More... | |
Creates an instrument data from a XML instrument description file.
Definition at line 43 of file InstrumentDefinitionParser.h.
Caching.
Enumerator | |
---|---|
NoneApplied | |
ReadGeomCache | |
ReadFallBack | |
WroteGeomCache | |
WroteCacheTemp |
Definition at line 52 of file InstrumentDefinitionParser.h.
Mantid::Geometry::InstrumentDefinitionParser::InstrumentDefinitionParser | ( | ) |
Default Constructor - not very functional in this state.
Definition at line 65 of file InstrumentDefinitionParser.cpp.
References initialise().
Mantid::Geometry::InstrumentDefinitionParser::InstrumentDefinitionParser | ( | const std::string & | filename, |
const std::string & | instName, | ||
const std::string & | xmlText | ||
) |
Constructor.
filename | :: IDF .xml path (full). This is needed mostly to find the instrument geometry cache. |
instName | :: name of the instrument |
xmlText | :: XML contents of IDF |
Definition at line 78 of file InstrumentDefinitionParser.cpp.
References initialise().
Mantid::Geometry::InstrumentDefinitionParser::InstrumentDefinitionParser | ( | const IDFObject_const_sptr & | xmlFile, |
const IDFObject_const_sptr & | expectedCacheFile, | ||
const std::string & | instName, | ||
const std::string & | xmlText | ||
) |
Construct the XML parser based on an IDF xml and cached vtp file objects.
xmlFile | :: The xml file, here wrapped in a IDFObject |
expectedCacheFile | :: Expected vtp cache file |
instName | :: Instrument name |
xmlText | :: XML contents of IDF |
Definition at line 94 of file InstrumentDefinitionParser.cpp.
References initialise(), and m_cacheFile.
|
default |
|
private |
Takes as input a <type> element containing a <combine-components-into-one-shape>, and adjust the <type> element by replacing its containing <component> elements with <cuboid>'s (note for now this will only work for <cuboid>'s and when necessary this can be extended).
pElem | :: Poco::XML <type> element that we want to adjust |
isTypeAssembly | [in] :: tell whether any other type, but the special one treated here, is assembly or not |
getTypeElement | [in] :: contain pointers to all types but the onces treated here |
InstrumentDefinitionError | Thrown if issues with the content of XML instrument file |
Definition at line 2615 of file InstrumentDefinitionParser.cpp.
References getParentComponent(), getShapeCoorSysComp(), getTypeElement, isTypeAssembly, m_angleConvertConst, setLocation(), translateRotateXMLcuboid(), and UNUSED_ARG.
Referenced by adjustTypesContainingCombineComponentsElement().
|
private |
Adjust each type which contains a <combine-components-into-one-shape> element.
"Adjust" (see adjust method) each type which contains a <combine-components-into-one-shape> element
shapeCreator | :: Factory for creating a shape |
filename | :: Name of the IDF file |
typeElems | :: Vector of pointers to type elements |
numberOfTypes | :: Total number of type elements |
Definition at line 455 of file InstrumentDefinitionParser.cpp.
References adjust(), Mantid::Geometry::ShapeFactory::createShape(), getTypeElement, isTypeAssembly, mapTypeNameToShape, and throwIfTypeNameNotUnique().
Referenced by collateTypeInformation().
|
private |
Add XML element to parent assuming the element contains other component elements.
Assumes second argument is a XML location element and its parent is a component element which is assigned to be an assembly.
This method appends the parent component element of the location element to the CompAssembly passed as the 1st arg. Note this method may call itself, i.e. it may act recursively.
parent | :: CompAssembly to append new component to |
pLocElem | :: Poco::XML element that points to a location element in an instrument description XML file, which optionally may be detached (meaning it is not required to be part of the DOM tree of the IDF) |
pCompElem | :: The Poco::XML <component> element that contains the <location> element |
idList | :: The current IDList |
Definition at line 1076 of file InstrumentDefinitionParser.cpp.
References appendAssembly(), appendLeaf(), appendLocations(), buildExcludeList(), Mantid::Geometry::g_log, getNameOfLocationElement(), getParentComponent(), getTypeElement, Mantid::Geometry::InstrumentDefinitionParser::IdList::idname, isAssembly(), m_angleConvertConst, m_deltaOffsets, m_indirectPositions, m_instrument, m_neutronicPos, m_xmlFile, mapTypeNameToShape, obj, populateIdList(), Mantid::Geometry::InstrumentDefinitionParser::IdList::reset(), setFacing(), setLocation(), setLogfile(), and Mantid::Kernel::Logger::warning().
Referenced by appendAssembly(), appendLocations(), and parseLocationsForEachTopLevelComponent().
|
private |
Add XML element to parent assuming the element contains no other component elements.
Assumes second argument is pointing to a leaf, which here means the location element (indirectly representing a component element) that contains no sub-components.
This component is appended to the parent (1st argument).
parent | :: CompAssembly to append component to |
pLocElem | :: Poco::XML element that points to the element in the XML doc we want to add, which optionally may be detached (meaning it is not required to be part of the DOM tree of the IDF) |
pCompElem | :: The Poco::XML <component> element that contains the <location> element, which may optionally be detached from the DOM tree also |
idList | :: The current IDList |
InstrumentDefinitionError | Thrown if issues with the content of XML instrument file |
Definition at line 1645 of file InstrumentDefinitionParser.cpp.
References Mantid::Geometry::ICompAssembly::add(), Mantid::Geometry::GridDetector::compareName(), Mantid::Geometry::RectangularDetector::compareName(), Mantid::Geometry::StructuredDetector::compareName(), createDetectorOrMonitor(), createGridDetector(), createRectangularDetector(), createStructuredDetector(), getNameOfLocationElement(), getTypeElement, Mantid::Geometry::InstrumentDefinitionParser::IdList::idname, m_angleConvertConst, m_deltaOffsets, m_instrument, m_xmlFile, mapTypeNameToShape, populateIdList(), Mantid::Geometry::InstrumentDefinitionParser::IdList::reset(), setFacing(), setLocation(), and setLogfile().
Referenced by appendAssembly(), appendLocations(), and parseLocationsForEachTopLevelComponent().
|
private |
Append <locations> in a locations element.
Assumes second argument is a XML location element and its parent is a component element which is assigned to be an assembly.
This method appends the parent component element of the location element to the CompAssembly passed as the 1st arg. Note this method may call itself, i.e. it may act recursively.
parent | :: CompAssembly to append new component to |
pLocElems | :: Poco::XML element that points to a locations element in an instrument description XML file, which optionally may be detached (meaning it is not required to be part of the DOM tree of the IDF) |
pCompElem | :: The Poco::XML <component> element that contains the <locations> element |
idList | :: The current IDList |
Definition at line 552 of file InstrumentDefinitionParser.cpp.
References appendAssembly(), appendLeaf(), convertLocationsElement(), and isAssembly().
Referenced by appendAssembly(), and parseLocationsForEachTopLevelComponent().
|
private |
Reads from a cache file.
Apply the cache.
cacheToApply | : Cache file object to use the the geometries. |
Definition at line 2472 of file InstrumentDefinitionParser.cpp.
References Mantid::Geometry::g_log, Mantid::Kernel::Logger::information(), and mapTypeNameToShape.
Referenced by setupGeometryCache().
|
private |
return 0 if the attribute doesn't exist.
This is to follow the behavior of atof which always returns 0 if there is a problem.
Definition at line 600 of file InstrumentDefinitionParser.cpp.
References Mantid::Geometry::g_log, value, and Mantid::Kernel::Logger::warning().
Referenced by createGridDetector(), createRectangularDetector(), createStructuredDetector(), getRelativeTranslation(), parseFacingElementToV3D(), parsePosition(), setFacing(), setLocation(), and setLogfile().
|
private |
Definition at line 1046 of file InstrumentDefinitionParser.cpp.
Referenced by appendAssembly().
|
private |
Check component has a <location> or <locations> element.
Component must contain a <location> or <locations> Throw an exception if it does not.
pElem | :: Element with the idlist |
filename | :: Name of the IDF, for exception message |
Definition at line 372 of file InstrumentDefinitionParser.cpp.
References Mantid::Kernel::Logger::error(), and Mantid::Geometry::g_log.
Referenced by parseLocationsForEachTopLevelComponent().
|
private |
Check IdList.
Check that the required IdList exists in the IDF and defines a sufficient number of IDs.
idList | :: The IdList |
pElem | :: Element with the idlist |
filename | :: Name of the IDF, for exception message |
Definition at line 398 of file InstrumentDefinitionParser.cpp.
References Mantid::Geometry::InstrumentDefinitionParser::IdList::counted, Mantid::Kernel::Logger::error(), Mantid::Geometry::g_log, and Mantid::Geometry::InstrumentDefinitionParser::IdList::vec.
Referenced by parseLocationsForEachTopLevelComponent().
|
private |
Collect some information about types for later use.
Collect some information about types for later use including:
filename | :: Name of the IDF, for exception message |
typeElems | :: Vector of pointers to type elements |
shapeCreator | :: Factory for creating a shape |
Definition at line 291 of file InstrumentDefinitionParser.cpp.
References adjustTypesContainingCombineComponentsElement(), createShapeIfTypeIsNotAnAssembly(), getTypeElement, and throwIfTypeNameNotUnique().
Referenced by parseXML().
|
private |
Take as input a <locations> element.
Such an element is a short-hand notation for a sequence of <location> elements. This method return this sequence as a xml string
Such an element is a short-hand notation for a sequence of <location> elements. This method return this sequence as a xml string
pElem | Input <locations> element |
InstrumentDefinitionError | Thrown if issues with the content of XML instrument file |
Definition at line 2832 of file InstrumentDefinitionParser.cpp.
References n, Mantid::Kernel::Strings::strip(), and std::to_string().
Referenced by appendLocations().
|
private |
Definition at line 1210 of file InstrumentDefinitionParser.cpp.
References Mantid::Geometry::ICompAssembly::add(), Mantid::Geometry::InstrumentDefinitionParser::IdList::counted, Mantid::Kernel::Logger::error(), Mantid::Geometry::g_log, Mantid::Geometry::Detector::getID(), getNameOfLocationElement(), Mantid::Geometry::InstrumentDefinitionParser::IdList::idname, m_angleConvertConst, m_deltaOffsets, m_facingComponent, m_indirectPositions, m_instrument, m_neutronicPos, mapTypeNameToShape, setFacing(), setLocation(), setLogfile(), Mantid::Geometry::InstrumentDefinitionParser::IdList::vec, and Mantid::Kernel::Logger::warning().
Referenced by appendLeaf().
|
private |
Definition at line 1298 of file InstrumentDefinitionParser.cpp.
References attrToDouble(), getNameOfLocationElement(), m_angleConvertConst, m_defaultFacing, m_deltaOffsets, m_haveDefaultFacing, m_instrument, makeXYplaneFaceComponent(), mapTypeNameToShape, setFacing(), setLocation(), setLogfile(), Mantid::Geometry::x, Mantid::Geometry::y, and Mantid::Geometry::z.
Referenced by appendLeaf().
|
private |
If appropriate, creates a second instrument containing neutronic detector positions.
Definition at line 2560 of file InstrumentDefinitionParser.cpp.
References m_angleConvertConst, m_deltaOffsets, m_instrument, m_neutronicPos, mapTypeNameToShape, setLocation(), and Mantid::Geometry::ObjComponent::setShape().
Referenced by parseXML().
|
private |
Definition at line 1400 of file InstrumentDefinitionParser.cpp.
References attrToDouble(), getNameOfLocationElement(), m_angleConvertConst, m_defaultFacing, m_deltaOffsets, m_haveDefaultFacing, m_instrument, makeXYplaneFaceComponent(), mapTypeNameToShape, setFacing(), setLocation(), setLogfile(), Mantid::Geometry::x, and Mantid::Geometry::y.
Referenced by appendLeaf().
|
private |
Record type as an assembly if it contains a component, otherwise create a shape for it.
If type does not contain a component element then it is not an assembly and a shape can be created.
shapeCreator | :: Factory for creating a shape |
iType | :: The i-th type |
pTypeElem | :: Pointer to the type element |
typeName | :: Name of the type |
Definition at line 495 of file InstrumentDefinitionParser.cpp.
References Mantid::Geometry::ShapeFactory::createShape(), isTypeAssembly, and mapTypeNameToShape.
Referenced by collateTypeInformation().
|
private |
Definition at line 1492 of file InstrumentDefinitionParser.cpp.
References attrToDouble(), Mantid::Geometry::StructuredDetector::compareName(), getNameOfLocationElement(), m_angleConvertConst, m_defaultFacing, m_deltaOffsets, m_haveDefaultFacing, m_instrument, makeXYplaneFaceComponent(), mapTypeNameToShape, setLocation(), setLogfile(), Mantid::Geometry::x, and Mantid::Geometry::y.
Referenced by appendLeaf().
|
private |
Create a vector of elements which contain a <parameter>
pRootElem | :: Pointer to the root element |
Definition at line 425 of file InstrumentDefinitionParser.cpp.
References m_hasParameterElement, and m_hasParameterElement_beenSet.
Referenced by parseXML().
const std::string Mantid::Geometry::InstrumentDefinitionParser::createVTPFileName | ( | ) |
creates a vtp filename from a given xml filename
Generates a vtp filename from a xml filename.
Definition at line 2943 of file InstrumentDefinitionParser.cpp.
References getMangledName(), and Mantid::Kernel::SingletonHolder< T >::Instance().
Referenced by initialise().
V3D Mantid::Geometry::InstrumentDefinitionParser::getAbsolutPositionInCompCoorSys | ( | Geometry::ICompAssembly * | comp, |
Kernel::V3D | pos | ||
) |
return absolute position of point which is set relative to the coordinate system of the input component
comp | Reference coordinate system |
pos | A position relative to the coord. sys. of comp |
Definition at line 2788 of file InstrumentDefinitionParser.cpp.
References Mantid::Geometry::ICompAssembly::add(), Mantid::Geometry::Component::getPos(), and Mantid::Geometry::Component::setPos().
Referenced by translateRotateXMLcuboid().
InstrumentDefinitionParser::CachingOption Mantid::Geometry::InstrumentDefinitionParser::getAppliedCachingOption | ( | ) | const |
Getter the the applied caching option.
Getter for the applied caching option.
Definition at line 2556 of file InstrumentDefinitionParser.cpp.
References m_cachingOption.
|
private |
lazy loads the document and returns a pointer
Lazy loads the document and returns a autopointer.
Definition at line 172 of file InstrumentDefinitionParser.cpp.
References m_instrument, and m_pDoc.
Referenced by parseXML(), and saveDOM_Tree().
std::string Mantid::Geometry::InstrumentDefinitionParser::getMangledName | ( | ) |
Handle used in the singleton constructor for instrument file should append the value file sha-1 checksum to determine if it is already in memory so that changes to the instrument file will cause file to be reloaded.
Definition at line 152 of file InstrumentDefinitionParser.cpp.
References m_instName, m_instrument, m_xmlFile, and Mantid::Kernel::ChecksumHelper::sha1FromString().
Referenced by createVTPFileName(), Mantid::DataHandling::LoadInstrument::exec(), Mantid::DataHandling::LoadMcStas::readEventData(), MantidQt::MantidWidgets::SlitCalculator::setInstrument(), Mantid::API::ExperimentInfo::setInstumentFromXML(), and setupGeometryCache().
|
static |
get name of location element
Get name of a location element.
It will return the value of the attribute 'name', or the parent's name attribute, or the parent's type, if all else fails.
pElem | :: Poco::XML element that points to a <location> element, which optionally may be detached (meaning it is not required to be part of the DOM tree of the IDF) |
pCompElem | :: The Poco::XML <component> element that contain the location element, which may optionally be detached from the DOM tree also |
Definition at line 871 of file InstrumentDefinitionParser.cpp.
Referenced by appendAssembly(), appendLeaf(), createDetectorOrMonitor(), createGridDetector(), createRectangularDetector(), createStructuredDetector(), and getShapeCoorSysComp().
|
static |
Get parent component element of location element.
Get parent <component> element of <location> element.
pLocElem | :: Poco::XML element that points a location element in the XML doc |
logic_error | Thrown if argument is not a child of component element |
Definition at line 824 of file InstrumentDefinitionParser.cpp.
References Mantid::Kernel::Logger::error(), and Mantid::Geometry::g_log.
Referenced by adjust(), appendAssembly(), and getShapeCoorSysComp().
|
private |
Calculate the position of comp relative to its parent from info provided by <location> element.
comp | :: To set position/location off |
pElem | :: Poco::XML element that points a <location> element, which optionally may be detached (meaning it is not required to be part of the DOM tree of the IDF) |
angleConvertConst | :: constant for converting deg to rad |
deltaOffsets | :: radial position offsets |
Definition at line 736 of file InstrumentDefinitionParser.cpp.
References attrToDouble(), Mantid::Geometry::IComponent::getParent(), m_tempPosHolder, Mantid::Kernel::V3D::spherical(), tmp, Mantid::Geometry::x, Mantid::Geometry::y, and Mantid::Geometry::z.
Referenced by setLocation().
|
private |
This method returns the parent appended which its child components and also name of type of the last child component.
Adds component with coordinate system as defined by the input <location> element to the input parent component.
Nested <location> elements are allowed and this method is recursive. As this method is running recursively it will eventually return a leaf component (in endAssembly) and the name of the <type> of this leaf
parent | :: CompAssembly Parent component |
pLocElem | :: Poco::XML element that points to a location element |
getTypeElement | :: contain pointers to all <type>s |
endAssembly | :: Output child component, which coor. sys. modified according to pLocElem |
InstrumentDefinitionError | Thrown if issues with the content of XML instrument file |
Definition at line 3032 of file InstrumentDefinitionParser.cpp.
References getNameOfLocationElement(), getParentComponent(), getShapeCoorSysComp(), getTypeElement, m_angleConvertConst, and setLocation().
Referenced by adjust(), and getShapeCoorSysComp().
|
private |
Return a subelement of an XML element.
Return a subelement of an XML element, but also checks that there exist exactly one entry of this subelement.
pElem | :: XML from instrument def. file |
name | :: Name of subelement |
std::invalid_argument | Thrown if issues with XML string |
Definition at line 2965 of file InstrumentDefinitionParser.cpp.
Referenced by translateRotateXMLcuboid().
|
private |
Populate vectors of pointers to type and component xml elements.
Create vectors of pointers to <type>s and <component>s".
pRootElem | :: Pointer to the root element |
typeElems | :: Reference to type vector to populate |
compElems | :: Reference to component vector to populate |
Definition at line 523 of file InstrumentDefinitionParser.cpp.
Referenced by parseXML().
|
private |
shared Constructor logic
Initialise method used in Constructor.
filename | :: IDF .xml path (full). This is needed mostly to find the instrument geometry cache. |
instName | :: name of the instrument |
xmlText | :: XML contents of IDF |
vtpFilename | :: the path to the vtp file if you want to override the default |
Definition at line 114 of file InstrumentDefinitionParser.cpp.
References createVTPFileName(), m_cacheFile, m_instName, m_instrument, and m_xmlFile.
Referenced by InstrumentDefinitionParser().
|
private |
Return true if assembly, false if not assembly and throws exception if string not in assembly.
Returns True if the (string) type given is an assembly.
type | :: name of the type of a component in XML instrument definition |
InstrumentDefinitionError | Thrown if type not defined in XML definition |
Definition at line 1868 of file InstrumentDefinitionParser.cpp.
References isTypeAssembly, and m_xmlFile.
Referenced by appendAssembly(), appendLocations(), and parseLocationsForEachTopLevelComponent().
|
private |
Make the shape defined in 1st argument face the component in the second argument.
Make the shape defined in 1st argument face the component in the second argument, by rotating the z-axis of the component passed in 1st argument so that it points in the direction: from the component as specified 2nd argument to the component as specified in 1st argument.
in | :: Component to be rotated |
facing | :: Object to face |
Definition at line 1890 of file InstrumentDefinitionParser.cpp.
References Mantid::Geometry::Component::getPos(), and makeXYplaneFaceComponent().
Referenced by createGridDetector(), createRectangularDetector(), createStructuredDetector(), makeXYplaneFaceComponent(), and setFacing().
|
private |
Make the shape defined in 1st argument face the position in the second argument.
Make the shape defined in 1st argument face the position in the second argument, by rotating the z-axis of the component passed in 1st argument so that it points in the direction: from the position (as specified 2nd argument) to the component (1st argument).
in | :: Component to be rotated |
facingPoint | :: position to face |
Definition at line 1904 of file InstrumentDefinitionParser.cpp.
References Mantid::Kernel::V3D::angle(), Mantid::Kernel::V3D::cross_prod(), Mantid::Geometry::IComponent::getPos(), Mantid::Geometry::IComponent::getRotation(), Mantid::Kernel::Quat::inverse(), Mantid::Kernel::V3D::norm(), Mantid::Kernel::normalize(), Mantid::Geometry::IComponent::rotate(), Mantid::Kernel::Quat::rotate(), and Mantid::Geometry::z.
|
private |
Parse position of facing element to V3D.
pElem | :: Facing type element to parse |
Definition at line 1946 of file InstrumentDefinitionParser.cpp.
References attrToDouble(), m_angleConvertConst, Mantid::Kernel::V3D::spherical(), Mantid::Geometry::x, Mantid::Geometry::y, and Mantid::Geometry::z.
Referenced by readDefaults(), and setFacing().
|
private |
Aggregate locations and IDs for components.
progressReporter | :: A progress reporter |
filename | :: Name of the IDF, for exception message |
compElems | :: Vector of pointers for component elements |
Definition at line 322 of file InstrumentDefinitionParser.cpp.
References appendAssembly(), appendLeaf(), appendLocations(), checkComponentContainsLocationElement(), checkIdListExistsAndDefinesEnoughIDs(), isAssembly(), m_instrument, Mantid::Kernel::ProgressBase::report(), Mantid::Geometry::InstrumentDefinitionParser::IdList::reset(), and Mantid::Kernel::ProgressBase::resetNumSteps().
Referenced by parseXML().
|
private |
Get position coordinates from XML element.
pElem | :: XML element whose attributes contain position coordinates |
Definition at line 2983 of file InstrumentDefinitionParser.cpp.
References attrToDouble(), Mantid::Kernel::V3D::spherical(), Mantid::Geometry::x, Mantid::Geometry::y, and Mantid::Geometry::z.
Referenced by translateRotateXMLcuboid().
Instrument_sptr Mantid::Geometry::InstrumentDefinitionParser::parseXML | ( | Kernel::ProgressBase * | progressReporter | ) |
Parse XML contents.
Fully parse the IDF XML contents and returns the instrument thus created.
progressReporter | :: Optional Progress reporter object. If NULL, no progress reporting. |
Definition at line 218 of file InstrumentDefinitionParser.cpp.
References collateTypeInformation(), createNeutronicInstrument(), createVectorOfElementsContainingAParameterElement(), Mantid::Kernel::Logger::error(), Mantid::Geometry::g_log, getDocument(), getTypeAndComponentPointers(), m_cachingOption, m_indirectPositions, m_instrument, m_tempPosHolder, m_xmlFile, parseLocationsForEachTopLevelComponent(), readDefaults(), setComponentLinks(), setLogfile(), setupGeometryCache(), and setValidityRange().
Referenced by Mantid::DataObjects::MDEventsTestHelper::createDiffractionEventWorkspace(), Mantid::DataHandling::LoadInstrument::exec(), Mantid::DataHandling::LoadMcStas::readEventData(), MantidQt::MantidWidgets::SlitCalculator::setInstrument(), and Mantid::API::ExperimentInfo::setInstumentFromXML().
|
private |
Method for populating IdList.
pE | :: Poco::XML element that points to an <idlist> |
idList | :: The structure to populate with detector ID numbers |
logic_error | Thrown if argument is not a child of component element |
InstrumentDefinitionError | Thrown if issues with the content of XML instrument file |
Definition at line 1738 of file InstrumentDefinitionParser.cpp.
References Mantid::Kernel::Logger::error(), Mantid::Geometry::g_log, Mantid::Geometry::InstrumentDefinitionParser::IdList::idname, m_xmlFile, and Mantid::Geometry::InstrumentDefinitionParser::IdList::vec.
Referenced by appendAssembly(), and appendLeaf().
|
private |
Reads the contents of the <defaults> element to set member variables,.
Reads the contents of the <defaults> element to set member variables, requires m_instrument to be already set.
defaults | :: points to the data read from the <defaults> element, can be null. |
Definition at line 945 of file InstrumentDefinitionParser.cpp.
References Mantid::Geometry::axisNameToAxisType(), Mantid::Geometry::Left, m_angleConvertConst, m_defaultFacing, m_deltaOffsets, m_haveDefaultFacing, m_indirectPositions, m_instrument, parseFacingElementToV3D(), and Mantid::Geometry::Right.
Referenced by parseXML().
void Mantid::Geometry::InstrumentDefinitionParser::saveDOM_Tree | ( | std::string & | outFilename | ) |
Save DOM tree to xml file.
This method was initially added for testing purpose but may be useful for other purposes. During the parsing of the DOM tree in parseXML() the tree may be modified, e.g. if <combine-components-into-one-shape> is used.
outFilename | :: Output filename |
Definition at line 589 of file InstrumentDefinitionParser.cpp.
References getDocument().
void Mantid::Geometry::InstrumentDefinitionParser::setComponentLinks | ( | std::shared_ptr< Geometry::Instrument > & | instrument, |
Poco::XML::Element * | pRootElem, | ||
Kernel::ProgressBase * | progress = nullptr , |
||
const std::string & | requestedDate = std::string() |
||
) |
Add/overwrite any parameters specified in instrument with param values specified in <component-link> XML elements.
Apply parameters that may be specified in <component-link> XML elements.
Input variable pRootElem may e.g. be the root element of an XML parameter file or the root element of a IDF
instrument | :: Instrument |
pRootElem | :: Associated Poco::XML element that may contain <component-link> elements |
progress | :: Optional progress object for reporting progress to an algorithm |
requestedDate | :: Optional Date against which to check the validity of an IPF parameter |
Definition at line 2371 of file InstrumentDefinitionParser.cpp.
References Mantid::Kernel::Logger::error(), Mantid::Geometry::g_log, Mantid::Kernel::ProgressBase::hasCancellationBeenRequested(), m_angleConvertConst, Mantid::Kernel::ProgressBase::report(), Mantid::Kernel::ProgressBase::resetNumSteps(), setLogfile(), and Mantid::Kernel::Logger::warning().
Referenced by Mantid::DataHandling::LoadParameterFile::exec(), and parseXML().
|
private |
Set facing of comp as specified in XML facing element.
Set facing of comp as specified in XML facing element (which must be sub-element of a location element).
comp | :: To set facing of |
pElem | :: Poco::XML element that points a <location> element, which optionally may be detached (meaning it is not required to be part of the DOM tree of the IDF) |
logic_error | Thrown if second argument is not a pointer to a 'location' XML element |
Definition at line 1989 of file InstrumentDefinitionParser.cpp.
References attrToDouble(), Mantid::Kernel::Logger::error(), Mantid::Geometry::g_log, m_angleConvertConst, m_defaultFacing, m_haveDefaultFacing, makeXYplaneFaceComponent(), parseFacingElementToV3D(), and Mantid::Geometry::IComponent::rotate().
Referenced by appendAssembly(), appendLeaf(), createDetectorOrMonitor(), createGridDetector(), and createRectangularDetector().
|
private |
Set location (position) of comp as specified in XML location element.
comp | :: To set position/location off |
pElem | :: Poco::XML element that points a <location> element, which optionally may be detached (meaning it is not required to be part of the DOM tree of the IDF) |
angleConvertConst | :: constant for converting deg to rad |
deltaOffsets | :: radial position offsets |
logic_error | Thrown if second argument is not a pointer to a 'location' XML element |
Definition at line 631 of file InstrumentDefinitionParser.cpp.
References attrToDouble(), Mantid::Geometry::CompAssembly::getPos(), getRelativeTranslation(), Mantid::Geometry::IComponent::getRotation(), Mantid::Geometry::IComponent::rotate(), Mantid::Geometry::Component::setParent(), Mantid::Geometry::Component::setPos(), Mantid::Geometry::IComponent::setPos(), Mantid::Geometry::Component::setRot(), and Mantid::Geometry::IComponent::translate().
Referenced by adjust(), appendAssembly(), appendLeaf(), createDetectorOrMonitor(), createGridDetector(), createNeutronicInstrument(), createRectangularDetector(), createStructuredDetector(), and getShapeCoorSysComp().
|
private |
Set parameter/logfile info (if any) associated with component.
comp | :: Some component |
pElem | :: Poco::XML element that may hold <parameter> elements |
logfileCache | :: Cache to add information about parameter to |
requestedDate | :: Reference date to check the validity of the parameter against |
InstrumentDefinitionError | Thrown if issues with the content of XML instrument file |
Definition at line 2044 of file InstrumentDefinitionParser.cpp.
References attrToDouble(), Mantid::Kernel::Logger::error(), Mantid::Geometry::g_log, Mantid::Geometry::IComponent::getName(), index, Mantid::Kernel::SingletonHolder< T >::Instance(), m_angleConvertConst, m_hasParameterElement, m_hasParameterElement_beenSet, m_xmlFile, value, Mantid::Kernel::Logger::warning(), Mantid::Geometry::x, and Mantid::Geometry::y.
Referenced by appendAssembly(), appendLeaf(), createDetectorOrMonitor(), createGridDetector(), createRectangularDetector(), createStructuredDetector(), parseXML(), and setComponentLinks().
|
private |
Reads in or creates the geometry cache ('vtp') file.
Definition at line 2532 of file InstrumentDefinitionParser.cpp.
References applyCache(), getMangledName(), Mantid::Kernel::SingletonHolder< T >::Instance(), m_cacheFile, NoneApplied, ReadFallBack, ReadGeomCache, and writeAndApplyCache().
Referenced by parseXML().
|
private |
Check the validity range and add it to the instrument object.
Checks the validity range in the IDF and adds it to the instrument object.
pRootElem | A pointer to the root element of the instrument definition |
Definition at line 890 of file InstrumentDefinitionParser.cpp.
References Mantid::Geometry::d, m_instrument, and m_xmlFile.
Referenced by parseXML().
|
private |
Throw exception if type name is not unique in the IDF.
Type names in the IDF must be unique.
Throw an exception if this one is not.
filename | :: Filename of the IDF, for the exception message |
typeName | :: Name of the type being checked |
Definition at line 197 of file InstrumentDefinitionParser.cpp.
References Mantid::Kernel::Logger::error(), Mantid::Geometry::g_log, and getTypeElement.
Referenced by adjustTypesContainingCombineComponentsElement(), and collateTypeInformation().
|
private |
Returns a translated and rotated <cuboid> element.
Returns a translated and rotated <cuboid> element with "id" attribute equal cuboidName.
comp | coordinate system to translate and rotate cuboid to |
cuboidEle | Input <cuboid> element |
cuboidName | What the "id" attribute of the returned <coboid> will be set to |
Definition at line 2735 of file InstrumentDefinitionParser.cpp.
References getAbsolutPositionInCompCoorSys(), getShapeElement(), parsePosition(), Mantid::Kernel::V3D::X(), Mantid::Kernel::V3D::Y(), and Mantid::Kernel::V3D::Z().
Referenced by adjust(), and translateRotateXMLcuboid().
|
private |
Returns a translated and rotated <cuboid> element.
Returns a translated and rotated <cuboid> element with "id" attribute equal cuboidName.
comp | coordinate system to translate and rotate cuboid to |
cuboidXML | Input <cuboid> xml string |
cuboidName | What the "id" attribute of the returned <coboid> will be set to |
Definition at line 2807 of file InstrumentDefinitionParser.cpp.
References translateRotateXMLcuboid().
|
private |
Write out a cache file.
Write the cache file from the IDF file and apply it.
firstChoiceCache | : File location for a first choice cache. |
fallBackCache | : File location for a fallback cache if required. |
Definition at line 2493 of file InstrumentDefinitionParser.cpp.
References Mantid::Kernel::Logger::error(), Mantid::Geometry::g_log, Mantid::Kernel::Logger::information(), mapTypeNameToShape, Mantid::Kernel::Logger::notice(), WroteCacheTemp, and WroteGeomCache.
Referenced by setupGeometryCache().
|
private |
map which holds names of types and pointers to these type for fast retrieval in code
Definition at line 311 of file InstrumentDefinitionParser.h.
Referenced by adjust(), adjustTypesContainingCombineComponentsElement(), appendAssembly(), appendLeaf(), collateTypeInformation(), getShapeCoorSysComp(), and throwIfTypeNameNotUnique().
|
private |
map which holds names of types and whether or not they are categorized as being assemblies, which means whether the type element contains component elements
Definition at line 298 of file InstrumentDefinitionParser.h.
Referenced by adjust(), adjustTypesContainingCombineComponentsElement(), createShapeIfTypeIsNotAnAssembly(), and isAssembly().
|
private |
when this const equals 1 it means that angle=degree (default) is set in IDF otherwise if this const equals 180/pi it means that angle=radian is set in IDF
Definition at line 325 of file InstrumentDefinitionParser.h.
Referenced by adjust(), appendAssembly(), appendLeaf(), createDetectorOrMonitor(), createGridDetector(), createNeutronicInstrument(), createRectangularDetector(), createStructuredDetector(), getShapeCoorSysComp(), parseFacingElementToV3D(), readDefaults(), setComponentLinks(), setFacing(), and setLogfile().
|
private |
Input vtp file.
Definition at line 273 of file InstrumentDefinitionParser.h.
Referenced by initialise(), InstrumentDefinitionParser(), and setupGeometryCache().
|
private |
Caching applied.
Definition at line 350 of file InstrumentDefinitionParser.h.
Referenced by getAppliedCachingOption(), and parseXML().
|
private |
Hold default facing position.
Definition at line 308 of file InstrumentDefinitionParser.h.
Referenced by createGridDetector(), createRectangularDetector(), createStructuredDetector(), readDefaults(), and setFacing().
|
private |
Flag to indicate whether offsets given in spherical coordinates are to be added to the current position (true) or are a vector from the current position (false, default)
Definition at line 319 of file InstrumentDefinitionParser.h.
Referenced by appendAssembly(), appendLeaf(), createDetectorOrMonitor(), createGridDetector(), createNeutronicInstrument(), createRectangularDetector(), createStructuredDetector(), and readDefaults().
|
private |
Container to hold all detectors and monitors added to the instrument.
Used for 'facing' these to component specified under <defaults>. NOTE: Seems unused, ever.
Definition at line 304 of file InstrumentDefinitionParser.h.
Referenced by createDetectorOrMonitor().
|
private |
Holds all the xml elements that have a <parameter> child element.
Added purely for the purpose of computing speed and is used in setLogFile() for the purpose of quickly accessing if a component have a parameter/logfile associated with it or not
Definition at line 289 of file InstrumentDefinitionParser.h.
Referenced by createVectorOfElementsContainingAParameterElement(), and setLogfile().
|
private |
has m_hasParameterElement been set - used when public method setComponentLinks is used
Definition at line 292 of file InstrumentDefinitionParser.h.
Referenced by createVectorOfElementsContainingAParameterElement(), and setLogfile().
|
private |
True if defaults->components-are-facing is set in instrument def. file.
Definition at line 306 of file InstrumentDefinitionParser.h.
Referenced by createGridDetector(), createRectangularDetector(), createStructuredDetector(), readDefaults(), and setFacing().
|
private |
Flag to indicate whether IDF contains physical & neutronic positions.
Definition at line 327 of file InstrumentDefinitionParser.h.
Referenced by appendAssembly(), createDetectorOrMonitor(), parseXML(), and readDefaults().
|
private |
Name of the instrument.
Definition at line 276 of file InstrumentDefinitionParser.h.
Referenced by getMangledName(), and initialise().
|
private |
For convenience added pointer to instrument here.
Definition at line 314 of file InstrumentDefinitionParser.h.
Referenced by appendAssembly(), appendLeaf(), createDetectorOrMonitor(), createGridDetector(), createNeutronicInstrument(), createRectangularDetector(), createStructuredDetector(), getDocument(), getMangledName(), initialise(), parseLocationsForEachTopLevelComponent(), parseXML(), readDefaults(), and setValidityRange().
|
private |
A map containing the neutronic position for each detector.
Used when m_indirectPositions is true.
Definition at line 331 of file InstrumentDefinitionParser.h.
Referenced by appendAssembly(), createDetectorOrMonitor(), and createNeutronicInstrument().
|
private |
XML document is lazy loaded.
Definition at line 279 of file InstrumentDefinitionParser.h.
Referenced by getDocument().
|
private |
Map to store positions of parent components in spherical coordinates.
Definition at line 347 of file InstrumentDefinitionParser.h.
Referenced by getRelativeTranslation(), and parseXML().
|
private |
Input xml file.
Definition at line 270 of file InstrumentDefinitionParser.h.
Referenced by appendAssembly(), appendLeaf(), getMangledName(), initialise(), isAssembly(), parseXML(), populateIdList(), setLogfile(), and setValidityRange().
|
private |
map which maps the type name to a shared pointer to a geometric shape
Definition at line 300 of file InstrumentDefinitionParser.h.
Referenced by adjustTypesContainingCombineComponentsElement(), appendAssembly(), appendLeaf(), applyCache(), createDetectorOrMonitor(), createGridDetector(), createNeutronicInstrument(), createRectangularDetector(), createShapeIfTypeIsNotAnAssembly(), createStructuredDetector(), and writeAndApplyCache().