Pandora
Pandora source code navigator
Loading...
Searching...
No Matches
XmlFileWriter.h
Go to the documentation of this file.
1
8#ifndef PANDORA_XML_FILE_WRITER_H
9#define PANDORA_XML_FILE_WRITER_H 1
10
11#include "Pandora/Pandora.h"
12
14#include "Objects/TrackState.h"
15
17
18#include "Xml/tinyxml.h"
19
20namespace pandora
21{
22
27{
28public:
36 XmlFileWriter(const pandora::Pandora &pandora, const std::string &fileName, const FileMode fileMode = APPEND);
37
42
48 template<typename T>
49 StatusCode WriteVariable(const std::string &xmlKey, const T &t);
50
51private:
52 StatusCode WriteHeader(const ContainerId containerId);
54 StatusCode WriteSubDetector(const SubDetector *const pSubDetector);
55 StatusCode WriteLArTPC(const LArTPC *const pLArTPC);
56 StatusCode WriteDetectorGap(const DetectorGap *const pDetectorGap);
57 StatusCode WriteCaloHit(const CaloHit *const pCaloHit);
58 StatusCode WriteTrack(const Track *const pTrack);
59 StatusCode WriteMCParticle(const MCParticle *const pMCParticle);
60 StatusCode WriteRelationship(const RelationshipId relationshipId, const void *address1, const void *address2, const float weight);
61
65};
66
67//------------------------------------------------------------------------------------------------------------------------------------------
68
69template<typename T>
70inline StatusCode XmlFileWriter::WriteVariable(const std::string &xmlKey, const T &t)
71{
73 return STATUS_CODE_FAILURE;
74
75 TiXmlElement *const pTiXmlElement = new TiXmlElement(xmlKey);
76 pTiXmlElement->LinkEndChild(new TiXmlText(TypeToStringPrecision(t)));
77 m_pCurrentXmlElement->LinkEndChild(pTiXmlElement);
78
79 return STATUS_CODE_SUCCESS;
80}
81
82template<>
83inline StatusCode XmlFileWriter::WriteVariable(const std::string &xmlKey, const CartesianVector &t)
84{
85 return this->WriteVariable(xmlKey, TypeToStringPrecision(t.GetX()) + " " + TypeToStringPrecision(t.GetY()) + " " + TypeToStringPrecision(t.GetZ()));
86}
87
88template<>
94
95} // namespace pandora
96
97#endif // #ifndef PANDORA_XML_FILE_WRITER_H
Header file for the cartesian vector class.
Header file for the file writer class.
Header file for the pandora class.
Header file for the track state class.
CaloHit class.
Definition CaloHit.h:26
CartesianVector class.
float GetX() const
Get the cartesian x coordinate.
float GetZ() const
Get the cartesian z coordinate.
float GetY() const
Get the cartesian y coordinate.
DetectorGap class.
Definition DetectorGap.h:25
FileWriter class.
Definition FileWriter.h:29
LArTPC class.
Definition LArTPC.h:26
MCParticle class.
Definition MCParticle.h:26
Pandora class.
Definition Pandora.h:40
SubDetector class.
Definition SubDetector.h:26
TiXmlNode * LinkEndChild(TiXmlNode *addThis)
Definition tinyxml.cc:189
Track class.
Definition Track.h:26
TrackState class.
Definition TrackState.h:22
const CartesianVector & GetMomentum() const
Get the track momentum vector.
Definition TrackState.h:80
const CartesianVector & GetPosition() const
Get the track position vector.
Definition TrackState.h:73
XmlFileWriter class.
StatusCode WriteVariable(const std::string &xmlKey, const T &t)
Write a variable to the file.
TiXmlDocument * m_pXmlDocument
The xml document.
TiXmlElement * m_pContainerXmlElement
The container xml element.
StatusCode WriteLArTPC(const LArTPC *const pLArTPC)
Write a lar tpc to the file.
StatusCode WriteHeader(const ContainerId containerId)
Write the container header to the file.
StatusCode WriteSubDetector(const SubDetector *const pSubDetector)
Write a sub detector to the file.
StatusCode WriteCaloHit(const CaloHit *const pCaloHit)
Write a calo hit to the current position in the file.
StatusCode WriteTrack(const Track *const pTrack)
Write a track to the current position in the file.
StatusCode WriteMCParticle(const MCParticle *const pMCParticle)
Write a mc particle to the current position in the file.
StatusCode WriteFooter()
Write the container footer to the file.
~XmlFileWriter()
Destructor.
StatusCode WriteDetectorGap(const DetectorGap *const pDetectorGap)
Write the detector gap parameters to the file.
TiXmlElement * m_pCurrentXmlElement
The current xml element.
StatusCode WriteRelationship(const RelationshipId relationshipId, const void *address1, const void *address2, const float weight)
Write a relationship between two objects with specified addresses.
FileMode
The file mode enum.
Definition PandoraIO.h:84
RelationshipId
The relationship identification enum.
Definition PandoraIO.h:57
std::string TypeToStringPrecision(const T &t, const unsigned int precision=12)
ContainerId
The container identification enum.
Definition PandoraIO.h:24
StatusCode
The StatusCode enum.