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 // ============================================================================
30 ( const TH1D& histo ,
31  const bool asXML )
32 { return Gaudi::Utils::toString ( histo , asXML ) ; }
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 // ============================================================================
43 ( const TH2D& histo ,
44  const bool asXML )
45 { return Gaudi::Utils::toString ( histo , asXML ) ; }
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 // ============================================================================
56 ( const AIDA::IHistogram1D& histo ,
57  const bool asXML )
58 { return Gaudi::Utils::toString ( histo , asXML ) ; }
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 // ============================================================================
69 ( const AIDA::IHistogram2D& histo ,
70  const bool asXML )
71 { return Gaudi::Utils::toString ( histo , asXML ) ; }
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 ( TH1D& result , const std::string& input )
81 { return Gaudi::Parsers::parse ( result , input ) ; }
82 // ============================================================================
83 /* parse the histogram from string
84  * @param result (OUTPUT) the parsed histogram
85  * @param input (INPUT) the input string
86  * @return status code
87  */
88 // ============================================================================
90 ( TH2D& result , const std::string& input )
91 { return Gaudi::Parsers::parse ( result , input ) ; }
92 // ============================================================================
93 /* parse the histogram from string
94  * @param result (OUTPUT) the parsed histogram
95  * @param input (INPUT) the input XML string
96  * @return status code
97  */
98 // ============================================================================
100 ( AIDA::IHistogram1D& result , const std::string& input )
101 { return Gaudi::Parsers::parse ( result , input ) ; }
102 // ============================================================================
103 /* parse the histogram from string
104  * @param result (OUTPUT) the parsed histogram
105  * @param input (INPUT) the input XML string
106  * @return status code
107  */
108 // ============================================================================
110 ( AIDA::IHistogram2D& result , const std::string& input )
111 { return Gaudi::Parsers::parse ( result , input ) ; }
112 // ============================================================================
113 namespace
114 {
115  // ==========================================================================
116  template <class TYPE>
117  std::string _toXml ( const TYPE& object )
118  {
120  Gaudi::Utils::Histos::toXml ( object , s ) ;
121  return s.str() ;
122  }
123  // ==========================================================================
124  template <class TYPE>
125  StatusCode _fromXml ( TYPE& object , const std::string& input )
126  {
127  return Gaudi::Utils::Histos::fromXml ( object , input ) ;
128  }
129  // ==========================================================================
130 } // end of anonymous namespace
131 // ============================================================================
133 ( const TH1D& histo ) { return _toXml ( histo ) ; }
135 ( const TH2D& histo ) { return _toXml ( histo ) ; }
137 ( const TH3D& histo ) { return _toXml ( histo ) ; }
139 ( const TProfile& histo ) { return _toXml ( histo ) ; }
141 ( const TProfile2D& histo ) { return _toXml ( histo ) ; }
142 // ============================================================================
144 ( const AIDA::IHistogram1D& histo ) { return _toXml ( histo ) ; }
146 ( const AIDA::IHistogram2D& histo ) { return _toXml ( histo ) ; }
148 ( const AIDA::IHistogram3D& histo ) { return _toXml ( histo ) ; }
150 ( const AIDA::IProfile1D& histo ) { return _toXml ( histo ) ; }
152 ( const AIDA::IProfile2D& histo ) { return _toXml ( histo ) ; }
153 // ============================================================================
155 ( TH1D& result , const std::string& input )
156 { return _fromXml ( result , input ) ; }
158 ( TH2D& result , const std::string& input )
159 { return _fromXml ( result , input ) ; }
161 ( TH3D& result , const std::string& input )
162 { return _fromXml ( result , input ) ; }
164 ( TProfile& result , const std::string& input )
165 { return _fromXml ( result , input ) ; }
167 ( TProfile2D& result , const std::string& input )
168 { return _fromXml ( result , input ) ; }
169 // ============================================================================
171 ( AIDA::IHistogram1D& result , const std::string& input )
172 { return _fromXml ( result , input ) ; }
174 ( AIDA::IHistogram2D& result , const std::string& input )
175 { return _fromXml ( result , input ) ; }
177 ( AIDA::IHistogram3D& result , const std::string& input )
178 { return _fromXml ( result , input ) ; }
180 ( AIDA::IProfile1D& result , const std::string& input )
181 { return _fromXml ( result , input ) ; }
183 ( AIDA::IProfile2D& result , const std::string& input )
184 { return _fromXml ( result , input ) ; }
185 // ============================================================================
186 
187 
188 
189 
190 // ============================================================================
191 // The END
192 // ============================================================================
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:229
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:367
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:26
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:67
string s
Definition: gaudirun.py:245