The Gaudi Framework  v30r3 (a5ef0a68)
ParsersVct.cpp
Go to the documentation of this file.
1 // ============================================================================
2 // Include files
3 // ============================================================================
5 // ============================================================================
7 #include "GaudiKernel/ToStream.h"
8 // ============================================================================
9 namespace
10 {
11  // ==========================================================================
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>
39  {
40  Skipper skipper;
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 StatusCode::SUCCESS;
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  // ==========================================================================
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  // ==========================================================================
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  // ==========================================================================
112  {
113  return parse_( result, input );
114  }
115 #endif
116  }
117 } // namespace Gaudi::Parsers
118 // ============================================================================
119 // print XYZ-point
120 // ============================================================================
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 // ============================================================================
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 // ============================================================================
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 // ============================================================================
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:303
StatusCode parse_(ResultT &result, const std::string &input)
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:139
STL class.
int N
Definition: IOTest.py:101
std::string::const_iterator IteratorT
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:51
constexpr double m
Definition: SystemOfUnits.h:94
std::ostream & toStream(const DataObjID &d, std::ostream &os)
Definition: DataObjID.cpp:92
T clear(T...args)
constexpr static const auto SUCCESS
Definition: StatusCode.h:87
T find(T...args)
STL class.
T begin(T...args)
string s
Definition: gaudirun.py:253
dictionary g
Definition: gaudirun.py:439
ROOT::Math::PxPyPzEVector LorentzVector
Cartesian 4 Vector.
Definition: Vector4DTypes.h:31
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