The Gaudi Framework  v33r1 (b1225454)
ParsersVct.cpp
Go to the documentation of this file.
1 /***********************************************************************************\
2 * (c) Copyright 1998-2019 CERN for the benefit of the LHCb and ATLAS collaborations *
3 * *
4 * This software is distributed under the terms of the Apache version 2 licence, *
5 * copied verbatim in the file "LICENSE". *
6 * *
7 * In applying this licence, CERN does not waive the privileges and immunities *
8 * granted to it by virtue of its status as an Intergovernmental Organization *
9 * or submit itself to any jurisdiction. *
10 \***********************************************************************************/
11 // ============================================================================
12 // Include files
13 // ============================================================================
15 // ============================================================================
16 #include "GaudiKernel/ToStream.h"
17 #include <Gaudi/Parsers/Factory.h>
18 // ============================================================================
19 namespace {
20  // ==========================================================================
22 
23  template <unsigned int N>
24  inline MAP::const_iterator find( const MAP& m, const std::string ( &keys )[N] ) {
25  for ( unsigned int i = 0; i < N; ++i ) {
26  auto found = m.find( keys[i] );
27  if ( m.end() != found ) { return found; }
28  }
29  return m.end();
30  }
31  // ==========================================================================
32  const std::string s_X[] = {"x", "X", "px", "pX", "Px", "PX"};
33  const std::string s_Y[] = {"y", "Y", "py", "pY", "Py", "PY"};
34  const std::string s_Z[] = {"z", "Z", "pz", "pZ", "Pz", "PZ"};
35  const std::string s_E[] = {"t", "T", "e", "E"};
36  // ==========================================================================
37 } // namespace
38 // ============================================================================
39 namespace Gaudi {
40  namespace Parsers {
41  template <typename T1, typename T2>
43  Skipper skipper;
45  IteratorT iter = input.begin(), end = input.end();
46  if ( qi::phrase_parse( iter, end, g, skipper, result ) ) { return StatusCode::SUCCESS; }
47  //@attention always
48  return StatusCode::SUCCESS;
49  }
50  // ==========================================================================
51 
52  StatusCode parse( Gaudi::XYZPoint& result, const std::string& input ) { return parse_( result, input ); }
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  */
62  StatusCode parse( Gaudi::XYZVector& result, const std::string& input ) {
63 
64  Gaudi::XYZPoint point;
65  StatusCode sc = parse( point, input );
66  if ( sc.isFailure() ) { return sc; } // RETURN
67  result = point;
68  return StatusCode::SUCCESS; // RETURN
69  }
70 
71  StatusCode parse( Gaudi::LorentzVector& result, const std::string& input ) { return parse_( result, input ); }
72 
73  // ==========================================================================
74  /* parse the vector of points
75  * @param resut (OUTPUT) the parser vector
76  * @param input (INPIUT) the string to be parsed
77  * @author Vanya BELYAEV Ivan.Belyaev@nikhef.nl
78  * @date 2009-09-05
79  */
80  // ==========================================================================
82  result.clear();
83  return parse_( result, input );
84  }
85  // ==========================================================================
86  /* parse the vector of vectors
87  * @param resut (OUTPUT) the parser vector
88  * @param input (INPIUT) the string to be parsed
89  * @author Vanya BELYAEV Ivan.Belyaev@nikhef.nl
90  * @date 2009-09-05
91  */
92  // ==========================================================================
94  result.clear();
95  return parse_( result, input );
96  }
97 
98 #ifndef _WIN32
99  // ==========================================================================
100  /* parse the vector of vectors
101  * @param resut (OUTPUT) the parser vector
102  * @param input (INPIUT) the string to be parsed
103  * @author Vanya BELYAEV Ivan.Belyaev@nikhef.nl
104  * @date 2009-09-05
105  */
106  // ==========================================================================
108  return parse_( result, input );
109  }
110 #endif
111  } // namespace Parsers
112 } // namespace Gaudi
113 // ============================================================================
114 // print XYZ-point
115 // ============================================================================
117  s << "( ";
118  toStream( obj.X(), s );
119  s << " , ";
120  toStream( obj.Y(), s );
121  s << " , ";
122  toStream( obj.Z(), s );
123  s << " )";
124  return s;
125 }
126 // ============================================================================
127 // print XYZ-vector
128 // ============================================================================
130  s << "( ";
131  toStream( obj.X(), s );
132  s << " , ";
133  toStream( obj.Y(), s );
134  s << " , ";
135  toStream( obj.Z(), s );
136  s << " )";
137 
138  return s;
139 }
140 // ============================================================================
141 // print LorentzVector
142 // ============================================================================
144 
145  s << "( ";
146  toStream( obj.Px(), s, 12 );
147  s << " , ";
148  toStream( obj.Py(), s, 12 );
149  s << " , ";
150  toStream( obj.Pz(), s, 13 );
151  s << " , ";
152  toStream( obj.E(), s, 14 );
153  s << " )";
154 
155  return s;
156 }
157 // ============================================================================
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:291
StatusCode parse_(ResultT &result, const std::string &input)
Definition: Factory.h:39
constexpr static const auto SUCCESS
Definition: StatusCode.h:100
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.
STL class.
int N
Definition: IOTest.py:110
std::string::const_iterator IteratorT
Definition: Factory.h:34
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:61
constexpr double m
def end
Definition: IOTest.py:123
std::ostream & toStream(const DataObjID &d, std::ostream &os)
Definition: DataObjID.cpp:93
T clear(T... args)
T find(T... args)
STL class.
T begin(T... args)
string s
Definition: gaudirun.py:328
dictionary g
Definition: gaudirun.py:542
ROOT::Math::PxPyPzEVector LorentzVector
Cartesian 4 Vector.
Definition: Vector4DTypes.h:40
bool isFailure() const
Definition: StatusCode.h:145
implementation of various functions for streaming.
Declaration of parsing functions for various ROOT::Math objects to allow their usage as properties fo...
STL class.
Header file for std:chrono::duration-based Counters.
Definition: __init__.py:1