Marlin  1.17.1
 All Classes Namespaces Functions Variables Enumerations Friends Pages
Classes | Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
marlin::XMLParser Class Reference

XML parser for Marlin steering files. More...

#include <XMLParser.h>

Inheritance diagram for marlin::XMLParser:
marlin::IParser

Classes

class  LCTokenizer
 Helper class for XMLParser. More...
 

Public Member Functions

 XMLParser (const std::string &fileName, bool forCCheck=false)
 
void setCmdLineParameters (const CommandLineParametersMap &cmdlineparams)
 set command line parameters
 
void parse ()
 Parse the input file.
 
std::shared_ptr< StringParametersgetParameters (const std::string &sectionName) const
 Return the StringParameters for the section as read from the xml file.
 
void write (const std::string &filen) const
 Write the parsed XML tree in an other file.
 

Protected Member Functions

void parametersFromNode (TiXmlNode *section, std::map< std::string, std::string > &constants, std::pair< unsigned, unsigned > *typeCount=0)
 Extracts all parameters from the given node and adss them to the current StringParameters object.
 
const char * getAttribute (TiXmlNode *node, const std::string &name)
 Return named attribute - throws ParseException if attribute doesn't exist.
 
void replacegroups (TiXmlNode *section)
 Helper method - replaces all <group> tag with corresponding <processor> tags.
 
TiXmlNodefindElement (TiXmlNode *node, const std::string &type, const std::string &attribute, const std::string &value)
 Helper method - finds child element of node with given type and attribute value. More...
 
void processconditions (TiXmlNode *current, const std::string &conditions)
 Helper method - recursively moves processors from <if> tags to top level (<execute>) and adds corresponding conditions attribute.
 
void processIncludeElements (TiXmlElement *element, const std::map< std::string, std::string > &constants)
 Helper method - recursively replace all with the corresponding file content.
 
void processIncludeElement (TiXmlElement *element, const std::map< std::string, std::string > &constants, TiXmlDocument &document)
 
void processConstants (TiXmlNode *node, std::map< std::string, std::string > &constants)
 
void processConstant (TiXmlElement *element, std::map< std::string, std::string > &constants)
 
std::string & performConstantReplacement (std::string &value, const std::map< std::string, std::string > &constants)
 
void checkForNestedIncludes (const TiXmlNode *node)
 

Protected Attributes

StringParametersMap _map {}
 
StringParameters_current
 
std::unique_ptr< TiXmlDocument_doc {}
 
std::string _fileName
 

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.7 2007-07-18 12:43:09 engels Exp

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.

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

Referenced by replacegroups().


The documentation for this class was generated from the following files: