1 #include "gearxml/TPCParametersXML.h"
2 #include "gearimpl/TPCParametersImpl.h"
4 #include "gearxml/XMLHandler.h"
5 #include "gearxml/GearParametersXML.h"
6 #include "gearxml/PadRowLayout2DXML.h"
8 #include "gearxml/tinyxml.h"
9 #include "gear/GearMgr.h"
11 #include "gear/PadRowLayout2D.h"
22 throw ParseException (
"XML TPCParametersXML::toXML given parameter not of correct type. "
23 "Needs to be a gear::TPCParameter");
41 case PadRowLayout2D::CARTESIAN :
42 coordinateTypeElement.
SetAttribute(
"value",
"cartesian" );
break;
43 case PadRowLayout2D::POLAR :
44 coordinateTypeElement.
SetAttribute(
"value",
"polar" );
break;
46 throw ParseException(
"TPCParametersXML::toXML : Unknown coordinateType !");
56 const std::vector<TPCModule *> modules = mTPC->
getModules();
57 for ( std::vector<TPCModule *>::const_iterator moduleIter = modules.begin();
58 moduleIter < modules.end(); moduleIter++)
68 return modularTPCXML ;
83 std::string deaultString;
85 if ( typeString.empty() )
91 coordinateType = PadRowLayout2D::CARTESIAN;
94 if ( typeString==std::string(
"cartesian") )
95 coordinateType = PadRowLayout2D::CARTESIAN;
97 if ( typeString==std::string(
"polar") )
98 coordinateType = PadRowLayout2D::POLAR;
100 throw ParseException(
"TPCParametersXML::fromXML : Unknown coordinateType !");
113 std::stringstream str ;
114 str <<
"XMLParser::getChildElementValue missing element \"PadRowLayout2D\" "
115 <<
" in element <" << xmlElement->
Value() <<
"/> " ;
124 if( layoutXML == 0 ) {
126 throw ParseException(
"TPCParametersXML::fromXML: no handler for " + layoutType +
" found !" ) ;
153 while( ( modulesElement =dynamic_cast<const TiXmlElement*>(
158 int moduleIDOffset=0;
160 "moduleIDStartCount" ,
174 while( ( moduleNode = modulesElement->
IterateChildren( moduleNode ) ) != 0 )
184 if (moduleElement==0)
continue;
187 if( std::string(moduleElement->
Value()) == std::string(
"default") )
189 defaultModuleElement = moduleElement;
194 if ( std::string(moduleElement->
Value()) != std::string(
"module") )
196 std::cout <<
"GEAR::TPCParametersXML: WARNING "
197 <<
" Unknown tag " << moduleNode->
Value() <<
" in <modules> section."
204 defaultModuleElement,
206 moduleIDStartCount + moduleIDOffset++ ) );
virtual PadRowLayout2D * fromXML(const TiXmlElement *xmlElement) const =0
Creates the appropriate PadRowLayout2D subclass from the given XML element (node) ...
virtual int getCoordinateType() const =0
Returns coordinate type as an int (see PadRowLayout2D::CARTESIAN, PadRowLayout2D::POLAR) ...
virtual void setDriftVelocity(double driftVelocity)
Abstract description of a planar subdetector with pads (cells) that are positioned in rows (circular ...
std::string getOptionalXMLAttribute(const TiXmlNode *node, const std::string &name, const std::string &defaultValue)
Helper method used for parsing XML.
Proposal for an abstract interface that defines the geometry properties of a TPC like detector needed...
virtual void setTPCParameters(TPCParameters *tpcParameters)=0
Set the TPCParameters.
virtual double getDriftVelocity() const =0
The electron drift velocity in the TPC in mm/s.
const char * Value() const
The meaning of 'value' changes for the specific type of TiXmlNode.
std::string getOptionalChildElementValue(const TiXmlNode *node, const std::string &name, const std::string &defaultValue)
Helper method used for parsing XML - returns the attribute 'value' of the optional named child elemen...
virtual const std::vector< TPCModule * > & getModules() const =0
Returns vector of all modules in this TPC (endplate).
virtual TiXmlElement toXML(const TPCModule *layout) const
Creates an XML node for the given TPCModule.
virtual GearParameters * fromXML(const TiXmlElement *xmlElement, GearMgr *gearMgr=0) const
Creates the appropriate TPCParameters class from the given XML element (node)
static void setParametersFromXML(const TiXmlElement *xmlElement, GearParametersImpl *gearParams)
Static helper function that can be used by other subclass handlers to read parameters.
Abstract interface for a set of parameters that can be used to describe the geometrical properties of...
virtual void setPadLayout(PadRowLayout2D *padLayout)
virtual int getCoordinateType() const =0
The type of the row layouts coordinate system: PadRowLayout2D.CARTESIAN or PadRowLayout2D.POLAR.
static void getXMLForParameters(TiXmlElement *xmlElement, const GearParameters *gearParams)
Static helper function that can be used by other subclass handlers to create XML for parameters...
The parent class for everything in the Document Object Model.
ParseException used for parse errors, e.g.
std::string getXMLAttribute(const TiXmlNode *node, const std::string &name)
Helper method used for parsing XML.
static PadRowLayout2DXML * getHandler(const std::string &typeName)
Get handler for given type.
The element is a container class.
TiXmlNode * InsertEndChild(const TiXmlNode &addThis)
Add a new node related to this.
virtual void setReadoutFrequency(double readoutFrequency)
A Container for TPCModules which describe the geometry properties of a given TPC. ...
void SetDoubleAttribute(const char *name, double value)
Sets an attribute of name to a given value.
virtual void addModule(TPCModule *TPCModule)
Adds a Module to the vector of modules, or throws an exception.
Abstract interface for a manager class that returns the Gear classes for the relevant subdetectors...
const TiXmlNode * IterateChildren(const TiXmlNode *previous) const
An alternate way to walk the children of a node.
void SetAttribute(const char *name, const char *value)
Sets an attribute of name to a given value.
virtual double getMaxDriftLength() const =0
The maximum drift length in the TPC in mm.
virtual TPCModule * fromXML(const TiXmlElement *moduleElement, const TiXmlElement *defaultModuleElement, int tpcCoordinateType, int moduleID) const
Creates the appropriate TPCModule class from the given XML element (node)
std::string getChildElementValue(const TiXmlNode *node, const std::string &name)
Helper method used for parsing XML - returns the attribute 'value' of the named child element as doub...
virtual TiXmlElement toXML(const GearParameters &modularTPC) const
Creates an XML node for the given TPCParameters.
const TiXmlElement * FirstChildElement() const
Convenience function to get through elements.
Abstract XML handler for PadRowLayout2DXML.