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, 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     /// @todo Can do more here: AbsEtaLess, PtGtr
00047     //@}
00048   }
00049 
00050   /// @name Cut constructors
00051   //@{
00052   Cut operator < (Cuts::Quantity, double);
00053   Cut operator > (Cuts::Quantity, double);
00054   Cut operator <= (Cuts::Quantity, double);
00055   Cut operator >= (Cuts::Quantity, double);
00056 
00057   /// @internal Overload helpers for integer arguments
00058   //@{
00059   inline Cut operator <  (Cuts::Quantity qty, int i) { return qty <  double(i); }
00060   inline Cut operator >  (Cuts::Quantity qty, int i) { return qty >  double(i); }
00061   inline Cut operator <= (Cuts::Quantity qty, int i) { return qty <= double(i); }
00062   inline Cut operator >= (Cuts::Quantity qty, int i) { return qty >= double(i); }
00063   //@}
00064 
00065   //@}
00066 
00067   /// @name Cut combiners
00068   //@{
00069   /// Logical AND operation on two cuts
00070   Cut operator & (const Cut aptr, const Cut bptr);
00071   /// Logical OR operation on two cuts
00072   Cut operator | (const Cut aptr, const Cut bptr);
00073   /// Logical NOT operation on a cut
00074   Cut operator ~ (const Cut cptr);
00075   /// Logical XOR operation on two cuts
00076   Cut operator ^ (const Cut aptr, const Cut bptr);
00077   //@}
00078 }
00079 
00080 #endif
00081