CMS 3D CMS Logo

AbsHcalFunctor.h
Go to the documentation of this file.
1 #ifndef CondFormats_HcalObjects_AbsHcalFunctor_h
2 #define CondFormats_HcalObjects_AbsHcalFunctor_h
3 
4 #include <cfloat>
5 #include <typeinfo>
6 
7 #include "boost/serialization/access.hpp"
8 #include "boost/serialization/base_object.hpp"
9 #include "boost/serialization/export.hpp"
10 
11 // Archive headers are needed here for the serialization registration to work.
12 // <cassert> is needed for the archive headers to work.
13 #if !defined(__GCCXML__)
14 #include <cassert>
15 #include "CondFormats/Serialization/interface/eos/portable_iarchive.hpp"
16 #include "CondFormats/Serialization/interface/eos/portable_oarchive.hpp"
17 #endif /* #if !defined(__GCCXML__) */
18 
20 public:
21  inline virtual ~AbsHcalFunctor() {}
22 
23  // Method to override by concrete storable functor classes
24  virtual double operator()(double x) const = 0;
25 
26  // Functor domain. Should be overriden by derived classes if needed.
27  inline virtual double xmin() const { return -DBL_MAX; }
28  inline virtual double xmax() const { return DBL_MAX; }
29 
30  // Comparison operators. Note that they are not virtual and should
31  // not be overriden by derived classes. These operators are very
32  // useful for I/O testing.
33  inline bool operator==(const AbsHcalFunctor& r) const { return (typeid(*this) == typeid(r)) && this->isEqual(r); }
34  inline bool operator!=(const AbsHcalFunctor& r) const { return !(*this == r); }
35 
36 protected:
37  // Method needed to compare objects for equality.
38  // Must be implemented by derived classes.
39  virtual bool isEqual(const AbsHcalFunctor&) const = 0;
40 
41  // Check if the sequence of values is strictly increasing
42  template <class Iter>
43  static bool isStrictlyIncreasing(Iter begin, Iter const end) {
44  if (begin == end)
45  return false;
46  Iter first(begin);
47  bool status = ++begin != end;
48  for (; begin != end && status; ++begin, ++first)
49  if (!(*first < *begin))
50  status = false;
51  return status;
52  }
53 
54  // Check if the sequence of values is strictly decreasing
55  template <class Iter>
56  static bool isStrictlyDecreasing(Iter begin, Iter const end) {
57  if (begin == end)
58  return false;
59  Iter first(begin);
60  bool status = ++begin != end;
61  for (; begin != end && status; ++begin, ++first)
62  if (!(*begin < *first))
63  status = false;
64  return status;
65  }
66 
67 private:
69  template <typename Ar>
70  inline void serialize(Ar& ar, unsigned /* version */) {}
71 };
72 
73 BOOST_CLASS_EXPORT_KEY(AbsHcalFunctor)
74 
75 #endif // CondFormats_HcalObjects_AbsHcalFunctor_h
AbsHcalFunctor::isStrictlyDecreasing
static bool isStrictlyDecreasing(Iter begin, Iter const end)
Definition: AbsHcalFunctor.h:56
AbsHcalFunctor
Definition: AbsHcalFunctor.h:19
AbsHcalFunctor::access
friend class boost::serialization::access
Definition: AbsHcalFunctor.h:68
mps_update.status
status
Definition: mps_update.py:69
DDAxes::x
AbsHcalFunctor::operator!=
bool operator!=(const AbsHcalFunctor &r) const
Definition: AbsHcalFunctor.h:34
AbsHcalFunctor::isStrictlyIncreasing
static bool isStrictlyIncreasing(Iter begin, Iter const end)
Definition: AbsHcalFunctor.h:43
AbsHcalFunctor::xmin
virtual double xmin() const
Definition: AbsHcalFunctor.h:27
mps_fire.end
end
Definition: mps_fire.py:242
AbsHcalFunctor::xmax
virtual double xmax() const
Definition: AbsHcalFunctor.h:28
first
auto first
Definition: CAHitNtupletGeneratorKernelsImpl.h:112
AbsHcalFunctor::operator==
bool operator==(const AbsHcalFunctor &r) const
Definition: AbsHcalFunctor.h:33
AbsHcalFunctor::~AbsHcalFunctor
virtual ~AbsHcalFunctor()
Definition: AbsHcalFunctor.h:21
AbsHcalFunctor::operator()
virtual double operator()(double x) const =0
alignCSCRings.r
r
Definition: alignCSCRings.py:93
AbsHcalFunctor::serialize
void serialize(Ar &ar, unsigned)
Definition: AbsHcalFunctor.h:70
AbsHcalFunctor::isEqual
virtual bool isEqual(const AbsHcalFunctor &) const =0