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