00001
00002 #ifndef RIVET_Cuts_HH
00003 #define RIVET_Cuts_HH
00004
00005 #include "Rivet/Rivet.hh"
00006 #include "Rivet/Cuts.fhh"
00007 #include <iostream>
00008
00009
00010 namespace Rivet {
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 class Cuts {
00021
00022 public:
00023
00024
00025
00026
00027 inline Cuts() { }
00028
00029
00030 public:
00031
00032
00033 Cuts& addCut(const string& quantity, const Comparison& comparison, const double value);
00034
00035
00036
00037 inline Cuts& addCuts(const Cuts& other) {
00038 for (const_iterator cut = other.begin(); cut != other.end(); ++cut) {
00039 addCut(cut->first, MORE_EQ, cut->second.higherthan());
00040 addCut(cut->first, LESS_EQ, cut->second.lowerthan());
00041 }
00042 return *this;
00043 }
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053 bool checkConsistency() const;
00054
00055
00056 ostream& print(ostream& stream) const;
00057
00058
00059 public:
00060
00061 class BinaryCut {
00062 public:
00063
00064 BinaryCut() {
00065 _raw = pair<double, double>(numeric_limits<double>::max(), -numeric_limits<double>::max());
00066 }
00067
00068
00069 BinaryCut(double lowerthan, double higherthan) {
00070 _raw = pair<double, double>(lowerthan, higherthan);
00071 }
00072
00073
00074
00075 inline double& lowerthan() { return _raw.first; }
00076 inline double& higherthan() { return _raw.second; }
00077 inline const double& lowerthan() const { return _raw.first; }
00078 inline const double& higherthan() const { return _raw.second; }
00079
00080
00081 private:
00082 pair<double, double> _raw;
00083 };
00084
00085
00086 typedef map<string, BinaryCut> NamedBinaryCuts;
00087
00088
00089 public:
00090
00091
00092
00093 typedef NamedBinaryCuts::iterator iterator;
00094 inline iterator begin() { return _cuts.begin(); }
00095 inline iterator end() { return _cuts.end(); }
00096 inline iterator find(const string& quantity) { return _cuts.find(quantity); }
00097
00098
00099
00100
00101 typedef NamedBinaryCuts::const_iterator const_iterator;
00102 inline const const_iterator begin() const { return _cuts.begin(); }
00103 inline const const_iterator end() const { return _cuts.end(); }
00104 inline const const_iterator find(const string& quantity) const { return _cuts.find(quantity); }
00105
00106
00107
00108 private:
00109 NamedBinaryCuts _cuts;
00110
00111 };
00112
00113
00114
00115 inline ostream& operator<<(ostream& os, const Cuts& cuts) {
00116 return cuts.print(os);
00117 }
00118
00119 }
00120
00121 #endif