GEAR  1.9.0
 All Classes Namespaces Functions Variables Typedefs Enumerations Friends Pages
FixedPadSizeDiskLayoutXML.cc
1 #include "gearxml/FixedPadSizeDiskLayoutXML.h"
2 
3 #include "gearxml/XMLHandler.h"
4 // #include "gearxml/GearParametersXML.h"
5 
6 #include "gearxml/tinyxml.h"
7 #include "gearimpl/FixedPadSizeDiskLayout.h"
8 #include "gear/GearMgr.h"
9 
10 // #include <vector>
11 // #include <algorithm>
12 // #include <sstream>
13 
14 #include <cmath>
15 
16 namespace gear {
17 
18 
20 
21  // Check if type is FixedPadSizeDiskLayout
22 
23  const FixedPadSizeDiskLayout* fixedPadLayout=dynamic_cast<const FixedPadSizeDiskLayout*>(layout);
24 
25  if (fixedPadLayout==NULL) {
26 
27  throw ParseException("FixedPadSizeDiskLayoutXML::toXML wrong type !");
28  }
29 
30  // append data to PadRowLayout2D
31  TiXmlElement padRowLayout2DXML("PadRowLayout2D");
32 
33  padRowLayout2DXML.SetAttribute("type","FixedPadSizeDiskLayout");
34 
35  padRowLayout2DXML.SetDoubleAttribute("rMin",(fixedPadLayout->getPlaneExtent())[0]);
36 
37  padRowLayout2DXML.SetDoubleAttribute("rMax",(fixedPadLayout->getPlaneExtent())[1]);
38 
39  padRowLayout2DXML.SetDoubleAttribute("padHeight",fixedPadLayout->getPadHeight(1));
40 
41  padRowLayout2DXML.SetDoubleAttribute("padWidth", fixedPadLayout->getFixedPadWidth());
42 
43  padRowLayout2DXML.SetAttribute("maxRow",fixedPadLayout->getNRows());
44 
45  padRowLayout2DXML.SetDoubleAttribute("padGap",fixedPadLayout->getPadGap());
46 
47  padRowLayout2DXML.SetDoubleAttribute("phiMax",(fixedPadLayout->getPlaneExtent())[3]);
48 
49  return padRowLayout2DXML ;
50  }
51 
52 
54 
55 
56  double rMin = atof( getXMLAttribute( layout , "rMin" ) .c_str() ) ;
57  double rMax = atof( getXMLAttribute( layout , "rMax" ) .c_str() ) ;
58  double padHeight = atof( getXMLAttribute( layout , "padHeight" ) .c_str() ) ;
59  double padWidth = atof( getXMLAttribute( layout , "padWidth" ) .c_str() ) ;
60  int maxRow = atoi( getXMLAttribute( layout , "maxRow" ) .c_str() ) ;
61  double padGap = atof( getXMLAttribute( layout , "padGap" ) .c_str() ) ;
62 
63  double phiMax = 2*M_PI;
64 
65  try {
66  phiMax = atof( getXMLAttribute( layout , "phiMax" ) .c_str() ) ;
67  } catch (ParseException &) {
68  // Redundant, but anyway..
69  phiMax = 2*M_PI;
70  }
71 
72  return new FixedPadSizeDiskLayout( rMin, rMax, padHeight, padWidth, maxRow, padGap, phiMax ) ;
73 
74  }
75 
76 }
virtual int getNRows() const
The number of rows.
Abstract description of a planar subdetector with pads (cells) that are positioned in rows (circular ...
Implementation of PadRowLayout2D for a disk with fixed sized keystone pads.
virtual double getPadGap() const
The gap width in mm that was given in the C&#39;tor.
virtual PadRowLayout2D * fromXML(const TiXmlElement *xmlElement) const
Creates the appropriate PadRowLayout2D subclass from the given XML element (node) ...
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.
The element is a container class.
Definition: tinyxml.h:827
virtual double getFixedPadWidth() const
The fixed width of the pads in mm.
virtual double getPadHeight(int) const
The height of the pad in mm.
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 const std::vector< double > & getPlaneExtent() const
Extent of the sensitive plane - [xmin,xmax,ymin,ymax] CARTESIAN or [rmin,rmax,phimin,phimax] POLAR.
virtual TiXmlElement toXML(const PadRowLayout2D *layout) const
Creates an XML node for the given PadRowLayout2D.