1 #include "gearxml/TPCModuleXML.h"
2 #include "gearimpl/TPCModuleImpl.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"
27 TiXmlElement readoutFrequencyElement(
"readoutFrequency");
75 int tpcCoordinateType,
int moduleID)
const
80 if ( ( moduleIDElement == 0 ) && defaultModuleElement)
84 if ( moduleIDElement != 0 )
86 moduleID = atoi(
getXMLAttribute( moduleIDElement ,
"value" ).c_str() );
93 if ( ( readoutFrequencyElement == 0 ) && defaultModuleElement)
96 readoutFrequencyElement = defaultModuleElement->
FirstChildElement(
"readoutFrequency" );
98 if ( readoutFrequencyElement == 0 )
100 throw ParseException(
"TPCModuleXML: No readoutFrequency in TPCModule" ) ;
102 double readoutFrequency = atoi(
getXMLAttribute( readoutFrequencyElement ,
"value" ).c_str() );
106 if( ( padLayoutElement == 0 ) && defaultModuleElement)
111 if( padLayoutElement == 0 )
113 throw ParseException(
"TPCModuleXML: No PadRowLayout2D in TPCModule" );
116 std::string layoutType =
getXMLAttribute( padLayoutElement ,
"type" ) ;
119 if( padLayoutXML == 0 )
121 throw ParseException(
"TPCParametersXML::fromXML: no handler for " + layoutType +
" found !" ) ;
137 if ( ( offsetElement == 0 ) && defaultModuleElement)
141 if ( offsetElement != 0 )
149 if ( ( zPositionElement == 0 ) && defaultModuleElement)
154 if ( zPositionElement != 0 )
160 if ( ( angleElement == 0 ) && defaultModuleElement )
164 if ( angleElement != 0 )
166 tpcModule->setAngle ( atof(
getXMLAttribute( angleElement ,
"value" ).c_str() ) );
171 if ( ( borderWidthElement == 0 ) && defaultModuleElement)
173 borderWidthElement = defaultModuleElement->
FirstChildElement(
"enlargeActiveAreaBy" );
175 if ( borderWidthElement != 0 )
177 tpcModule->setBorderWidth ( atof(
getXMLAttribute( borderWidthElement ,
"value" ).c_str() ) );
virtual PadRowLayout2D * fromXML(const TiXmlElement *xmlElement) const =0
Creates the appropriate PadRowLayout2D subclass from the given XML element (node) ...
virtual TiXmlElement toXML(const PadRowLayout2D *layout) const =0
Creates an XML node for the given PadRowLayout2D.
void setOffset(double x_r, double y_phi)
Set the offset of the local pad plane wrt.
virtual double getZPosition() const =0
Returns the z position of the module.
Abstract description of a planar subdetector with pads (cells) that are positioned in rows (circular ...
virtual const Vector2D & getOffset() const =0
Returns the offest of Modules origin from the global origin A vector from Global (0,0) to module (0,0)
virtual TiXmlElement toXML(const TPCModule *layout) const
Creates an XML node for the given TPCModule.
static void setParametersFromXML(const TiXmlElement *xmlElement, GearParametersImpl *gearParams)
Static helper function that can be used by other subclass handlers to read parameters.
virtual const PadRowLayout2D & getLocalPadLayout() const =0
Returns a reference to the instance of the underlaying pad layout.
virtual double getReadoutFrequency() const =0
The readout frequency in Hz.
static void getXMLForParameters(TiXmlElement *xmlElement, const GearParameters *gearParams)
Static helper function that can be used by other subclass handlers to create XML for parameters...
void setZPosition(double z)
Set the z position of the module.
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 int getModuleID() const =0
Returns module ID.
void SetDoubleAttribute(const char *name, double value)
Sets an attribute of name to a given value.
virtual double getAngle() const =0
Returns the rotation of the module, in Rads, with respect to the modules internal origin...
virtual double getBorderWidth() const =0
Returns the amount by which the pad plane has been extended to produce the module plane...
void SetAttribute(const char *name, const char *value)
Sets an attribute of name to a given value.
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)
An exception that is special for the TPCModule.
const TiXmlElement * FirstChildElement() const
Convenience function to get through elements.
A wrapper Class for PadRowLayout2D which converts between the actual pad layouts local coodinate syst...
A wrapper Class for PadRowLayout2D, allowing which converts between local and global coordinate syste...
Abstract XML handler for PadRowLayout2DXML.