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 // ============================================================================
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
16  ( const MAP& m ,
17  const std::string (&keys)[N] )
18  {
19  for ( unsigned int i = 0 ; i < N ; ++ i )
20  {
21  auto found = m.find ( keys[i] ) ;
22  if ( m.end() != found ) { return found ; }
23  }
24  return m.end() ;
25  }
26  // ==========================================================================
27  const std::string s_X[] = { "x" , "X" , "px" , "pX" , "Px" , "PX" } ;
28  const std::string s_Y[] = { "y" , "Y" , "py" , "pY" , "Py" , "PY" } ;
29  const std::string s_Z[] = { "z" , "Z" , "pz" , "pZ" , "Pz" , "PZ" } ;
30  const std::string s_E[] = { "t" , "T" , "e" , "E" } ;
31  // ==========================================================================
32 }
33 // ============================================================================
34 namespace Gaudi { namespace Parsers {
35  template<typename T1, typename T2>
36  inline StatusCode
38  Skipper skipper;
40  IteratorT iter = input.begin(), end = input.end();
41  if (qi::phrase_parse( iter, end, g, skipper, result)){
42  return StatusCode::SUCCESS;
43  }
44  //@attention always
45  return true;
46  }
47  // ==========================================================================
48 
50  const std::string& input ) {
51  return parse_(result, input);
52  }
53 
54  // ==========================================================================
55  /* parse 3D-vector
56  * @param result (output) the parsed vector
57  * @param input (input) the input string
58  * @return status code
59  * @author Vanya BELYAEV Ivan.Belyaev@nikhef.nl
60  * @date 2009-09-05
61  */
63  ( Gaudi::XYZVector& result ,
64  const std::string& input )
65  {
66 
67  Gaudi::XYZPoint point ;
68  StatusCode sc = parse ( point , input ) ;
69  if ( sc.isFailure() ){ return sc ; } // RETURN
70  result = point ;
71  return StatusCode::SUCCESS ; // RETURN
72  }
73 
75  return parse_(result, input);
76  }
77 
78  // ==========================================================================
79  /* parse the vector of points
80  * @param resut (OUTPUT) the parser vector
81  * @param input (INPIUT) the string to be parsed
82  * @author Vanya BELYAEV Ivan.Belyaev@nikhef.nl
83  * @date 2009-09-05
84  */
85  // ==========================================================================
88  const std::string& input )
89  {
90  result.clear() ;
91  return parse_(result, input);
92  }
93  // ==========================================================================
94  /* parse the vector of vectors
95  * @param resut (OUTPUT) the parser vector
96  * @param input (INPIUT) the string to be parsed
97  * @author Vanya BELYAEV Ivan.Belyaev@nikhef.nl
98  * @date 2009-09-05
99  */
100  // ==========================================================================
103  const std::string& input )
104  {
105  result.clear() ;
106  return parse_(result, input);
107  }
108 
109 #ifndef _WIN32
110  // ==========================================================================
111  /* parse the vector of vectors
112  * @param resut (OUTPUT) the parser vector
113  * @param input (INPIUT) the string to be parsed
114  * @author Vanya BELYAEV Ivan.Belyaev@nikhef.nl
115  * @date 2009-09-05
116  */
117  // ==========================================================================
120  const std::string& input )
121  {
122  return parse_(result, input);
123  }
124 #endif
125 } } // namespace Gaudi::Parsers
126 // ============================================================================
127 // print XYZ-point
128 // ============================================================================
131 {
132  s << "( " ;
133  toStream ( obj.X () , s ) ;
134  s << " , " ;
135  toStream ( obj.Y () , s ) ;
136  s << " , " ;
137  toStream ( obj.Z () , s ) ;
138  s << " )" ;
139  return s ;
140 }
141 // ============================================================================
142 // print XYZ-vector
143 // ============================================================================
145 ( const Gaudi::XYZVector& obj, std::ostream& s )
146 {
147  s << "( " ;
148  toStream ( obj.X () , s ) ;
149  s << " , " ;
150  toStream ( obj.Y () , s ) ;
151  s << " , " ;
152  toStream ( obj.Z () , s ) ;
153  s << " )" ;
154 
155  return s ;
156 }
157 // ============================================================================
158 // print LorentzVector
159 // ============================================================================
162 {
163 
164  s << "( " ;
165  toStream ( obj.Px () , s , 12 ) ;
166  s << " , " ;
167  toStream ( obj.Py () , s , 12 ) ;
168  s << " , " ;
169  toStream ( obj.Pz () , s , 13 ) ;
170  s << " , " ;
171  toStream ( obj.E () , s , 14 ) ;
172  s << " )" ;
173 
174  return s ;
175 }
176 // ============================================================================
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:315
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
Test for a status code of FAILURE.
Definition: StatusCode.h:84
STL class.
int N
Definition: IOTest.py:90
std::string::const_iterator IteratorT
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:26
constexpr double m
Definition: SystemOfUnits.h:93
auto end(reverse_wrapper< T > &w)
Definition: reverse.h:50
T clear(T...args)
T find(T...args)
STL class.
T begin(T...args)
string s
Definition: gaudirun.py:245
dictionary g
Definition: gaudirun.py:420
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