5 #include "Rivet/Rivet.hh"
6 #include "Rivet/Projection.hh"
34 Cmp(
const T& t1,
const T& t2)
35 : _value(UNDEFINED), _objects(&t1, &t2) { }
40 : _value(x), _objects(0, 0) { }
57 operator CmpState()
const {
63 operator int()
const {
72 if (_value == EQUIVALENT) _value = c;
79 void _compare()
const {
80 if (_value == UNDEFINED) {
82 if ( l(*_objects.first, *_objects.second) ) _value = ORDERED;
83 else if ( l(*_objects.second, *_objects.first) ) _value = UNORDERED;
84 else _value = EQUIVALENT;
89 mutable CmpState _value;
92 pair<const T*, const T*> _objects;
119 : _value(UNDEFINED), _objects(&p1, &p2)
123 template <
typename U>
125 : _value(x), _objects(0, 0)
132 template <
typename U>
142 operator CmpState()
const {
149 operator int()
const {
155 template <
typename U>
158 if (_value == EQUIVALENT) _value = c;
165 void _compare()
const {
166 if (_value == UNDEFINED) {
167 const std::type_info& id1 =
typeid(*_objects.first);
168 const std::type_info& id2 =
typeid(*_objects.second);
169 if (id1.before(id2)) _value = ORDERED;
170 else if (id2.before(id1)) _value = UNORDERED;
172 int c = _objects.first->compare(*_objects.second);
173 if (c < 0) _value = ORDERED;
174 else if (c > 0) _value = UNORDERED;
175 else _value = EQUIVALENT;
183 mutable CmpState _value;
186 pair<const Projection*, const Projection*> _objects;
212 Cmp(
const double p1,
const double p2)
214 : _value(UNDEFINED), _numA(p1), _numB(p2)
218 template <
typename U>
220 : _value(x), _numA(0.0), _numB(0.0)
227 template <
typename U>
237 operator CmpState()
const {
243 operator int()
const {
249 template <
typename U>
252 if (_value == EQUIVALENT) _value = c;
259 void _compare()
const {
260 if (_value == UNDEFINED) {
262 else if (_numA < _numB) _value = ORDERED;
263 else _value = UNORDERED;
270 mutable CmpState _value;
284 template <
typename T>
Definition: MC_JetAnalysis.hh:9
const PROJ & getProjection(const std::string &name) const
Get the named projection, specifying return type via a template argument.
Definition: ProjectionApplier.hh:49
Cmp(const Cmp< U > &x)
The copy constructor.
Definition: Cmp.hh:39
Cmp(const Cmp< U > &x)
The copy constructor.
Definition: Cmp.hh:219
const Cmp< T > & operator||(const Cmp< U > &c) const
If this state is equivalent, set this state to the state of c.
Definition: Cmp.hh:70
~Cmp()
The destructor is not virtual since this is not intended to be a base class.
Definition: Cmp.hh:224
Cmp(const T &t1, const T &t2)
The default constructor.
Definition: Cmp.hh:34
~Cmp()
The destructor is not virtual since this is not intended to be a base class.
Definition: Cmp.hh:43
const Cmp< double > & operator=(const Cmp< U > &x)
The assignment operator.
Definition: Cmp.hh:228
const Cmp< Projection > & operator=(const Cmp< U > &x)
The assignment operator.
Definition: Cmp.hh:133
~Cmp()
The destructor is not virtual since this is not intended to be a base class.
Definition: Cmp.hh:129
Specialization of Cmp for checking the ordering of two {Projection}s.
Definition: Cmp.hh:112
Cmp< Projection > pcmp(const Projection &p1, const Projection &p2)
Global helper function for easy creation of Cmp
objects. Definition: Cmp.hh:295
const Cmp< double > & operator||(const Cmp< U > &c) const
If this state is equivalent, set this state to the state of c.
Definition: Cmp.hh:250
Cmp< Projection > PCmp
Definition: Cmp.hh:291
Specialization of Cmp for checking the ordering of two floating point numbers.
Definition: Cmp.hh:207
const Cmp< Projection > & operator||(const Cmp< U > &c) const
If this state is equivalent, set this state to the state of c.
Definition: Cmp.hh:156
const Cmp< T > & operator=(const Cmp< U > &x)
The assignment operator.
Definition: Cmp.hh:47
Base class for all Rivet projections.
Definition: Projection.hh:28
bool fuzzyEquals(double a, double b, double tolerance=1E-5)
Compare two floating point numbers for equality with a degree of fuzziness.
Definition: MathUtils.hh:34
Cmp(const Cmp< U > &x)
The copy constructor.
Definition: Cmp.hh:124
Cmp< T > cmp(const T &t1, const T &t2)
Global helper function for easy creation of Cmp objects.
Definition: Cmp.hh:285