rivet is hosted by Hepforge, IPPP Durham
Rivet  2.7.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 };
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: ALICE_2010_I880049.cc:13
Cut operator&(const Cut &aptr, const Cut &bptr)
Logical AND operation on two cuts.
Definition: Cuts.cc:329
Cut operator~(const Cut &cptr)
Logical NOT operation on a cut.
Definition: Cuts.cc:337
int abspid(const Particle &p)
Unbound function access to abs PID code.
Definition: ParticleUtils.hh:23
Cut operator!(const Cut &cptr)
Logical NOT operation on a cut.
Definition: Cuts.cc:324
virtual std::string toString() const =0
String representation.
virtual ~CutBase()
Default destructor.
Definition: Cuts.hh:30
Cut operator^(const Cut &aptr, const Cut &bptr)
Logical XOR operation on two cuts.
Definition: Cuts.cc:341
int pid(const Particle &p)
Unbound function access to PID code.
Definition: ParticleUtils.hh:20
bool accept(const ClassToCheck &) const
Cut operator||(const Cut &aptr, const Cut &bptr)
Definition: Cuts.cc:320
Cut operator&&(const Cut &aptr, const Cut &bptr)
Operators.
Definition: Cuts.cc:316
const Cut & open()
Fully open cut singleton, accepts everything.
Definition: Cuts.cc:81
Quantity
Available categories of cut objects.
Definition: Cuts.hh:48
Definition: Cuts.hh:10
bool operator()(const ClassToCheck &x) const
Call operator alias for accept.
Definition: Cuts.hh:21
virtual bool operator==(const Cut &) const =0
Comparison to another Cut.
Cut operator|(const Cut &aptr, const Cut &bptr)
Logical OR operation on two cuts.
Definition: Cuts.cc:333