Cuts.hh
Go to the documentation of this file.
00001 #ifndef RIVET_Cuts_HH 00002 #define RIVET_Cuts_HH 00003 00004 #include "Rivet/Tools/Cuts.fhh" 00005 #include <memory> 00006 00007 namespace Rivet { 00008 00009 00010 class CutBase { 00011 public: 00012 00013 /// Main work method, checking whether the cut is passed 00014 /// @internal Forwards the received object to @ref accept_, wrapped in the Cuttable converter 00015 template <typename ClassToCheck> 00016 bool accept(const ClassToCheck&) const; 00017 00018 /// @brief Call operator alias for @a accept 00019 /// @note A bit subtle, because this gets wrapped in a shared_ptr so you need to dereference to get the functor 00020 template <typename ClassToCheck> 00021 bool operator () (const ClassToCheck& x) const { return accept(x); } 00022 00023 /// Comparison to another Cut 00024 virtual bool operator == (const Cut&) const = 0; 00025 00026 /// Default destructor 00027 virtual ~CutBase() {} 00028 00029 protected: 00030 00031 /// @internal Actual accept implementation, overloadable by various cut combiners 00032 virtual bool _accept(const CuttableBase&) const = 0; 00033 00034 }; 00035 00036 00037 /// Compare two cuts for equality, forwards to the cut-specific implementation 00038 inline bool operator == (const Cut& a, const Cut& b) { return *a == b; } 00039 00040 00041 /// Namespace used for ambiguous identifiers. 00042 namespace Cuts { 00043 00044 /// Available categories of cut objects 00045 enum Quantity { pT=0, pt=0, Et=1, et=1, mass, rap, absrap, eta, abseta, phi, 00046 pid, abspid, charge, abscharge, charge3, abscharge3 }; 00047 00048 /// Fully open cut singleton, accepts everything 00049 const Cut& open(); //< access by factory function 00050 00051 extern const Cut& OPEN; //= open(); //< access by constant 00052 extern const Cut& NOCUT; //= open(); //< access by constant 00053 00054 /// @name Shortcuts for common cuts 00055 //@{ 00056 Cut range(Quantity, double m, double n); 00057 inline Cut etaIn(double m, double n) { return range(eta,m,n); } 00058 inline Cut rapIn(double m, double n) { return range(rap,m,n); } 00059 inline Cut absetaIn(double m, double n) { return range(abseta,m,n); } 00060 inline Cut absrapIn(double m, double n) { return range(absrap,m,n); } 00061 inline Cut ptIn(double m, double n) { return range(pT,m,n); } 00062 inline Cut etIn(double m, double n) { return range(Et,m,n); } 00063 inline Cut massIn(double m, double n) { return range(mass,m,n); } 00064 //@} 00065 00066 } 00067 00068 00069 /// @name Cut constructors 00070 //@{ 00071 Cut operator == (Cuts::Quantity, double); 00072 Cut operator != (Cuts::Quantity, double); 00073 Cut operator < (Cuts::Quantity, double); 00074 Cut operator > (Cuts::Quantity, double); 00075 Cut operator <= (Cuts::Quantity, double); 00076 Cut operator >= (Cuts::Quantity, double); 00077 00078 /// @internal Overload helpers for integer arguments 00079 //@{ 00080 inline Cut operator == (Cuts::Quantity qty, int i) { return qty == double(i); } 00081 inline Cut operator != (Cuts::Quantity qty, int i) { return qty != double(i); } 00082 // Cut operator == (Cuts::Quantity qty, int i); 00083 // Cut operator != (Cuts::Quantity qty, int i); 00084 inline Cut operator < (Cuts::Quantity qty, int i) { return qty < double(i); } 00085 inline Cut operator > (Cuts::Quantity qty, int i) { return qty > double(i); } 00086 inline Cut operator <= (Cuts::Quantity qty, int i) { return qty <= double(i); } 00087 inline Cut operator >= (Cuts::Quantity qty, int i) { return qty >= double(i); } 00088 //@} 00089 00090 //@} 00091 00092 00093 /// @name Cut combiners 00094 //@{ 00095 00096 /// Logical AND operation on two cuts 00097 /// @note No comparison short-circuiting for overloaded &&! 00098 Cut operator && (const Cut & aptr, const Cut & bptr); 00099 /// Logical OR operation on two cuts 00100 /// @note No comparison short-circuiting for overloaded ||! 00101 Cut operator || (const Cut & aptr, const Cut & bptr); 00102 /// Logical NOT operation on a cut 00103 Cut operator ! (const Cut & cptr); 00104 00105 /// Logical AND operation on two cuts 00106 Cut operator & (const Cut & aptr, const Cut & bptr); 00107 /// Logical OR operation on two cuts 00108 Cut operator | (const Cut & aptr, const Cut & bptr); 00109 /// Logical NOT operation on a cut 00110 Cut operator ~ (const Cut & cptr); 00111 /// Logical XOR operation on two cuts 00112 Cut operator ^ (const Cut & aptr, const Cut & bptr); 00113 00114 //@} 00115 00116 00117 } 00118 00119 #endif Generated on Tue Dec 13 2016 16:32:37 for The Rivet MC analysis system by ![]() |