Loading [MathJax]/extensions/tex2jax.js
The Gaudi Framework  v31r0 (aeb156f0)
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 // Include files
3 // ============================================================================
5 // ============================================================================
6 #include "GaudiKernel/ToStream.h"
8 // ============================================================================
9 namespace {
10  // ==========================================================================
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>
33  Skipper skipper;
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  // ==========================================================================
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  // ==========================================================================
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  // ==========================================================================
98  return parse_( result, input );
99  }
100 #endif
101  } // namespace Parsers
102 } // namespace Gaudi
103 // ============================================================================
104 // print XYZ-point
105 // ============================================================================
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 // ============================================================================
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 // ============================================================================
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 // ============================================================================
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
StatusCode parse_(ResultT &result, const std::string &input)
Definition: Factory.h:29
constexpr static const auto SUCCESS
Definition: StatusCode.h:85
StatusCode parse(GaudiUtils::HashMap< K, V > &result, const std::string &input)
Basic parser for the types of HashMap used in DODBasicMapper.
T end(T...args)
STL class.
bool isFailure() const
Definition: StatusCode.h:130
STL class.
int N
Definition: IOTest.py:99
std::string::const_iterator IteratorT
Definition: Factory.h:24
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:50
constexpr double m
Definition: SystemOfUnits.h:92
std::ostream & toStream(const DataObjID &d, std::ostream &os)
Definition: DataObjID.cpp:82
T clear(T...args)
T find(T...args)
STL class.
T begin(T...args)
string s
Definition: gaudirun.py:312
dictionary g
Definition: gaudirun.py:516
ROOT::Math::PxPyPzEVector LorentzVector
Cartesian 4 Vector.
Definition: Vector4DTypes.h:30
implementation of various functions for streaming.
Declaration of parsing functions for various ROOT::Math objects to allow their usage as properties fo...
STL class.
Helper functions to set/get the application return code.
Definition: __init__.py:1