| The Gaudi Framework v32r1 (f65d50dc)

ParsersVct.cpp
Go to the documentation of this file.
1 // ============================================================================
2 // Include files
3 // ============================================================================
4 #include "GaudiKernel/VectorsAsProperty.h"
5 // ============================================================================
6 #include "GaudiKernel/ToStream.h"
7 #include <Gaudi/Parsers/Factory.h>
8 // ============================================================================
9 namespace {
10 // ==========================================================================
11 typedef std::map<std::string, double> MAP;
12
13 template <unsigned int N>
14 inline MAP::const_iterator find( const MAP& m, const std::string ( &keys )[N] ) {
15 for ( unsigned int i = 0; i < N; ++i ) {
16 auto found = m.find( keys[i] );
17 if ( m.end() != found ) { return found; }
18 }
19 return m.end();
20 }
21 // ==========================================================================
22 const std::string s_X[] = {"x", "X", "px", "pX", "Px", "PX"};
23 const std::string s_Y[] = {"y", "Y", "py", "pY", "Py", "PY"};
24 const std::string s_Z[] = {"z", "Z", "pz", "pZ", "Pz", "PZ"};
25 const std::string s_E[] = {"t", "T", "e", "E"};
26 // ==========================================================================
27 } // namespace
28 // ============================================================================
29 namespace Gaudi {
30 namespace Parsers {
31 template <typename T1, typename T2>
32 inline StatusCode parse_( ROOT::Math::PositionVector3D<T1, T2>& result, const std::string& input ) {
33 Skipper skipper;
34 typename Grammar_<IteratorT, ROOT::Math::PositionVector3D<T1, T2>, Skipper>::Grammar g;
35 IteratorT iter = input.begin(), end = input.end();
36 if ( qi::phrase_parse( iter, end, g, skipper, result ) ) { return StatusCode::SUCCESS; }
37 //@attention always
38 return StatusCode::SUCCESS;
39 }
40 // ==========================================================================
41
42 StatusCode parse( Gaudi::XYZPoint& result, const std::string& input ) { return parse_( result, input ); }
43
44 // ==========================================================================
45 /* parse 3D-vector
46 * @param result (output) the parsed vector
47 * @param input (input) the input string
48 * @return status code
49 * @author Vanya BELYAEV Ivan.Belyaev@nikhef.nl
50 * @date 2009-09-05
51 */
52 StatusCode parse( Gaudi::XYZVector& result, const std::string& input ) {
53
54 Gaudi::XYZPoint point;
55 StatusCode sc = parse( point, input );
56 if ( sc.isFailure() ) { return sc; } // RETURN
57 result = point;
58 return StatusCode::SUCCESS; // RETURN
59 }
60
61 StatusCode parse( Gaudi::LorentzVector& result, const std::string& input ) { return parse_( result, input ); }
62
63 // ==========================================================================
64 /* parse the vector of points
65 * @param resut (OUTPUT) the parser vector
66 * @param input (INPIUT) the string to be parsed
67 * @author Vanya BELYAEV Ivan.Belyaev@nikhef.nl
68 * @date 2009-09-05
69 */
70 // ==========================================================================
71 StatusCode parse( std::vector<Gaudi::XYZPoint>& result, const std::string& input ) {
72 result.clear();
73 return parse_( result, input );
74 }
75 // ==========================================================================
76 /* parse the vector of vectors
77 * @param resut (OUTPUT) the parser vector
78 * @param input (INPIUT) the string to be parsed
79 * @author Vanya BELYAEV Ivan.Belyaev@nikhef.nl
80 * @date 2009-09-05
81 */
82 // ==========================================================================
83 StatusCode parse( std::vector<Gaudi::XYZVector>& result, const std::string& input ) {
84 result.clear();
85 return parse_( result, input );
86 }
87
88 #ifndef _WIN32
89 // ==========================================================================
90 /* parse the vector of vectors
91 * @param resut (OUTPUT) the parser vector
92 * @param input (INPIUT) the string to be parsed
93 * @author Vanya BELYAEV Ivan.Belyaev@nikhef.nl
94 * @date 2009-09-05
95 */
96 // ==========================================================================
97 StatusCode parse( std::vector<Gaudi::LorentzVector>& result, const std::string& input ) {
98 return parse_( result, input );
99 }
100 #endif
101 } // namespace Parsers
102 } // namespace Gaudi
103 // ============================================================================
104 // print XYZ-point
105 // ============================================================================
106 std::ostream& Gaudi::Utils::toStream( const Gaudi::XYZPoint& obj, std::ostream& s ) {
107 s << "( ";
108 toStream( obj.X(), s );
109 s << " , ";
110 toStream( obj.Y(), s );
111 s << " , ";
112 toStream( obj.Z(), s );
113 s << " )";
114 return s;
115 }
116 // ============================================================================
117 // print XYZ-vector
118 // ============================================================================
119 std::ostream& Gaudi::Utils::toStream( const Gaudi::XYZVector& obj, std::ostream& s ) {
120 s << "( ";
121 toStream( obj.X(), s );
122 s << " , ";
123 toStream( obj.Y(), s );
124 s << " , ";
125 toStream( obj.Z(), s );
126 s << " )";
127
128 return s;
129 }
130 // ============================================================================
131 // print LorentzVector
132 // ============================================================================
133 std::ostream& Gaudi::Utils::toStream( const Gaudi::LorentzVector& obj, std::ostream& s ) {
134
135 s << "( ";
136 toStream( obj.Px(), s, 12 );
137 s << " , ";
138 toStream( obj.Py(), s, 12 );
139 s << " , ";
140 toStream( obj.Pz(), s, 13 );
141 s << " , ";
142 toStream( obj.E(), s, 14 );
143 s << " )";
144
145 return s;
146 }
147 // ============================================================================
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:284
Gaudi::Parsers::parse_
StatusCode parse_(ResultT &result, const std::string &input)
Definition: Factory.h:29
StatusCode::SUCCESS
constexpr static const auto SUCCESS
Definition: StatusCode.h:85
Gaudi::Parsers::parse
StatusCode parse(GaudiUtils::HashMap< K, V > &result, const std::string &input)
Basic parser for the types of HashMap used in DODBasicMapper.
Definition: DODBasicMapper.cpp:11
std::string::end
T end(T... args)
ROOT::Math::PositionVector3D
Definition: IMagneticFieldSvc.h:15
std::map
STL class.
std::string
STL class.
IOTest.N
int N
Definition: IOTest.py:99
Gaudi::Parsers::IteratorT
std::string::const_iterator IteratorT
Definition: Factory.h:24
StatusCode
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:50
Gaudi::Units::m
constexpr double m
Definition: SystemOfUnits.h:92
Gaudi::Parsers::Grammar_
Definition: Grammars.h:58
IOTest.end
def end
Definition: IOTest.py:112
toStream
std::ostream & toStream(const DataObjID &d, std::ostream &os)
Definition: DataObjID.cpp:82
std::vector::clear
T clear(T... args)
Gaudi::Parsers::SkipperGrammar
Definition: Grammar.h:41
ROOT::Math::DisplacementVector3D
Definition: IMagneticFieldSvc.h:18
std::find
T find(T... args)
std::vector
STL class.
std::string::begin
T begin(T... args)
gaudirun.s
string s
Definition: gaudirun.py:316
gaudirun.g
dictionary g
Definition: gaudirun.py:520
Gaudi::LorentzVector
ROOT::Math::PxPyPzEVector LorentzVector
Cartesian 4 Vector.
Definition: Vector4DTypes.h:30
StatusCode::isFailure
bool isFailure() const
Definition: StatusCode.h:130
ToStream.h
implementation of various functions for streaming.
VectorsAsProperty.h
Declaration of parsing functions for various ROOT::Math objects to allow their usage as properties fo...
std::ostream
STL class.
Factory.h
Gaudi
Header file for std:chrono::duration-based Counters.
Definition: __init__.py:1