2 #include "gearxml/GearXML.h"
3 #include "gearxml/tinyxml.h"
4 #include "gearxml/XMLHandlerMgr.h"
5 #include "gearxml/GearParametersXML.h"
6 #include "gearxml/TPCParametersXML.h"
7 #include "gearxml/CalorimeterParametersXML.h"
8 #include "gearxml/ZPlanarParametersXML.h"
9 #include "gearxml/FTDParametersXML.h"
10 #include "gearxml/ConstantBFieldXML.h"
11 #include "gearxml/TrackerPlanesParametersXML.h"
12 #include "gearxml/SiPlanesParametersXML.h"
13 #include "gearxml/SimpleMaterialXML.h"
14 #include "gearimpl/GearMgrImpl.h"
16 #include "gear/GEAR.h"
17 #include "gear/CalorimeterParameters.h"
18 #include "gear/ZPlanarParameters.h"
19 #include "gear/FTDParameters.h"
20 #include "gear/TrackerPlanesParameters.h"
21 #include "gear/SiPlanesParameters.h"
28 #include "gear/GearMaterialProperties.h"
38 GearXML::GearXML(
const std::string& fileName ) :
39 _fileName( fileName ),
53 throw Exception(
"GearXML::createXMLFile: GearMgr dosn't exist");
67 std::string detName(
"Unknown") ;
79 rootComment.
SetValue(
"Gear XML file automatically created with GearXML::createXMLFile ...." ) ;
107 detector.
SetAttribute(
"geartype" , GEAR::TPCPARAMETERS ) ;
124 detector.
SetAttribute(
"geartype" , GEAR::CALORIMETERPARAMETERS ) ;
140 detector.
SetAttribute(
"geartype" , GEAR::CALORIMETERPARAMETERS ) ;
156 detector.
SetAttribute(
"geartype" , GEAR::CALORIMETERPARAMETERS ) ;
172 detector.
SetAttribute(
"geartype" , GEAR::CALORIMETERPARAMETERS ) ;
188 detector.
SetAttribute(
"geartype" , GEAR::CALORIMETERPARAMETERS ) ;
204 detector.
SetAttribute(
"geartype" , GEAR::CALORIMETERPARAMETERS ) ;
220 detector.
SetAttribute(
"geartype" , GEAR::CALORIMETERPARAMETERS ) ;
236 detector.
SetAttribute(
"geartype" , GEAR::CALORIMETERPARAMETERS ) ;
252 detector.
SetAttribute(
"geartype" , GEAR::CALORIMETERPARAMETERS ) ;
268 detector.
SetAttribute(
"geartype" , GEAR::CALORIMETERPARAMETERS ) ;
284 detector.
SetAttribute(
"geartype" , GEAR::CALORIMETERPARAMETERS ) ;
300 detector.
SetAttribute(
"geartype" , GEAR::CALORIMETERPARAMETERS ) ;
321 detector.
SetAttribute(
"geartype" , GEAR::ZPLANARPARAMETERS ) ;
339 detector.
SetAttribute(
"geartype" , GEAR::FTDPARAMETERS ) ;
357 detector.
SetAttribute(
"geartype" , GEAR::ZPLANARPARAMETERS ) ;
375 detector.
SetAttribute(
"geartype" , GEAR::ZPLANARPARAMETERS ) ;
393 detector.
SetAttribute(
"geartype" , GEAR::TRACKERPLANESPARAMETERS ) ;
411 detector.
SetAttribute(
"geartype" , GEAR::SIPLANESPARAMETERS ) ;
423 for(
unsigned int i=0; i<keys.size(); i++ ){
431 detector.
SetAttribute(
"geartype" , GEAR::GEARPARAMETERS ) ;
442 for(
unsigned int i=0; i< mNames.size(); i++ ){
492 bool loadOkay = doc.
LoadFile( _fileName ) ;
496 std::stringstream str ;
498 str <<
"GearXML::createGearMgr error in file [" << _fileName
510 throw ParseException( std::string(
"GearXML::createGearMgr : no root tag found in ")
522 if( detectors == 0 ){
523 throw ParseException( std::string(
"GearXML::createGearMgr : no detectors tag found in ")
547 std::string libName =
"libgeartgeo.dylib" ;
549 std::string libName =
"libgeartgeo.so" ;
554 void* libPointer = dlopen( libName.c_str() , RTLD_LAZY | RTLD_GLOBAL) ;
559 mProp->
config()[
"GDMLFileName"] = gdmlname ;
570 std::cout <<
" WARNING: GearXML::createGearMgr: GDML file specified " << std::endl
571 <<
" but failed to load library " << libName <<
" ! " << std::endl
572 <<
" Check your dynamic library search path ($(DY)LD_LIBRARY_PATH )... " << std::endl
585 std::string type(
"UNKOWN") ;
595 if( type==std::string(
"VXDParameters") ){
596 type =
"ZPlanarParameters" ;
602 std::cout <<
"GearXML::createGearMgr: igoring detector " << name
603 <<
" with missing attribute \"geartype\" " << std::endl ;
608 const XMLHandler* handler = XMLHandlerMgr::instance()->getHandler( type ) ;
612 throw ParseException( std::string(
"GearXML::createGearMgr : unknown geartype \"")
613 + type +
"\" in file " + _fileName ) ;
627 if( materials != 0 ){
bool SaveFile() const
Save a file using the current document value. Returns true if successful.
virtual void setPointProperties(GearPointProperties *pointProperties)
Set the point properties object.
XML handler for ZPlanarParameters.
virtual GearParameters * fromXML(const TiXmlElement *xmlElement, GearMgr *gearMgr=0) const
Creates the appropriate GearParameters subclass from the given XML element (node) ...
int ErrorRow()
Returns the location (if known) of the error.
Abstract interface for a class that returns the (material) properties along a given distance between ...
virtual const TPCParameters & getTPCParameters() const =0
Get the TPCParameters.
void SetValue(const char *_value)
Changes the value of the node.
XML handler for SimpleMaterial.
bool LoadFile(TiXmlEncoding encoding=TIXML_DEFAULT_ENCODING)
Load a file using the current document value.
static const GearMaterialPropertiesFactory * instance()
The instance.
virtual const CalorimeterParameters & getHcalEndcapParameters() const =0
Get the Hcal endcap parameters.
virtual const FTDParameters & getFTDParameters() const =0
Get the FTD parameters.
GearMgr * createGearMgr()
Creates an instance of GearMgr from the data given in the XML file.
virtual GearDistanceProperties * getGearDistanceProperties() const =0
Get an instance of the GearDistanceProperties - 0 if not initialized.
XML handler for ConstantBField.
virtual const ZPlanarParameters & getVXDParameters() const =0
Get the VXD parameters.
Base exception class for GEAR - all other exceptions extend this.
virtual GearParameters * fromXML(const TiXmlElement *xmlElement, GearMgr *gearMgr=0) const =0
Creates the approprtiate GearParameters subclass from the given XML element (node) and adss it to the...
virtual const SiPlanesParameters & getSiPlanesParameters() const =0
Get the SiPlanes parameters.
Interface for XML handlers of GEAR classes.
XML handler for SiPlanesParameters.
XML handler for CalorimeterParameters.
Manager class that returns the Gear classes for the relevant subdetectors.
virtual const CalorimeterParameters & getBeamCalParameters() const =0
Get the BeamCal parameters.
const char * ErrorDesc() const
Contains a textual (english) description of the error if one occurs.
Abstract XML handler for TPCParameters.
virtual const BField & getBField() const =0
Get the B field map.
virtual GearMaterialProperties * create() const =0
Create a new object of the GearMaterialProperties.
virtual const CalorimeterParameters & getYokeBarrelParameters() const =0
Get the Yoke barrel parameters.
int ErrorCol()
The column where the error occured. See ErrorRow()
virtual const ZPlanarParameters & getSITParameters() const =0
Get the SIT parameters.
XML handler for GearParameters.
Always the top level node.
XML handler for FTDParameters.
virtual const GearParameters & getGearParameters(const std::string &key) const =0
Get named parameters for key.
virtual const CalorimeterParameters & getLHcalParameters() const =0
Get the LHcal parameters.
UnknownParameterException call Processor::end().
static void createXMLFile(GearMgr *mgr, const std::string &fileName)
Write an XML file to disk from the given GearMgr object.
XML handler for TrackerPlanesParameters.
The parent class for everything in the Document Object Model.
virtual const SimpleMaterial & getSimpleMaterial(const std::string name) const =0
Return the SimpleMaterial for the given name throws UnknownParameterException if no material is unkno...
virtual GearPointProperties * getGearPointProperties() const =0
Get an instance of the GearPointProperties - 0 if not initialized.
virtual const TrackerPlanesParameters & getTrackerPlanesParameters() const =0
Get the TrackerPlanes parameters.
virtual const std::vector< std::string > & getGearParameterKeys() const =0
Keys of all GearParameters.
ParseException used for parse errors, e.g.
std::string getXMLAttribute(const TiXmlNode *node, const std::string &name)
Helper method used for parsing XML.
virtual const std::vector< std::string > & getMaterialNames() const =0
Names of registered materials.
virtual const std::string & getDetectorName() const =0
The unique detector name - typically the model name used in the simulation program.
const TiXmlElement * ToElement() const
Cast to a more defined type. Will return null not of the requested type.
virtual TiXmlElement toXML(const GearParameters ¶meters) const
Creates an XML node for the given parameters.
const TiXmlElement * RootElement() const
Get the root element – the only top level element – of the document.
virtual const CalorimeterParameters & getEcalPlugParameters() const =0
Get the Ecal plug parameters.
virtual const CalorimeterParameters & getEcalBarrelParameters() const =0
Get the Ecal barrel parameters.
The element is a container class.
virtual const CalorimeterParameters & getYokePlugParameters() const =0
Get the Yoke plug parameters.
virtual const ZPlanarParameters & getSETParameters() const =0
Get the SET parameters.
TiXmlNode * InsertEndChild(const TiXmlNode &addThis)
Add a new node related to this.
virtual TiXmlElement toXML(const GearParameters ¶meters) const
Creates an XML node for the given parameters.
virtual SimpleMaterial * fromXML(const TiXmlElement *xmlElement, GearMgr *gearMgr=0) const
Creates a SimpleMaterial from the XML element (node)
virtual const CalorimeterParameters & getLcalParameters() const =0
Get the Lcal parameters.
virtual const CalorimeterParameters & getYokeEndcapParameters() const =0
Get the Yoke endcap parameters.
virtual TiXmlElement toXML(const GearParameters ¶meters) const
Creates an XML node for the given parameters.
virtual TiXmlElement toXML(const SimpleMaterial &material) const
Creates an XML node for the given material.
virtual const CalorimeterParameters & getHcalRingParameters() const =0
Get the Hcal ring parameters.
virtual void setDistanceProperties(GearDistanceProperties *distanceProperties)
Set the distance properties object.
virtual TiXmlElement toXML(const GearParameters ¶meters) const
Creates an XML node for the given parameters.
const TiXmlNode * FirstChild() const
The first child of this node. Will be null if there are no children.
virtual TiXmlElement toXML(const GearParameters ¶meters) const
Creates an XML node for the given parameters.
virtual const CalorimeterParameters & getHcalBarrelParameters() const =0
Get the Hcal barrel parameters.
Abstract base class for implemenations of the GearPointPtoperties and GearDistanceProperties.
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.
virtual const CalorimeterParameters & getEcalEndcapParameters() const =0
Get the Ecal endcap parameters.
void SetAttribute(const char *name, const char *value)
Sets an attribute of name to a given value.
virtual TiXmlElement toXML(const GearParameters &modularTPC) const
Creates an XML node for the given TPCParameters.
virtual TiXmlElement toXML(const GearParameters ¶meters) const
Creates an XML node for the given parameters.
virtual void initialize()=0
Initialize a concrete implemetaiton of the detailed material properties - after the configuration...
Abstract interface for a class that returns the (material) properties of a given point in in world co...
virtual void setDetectorName(const std::string &name)
Set detector name.
virtual TiXmlElement toXML(const GearParameters ¶meters) const
Creates an XML node for the given parameters.
ConfigMap & config()
Use to configure an instance of the material properties, e.g.