rivet is hosted by Hepforge, IPPP Durham
Cuts.hh
Go to the documentation of this file.
00001 #ifndef RIVET_Cuts_HH
00002 #define RIVET_Cuts_HH
00003 #include <boost/smart_ptr.hpp>
00004 
00005 namespace Rivet {
00006 
00007 
00008   /// @internal Forward declaration of helper class. Not for end users.
00009   class CuttableBase;
00010 
00011   /// @internal Base class for cut objects.
00012   /// @note End users should always use the @ref Cut typedef instead.
00013   class CutBase;
00014 
00015   /// Main cut object
00016   typedef boost::shared_ptr<CutBase> Cut;
00017 
00018 
00019   class CutBase {
00020   public:
00021     /// Main work method.
00022     /// @internal Forwards the received object to @ref accept_, wrapped in the Cuttable converter
00023     template <typename ClassToCheck> bool accept(const ClassToCheck&) const;
00024     /// Comparison to another Cut
00025     virtual bool operator==(const Cut&) const = 0;
00026     /// Default destructor
00027     virtual ~CutBase() {}
00028   protected:
00029     /// @internal Actual accept implementation, overloadable by various cut combiners
00030     virtual bool _accept(const CuttableBase&) const = 0;
00031   };
00032 
00033 
00034   /// Compare two cuts for equality, forwards to the cut-specific implementation
00035   inline bool operator == (const Cut& a, const Cut& b) { return *a == b; }
00036 
00037 
00038   /// Namespace used for ambiguous identifiers.
00039   namespace Cuts {
00040 
00041     /// Available categories of cut objects
00042     enum Quantity { pT=0, pt=0, Et=1, et=1, mass, rap, absrap, eta, abseta, phi };
00043     /// Fully open cut singleton, accepts everything
00044     const Cut& open();
00045 
00046     /// @name Shortcuts for common cuts
00047     //@{
00048     Cut range(Quantity, double m, double n);
00049     inline Cut etaIn(double m, double n) { return range(eta,m,n); }
00050     inline Cut rapIn(double m, double n) { return range(rap,m,n); }
00051     inline Cut absetaIn(double m, double n) { return range(abseta,m,n); }
00052     inline Cut absrapIn(double m, double n) { return range(absrap,m,n); }
00053     inline Cut ptIn(double m, double n) { return range(pT,m,n); }
00054     inline Cut etIn(double m, double n) { return range(Et,m,n); }
00055     inline Cut massIn(double m, double n) { return range(mass,m,n); }
00056     //@}
00057 
00058   }
00059 
00060 
00061   /// @name Cut constructors
00062   //@{
00063   Cut operator < (Cuts::Quantity, double);
00064   Cut operator > (Cuts::Quantity, double);
00065   Cut operator <= (Cuts::Quantity, double);
00066   Cut operator >= (Cuts::Quantity, double);
00067 
00068   /// @internal Overload helpers for integer arguments
00069   //@{
00070   inline Cut operator <  (Cuts::Quantity qty, int i) { return qty <  double(i); }
00071   inline Cut operator >  (Cuts::Quantity qty, int i) { return qty >  double(i); }
00072   inline Cut operator <= (Cuts::Quantity qty, int i) { return qty <= double(i); }
00073   inline Cut operator >= (Cuts::Quantity qty, int i) { return qty >= double(i); }
00074   //@}
00075 
00076   //@}
00077 
00078 
00079   /// @name Cut combiners
00080   //@{
00081 
00082   /// Logical AND operation on two cuts
00083   /// @note No comparison short-circuiting for overloaded &&!
00084   Cut operator && (const Cut & aptr, const Cut & bptr);
00085   /// Logical OR operation on two cuts
00086   /// @note No comparison short-circuiting for overloaded ||!
00087   Cut operator || (const Cut & aptr, const Cut & bptr);
00088   /// Logical NOT operation on a cut
00089   Cut operator ! (const Cut & cptr);
00090 
00091   /// Logical AND operation on two cuts
00092   Cut operator & (const Cut & aptr, const Cut & bptr);
00093   /// Logical OR operation on two cuts
00094   Cut operator | (const Cut & aptr, const Cut & bptr);
00095   /// Logical NOT operation on a cut
00096   Cut operator ~ (const Cut & cptr);
00097   /// Logical XOR operation on two cuts
00098   Cut operator ^ (const Cut & aptr, const Cut & bptr);
00099 
00100   //@}
00101 
00102 
00103 }
00104 
00105 #endif