The Gaudi Framework  master (82fdf313)
Loading...
Searching...
No Matches
HistoParsers.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 <map>
17#include <memory>
18// =============================================================================
19// AIDA
20// ============================================================================
21#include <AIDA/IHistogram1D.h>
22#include <AIDA/IHistogram2D.h>
23#include <AIDA/IHistogram3D.h>
24// ============================================================================
25// ROOT
26// ============================================================================
27#include <TAxis.h>
28#include <TH1D.h>
29#include <TH1F.h>
30#include <TH2D.h>
31#include <TH2F.h>
32#include <TH3D.h>
33// ============================================================================
34// GaudiKernel
35// ============================================================================
37// ============================================================================
38// local
39// ============================================================================
42#include <GaudiUtils/HistoXML.h>
43// ============================================================================
44// Local
45// ============================================================================
46#include "H1.h"
47// ============================================================================
48namespace Gaudi {
49 // ==========================================================================
50 namespace Parsers {
51 // ========================================================================
57 template <typename Iterator, typename Skipper>
58 class EdgeGrammar : public qi::grammar<Iterator, Edges(), qi::locals<char>, Skipper> {
59 // ======================================================================
60 public:
61 // ======================================================================
62 typedef Edges ResultT;
63 // ======================================================================
64 public:
65 // ======================================================================
66 EdgeGrammar() : EdgeGrammar::base_type( result ) {
67 inner = ( ( qi::lit( "edges" ) | "'edges'" | "\"edges\"" ) >> ":" >> edges[qi::_val *= qi::_1] ) |
68 inner_pairs[qi::_val = qi::_1];
69 inner_pairs = ( ( ( qi::lit( "nbins" ) | "'nbins'" | "\"nbins\"" ) >> ":" >> nbins[qi::_val /= qi::_1] ) |
70 ( ( qi::lit( "low" ) | "'low'" | "\"low\"" ) >> ":" >> low[qi::_val -= qi::_1] ) |
71 ( ( qi::lit( "high" ) | "'high'" | "\"high\"" ) >> ":" >> high[qi::_val += qi::_1] ) ) %
72 ',';
73
74 begin =
75 enc::char_( '[' )[qi::_val = ']'] | enc::char_( '{' )[qi::_val = '}'] | enc::char_( '(' )[qi::_val = ')'];
76 end = enc::char_( qi::_r1 );
77 result = begin[qi::_a = qi::_1] >> inner[qi::_val = qi::_1] >> end( qi::_a );
78 }
82 qi::rule<Iterator, Edges(), qi::locals<char>, Skipper> result;
83 qi::rule<Iterator, Edges(), Skipper> inner, inner_pairs;
84 qi::rule<Iterator, char()> begin;
85 qi::rule<Iterator, void( char )> end;
86 // ======================================================================
87 };
89 // ========================================================================
90 template <typename Iterator, typename Skipper>
91 class H1Grammar : public qi::grammar<Iterator, H1(), qi::locals<char>, Skipper> {
92 // ======================================================================
93 public:
94 // ======================================================================
95 typedef H1 ResultT;
96 // ======================================================================
97 public:
98 // ======================================================================
99 H1Grammar() : H1Grammar::base_type( result ) {
100 inner = ( ( ( qi::lit( "name" ) | "'name'" | "\"name\"" ) >> ":" >> name[qi::_val *= qi::_1] ) |
101 ( ( qi::lit( "title" ) | "'title'" | "\"title\"" ) >> ":" >> title[qi::_val /= qi::_1] ) |
102 ( -( ( qi::lit( "X" ) | "'X'" | "\"X\"" | "x" | "'x'" | "\"x\"" ) >> ':' ) >>
103 edges[qi::_val &= qi::_1] ) |
104 ( ( qi::lit( "nbins" ) | "'nbins'" | "\"nbins\"" ) >> ":" >> nbins[qi::_val |= qi::_1] ) |
105 ( ( qi::lit( "low" ) | "'low'" | "\"low\"" ) >> ":" >> low[qi::_val -= qi::_1] ) |
106 ( ( qi::lit( "high" ) | "'high'" | "\"high\"" ) >> ":" >> high[qi::_val ^= qi::_1] ) |
107 ( ( qi::lit( "bins" ) | "'bins'" | "\"bins\"" ) >> ':' >> bins[qi::_val += qi::_1] ) ) %
108 ',';
109
110 begin =
111 enc::char_( '[' )[qi::_val = ']'] | enc::char_( '{' )[qi::_val = '}'] | enc::char_( '(' )[qi::_val = ')'];
112 end = enc::char_( qi::_r1 );
113 result = ( begin[qi::_a = qi::_1] >> inner[qi::_val = qi::_1] >> end( qi::_a ) ) | inner;
114 }
115
120
122 qi::rule<Iterator, H1(), qi::locals<char>, Skipper> result;
123 qi::rule<Iterator, H1(), Skipper> inner;
124 qi::rule<Iterator, char()> begin;
125 qi::rule<Iterator, void( char )> end;
126 };
128 // ========================================================================
129 template <typename Iterator, typename Skipper>
130 class H2Grammar : public qi::grammar<Iterator, H2(), qi::locals<char>, Skipper> {
131 // ======================================================================
132 public:
133 // ======================================================================
134 typedef H2 ResultT;
135 // ======================================================================
136 public:
137 // ======================================================================
138 H2Grammar() : H2Grammar::base_type( result ) {
139 inner = ( ( ( qi::lit( "name" ) | "'name'" | "\"name\"" ) >> ":" >> name[qi::_val *= qi::_1] ) |
140 ( ( qi::lit( "title" ) | "'title'" | "\"title\"" ) >> ":" >> title[qi::_val /= qi::_1] ) |
141 ( ( qi::lit( "X" ) | "'X'" | "\"X\"" | "x" | "'x'" | "\"x\"" ) >> ':' >> edges[qi::_val &= qi::_1] ) |
142 ( ( qi::lit( "Y" ) | "'Y'" | "\"Y\"" | "y" | "'y'" | "\"y\"" ) >> ':' >> edges[qi::_val |= qi::_1] ) |
143 ( ( qi::lit( "bins" ) | "'bins'" | "\"bins\"" ) >> ':' >> bins[qi::_val += qi::_1] ) ) %
144 ',';
145
146 begin =
147 enc::char_( '[' )[qi::_val = ']'] | enc::char_( '{' )[qi::_val = '}'] | enc::char_( '(' )[qi::_val = ')'];
148 end = enc::char_( qi::_r1 );
149 result = ( begin[qi::_a = qi::_1] >> inner[qi::_val = qi::_1] >> end( qi::_a ) ) | inner[qi::_val = qi::_1];
150 }
151
155 qi::rule<Iterator, H2(), qi::locals<char>, Skipper> result;
156 qi::rule<Iterator, H2(), Skipper> inner;
157 qi::rule<Iterator, char()> begin;
158 qi::rule<Iterator, void( char )> end;
159
160 // ======================================================================
161 };
163 // ========================================================================
164 template <typename Iterator, typename Skipper>
165 class H3Grammar : public qi::grammar<Iterator, H3(), qi::locals<char>, Skipper> {
166 // ======================================================================
167 public:
168 // ======================================================================
169 typedef H3 ResultT;
170 // ======================================================================
171 public:
172 // ======================================================================
173 H3Grammar() : H3Grammar::base_type( result ) {
174 inner = ( ( ( qi::lit( "name" ) | "'name'" | "\"name\"" ) >> ":" >> name[qi::_val *= qi::_1] ) |
175 ( ( qi::lit( "title" ) | "'title'" | "\"title\"" ) >> ":" >> title[qi::_val /= qi::_1] ) |
176 ( ( qi::lit( "X" ) | "'X'" | "\"X\"" | "x" | "'x'" | "\"x\"" ) >> ':' >> edges[qi::_val &= qi::_1] ) |
177 ( ( qi::lit( "Y" ) | "'Y'" | "\"Y\"" | "y" | "'y'" | "\"y\"" ) >> ':' >> edges[qi::_val |= qi::_1] ) |
178 ( ( qi::lit( "Z" ) | "'Z'" | "\"Z\"" | "z" | "'z'" | "\"z\"" ) >> ':' >> edges[qi::_val -= qi::_1] ) |
179 ( ( qi::lit( "bins" ) | "'bins'" | "\"bins\"" ) >> ':' >> bins[qi::_val += qi::_1] ) ) %
180 ',';
181
182 begin =
183 enc::char_( '[' )[qi::_val = ']'] | enc::char_( '{' )[qi::_val = '}'] | enc::char_( '(' )[qi::_val = ')'];
184 end = enc::char_( qi::_r1 );
185 result = ( begin[qi::_a = qi::_1] >> inner[qi::_val = qi::_1] >> end( qi::_a ) ) | inner[qi::_val = qi::_1];
186 }
187
191 qi::rule<Iterator, H3(), qi::locals<char>, Skipper> result;
192 qi::rule<Iterator, H3(), Skipper> inner;
193 qi::rule<Iterator, char()> begin;
194 qi::rule<Iterator, void( char )> end;
195
196 // ======================================================================
197 };
199 // ========================================================================
200 } // namespace Parsers
201 // ==========================================================================
202} // end of namespace Gaudi
203// ============================================================================
204namespace {
205 // ==========================================================================
207 StatusCode _parse( H1& h1, std::string_view input ) {
208 // check the parsing
209 StatusCode sc = Gaudi::Parsers::parse_( h1, input );
210 if ( sc.isFailure() ) { return sc; } // RETURN
211 return h1.ok() ? StatusCode::SUCCESS : StatusCode::FAILURE;
212 }
213 // ==========================================================================
215 StatusCode _parse( H2& h2, std::string_view input ) {
216 // check the parsing
217 StatusCode sc = Gaudi::Parsers::parse_( h2, input );
218 if ( sc.isFailure() ) { return sc; } // RETURN
219 return h2.ok() ? StatusCode::SUCCESS : StatusCode::FAILURE;
220 }
221 // ==========================================================================
223 StatusCode _parse( H3& h3, std::string_view input ) {
224 // check the parsing
225 StatusCode sc = Gaudi::Parsers::parse_( h3, input );
226 if ( sc.isFailure() ) { return sc; } // RETURN
227 return h3.ok() ? StatusCode::SUCCESS : StatusCode::FAILURE;
228 }
229 // ==========================================================================
230 template <class HISTO1>
231 std::unique_ptr<HISTO1> _parse_1D( std::string_view input, std::string& name ) {
232 //
233 typedef std::unique_ptr<HISTO1> H1P;
234 // ==========================================================================
235 // 1) parse the custom format
236 //
237 H1 h1;
238 StatusCode sc = _parse( h1, input );
239 if ( sc.isFailure() || !h1.ok() ) { return H1P(); } // RETURN
240 //
241 // 2) create the histogram
242 //
243 H1P histo( h1.m_edges.edges.empty() ? // FIXED binning?
244 new HISTO1( "", // h1.m_name.c_str () , // NAME
245 h1.m_title.c_str(), // TITLE
246 h1.m_edges.nbins, // #bins
247 h1.m_edges.low, // low edge
248 h1.m_edges.high )
249 : // high edge
250 new HISTO1( "", // h1.m_name .c_str () , // NAME
251 h1.m_title.c_str(), // TITLE
252 h1.m_edges.edges.size() - 1, // #bins
253 &h1.m_edges.edges.front() ) ); // vector of edges
254
255 // fill the histogram
256 for ( unsigned int ibin = 0; ibin < h1.m_bins.size(); ++ibin ) {
257 histo->SetBinContent( ibin, h1.m_bins[ibin].first );
258 histo->SetBinError( ibin, h1.m_bins[ibin].second );
259 }
260 //
261 name = h1.m_name;
262 //
263 return histo;
264 }
265 // ==========================================================================
266 template <class HISTO2>
267 std::unique_ptr<HISTO2> _parse_2D( std::string_view input, std::string& name ) {
268 //
269 typedef std::unique_ptr<HISTO2> H2P;
270 // 1) parse the custom format
271 //
272 H2 h2;
273 StatusCode sc = _parse( h2, input );
274 if ( sc.isFailure() || !h2.ok() ) { return H2P(); } // RETURN
275 //
276 // 2) create the histogram
277 //
278 H2P histo( h2.m_xedges.edges.empty() && h2.m_yedges.edges.empty()
279 ? // FIXED binning?
280 new HISTO2( "", // h1.m_name.c_str () , // NAME
281 h2.m_title.c_str(), // TITLE
282 h2.m_xedges.nbins, // #bins
283 h2.m_xedges.low, // low edge
284 h2.m_xedges.high, // high edge
285 h2.m_yedges.nbins, // #bins
286 h2.m_yedges.low, // low edge
287 h2.m_yedges.high )
288 : h2.m_xedges.edges.empty() && !h2.m_xedges.edges.empty()
289 ? new HISTO2( "", // h1.m_name.c_str () , // NAME
290 h2.m_title.c_str(), // TITLE
291 h2.m_xedges.nbins, // #bins
292 h2.m_xedges.low, // low edge
293 h2.m_xedges.high, // high edge
294 h2.m_yedges.nBins(), // #bins
295 &h2.m_yedges.edges.front() )
296 : // vector of edges
297 !h2.m_xedges.edges.empty() && h2.m_xedges.edges.empty()
298 ? new HISTO2( "", // h1.m_name.c_str () , // NAME
299 h2.m_title.c_str(), // TITLE
300 h2.m_xedges.nBins(), // #bins
301 &h2.m_xedges.edges.front(), // vector of edges
302 h2.m_yedges.nbins, // #bins
303 h2.m_yedges.low, // low edge
304 h2.m_yedges.high )
305 : // high edge
306 new HISTO2( "", // h1.m_name.c_str () , // NAME
307 h2.m_title.c_str(), // TITLE
308 h2.m_xedges.nBins(), // #bins
309 &h2.m_xedges.edges.front(), // vector of edges
310 h2.m_yedges.nBins(), // #bins
311 &h2.m_yedges.edges.front() ) ); // vector of edges
312
313 int ibin = 0;
314 const int xBins = h2.m_xedges.nBins();
315 const int yBins = h2.m_yedges.nBins();
316
317 for ( int jBin = yBins + 1; jBin >= 0; --jBin ) {
318 for ( int iBin = 0; iBin <= xBins + 1; ++iBin ) {
319 histo->SetBinContent( iBin, jBin, h2.m_bins[ibin].first );
320 histo->SetBinError( iBin, jBin, h2.m_bins[ibin].second );
321 ++ibin;
322 }
323 }
324 //
325 name = h2.m_name;
326 //
327 return histo;
328 }
329 // ==========================================================================
330 template <class HISTO3>
331 std::unique_ptr<HISTO3> _parse_3D( std::string_view input, std::string& name ) {
332 //
333 typedef std::unique_ptr<HISTO3> H3P;
334 // 1) parse the custom format
335 //
336 H3 h3;
337 StatusCode sc = _parse( h3, input );
338 if ( sc.isFailure() || !h3.ok() ) { return H3P(); } // RETURN
339 //
340 // 2) create the histogram
341 //
342 H3P histo( h3.m_xedges.edges.empty() || h3.m_yedges.edges.empty() || h3.m_zedges.edges.empty() ? // FIXED binning?
343 new HISTO3( "", // h3.m_name.c_str () , // NAME
344 h3.m_title.c_str(), // TITLE
345 h3.m_xedges.nbins, // #bins
346 h3.m_xedges.low, // low edge
347 h3.m_xedges.high, // high edge
348 h3.m_yedges.nbins, // #bins
349 h3.m_yedges.low, // low edge
350 h3.m_yedges.high, // high edge
351 h3.m_zedges.nbins, // #bins
352 h3.m_zedges.low, // low edge
353 h3.m_zedges.high )
354 : // high edge
355 new HISTO3( "", // h3.m_name.c_str () , // NAME
356 h3.m_title.c_str(), // TITLE
357 h3.m_xedges.nBins(), // #bins
358 &h3.m_xedges.edges.front(), // vector of edges
359 h3.m_yedges.nBins(), // #bins
360 &h3.m_yedges.edges.front(), h3.m_zedges.nBins(),
361 &h3.m_zedges.edges.front() ) ); // vector of edges
362
363 int ibin = 0;
364 const int xBins = h3.m_xedges.nBins();
365 const int yBins = h3.m_yedges.nBins();
366 const int zBins = h3.m_yedges.nBins();
367
368 for ( int kBin = 0; kBin <= zBins + 1; ++kBin ) {
369 for ( int jBin = yBins + 1; jBin >= 0; --jBin ) {
370 for ( int iBin = 0; iBin <= xBins + 1; ++iBin ) {
371 histo->SetBinContent( iBin, jBin, kBin, h3.m_bins[ibin].first );
372 histo->SetBinError( iBin, jBin, kBin, h3.m_bins[ibin].second );
373 ++ibin;
374 }
375 }
376 }
377 //
378 name = h3.m_name;
379 //
380 return histo;
381 }
382 // ==========================================================================
383} // end of anonymous namespace
384// ============================================================================
385/* parse ROOT histogram from text representation
386 * @param result (OUTPUT) the histogram
387 * @param input (INPUT) the input to be parsed
388 * @return status code
389 */
390// ============================================================================
391StatusCode Gaudi::Parsers::parse( TH1D& result, std::string_view input ) {
392 // 1) check the parsing
393 std::string name;
394 //
395 auto h1 = _parse_1D<TH1D>( input, name );
396 if ( h1 ) {
397 result.Reset();
398 h1->Copy( result ); // ASSIGN
399 result.SetName( name.c_str() );
400 return StatusCode::SUCCESS; // RETURN
401 }
402 //
403 // XML-like text?
404 return ( std::string::npos != input.find( '<' ) ) ? Gaudi::Utils::Histos::fromXml( result, input )
406}
407// ============================================================================
408/* parse ROOT histogram from text representation
409 * @param result (OUTPUT) the histogram
410 * @param input (INPUT) the input to be parsed
411 * @return status code
412 */
413// ============================================================================
414StatusCode Gaudi::Parsers::parse( TH1F& result, std::string_view input ) {
415 // 1) check the parsing
416 std::string name;
417 //
418 auto h1 = _parse_1D<TH1F>( input, name );
419 if ( h1 ) {
420 result.Reset();
421 h1->Copy( result ); // ASSIGN
422 result.SetName( name.c_str() );
423 return StatusCode::SUCCESS; // RETURN
424 }
425 //
426 // XML-like text?
427 return ( std::string::npos != input.find( '<' ) ) ? Gaudi::Utils::Histos::fromXml( result, input )
429}
430// ============================================================================
431/* parse ROOT histogram from text representation
432 * @param result (OUTPUT) the histogram
433 * @param input (INPUT) the input to be parsed
434 * @return status code
435 */
436// ============================================================================
437StatusCode Gaudi::Parsers::parse( TH2D& result, std::string_view input ) {
438 // 1) check the parsing
439 std::string name;
440 auto h2 = _parse_2D<TH2D>( input, name );
441 if ( h2 ) {
442 result.Reset();
443 h2->Copy( result ); // ASSIGN
444 result.SetName( name.c_str() );
445 return StatusCode::SUCCESS; // RETURN
446 }
447 //
448 // XML-like text?
449 return ( std::string::npos != input.find( '<' ) ) ? Gaudi::Utils::Histos::fromXml( result, input )
451}
452// ============================================================================
453/* parse ROOT histogram from text representation
454 * @param result (OUTPUT) the histogram
455 * @param input (INPUT) the input to be parsed
456 * @return status code
457 */
458// ============================================================================
459StatusCode Gaudi::Parsers::parse( TH2F& result, std::string_view input ) {
460 // 1) check the parsing
461 std::string name;
462 auto h2 = _parse_2D<TH2F>( input, name );
463 if ( h2 ) {
464 result.Reset();
465 h2->Copy( result ); // ASSIGN
466 result.SetName( name.c_str() );
467 return StatusCode::SUCCESS; // RETURN
468 }
469 //
470 // XML-like text?
471 if ( std::string::npos != input.find( '<' ) ) { return Gaudi::Utils::Histos::fromXml( result, input ); }
472 //
473 return StatusCode::FAILURE;
474}
475// ============================================================================
476/* parse ROOT histogram from text representation
477 * @param result (OUTPUT) the histogram
478 * @param input (INPUT) the input to be parsed
479 * @return status code
480 */
481// ============================================================================
482StatusCode Gaudi::Parsers::parse( TH3D& result, std::string_view input ) {
483 // 1) check the parsing
484 std::string name;
485 auto h3 = _parse_3D<TH3D>( input, name );
486 if ( h3 ) {
487 result.Reset();
488 h3->Copy( result ); // ASSIGN
489 result.SetName( name.c_str() );
490 return StatusCode::SUCCESS; // RETURN
491 }
492 //
493 // XML-like text?
494 return ( std::string::npos != input.find( '<' ) ) ? Gaudi::Utils::Histos::fromXml( result, input )
496}
497// ============================================================================
498/* parse ROOT histogram from text representation
499 * @param result (OUTPUT) the histogram
500 * @param input (INPUT) the input to be parsed
501 * @return status code
502 */
503// ============================================================================
504StatusCode Gaudi::Parsers::parse( TH3F& result, std::string_view input ) {
505 // 1) check the parsing
506 std::string name;
507 auto h3 = _parse_3D<TH3F>( input, name );
508 if ( h3 ) {
509 result.Reset();
510 h3->Copy( result ); // ASSIGN
511 result.SetName( name.c_str() );
512 return StatusCode::SUCCESS; // RETURN
513 }
514 //
515 // XML-like text?
516 if ( std::string::npos != input.find( '<' ) ) { return Gaudi::Utils::Histos::fromXml( result, input ); }
517 //
518 return StatusCode::FAILURE;
519}
520// ============================================================================
521/* parse ROOT histogram from text representation
522 * @param result (OUTPUT) the histogram
523 * @param input (INPUT) the input to be parsed
524 * @return status code
525 */
526// ============================================================================
527StatusCode Gaudi::Parsers::parse( TH1D*& result, std::string_view input ) {
528 if ( result ) { return parse( *result, input ); } // RETURN
529
530 // 1) check the parsing
531 std::string name;
532 auto h1 = _parse_1D<TH1D>( input, name );
533 if ( h1 ) {
534 result = h1.release();
535 result->SetName( name.c_str() );
536 return StatusCode::SUCCESS; // RETURN
537 }
538 //
539 // XML-like text?
540 return ( std::string::npos != input.find( '<' ) ) ? Gaudi::Utils::Histos::fromXml( result, input )
542}
543// ============================================================================
544/* parse ROOT histogram from text representation
545 * @param result (OUTPUT) the histogram
546 * @param input (INPUT) the input to be parsed
547 * @return status code
548 */
549// ============================================================================
550StatusCode Gaudi::Parsers::parse( TH2D*& result, std::string_view input ) {
551 if ( result ) { return parse( *result, input ); } // RETURN
552
553 // 1) check the parsing
554 std::string name;
555 auto h2 = _parse_2D<TH2D>( input, name );
556 if ( h2 ) {
557 result = h2.release();
558 result->SetName( name.c_str() );
559 return StatusCode::SUCCESS; // RETURN
560 }
561 //
562 // XML-like text?
563 return ( std::string::npos != input.find( '<' ) ) ? Gaudi::Utils::Histos::fromXml( result, input )
565}
566// ============================================================================
567/* parse ROOT histogram from text representation
568 * @param result (OUTPUT) the histogram
569 * @param input (INPUT) the input to be parsed
570 * @return status code
571 */
572// ============================================================================
573StatusCode Gaudi::Parsers::parse( TH3D*& result, std::string_view input ) {
574 if ( result ) { return parse( *result, input ); } // RETURN
575
576 // 1) check the parsing
577 std::string name;
578 auto h3 = _parse_3D<TH3D>( input, name );
579 if ( h3 ) {
580 result = h3.release();
581 result->SetName( name.c_str() );
582 return StatusCode::SUCCESS; // RETURN
583 }
584 //
585 // XML-like text?
586 return ( std::string::npos != input.find( '<' ) ) ? Gaudi::Utils::Histos::fromXml( result, input )
588}
589// ============================================================================
590/* parse AIDA histogram from text representation
591 * @param result (OUTPUT) the histogram
592 * @param input (INPUT) the input to be parsed
593 * @return status code
594 */
595// ============================================================================
596StatusCode Gaudi::Parsers::parse( AIDA::IHistogram1D& result, std::string_view input ) {
597 // 1) convert to ROOT
598 auto root = Gaudi::Utils::Aida2ROOT::aida2root( &result );
599 // 2) read ROOT histogram
600 return root ? parse( *root, input ) : StatusCode::FAILURE;
601}
602// ============================================================================
603/* parse AIDA histogram from text representation
604 * @param result (OUTPUT) the histogram
605 * @param input (INPUT) the input to be parsed
606 * @return status code
607 */
608// ============================================================================
609StatusCode Gaudi::Parsers::parse( AIDA::IHistogram2D& result, std::string_view input ) {
610 // 1) convert to ROOT
611 auto root = Gaudi::Utils::Aida2ROOT::aida2root( &result );
612 // 2) read ROOT histogram
613 return root ? parse( *root, input ) : StatusCode::FAILURE;
614}
615// ============================================================================
616/* parse AIDA histogram from text representation
617 * @param result (OUTPUT) the histogram
618 * @param input (INPUT) the input to be parsed
619 * @return status code
620 */
621// ============================================================================
622StatusCode Gaudi::Parsers::parse( AIDA::IHistogram3D& result, std::string_view input ) {
623 // 1) convert to ROOT
624 auto root = Gaudi::Utils::Aida2ROOT::aida2root( &result );
625 // 2) read ROOT histogram
626 return root ? parse( *root, input ) : StatusCode::FAILURE;
627}
628// ============================================================================
629// The END
630// ============================================================================
StatusCode parse(DataObjID &dest, std::string_view src)
Definition DataObjID.cpp:58
#define REGISTER_GRAMMAR(ResultType, GrammarName)
Definition Grammars.h:71
boost::spirit::classic::position_iterator2< ForwardIterator > Iterator
Definition Iterator.h:18
VectorGrammar< Iterator, std::vector< double >, Skipper > edges
qi::rule< Iterator, Edges(), qi::locals< char >, Skipper > result
qi::rule< Iterator, Edges(), Skipper > inner
qi::rule< Iterator, void(char)> end
RealGrammar< Iterator, double, Skipper > high
RealGrammar< Iterator, double, Skipper > low
qi::rule< Iterator, Edges(), Skipper > inner_pairs
IntGrammar< Iterator, unsigned int, Skipper > nbins
qi::rule< Iterator, char()> begin
VectorGrammar< Iterator, std::vector< std::pair< double, double > >, Skipper > bins
qi::rule< Iterator, H1(), Skipper > inner
StringGrammar< Iterator, Skipper > name
RealGrammar< Iterator, double, Skipper > low
IntGrammar< Iterator, unsigned int, Skipper > nbins
qi::rule< Iterator, char()> begin
qi::rule< Iterator, void(char)> end
RealGrammar< Iterator, double, Skipper > high
qi::rule< Iterator, H1(), qi::locals< char >, Skipper > result
EdgeGrammar< Iterator, Skipper > edges
StringGrammar< Iterator, Skipper > title
StringGrammar< Iterator, Skipper > name
StringGrammar< Iterator, Skipper > title
VectorGrammar< Iterator, std::vector< std::pair< double, double > >, Skipper > bins
qi::rule< Iterator, void(char)> end
qi::rule< Iterator, H2(), qi::locals< char >, Skipper > result
qi::rule< Iterator, char()> begin
qi::rule< Iterator, H2(), Skipper > inner
EdgeGrammar< Iterator, Skipper > edges
VectorGrammar< Iterator, std::vector< std::pair< double, double > >, Skipper > bins
qi::rule< Iterator, H3(), qi::locals< char >, Skipper > result
StringGrammar< Iterator, Skipper > name
qi::rule< Iterator, char()> begin
qi::rule< Iterator, H3(), Skipper > inner
StringGrammar< Iterator, Skipper > title
qi::rule< Iterator, void(char)> end
EdgeGrammar< Iterator, Skipper > edges
static TH1D * aida2root(AIDA::IHistogram1D *aida)
get the underlying pointer for 1D-histogram
Definition Aida2ROOT.cpp:60
This class is used for returning status codes from appropriate routines.
Definition StatusCode.h:64
bool isFailure() const
Definition StatusCode.h:129
constexpr static const auto SUCCESS
Definition StatusCode.h:99
constexpr static const auto FAILURE
Definition StatusCode.h:100
SkipperGrammar< IteratorT > Skipper
Definition Factory.h:24
StatusCode parse(GaudiUtils::HashMap< K, V > &result, std::string_view input)
Basic parser for the types of HashMap used in DODBasicMapper.
StatusCode parse_(ResultT &result, std::string_view input)
Definition Factory.h:26
GAUDI_API StatusCode fromXml(TH1D &result, std::string_view input)
parse the histogram from standard ROOT XML
Definition HistoXML.cpp:199
This file provides a Grammar for the type Gaudi::Accumulators::Axis It allows to use that type from p...
Definition __init__.py:1