The Gaudi Framework  v36r16 (ea80daf8)
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 * (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 // ============================================================================
VectorsAsProperty.h
Gaudi::Parsers::IteratorT
std::string::const_iterator IteratorT
Definition: Factory.h:34
std::string
STL class.
IOTest.N
N
Definition: IOTest.py:110
ROOT::Math::PositionVector3D
Definition: IMagneticFieldSvc.h:25
gaudirun.s
string s
Definition: gaudirun.py:348
Gaudi::XYZVector
ROOT::Math::XYZVector XYZVector
Cartesian 3D vector (double)
Definition: Vector3DTypes.h:39
std::vector< Gaudi::XYZPoint >
std::find
T find(T... args)
ToStream.h
std::vector::clear
T clear(T... args)
StatusCode
Definition: StatusCode.h:65
gaudirun.g
dictionary g
Definition: gaudirun.py:581
Gaudi::Units::m
constexpr double m
Definition: SystemOfUnits.h:108
std::ostream
STL class.
Gaudi::Parsers::parse_
StatusCode parse_(ResultT &result, const std::string &input)
Definition: Factory.h:39
Gaudi::Parsers::SkipperGrammar
Definition: Grammar.h:51
std::map< std::string, double >
Gaudi
Header file for std:chrono::duration-based Counters.
Definition: __init__.py:1
Factory.h
StatusCode::isFailure
bool isFailure() const
Definition: StatusCode.h:129
toStream
std::ostream & toStream(const DataObjID &d, std::ostream &os)
Definition: DataObjID.cpp:93
StatusCode::SUCCESS
constexpr static const auto SUCCESS
Definition: StatusCode.h:100
Gaudi::Parsers::Grammar_
Definition: Grammars.h:68
StringKeyEx.keys
keys
Definition: StringKeyEx.py:64
std::string::begin
T begin(T... args)
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:299
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:21
std::string::end
T end(T... args)
IOTest.end
end
Definition: IOTest.py:123
Gaudi::LorentzVector
ROOT::Math::PxPyPzEVector LorentzVector
Cartesian 4 Vector.
Definition: Vector4DTypes.h:40
Gaudi::XYZPoint
ROOT::Math::XYZPoint XYZPoint
3D cartesian point (double)
Definition: Point3DTypes.h:39