GEAR  1.9.0
 All Classes Namespaces Functions Variables Typedefs Enumerations Friends Pages
FixedPadAngleDiskLayoutXML.cc
1 #include "gearxml/FixedPadAngleDiskLayoutXML.h"
2 
3 #include "gearxml/XMLHandler.h"
4 // #include "gearxml/GearParametersXML.h"
5 
6 #include "gearxml/tinyxml.h"
7 #include "gearimpl/FixedPadAngleDiskLayout.h"
8 #include "gear/GearMgr.h"
9 
10 // #include <vector>
11 // #include <algorithm>
12 // #include <sstream>
13 
14 namespace gear {
15 
16 
18 
19  // Check if type is FixedPadAngleDiskLayout
20 
21  const FixedPadAngleDiskLayout* fixedPadLayout=dynamic_cast<const FixedPadAngleDiskLayout*>(layout);
22 
23  if (fixedPadLayout==NULL) {
24 
25  throw ParseException("FixedPadAngleDiskLayoutXML::toXML wrong type !");
26  }
27 
28  // append data to PadRowLayout2D
29  TiXmlElement padRowLayout2DXML("PadRowLayout2D");
30 
31  padRowLayout2DXML.SetAttribute("type","FixedPadAngleDiskLayout");
32 
33  padRowLayout2DXML.SetDoubleAttribute("rMin",(fixedPadLayout->getPlaneExtent())[0]);
34 
35  padRowLayout2DXML.SetDoubleAttribute("rMax",(fixedPadLayout->getPlaneExtent())[1]);
36 
37  padRowLayout2DXML.SetAttribute("nRow",fixedPadLayout->getNRows());
38 
39  padRowLayout2DXML.SetDoubleAttribute("phiMin", (fixedPadLayout->getPlaneExtent())[2]);
40 
41  padRowLayout2DXML.SetDoubleAttribute("phiMax", (fixedPadLayout->getPlaneExtent())[3]);
42 
43  padRowLayout2DXML.SetAttribute("nPadInRow",fixedPadLayout->getNPadsInRow());
44 
45  return padRowLayout2DXML ;
46  }
47 
48 
50 
51 
52  double rMin = atof( getXMLAttribute( layout , "rMin" ) .c_str() ) ;
53  double rMax = atof( getXMLAttribute( layout , "rMax" ) .c_str() ) ;
54  int nRow = atoi( getXMLAttribute( layout , "nRow" ) .c_str() ) ;
55  double phiMin = atof( getXMLAttribute( layout , "phiMin" ) .c_str() ) ;
56  double phiMax = atof( getXMLAttribute( layout , "phiMax" ) .c_str() ) ;
57  int nPadsInRow = atoi( getXMLAttribute( layout , "nPadsInRow" ) .c_str() ) ;
58 
59 
60  return new FixedPadAngleDiskLayout( rMin, rMax, nRow, phiMin, phiMax, nPadsInRow ) ;
61  }
62 
63 }
64 
virtual TiXmlElement toXML(const PadRowLayout2D *layout) const
Creates an XML node for the given PadRowLayout2D.
Abstract description of a planar subdetector with pads (cells) that are positioned in rows (circular ...
Implementation of PadRowLayout2D for a disk with fixed angled keystone pads.
virtual const std::vector< double > & getPlaneExtent() const
Extent of the sensitive plane [rmin,rmax,phimin,phimax].
ParseException used for parse errors, e.g.
Definition: GEAR.h:65
std::string getXMLAttribute(const TiXmlNode *node, const std::string &name)
Helper method used for parsing XML.
virtual PadRowLayout2D * fromXML(const TiXmlElement *xmlElement) const
Creates the appropriate PadRowLayout2D subclass from the given XML element (node) ...
The element is a container class.
Definition: tinyxml.h:827
void SetDoubleAttribute(const char *name, double value)
Sets an attribute of name to a given value.
Definition: tinyxml.cc:738
void SetAttribute(const char *name, const char *value)
Sets an attribute of name to a given value.
Definition: tinyxml.cc:746
virtual int getNRows() const
The number of rows.
virtual int getNPadsInRow() const
Get the (fixed) number of pads per row.