Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-09-27 09:20:25

0001 /**
0002  *  @file   PandoraSDK/include/Persistency/XmlFileReader.h
0003  *
0004  *  @brief  Header file for the xml file reader class.
0005  *
0006  *  $Log: $
0007  */
0008 #ifndef PANDORA_XML_FILE_READER_H
0009 #define PANDORA_XML_FILE_READER_H 1
0010 
0011 #include "Helpers/XmlHelper.h"
0012 
0013 #include "Objects/CartesianVector.h"
0014 #include "Objects/TrackState.h"
0015 
0016 #include "Pandora/Pandora.h"
0017 
0018 #include "Persistency/FileReader.h"
0019 
0020 namespace pandora
0021 {
0022 
0023 /**
0024  *  @brief  XmlFileReader class
0025  */
0026 class XmlFileReader : public FileReader
0027 {
0028 public:
0029     /**
0030      *  @brief  Constructor
0031      *
0032      *  @param  pandora the pandora instance to be used alongside the file reader
0033      *  @param  fileName the name of the file containing the pandora objects
0034      */
0035     XmlFileReader(const pandora::Pandora &pandora, const std::string &fileName);
0036 
0037     /**
0038      *  @brief  Destructor
0039      */
0040     ~XmlFileReader();
0041 
0042     /**
0043      *  @brief  Read a variable from the file
0044      *
0045      *  @param  xmlKey the xml key
0046      */
0047     template <typename T>
0048     StatusCode ReadVariable(const std::string &xmlKey, T &t);
0049 
0050 private:
0051     StatusCode ReadHeader();
0052     StatusCode GoToNextContainer();
0053     ContainerId GetNextContainerId();
0054     StatusCode GoToGeometry(const unsigned int geometryNumber);
0055     StatusCode GoToEvent(const unsigned int eventNumber);
0056     StatusCode ReadNextGlobalHeaderComponent();
0057     StatusCode ReadNextGeometryComponent();
0058     StatusCode ReadNextEventComponent();
0059 
0060     /**
0061      *  @brief  Read file version info from the current position in the file
0062      */
0063     StatusCode ReadVersion();
0064 
0065     /**
0066      *  @brief  Read a sub detector from the current position in the file
0067      */
0068     StatusCode ReadSubDetector();
0069 
0070     /**
0071      *  @brief  Read a lar tpc from the current position in the file
0072      */
0073     StatusCode ReadLArTPC();
0074 
0075     /**
0076      *  @brief  Read a line gap from the current position in the file
0077      */
0078     StatusCode ReadLineGap();
0079 
0080     /**
0081      *  @brief  Read a box gap from the current position in the file
0082      */
0083     StatusCode ReadBoxGap();
0084 
0085     /**
0086      *  @brief  Read a concentric gap from the current position in the file
0087      */
0088     StatusCode ReadConcentricGap();
0089 
0090     /**
0091      *  @brief  Read a calo hit from the current position in the file, recreating the stored object
0092      */
0093     StatusCode ReadCaloHit();
0094 
0095     /**
0096      *  @brief  Read a track from the current position in the file, recreating the stored object
0097      */
0098     StatusCode ReadTrack();
0099 
0100     /**
0101      *  @brief  Read a mc particle from the current position in the file, recreating the stored object
0102      */
0103     StatusCode ReadMCParticle();
0104 
0105     /**
0106      *  @brief  Read a relationship from the current position in the file, recreating the stored relationship
0107      */
0108     StatusCode ReadRelationship();
0109 
0110     /**
0111      *  @brief  Read event-level information from the current position in the file, adding it to the pandora instance
0112      */
0113     StatusCode ReadEventInformation();
0114 
0115     TiXmlDocument *m_pXmlDocument;      ///< The xml document
0116     TiXmlNode *m_pContainerXmlNode;     ///< The document xml node
0117     TiXmlElement *m_pCurrentXmlElement; ///< The current xml element
0118     bool m_isAtFileStart;               ///< Whether reader is at file start
0119 };
0120 
0121 //------------------------------------------------------------------------------------------------------------------------------------------
0122 
0123 template <typename T>
0124 inline StatusCode XmlFileReader::ReadVariable(const std::string &xmlKey, T &t)
0125 {
0126     if (!m_pCurrentXmlElement)
0127         return STATUS_CODE_FAILURE;
0128 
0129     return XmlHelper::ReadValue(TiXmlHandle(m_pCurrentXmlElement), xmlKey, t);
0130 }
0131 
0132 template <>
0133 inline StatusCode XmlFileReader::ReadVariable(const std::string &xmlKey, IntVector &t)
0134 {
0135     if (!m_pCurrentXmlElement)
0136         return STATUS_CODE_FAILURE;
0137 
0138     return XmlHelper::ReadVectorOfValues(TiXmlHandle(m_pCurrentXmlElement), xmlKey, t);
0139 }
0140 
0141 template <>
0142 inline StatusCode XmlFileReader::ReadVariable(const std::string &xmlKey, FloatVector &t)
0143 {
0144     if (!m_pCurrentXmlElement)
0145         return STATUS_CODE_FAILURE;
0146 
0147     return XmlHelper::ReadVectorOfValues(TiXmlHandle(m_pCurrentXmlElement), xmlKey, t);
0148 }
0149 
0150 } // namespace pandora
0151 
0152 #endif // #ifndef PANDORA_XML_FILE_READER_H