Rivet  3.1.0
Cuts.hh
1 #ifndef RIVET_Cuts_HH
2 #define RIVET_Cuts_HH
3 
4 #include "Rivet/Tools/Cuts.fhh"
5 #include <string>
6 
7 namespace Rivet {
8 
9 
10  class CutBase {
11  public:
12 
15  template <typename ClassToCheck>
16  bool accept(const ClassToCheck&) const;
17 
20  template <typename ClassToCheck>
21  bool operator () (const ClassToCheck& x) const { return accept(x); }
22 
24  virtual bool operator == (const Cut&) const = 0;
25 
27  virtual std::string toString() const = 0;
28 
30  virtual ~CutBase() {}
31 
32  protected:
33 
35  virtual bool _accept(const CuttableBase&) const = 0;
36 
37  };
38 
39 
41  inline bool operator == (const Cut& a, const Cut& b) { return *a == b; }
42 
43 
45  namespace Cuts {
46 
48  enum Quantity { pT=0, pt=0, Et=1, et=1, E=2, energy=2,
49  mass, rap, absrap, eta, abseta, phi,
50  pid, abspid, charge, abscharge, charge3, abscharge3, pz };
51 
53  const Cut& open(); //< access by factory function
54 
55  extern const Cut& OPEN; //= open(); //< access by constant
56  extern const Cut& NOCUT; //= open(); //< access by constant
57 
59 
60  Cut range(Quantity, double m, double n);
61  inline Cut ptIn(double m, double n) { return range(pT, m,n); }
62  inline Cut etIn(double m, double n) { return range(Et, m,n); }
63  inline Cut energyIn(double m, double n) { return range(energy, m,n); }
64  inline Cut massIn(double m, double n) { return range(mass, m,n); }
65  inline Cut rapIn(double m, double n) { return range(rap, m,n); }
66  inline Cut absrapIn(double m, double n) { return range(absrap, m,n); }
67  inline Cut etaIn(double m, double n) { return range(eta, m,n); }
68  inline Cut absetaIn(double m, double n) { return range(abseta, m,n); }
70 
71  }
72 
73 
75 
76  Cut operator == (Cuts::Quantity, double);
77  Cut operator != (Cuts::Quantity, double);
78  Cut operator < (Cuts::Quantity, double);
79  Cut operator > (Cuts::Quantity, double);
80  Cut operator <= (Cuts::Quantity, double);
81  Cut operator >= (Cuts::Quantity, double);
82 
84 
85  inline Cut operator == (Cuts::Quantity qty, int i) { return qty == double(i); }
86  inline Cut operator != (Cuts::Quantity qty, int i) { return qty != double(i); }
87  // Cut operator == (Cuts::Quantity qty, int i);
88  // Cut operator != (Cuts::Quantity qty, int i);
89  inline Cut operator < (Cuts::Quantity qty, int i) { return qty < double(i); }
90  inline Cut operator > (Cuts::Quantity qty, int i) { return qty > double(i); }
91  inline Cut operator <= (Cuts::Quantity qty, int i) { return qty <= double(i); }
92  inline Cut operator >= (Cuts::Quantity qty, int i) { return qty >= double(i); }
94 
96 
97 
99 
100 
103  Cut operator && (const Cut & aptr, const Cut & bptr);
106  Cut operator || (const Cut & aptr, const Cut & bptr);
108  Cut operator ! (const Cut & cptr);
109 
111  Cut operator & (const Cut & aptr, const Cut & bptr);
113  Cut operator | (const Cut & aptr, const Cut & bptr);
115  Cut operator ~ (const Cut & cptr);
117  Cut operator ^ (const Cut & aptr, const Cut & bptr);
118 
120 
121 
123  inline std::ostream& operator << (std::ostream& os, const Cut& cptr) {
124  os << cptr->toString();
125  return os;
126  }
127 
128 
129 }
130 
131 #endif
Definition: MC_Cent_pPb.hh:10
Cut operator&(const Cut &aptr, const Cut &bptr)
Logical AND operation on two cuts.
Cut operator~(const Cut &cptr)
Logical NOT operation on a cut.
Cut operator!(const Cut &cptr)
Logical NOT operation on a cut.
Cut operator^(const Cut &aptr, const Cut &bptr)
Logical XOR operation on two cuts.
const Cut & open()
Fully open cut singleton, accepts everything.
int pid(const Particle &p)
Unbound function access to PID code.
Definition: ParticleUtils.hh:23
bool operator==(const Cut &a, const Cut &b)
Compare two cuts for equality, forwards to the cut-specific implementation.
Definition: Cuts.hh:41
Cut operator||(const Cut &aptr, const Cut &bptr)
Cut operator&&(const Cut &aptr, const Cut &bptr)
int abspid(const Particle &p)
Unbound function access to abs PID code.
Definition: ParticleUtils.hh:26
Quantity
Available categories of cut objects.
Definition: Cuts.hh:48
std::string toString(const AnalysisInfo &ai)
String representation.
std::ostream & operator<<(std::ostream &os, const AnalysisInfo &ai)
Stream an AnalysisInfo as a text description.
Definition: AnalysisInfo.hh:348
Cut operator|(const Cut &aptr, const Cut &bptr)
Logical OR operation on two cuts.