Loading [MathJax]/extensions/tex2jax.js
The Gaudi Framework  v31r0 (aeb156f0)
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
HistoStrings.cpp
Go to the documentation of this file.
1 // ============================================================================
2 // Include files
3 // ============================================================================
4 // STD & STL
5 // ============================================================================
6 #include <sstream>
7 // ============================================================================
8 // local
9 // ============================================================================
13 #include "GaudiUtils/HistoXML.h"
14 // ============================================================================
20 // ============================================================================
21 /* convert the histogram into the string
22  * @param histo (INPUT) the histogram to be streamed
23  * @param asXML (INPUT) use XML-format
24  * @return the string representation of the histogram
25  * @author Vanya BELYAEV Ivan.Belyaev@nikhef.nl
26  * @date 2009-09-26
27  */
28 // ============================================================================
29 std::string Gaudi::Utils::Histos::HistoStrings::toString( const TH1D& histo, const bool asXML ) {
30  return Gaudi::Utils::toString( histo, asXML );
31 }
32 // ============================================================================
33 /* convert the histogram into the string
34  * @param histo (INPUT) the histogram to be streamed
35  * @param asXML (INPUT) use XML-format
36  * @return the string representation of the histogram
37  * @author Vanya BELYAEV Ivan.Belyaev@nikhef.nl
38  * @date 2009-09-26
39  */
40 // ============================================================================
41 std::string Gaudi::Utils::Histos::HistoStrings::toString( const TH2D& histo, const bool asXML ) {
42  return Gaudi::Utils::toString( histo, asXML );
43 }
44 // ============================================================================
45 /* convert the histogram into the string
46  * @param histo (INPUT) the histogram to be streamed
47  * @param asXML (INPUT) use XML-format
48  * @return the string representation of the histogram
49  * @author Vanya BELYAEV Ivan.Belyaev@nikhef.nl
50  * @date 2009-09-26
51  */
52 // ============================================================================
53 std::string Gaudi::Utils::Histos::HistoStrings::toString( const AIDA::IHistogram1D& histo, const bool asXML ) {
54  return Gaudi::Utils::toString( histo, asXML );
55 }
56 // ============================================================================
57 /* convert the histogram into the string
58  * @param histo (INPUT) the histogram to be streamed
59  * @param asXML (INPUT) use XML-format
60  * @return the string representation of the histogram
61  * @author Vanya BELYAEV Ivan.Belyaev@nikhef.nl
62  * @date 2009-09-26
63  */
64 // ============================================================================
65 std::string Gaudi::Utils::Histos::HistoStrings::toString( const AIDA::IHistogram2D& histo, const bool asXML ) {
66  return Gaudi::Utils::toString( histo, asXML );
67 }
68 // ============================================================================
69 /* parse the histogram from string
70  * @param result (OUTPUT) the parsed histogram
71  * @param input (INPUT) the input string
72  * @return status code
73  */
74 // ============================================================================
76  return Gaudi::Parsers::parse( result, input );
77 }
78 // ============================================================================
79 /* parse the histogram from string
80  * @param result (OUTPUT) the parsed histogram
81  * @param input (INPUT) the input string
82  * @return status code
83  */
84 // ============================================================================
86  return Gaudi::Parsers::parse( result, input );
87 }
88 // ============================================================================
89 /* parse the histogram from string
90  * @param result (OUTPUT) the parsed histogram
91  * @param input (INPUT) the input XML string
92  * @return status code
93  */
94 // ============================================================================
95 StatusCode Gaudi::Utils::Histos::HistoStrings::fromString( AIDA::IHistogram1D& result, const std::string& input ) {
96  return Gaudi::Parsers::parse( result, input );
97 }
98 // ============================================================================
99 /* parse the histogram from string
100  * @param result (OUTPUT) the parsed histogram
101  * @param input (INPUT) the input XML string
102  * @return status code
103  */
104 // ============================================================================
105 StatusCode Gaudi::Utils::Histos::HistoStrings::fromString( AIDA::IHistogram2D& result, const std::string& input ) {
106  return Gaudi::Parsers::parse( result, input );
107 }
108 // ============================================================================
109 namespace {
110  // ==========================================================================
111  template <class TYPE>
112  std::string _toXml( const TYPE& object ) {
114  Gaudi::Utils::Histos::toXml( object, s );
115  return s.str();
116  }
117  // ==========================================================================
118  template <class TYPE>
119  StatusCode _fromXml( TYPE& object, const std::string& input ) {
120  return Gaudi::Utils::Histos::fromXml( object, input );
121  }
122  // ==========================================================================
123 } // end of anonymous namespace
124 // ============================================================================
125 std::string Gaudi::Utils::Histos::HistoStrings::toXml( const TH1D& histo ) { return _toXml( histo ); }
126 std::string Gaudi::Utils::Histos::HistoStrings::toXml( const TH2D& histo ) { return _toXml( histo ); }
127 std::string Gaudi::Utils::Histos::HistoStrings::toXml( const TH3D& histo ) { return _toXml( histo ); }
128 std::string Gaudi::Utils::Histos::HistoStrings::toXml( const TProfile& histo ) { return _toXml( histo ); }
129 std::string Gaudi::Utils::Histos::HistoStrings::toXml( const TProfile2D& histo ) { return _toXml( histo ); }
130 // ============================================================================
131 std::string Gaudi::Utils::Histos::HistoStrings::toXml( const AIDA::IHistogram1D& histo ) { return _toXml( histo ); }
132 std::string Gaudi::Utils::Histos::HistoStrings::toXml( const AIDA::IHistogram2D& histo ) { return _toXml( histo ); }
133 std::string Gaudi::Utils::Histos::HistoStrings::toXml( const AIDA::IHistogram3D& histo ) { return _toXml( histo ); }
134 std::string Gaudi::Utils::Histos::HistoStrings::toXml( const AIDA::IProfile1D& histo ) { return _toXml( histo ); }
135 std::string Gaudi::Utils::Histos::HistoStrings::toXml( const AIDA::IProfile2D& histo ) { return _toXml( histo ); }
136 // ============================================================================
138  return _fromXml( result, input );
139 }
141  return _fromXml( result, input );
142 }
144  return _fromXml( result, input );
145 }
147  return _fromXml( result, input );
148 }
150  return _fromXml( result, input );
151 }
152 // ============================================================================
153 StatusCode Gaudi::Utils::Histos::HistoStrings::fromXml( AIDA::IHistogram1D& result, const std::string& input ) {
154  return _fromXml( result, input );
155 }
156 StatusCode Gaudi::Utils::Histos::HistoStrings::fromXml( AIDA::IHistogram2D& result, const std::string& input ) {
157  return _fromXml( result, input );
158 }
159 StatusCode Gaudi::Utils::Histos::HistoStrings::fromXml( AIDA::IHistogram3D& result, const std::string& input ) {
160  return _fromXml( result, input );
161 }
162 StatusCode Gaudi::Utils::Histos::HistoStrings::fromXml( AIDA::IProfile1D& result, const std::string& input ) {
163  return _fromXml( result, input );
164 }
165 StatusCode Gaudi::Utils::Histos::HistoStrings::fromXml( AIDA::IProfile2D& result, const std::string& input ) {
166  return _fromXml( result, input );
167 }
168 // ============================================================================
169 
170 // ============================================================================
171 // The END
172 // ============================================================================
static std::string toXml(const TH1D &histo)
GAUDI_API StatusCode fromXml(TH1D &result, const std::string &input)
parse the histogram from standard ROOT XML
Definition: HistoXML.cpp:187
static StatusCode fromString(TH1D &result, const std::string &input)
parse the histogram from string
std::string toString(const TYPE &obj)
the generic implementation of the type conversion to the string
Definition: ToStream.h:334
StatusCode parse(GaudiUtils::HashMap< K, V > &result, const std::string &input)
Basic parser for the types of HashMap used in DODBasicMapper.
STL class.
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:50
static std::string toString(const TH1D &histo, const bool asXML=false)
convert the histogram into the string
static StatusCode fromXml(TH1D &result, const std::string &input)
GAUDI_API std::ostream & toXml(const TH1D &histo, std::ostream &stream)
stream the ROOT histogram into output stream as XML
Definition: HistoXML.cpp:64
string s
Definition: gaudirun.py:312