Loading [MathJax]/extensions/tex2jax.js
The Gaudi Framework  master (d98a2936)
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
ParsersVct.cpp
Go to the documentation of this file.
1 /***********************************************************************************\
2 * (c) Copyright 1998-2025 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 #include <Gaudi/Parsers/Factory.h>
12 #include <GaudiKernel/ToStream.h>
14 
15 namespace {
16  typedef std::map<std::string, double> MAP;
17 
18  template <unsigned int N>
19  inline MAP::const_iterator find( const MAP& m, const std::string ( &keys )[N] ) {
20  for ( unsigned int i = 0; i < N; ++i ) {
21  auto found = m.find( keys[i] );
22  if ( m.end() != found ) { return found; }
23  }
24  return m.end();
25  }
26 } // namespace
27 namespace Gaudi {
28  namespace Parsers {
29  template <typename T1, typename T2>
30  inline StatusCode parse_( ROOT::Math::PositionVector3D<T1, T2>& result, std::string_view input ) {
31  Skipper skipper;
33  IteratorT iter = input.begin(), end = input.end();
34  if ( qi::phrase_parse( iter, end, g, skipper, result ) ) { return StatusCode::SUCCESS; }
35  //@attention always
36  return StatusCode::SUCCESS;
37  }
38 
39  StatusCode parse( Gaudi::XYZPoint& result, std::string_view input ) { return parse_( result, input ); }
40 
41  /* parse 3D-vector
42  * @param result (output) the parsed vector
43  * @param input (input) the input string
44  * @return status code
45  * @author Vanya BELYAEV Ivan.Belyaev@nikhef.nl
46  * @date 2009-09-05
47  */
48  StatusCode parse( Gaudi::XYZVector& result, std::string_view input ) {
49 
50  Gaudi::XYZPoint point;
51  StatusCode sc = parse( point, input );
52  if ( sc.isFailure() ) { return sc; }
53  result = point;
54  return StatusCode::SUCCESS;
55  }
56 
57  StatusCode parse( Gaudi::LorentzVector& result, std::string_view input ) { return parse_( result, input ); }
58 
59  /* parse the vector of points
60  * @param resut (OUTPUT) the parser vector
61  * @param input (INPIUT) the string to be parsed
62  * @author Vanya BELYAEV Ivan.Belyaev@nikhef.nl
63  * @date 2009-09-05
64  */
65  StatusCode parse( std::vector<Gaudi::XYZPoint>& result, std::string_view input ) {
66  result.clear();
67  return parse_( result, input );
68  }
69  /* parse the vector of vectors
70  * @param resut (OUTPUT) the parser vector
71  * @param input (INPIUT) the string to be parsed
72  * @author Vanya BELYAEV Ivan.Belyaev@nikhef.nl
73  * @date 2009-09-05
74  */
75  StatusCode parse( std::vector<Gaudi::XYZVector>& result, std::string_view input ) {
76  result.clear();
77  return parse_( result, input );
78  }
79 
80  /* parse the vector of vectors
81  * @param resut (OUTPUT) the parser vector
82  * @param input (INPIUT) the string to be parsed
83  * @author Vanya BELYAEV Ivan.Belyaev@nikhef.nl
84  * @date 2009-09-05
85  */
86  StatusCode parse( std::vector<Gaudi::LorentzVector>& result, std::string_view input ) {
87  return parse_( result, input );
88  }
89  } // namespace Parsers
90 } // namespace Gaudi
91 std::ostream& Gaudi::Utils::toStream( const Gaudi::XYZPoint& obj, std::ostream& s ) {
92  s << "( ";
93  toStream( obj.X(), s );
94  s << " , ";
95  toStream( obj.Y(), s );
96  s << " , ";
97  toStream( obj.Z(), s );
98  s << " )";
99  return s;
100 }
101 std::ostream& Gaudi::Utils::toStream( const Gaudi::XYZVector& obj, std::ostream& s ) {
102  s << "( ";
103  toStream( obj.X(), s );
104  s << " , ";
105  toStream( obj.Y(), s );
106  s << " , ";
107  toStream( obj.Z(), s );
108  s << " )";
109 
110  return s;
111 }
112 std::ostream& Gaudi::Utils::toStream( const Gaudi::LorentzVector& obj, std::ostream& s ) {
113 
114  s << "( ";
115  toStream( obj.Px(), s, 12 );
116  s << " , ";
117  toStream( obj.Py(), s, 12 );
118  s << " , ";
119  toStream( obj.Pz(), s, 13 );
120  s << " , ";
121  toStream( obj.E(), s, 14 );
122  s << " )";
123 
124  return s;
125 }
VectorsAsProperty.h
Gaudi::Parsers::IteratorT
std::string_view::const_iterator IteratorT
Definition: Factory.h:23
IOTest.N
N
Definition: IOTest.py:112
ROOT::Math::PositionVector3D
Definition: IMagneticFieldSvc.h:22
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
gaudirun.s
string s
Definition: gaudirun.py:346
Gaudi::XYZVector
ROOT::Math::XYZVector XYZVector
Cartesian 3D vector (double)
Definition: Vector3DTypes.h:26
Gaudi::Parsers::parse_
StatusCode parse_(ResultT &result, std::string_view input)
Definition: Factory.h:26
ToStream.h
StatusCode
Definition: StatusCode.h:64
gaudirun.g
dictionary g
Definition: gaudirun.py:582
Gaudi::Units::m
constexpr double m
Definition: SystemOfUnits.h:107
Gaudi::Parsers::SkipperGrammar
Definition: Grammar.h:36
Gaudi
This file provides a Grammar for the type Gaudi::Accumulators::Axis It allows to use that type from p...
Definition: __init__.py:1
Factory.h
StatusCode::isFailure
bool isFailure() const
Definition: StatusCode.h:129
toStream
std::ostream & toStream(const DataObjID &d, std::ostream &os)
Definition: DataObjID.cpp:84
StatusCode::SUCCESS
constexpr static const auto SUCCESS
Definition: StatusCode.h:99
Gaudi::Parsers::Grammar_
Definition: Grammars.h:61
StringKeyEx.keys
keys
Definition: StringKeyEx.py:64
Gaudi::Utils::toStream
std::ostream & toStream(ITERATOR first, ITERATOR last, std::ostream &s, const std::string &open, const std::string &close, const std::string &delim)
the helper function to print the sequence
Definition: ToStream.h:304
IOTest.end
end
Definition: IOTest.py:125
Gaudi::LorentzVector
ROOT::Math::PxPyPzEVector LorentzVector
Cartesian 4 Vector.
Definition: Vector4DTypes.h:27
Gaudi::XYZPoint
ROOT::Math::XYZPoint XYZPoint
3D cartesian point (double)
Definition: Point3DTypes.h:37