Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members

marlin::XMLParser Class Reference

#include <XMLParser.h>

Inheritance diagram for marlin::XMLParser:

marlin::IParser List of all members.

Public Member Functions

 XMLParser (const std::string &fileName)
virtual ~XMLParser ()
void parse ()
StringParametersgetParameters (const std::string &sectionName) const

Protected Member Functions

void parametersFromNode (TiXmlNode *section, std::pair< unsigned, unsigned > *typeCount=0)
const char * getAttribute (TiXmlNode *node, const std::string &name)
void replacegroups (TiXmlNode *section)
TiXmlNodefindElement (TiXmlNode *node, const std::string &type, const std::string &attribute, const std::string &value)
void processconditions (TiXmlNode *current, const std::string &conditions)

Protected Attributes

StringParametersMap _map
StringParameters_current
TiXmlDocument_doc
std::string _fileName

Private Member Functions

 XMLParser ()

Detailed Description

XML parser for Marlin steering files. Marlin XML steering files have the following form (use Marlin -x > example.xml to generate a template steering file):

  <marlin>
   <execute>   [1]
      ...  // the processors and processor groups to be executed
   </execute>
   <global>    [1]
      ...  // global parameter section
   </global>
   <processor> [n]
      ...  // definition of the processor and its parameters
   </processor>
   <group> [m]   
      ...    // a group of processors
     <processor> [k]
      ...  // definition of the processor and its parameters
     </processor>
   </group> 
  </marlin>
 
where the numbers enclosed in "[]" denote how many elements of the given type are allowed or required, n,m,k = [0,1,2,...].

The <execute/> section defines the processors that are to be called in the order specified. The Processor::processEvent() method is only called if the relevant condition (<if condition="A"/>) is fullfilled. Conditions can be arbitrary logical expressions formed of [!,(,&&,||,),value], e.g.
( A && ( B || !C ) ) || ( !B && D ), where the keys A,B,C,D can be either procesor names (Processor::setReturnValue(bool val) ) or processor names followed by a string ( Processor::setReturnValue(const std::string &name, bool val) ).
In the following example the Pflow processor is only called for events where the EventSelection processor has returnd true and the TwoJetAnalysis is is then in turn only called for events identified as having tow jets by the Pflow processor

  <execute>
   <processor name="MyAIDAProcessor"/>
   <processor name="EventSelection"/>  
   <if condition="EventSelection">
     <processor name="Pflow"/>  
     <if condition="Pflow.TwoJet">
       <group name="TwoJetAnalysis"/>
     </if>
   </if>
   <processor name="MyLCIOOutputProcessor"/>  
  </execute>   
  
The <global> section defines the global paramters:
  <global>
    <parameter name="LCIOInputFiles">dd_rec.slcio </parameter>
    <parameter name="LCIOInputFiles">../tt500_all_set1_12.slcio </parameter>
    <parameter name="MaxRecordNumber" value="5001" />  
    <parameter name="SupressCheck" value="false" />  
  </global>
 
Parameters can be either specified as the content of the <parameter/> tag or in the value-attribute of the tag !

The <processor name="..." type="..." > section defines the processor and its parameters, where name and type are required attibutes, e.g.

  <processor name="EventSelection" type="SelectionProcessor">
    <parameter name="EnergyCut" type="float">50.0</parameter>
  </processor>
 
Note: the parameter's type-attribute is optional.

Processor sections can be enclosed in a <group/> tag, where parameters defined outside any <processor/> tag are group parameters valid for all processors in the group, .e.g.

  <group>
    <parameter name="PtCut" value="0.03">
    <processor name="TrackFinding" type="TrackFinder"/>
    <processor name="TrackFitting" type="KalmanProcessor">
      <parameter name="UseDAF" value="true">
    <processor>
  </group>
 

Author:
F. Gaede, DESY
Version:
Id
XMLParser.h,v 1.6 2006/11/16 14:44:45 gaede Exp

Definition at line 104 of file XMLParser.h.


Constructor & Destructor Documentation

marlin::XMLParser::XMLParser const std::string &  fileName  ) 
 

Definition at line 13 of file XMLParser.cc.

marlin::XMLParser::~XMLParser  )  [virtual]
 

Definition at line 17 of file XMLParser.cc.

marlin::XMLParser::XMLParser  )  [private]
 


Member Function Documentation

TiXmlNode * marlin::XMLParser::findElement TiXmlNode node,
const std::string &  type,
const std::string &  attribute,
const std::string &  value
[protected]
 

Helper method - finds child element of node with given type and attribute value.

Definition at line 444 of file XMLParser.cc.

References TiXmlElement::Attribute(), TiXmlNode::IterateChildren(), and TiXmlNode::ToElement().

Referenced by replacegroups().

const char * marlin::XMLParser::getAttribute TiXmlNode node,
const std::string &  name
[protected]
 

Return named attribute - throws ParseException if attribute doesn't exist

Definition at line 219 of file XMLParser.cc.

References TiXmlElement::Attribute(), TiXmlNode::ToElement(), and TiXmlNode::Value().

Referenced by parametersFromNode(), parse(), processconditions(), and replacegroups().

StringParameters * marlin::XMLParser::getParameters const std::string &  sectionName  )  const [virtual]
 

Return the StringParameters for the section as read from the xml file

Implements marlin::IParser.

Definition at line 326 of file XMLParser.cc.

References _map.

void marlin::XMLParser::parametersFromNode TiXmlNode section,
std::pair< unsigned, unsigned > *  typeCount = 0
[protected]
 

Extracts all parameters from the given node and adss them to the current StringParameters object

Definition at line 240 of file XMLParser.cc.

References _current, marlin::StringParameters::add(), TiXmlNode::FirstChild(), getAttribute(), TiXmlNode::IterateChildren(), and TiXmlNode::Value().

Referenced by parse().

void marlin::XMLParser::parse  )  [virtual]
 

Parse the input file

Implements marlin::IParser.

Definition at line 20 of file XMLParser.cc.

References _current, _doc, _fileName, _map, marlin::StringParameters::add(), TiXmlNode::Clone(), TiXmlDocument::ErrorCol(), TiXmlDocument::ErrorDesc(), TiXmlDocument::ErrorRow(), TiXmlNode::FirstChild(), getAttribute(), TiXmlNode::InsertBeforeChild(), TiXmlNode::InsertEndChild(), TiXmlNode::IterateChildren(), TiXmlDocument::LoadFile(), parametersFromNode(), processconditions(), TiXmlNode::RemoveChild(), replacegroups(), and TiXmlDocument::RootElement().

void marlin::XMLParser::processconditions TiXmlNode current,
const std::string &  conditions
[protected]
 

Helper method - recursively moves processors from <if/> tags to top level (<execute/>) and adds corresponding conditions attribute

Definition at line 339 of file XMLParser.cc.

References TiXmlElement::Attribute(), TiXmlNode::Clone(), getAttribute(), TiXmlNode::InsertBeforeChild(), TiXmlNode::IterateChildren(), TiXmlNode::Parent(), TiXmlNode::RemoveChild(), TiXmlElement::SetAttribute(), TiXmlNode::ToElement(), and TiXmlNode::Value().

Referenced by parse().

void marlin::XMLParser::replacegroups TiXmlNode section  )  [protected]
 

Helper method - replaces all <group/> tag with corresponding <processor/> tags

Definition at line 398 of file XMLParser.cc.

References _doc, TiXmlElement::Attribute(), findElement(), getAttribute(), TiXmlNode::InsertBeforeChild(), TiXmlNode::IterateChildren(), TiXmlNode::RemoveChild(), TiXmlDocument::RootElement(), TiXmlElement::SetAttribute(), TiXmlNode::ToElement(), and TiXmlNode::Value().

Referenced by parse().


Member Data Documentation

StringParameters* marlin::XMLParser::_current [protected]
 

Definition at line 184 of file XMLParser.h.

Referenced by parametersFromNode(), and parse().

TiXmlDocument* marlin::XMLParser::_doc [protected]
 

Definition at line 185 of file XMLParser.h.

Referenced by parse(), and replacegroups().

std::string marlin::XMLParser::_fileName [protected]
 

Definition at line 187 of file XMLParser.h.

Referenced by parse().

StringParametersMap marlin::XMLParser::_map [mutable, protected]
 

Definition at line 183 of file XMLParser.h.

Referenced by getParameters(), and parse().


The documentation for this class was generated from the following files:
Generated on Sun Jun 3 06:32:32 2007 for A TPC Tracking Environment by  doxygen 1.3.9.1