The Gaudi Framework
master (6507eef1)
Toggle main menu visibility
Loading...
Searching...
No Matches
HistoStrings.cpp
Go to the documentation of this file.
1
/***********************************************************************************\
2
* (c) Copyright 1998-2024 CERN for the benefit of the LHCb and ATLAS collaborations *
3
* *
4
* This software is distributed under the terms of the Apache version 2 licence, *
5
* copied verbatim in the file "LICENSE". *
6
* *
7
* In applying this licence, CERN does not waive the privileges and immunities *
8
* granted to it by virtue of its status as an Intergovernmental Organization *
9
* or submit itself to any jurisdiction. *
10
\***********************************************************************************/
11
// ============================================================================
12
// Include files
13
// ============================================================================
14
// STD & STL
15
// ============================================================================
16
#include <sstream>
17
// ============================================================================
18
// local
19
// ============================================================================
20
#include <
GaudiUtils/Histo2String.h
>
21
#include <
GaudiUtils/HistoParsers.h
>
22
#include <
GaudiUtils/HistoStrings.h
>
23
#include <
GaudiUtils/HistoXML.h
>
24
// ============================================================================
30
// ============================================================================
31
/* convert the histogram into the string
32
* @param histo (INPUT) the histogram to be streamed
33
* @param asXML (INPUT) use XML-format
34
* @return the string representation of the histogram
35
* @author Vanya BELYAEV Ivan.Belyaev@nikhef.nl
36
* @date 2009-09-26
37
*/
38
// ============================================================================
39
std::string
Gaudi::Utils::Histos::HistoStrings::toString
(
const
TH1D& histo,
const
bool
asXML ) {
40
return
Gaudi::Utils::toString
( histo, asXML );
41
}
42
// ============================================================================
43
/* convert the histogram into the string
44
* @param histo (INPUT) the histogram to be streamed
45
* @param asXML (INPUT) use XML-format
46
* @return the string representation of the histogram
47
* @author Vanya BELYAEV Ivan.Belyaev@nikhef.nl
48
* @date 2009-09-26
49
*/
50
// ============================================================================
51
std::string
Gaudi::Utils::Histos::HistoStrings::toString
(
const
TH2D& histo,
const
bool
asXML ) {
52
return
Gaudi::Utils::toString
( histo, asXML );
53
}
54
// ============================================================================
55
/* convert the histogram into the string
56
* @param histo (INPUT) the histogram to be streamed
57
* @param asXML (INPUT) use XML-format
58
* @return the string representation of the histogram
59
* @author Vanya BELYAEV Ivan.Belyaev@nikhef.nl
60
* @date 2009-09-26
61
*/
62
// ============================================================================
63
std::string
Gaudi::Utils::Histos::HistoStrings::toString
(
const
AIDA::IHistogram1D& histo,
const
bool
asXML ) {
64
return
Gaudi::Utils::toString
( histo, asXML );
65
}
66
// ============================================================================
67
/* convert the histogram into the string
68
* @param histo (INPUT) the histogram to be streamed
69
* @param asXML (INPUT) use XML-format
70
* @return the string representation of the histogram
71
* @author Vanya BELYAEV Ivan.Belyaev@nikhef.nl
72
* @date 2009-09-26
73
*/
74
// ============================================================================
75
std::string
Gaudi::Utils::Histos::HistoStrings::toString
(
const
AIDA::IHistogram2D& histo,
const
bool
asXML ) {
76
return
Gaudi::Utils::toString
( histo, asXML );
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
// ============================================================================
85
StatusCode
Gaudi::Utils::Histos::HistoStrings::fromString
( TH1D& result,
const
std::string& input ) {
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 string
92
* @return status code
93
*/
94
// ============================================================================
95
StatusCode
Gaudi::Utils::Histos::HistoStrings::fromString
( TH2D& 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::IHistogram1D& result,
const
std::string& input ) {
106
return
Gaudi::Parsers::parse
( result, input );
107
}
108
// ============================================================================
109
/* parse the histogram from string
110
* @param result (OUTPUT) the parsed histogram
111
* @param input (INPUT) the input XML string
112
* @return status code
113
*/
114
// ============================================================================
115
StatusCode
Gaudi::Utils::Histos::HistoStrings::fromString
( AIDA::IHistogram2D& result,
const
std::string& input ) {
116
return
Gaudi::Parsers::parse
( result, input );
117
}
118
// ============================================================================
119
namespace
{
120
// ==========================================================================
121
template
<
class
TYPE>
122
std::string _toXml(
const
TYPE&
object
) {
123
std::ostringstream s;
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
return
Gaudi::Utils::Histos::fromXml
(
object
, input );
131
}
132
// ==========================================================================
133
}
// end of anonymous namespace
134
// ============================================================================
135
std::string
Gaudi::Utils::Histos::HistoStrings::toXml
(
const
TH1D& histo ) {
return
_toXml( histo ); }
136
std::string
Gaudi::Utils::Histos::HistoStrings::toXml
(
const
TH2D& histo ) {
return
_toXml( histo ); }
137
std::string
Gaudi::Utils::Histos::HistoStrings::toXml
(
const
TH3D& histo ) {
return
_toXml( histo ); }
138
std::string
Gaudi::Utils::Histos::HistoStrings::toXml
(
const
TProfile& histo ) {
return
_toXml( histo ); }
139
std::string
Gaudi::Utils::Histos::HistoStrings::toXml
(
const
TProfile2D& histo ) {
return
_toXml( histo ); }
140
// ============================================================================
141
std::string
Gaudi::Utils::Histos::HistoStrings::toXml
(
const
AIDA::IHistogram1D& histo ) {
return
_toXml( histo ); }
142
std::string
Gaudi::Utils::Histos::HistoStrings::toXml
(
const
AIDA::IHistogram2D& histo ) {
return
_toXml( histo ); }
143
std::string
Gaudi::Utils::Histos::HistoStrings::toXml
(
const
AIDA::IHistogram3D& histo ) {
return
_toXml( histo ); }
144
std::string
Gaudi::Utils::Histos::HistoStrings::toXml
(
const
AIDA::IProfile1D& histo ) {
return
_toXml( histo ); }
145
std::string
Gaudi::Utils::Histos::HistoStrings::toXml
(
const
AIDA::IProfile2D& histo ) {
return
_toXml( histo ); }
146
// ============================================================================
147
StatusCode
Gaudi::Utils::Histos::HistoStrings::fromXml
( TH1D& result,
const
std::string& input ) {
148
return
_fromXml( result, input );
149
}
150
StatusCode
Gaudi::Utils::Histos::HistoStrings::fromXml
( TH2D& result,
const
std::string& input ) {
151
return
_fromXml( result, input );
152
}
153
StatusCode
Gaudi::Utils::Histos::HistoStrings::fromXml
( TH3D& result,
const
std::string& input ) {
154
return
_fromXml( result, input );
155
}
156
StatusCode
Gaudi::Utils::Histos::HistoStrings::fromXml
( TProfile& result,
const
std::string& input ) {
157
return
_fromXml( result, input );
158
}
159
StatusCode
Gaudi::Utils::Histos::HistoStrings::fromXml
( TProfile2D& result,
const
std::string& input ) {
160
return
_fromXml( result, input );
161
}
162
// ============================================================================
163
StatusCode
Gaudi::Utils::Histos::HistoStrings::fromXml
( AIDA::IHistogram1D& result,
const
std::string& input ) {
164
return
_fromXml( result, input );
165
}
166
StatusCode
Gaudi::Utils::Histos::HistoStrings::fromXml
( AIDA::IHistogram2D& result,
const
std::string& input ) {
167
return
_fromXml( result, input );
168
}
169
StatusCode
Gaudi::Utils::Histos::HistoStrings::fromXml
( AIDA::IHistogram3D& result,
const
std::string& input ) {
170
return
_fromXml( result, input );
171
}
172
StatusCode
Gaudi::Utils::Histos::HistoStrings::fromXml
( AIDA::IProfile1D& result,
const
std::string& input ) {
173
return
_fromXml( result, input );
174
}
175
StatusCode
Gaudi::Utils::Histos::HistoStrings::fromXml
( AIDA::IProfile2D& result,
const
std::string& input ) {
176
return
_fromXml( result, input );
177
}
178
// ============================================================================
179
180
// ============================================================================
181
// The END
182
// ============================================================================
Histo2String.h
HistoParsers.h
HistoStrings.h
HistoXML.h
Gaudi::Utils::Histos::HistoStrings::fromString
static StatusCode fromString(TH1D &result, const std::string &input)
parse the histogram from string
Definition
HistoStrings.cpp:85
Gaudi::Utils::Histos::HistoStrings::toString
static std::string toString(const TH1D &histo, const bool asXML=false)
convert the histogram into the string
Definition
HistoStrings.cpp:39
Gaudi::Utils::Histos::HistoStrings::fromXml
static StatusCode fromXml(TH1D &result, const std::string &input)
Definition
HistoStrings.cpp:147
Gaudi::Utils::Histos::HistoStrings::toXml
static std::string toXml(const TH1D &histo)
Definition
HistoStrings.cpp:135
StatusCode
This class is used for returning status codes from appropriate routines.
Definition
StatusCode.h:64
Gaudi::Parsers::parse
StatusCode parse(GaudiUtils::HashMap< K, V > &result, std::string_view input)
Basic parser for the types of HashMap used in DODBasicMapper.
Definition
DODBasicMapper.cpp:21
Gaudi::Utils::Histos::fromXml
GAUDI_API StatusCode fromXml(TH1D &result, std::string_view input)
parse the histogram from standard ROOT XML
Definition
HistoXML.cpp:199
Gaudi::Utils::Histos::toXml
GAUDI_API std::ostream & toXml(const TH1D &histo, std::ostream &stream)
stream the ROOT histogram into output stream as XML
Definition
HistoXML.cpp:76
Gaudi::Utils::toString
std::string toString(const TYPE &obj)
the generic implementation of the type conversion to the string
Definition
ToStream.h:329
GaudiUtils
src
Lib
HistoStrings.cpp
Generated on
for The Gaudi Framework by
1.17.0