Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-04-19 09:06:51

0001 #ifndef RIVET_Cuts_HH
0002 #define RIVET_Cuts_HH
0003 
0004 #include "Rivet/Tools/Cuts.fhh"
0005 #include <string>
0006 
0007 namespace Rivet {
0008 
0009 
0010   /// Base class for Cut selectors
0011   class CutBase {
0012   public:
0013 
0014     /// Main work method, checking whether the cut is passed
0015     ///
0016     /// @internal Forwards the received object to @ref accept_, wrapped in the Cuttable converter
0017     template <typename ClassToCheck>
0018     bool accept(const ClassToCheck&) const;
0019 
0020     /// @brief Call operator alias for @a accept
0021     /// @note A bit subtle, because this gets wrapped in a shared_ptr so you need to dereference to get the functor
0022     template <typename ClassToCheck>
0023     bool operator () (const ClassToCheck& x) const { return accept(x); }
0024 
0025     /// Comparison to another Cut
0026     virtual bool operator == (const Cut&) const = 0;
0027 
0028     /// String representation
0029     virtual std::string toString() const = 0;
0030 
0031     /// Default destructor
0032     virtual ~CutBase() {}
0033 
0034 
0035   protected:
0036 
0037     /// @internal Actual accept implementation, overloadable by various cut combiners
0038     virtual bool _accept(const CuttableBase&) const = 0;
0039 
0040   };
0041 
0042 
0043   /// Compare two cuts for equality, forwards to the cut-specific implementation
0044   inline bool operator == (const Cut& a, const Cut& b) { return *a == b; }
0045 
0046   /// Forbid use of the comma operator between two (or a chain of) Cuts
0047   /// @{
0048   Cut operator , (const Cut&, const Cut&) = delete;
0049   Cut& operator , (Cut&, Cut&) = delete;
0050   Cut operator , (Cut, Cut) = delete;
0051   /// @}
0052 
0053 
0054   /// Namespace used for ambiguous identifiers
0055   namespace Cuts {
0056 
0057     /// Available categories of cut objects
0058     enum Quantity { pT=0, pt=0, Et=1, et=1, E=2, energy=2,
0059                     mass, rap, absrap, eta, abseta, phi,
0060                     pid, abspid, charge, abscharge, charge3, abscharge3, pz };
0061 
0062     /// Fully open cut singleton, accepts everything
0063     const Cut& open(); //< access by factory function
0064 
0065     extern const Cut& OPEN; //= open(); //< access by constant
0066     extern const Cut& NOCUT; //= open(); //< access by constant
0067 
0068     /// @name Shortcuts for common cuts, using the Quantity enums defined above
0069     /// @{
0070     Cut range(Quantity, double m, double n);
0071     inline Cut ptIn(double m, double n) { return range(pT, m,n); }
0072     inline Cut etIn(double m, double n) { return range(Et, m,n); }
0073     inline Cut energyIn(double m, double n) { return range(energy, m,n); }
0074     inline Cut massIn(double m, double n) { return range(mass, m,n); }
0075     inline Cut rapIn(double m, double n) { return range(rap, m,n); }
0076     inline Cut absrapIn(double m, double n) { return range(absrap, m,n); }
0077     inline Cut etaIn(double m, double n) { return range(eta, m,n); }
0078     inline Cut absetaIn(double m, double n) { return range(abseta, m,n); }
0079     /// @}
0080 
0081   }
0082 
0083 
0084   /// @name Cut constructors
0085   /// @{
0086   Cut operator == (Cuts::Quantity, double);
0087   Cut operator != (Cuts::Quantity, double);
0088   Cut operator <  (Cuts::Quantity, double);
0089   Cut operator >  (Cuts::Quantity, double);
0090   Cut operator <= (Cuts::Quantity, double);
0091   Cut operator >= (Cuts::Quantity, double);
0092 
0093   /// @internal Overload helpers for integer arguments
0094   /// @{
0095   inline Cut operator == (Cuts::Quantity qty, int i) { return qty ==  double(i); }
0096   inline Cut operator != (Cuts::Quantity qty, int i) { return qty !=  double(i); }
0097   // Cut operator == (Cuts::Quantity qty, int i);
0098   // Cut operator != (Cuts::Quantity qty, int i);
0099   inline Cut operator <  (Cuts::Quantity qty, int i) { return qty <  double(i); }
0100   inline Cut operator >  (Cuts::Quantity qty, int i) { return qty >  double(i); }
0101   inline Cut operator <= (Cuts::Quantity qty, int i) { return qty <= double(i); }
0102   inline Cut operator >= (Cuts::Quantity qty, int i) { return qty >= double(i); }
0103   /// @}
0104 
0105   /// @}
0106 
0107 
0108   /// @name Cut combiners
0109   /// @{
0110 
0111   /// Logical AND operation on two cuts
0112   /// @note No comparison short-circuiting for overloaded &&!
0113   Cut operator && (const Cut & aptr, const Cut & bptr);
0114   /// Logical OR operation on two cuts
0115   /// @note No comparison short-circuiting for overloaded ||!
0116   Cut operator || (const Cut & aptr, const Cut & bptr);
0117   /// Logical NOT operation on a cut
0118   Cut operator ! (const Cut & cptr);
0119 
0120   /// Logical AND operation on two cuts
0121   Cut operator & (const Cut & aptr, const Cut & bptr);
0122   /// Logical OR operation on two cuts
0123   Cut operator | (const Cut & aptr, const Cut & bptr);
0124   /// Logical NOT operation on a cut
0125   Cut operator ~ (const Cut & cptr);
0126   /// Logical XOR operation on two cuts
0127   Cut operator ^ (const Cut & aptr, const Cut & bptr);
0128 
0129   /// @}
0130 
0131 
0132   /// String representation
0133   inline std::ostream& operator << (std::ostream& os, const Cut& cptr) {
0134     os << cptr->toString();
0135     return os;
0136   }
0137 
0138 
0139 }
0140 
0141 #endif