The Gaudi Framework  v29r0 (ff2e7097)
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 {
31  return Gaudi::Utils::toString( histo, asXML );
32 }
33 // ============================================================================
34 /* convert the histogram into the string
35  * @param histo (INPUT) the histogram to be streamed
36  * @param asXML (INPUT) use XML-format
37  * @return the string representation of the histogram
38  * @author Vanya BELYAEV Ivan.Belyaev@nikhef.nl
39  * @date 2009-09-26
40  */
41 // ============================================================================
42 std::string Gaudi::Utils::Histos::HistoStrings::toString( const TH2D& histo, const bool asXML )
43 {
44  return Gaudi::Utils::toString( histo, asXML );
45 }
46 // ============================================================================
47 /* convert the histogram into the string
48  * @param histo (INPUT) the histogram to be streamed
49  * @param asXML (INPUT) use XML-format
50  * @return the string representation of the histogram
51  * @author Vanya BELYAEV Ivan.Belyaev@nikhef.nl
52  * @date 2009-09-26
53  */
54 // ============================================================================
55 std::string Gaudi::Utils::Histos::HistoStrings::toString( const AIDA::IHistogram1D& histo, const bool asXML )
56 {
57  return Gaudi::Utils::toString( histo, asXML );
58 }
59 // ============================================================================
60 /* convert the histogram into the string
61  * @param histo (INPUT) the histogram to be streamed
62  * @param asXML (INPUT) use XML-format
63  * @return the string representation of the histogram
64  * @author Vanya BELYAEV Ivan.Belyaev@nikhef.nl
65  * @date 2009-09-26
66  */
67 // ============================================================================
68 std::string Gaudi::Utils::Histos::HistoStrings::toString( const AIDA::IHistogram2D& histo, const bool asXML )
69 {
70  return Gaudi::Utils::toString( histo, asXML );
71 }
72 // ============================================================================
73 /* parse the histogram from string
74  * @param result (OUTPUT) the parsed histogram
75  * @param input (INPUT) the input string
76  * @return status code
77  */
78 // ============================================================================
80 {
81  return Gaudi::Parsers::parse( result, input );
82 }
83 // ============================================================================
84 /* parse the histogram from string
85  * @param result (OUTPUT) the parsed histogram
86  * @param input (INPUT) the input string
87  * @return status code
88  */
89 // ============================================================================
91 {
92  return Gaudi::Parsers::parse( result, input );
93 }
94 // ============================================================================
95 /* parse the histogram from string
96  * @param result (OUTPUT) the parsed histogram
97  * @param input (INPUT) the input XML string
98  * @return status code
99  */
100 // ============================================================================
101 StatusCode Gaudi::Utils::Histos::HistoStrings::fromString( AIDA::IHistogram1D& result, const std::string& input )
102 {
103  return Gaudi::Parsers::parse( result, input );
104 }
105 // ============================================================================
106 /* parse the histogram from string
107  * @param result (OUTPUT) the parsed histogram
108  * @param input (INPUT) the input XML string
109  * @return status code
110  */
111 // ============================================================================
112 StatusCode Gaudi::Utils::Histos::HistoStrings::fromString( AIDA::IHistogram2D& result, const std::string& input )
113 {
114  return Gaudi::Parsers::parse( result, input );
115 }
116 // ============================================================================
117 namespace
118 {
119  // ==========================================================================
120  template <class TYPE>
121  std::string _toXml( const TYPE& object )
122  {
124  Gaudi::Utils::Histos::toXml( object, s );
125  return s.str();
126  }
127  // ==========================================================================
128  template <class TYPE>
129  StatusCode _fromXml( TYPE& object, const std::string& input )
130  {
131  return Gaudi::Utils::Histos::fromXml( object, input );
132  }
133  // ==========================================================================
134 } // end of anonymous namespace
135 // ============================================================================
136 std::string Gaudi::Utils::Histos::HistoStrings::toXml( const TH1D& histo ) { return _toXml( histo ); }
137 std::string Gaudi::Utils::Histos::HistoStrings::toXml( const TH2D& histo ) { return _toXml( histo ); }
138 std::string Gaudi::Utils::Histos::HistoStrings::toXml( const TH3D& histo ) { return _toXml( histo ); }
139 std::string Gaudi::Utils::Histos::HistoStrings::toXml( const TProfile& histo ) { return _toXml( histo ); }
140 std::string Gaudi::Utils::Histos::HistoStrings::toXml( const TProfile2D& histo ) { return _toXml( histo ); }
141 // ============================================================================
142 std::string Gaudi::Utils::Histos::HistoStrings::toXml( const AIDA::IHistogram1D& histo ) { return _toXml( histo ); }
143 std::string Gaudi::Utils::Histos::HistoStrings::toXml( const AIDA::IHistogram2D& histo ) { return _toXml( histo ); }
144 std::string Gaudi::Utils::Histos::HistoStrings::toXml( const AIDA::IHistogram3D& histo ) { return _toXml( histo ); }
145 std::string Gaudi::Utils::Histos::HistoStrings::toXml( const AIDA::IProfile1D& histo ) { return _toXml( histo ); }
146 std::string Gaudi::Utils::Histos::HistoStrings::toXml( const AIDA::IProfile2D& histo ) { return _toXml( histo ); }
147 // ============================================================================
149 {
150  return _fromXml( result, input );
151 }
153 {
154  return _fromXml( result, input );
155 }
157 {
158  return _fromXml( result, input );
159 }
161 {
162  return _fromXml( result, input );
163 }
165 {
166  return _fromXml( result, input );
167 }
168 // ============================================================================
169 StatusCode Gaudi::Utils::Histos::HistoStrings::fromXml( AIDA::IHistogram1D& result, const std::string& input )
170 {
171  return _fromXml( result, input );
172 }
173 StatusCode Gaudi::Utils::Histos::HistoStrings::fromXml( AIDA::IHistogram2D& result, const std::string& input )
174 {
175  return _fromXml( result, input );
176 }
177 StatusCode Gaudi::Utils::Histos::HistoStrings::fromXml( AIDA::IHistogram3D& result, const std::string& input )
178 {
179  return _fromXml( result, input );
180 }
181 StatusCode Gaudi::Utils::Histos::HistoStrings::fromXml( AIDA::IProfile1D& result, const std::string& input )
182 {
183  return _fromXml( result, input );
184 }
185 StatusCode Gaudi::Utils::Histos::HistoStrings::fromXml( AIDA::IProfile2D& result, const std::string& input )
186 {
187  return _fromXml( result, input );
188 }
189 // ============================================================================
190 
191 // ============================================================================
192 // The END
193 // ============================================================================
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:202
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:346
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:28
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:66
string s
Definition: gaudirun.py:253