| The Gaudi Framework v29r1 (5cd95fa2)

- Main Page
- Related Pages
- Modules
- Namespaces
- Classes
- Files

- File List
- File Members

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