Rivet  3.1.3
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 
11  class CutBase {
12  public:
13 
17  template <typename ClassToCheck>
18  bool accept(const ClassToCheck&) const;
19 
22  template <typename ClassToCheck>
23  bool operator () (const ClassToCheck& x) const { return accept(x); }
24 
26  virtual bool operator == (const Cut&) const = 0;
27 
29  virtual std::string toString() const = 0;
30 
32  virtual ~CutBase() {}
33 
34 
35  protected:
36 
38  virtual bool _accept(const CuttableBase&) const = 0;
39 
40  };
41 
42 
44  inline bool operator == (const Cut& a, const Cut& b) { return *a == b; }
45 
48  Cut operator , (const Cut&, const Cut&) = delete;
49  Cut& operator , (Cut&, Cut&) = delete;
50  Cut operator , (Cut, Cut) = delete;
52 
53 
55  namespace Cuts {
56 
58  enum Quantity { pT=0, pt=0, Et=1, et=1, E=2, energy=2,
59  mass, rap, absrap, eta, abseta, phi,
61 
63  const Cut& open(); //< access by factory function
64 
65  extern const Cut& OPEN; //= open(); //< access by constant
66  extern const Cut& NOCUT; //= open(); //< access by constant
67 
69 
70  Cut range(Quantity, double m, double n);
71  inline Cut ptIn(double m, double n) { return range(pT, m,n); }
72  inline Cut etIn(double m, double n) { return range(Et, m,n); }
73  inline Cut energyIn(double m, double n) { return range(energy, m,n); }
74  inline Cut massIn(double m, double n) { return range(mass, m,n); }
75  inline Cut rapIn(double m, double n) { return range(rap, m,n); }
76  inline Cut absrapIn(double m, double n) { return range(absrap, m,n); }
77  inline Cut etaIn(double m, double n) { return range(eta, m,n); }
78  inline Cut absetaIn(double m, double n) { return range(abseta, m,n); }
80 
81  }
82 
83 
85 
86  Cut operator == (Cuts::Quantity, double);
87  Cut operator != (Cuts::Quantity, double);
88  Cut operator < (Cuts::Quantity, double);
89  Cut operator > (Cuts::Quantity, double);
90  Cut operator <= (Cuts::Quantity, double);
91  Cut operator >= (Cuts::Quantity, double);
92 
94 
95  inline Cut operator == (Cuts::Quantity qty, int i) { return qty == double(i); }
96  inline Cut operator != (Cuts::Quantity qty, int i) { return qty != double(i); }
97  // Cut operator == (Cuts::Quantity qty, int i);
98  // Cut operator != (Cuts::Quantity qty, int i);
99  inline Cut operator < (Cuts::Quantity qty, int i) { return qty < double(i); }
100  inline Cut operator > (Cuts::Quantity qty, int i) { return qty > double(i); }
101  inline Cut operator <= (Cuts::Quantity qty, int i) { return qty <= double(i); }
102  inline Cut operator >= (Cuts::Quantity qty, int i) { return qty >= double(i); }
104 
106 
107 
109 
110 
113  Cut operator && (const Cut & aptr, const Cut & bptr);
116  Cut operator || (const Cut & aptr, const Cut & bptr);
118  Cut operator ! (const Cut & cptr);
119 
121  Cut operator & (const Cut & aptr, const Cut & bptr);
123  Cut operator | (const Cut & aptr, const Cut & bptr);
125  Cut operator ~ (const Cut & cptr);
127  Cut operator ^ (const Cut & aptr, const Cut & bptr);
128 
130 
131 
133  inline std::ostream& operator << (std::ostream& os, const Cut& cptr) {
134  os << cptr->toString();
135  return os;
136  }
137 
138 
139 }
140 
141 #endif
Definition: MC_Cent_pPb.hh:10
int abscharge3(int pid)
Return the absolute value of 3 times the EM charge.
Definition: ParticleIdUtils.hh:865
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.
double charge(int pid)
Return the EM charge (as floating point)
Definition: ParticleIdUtils.hh:868
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:44
int charge3(int pid)
Three times the EM charge (as integer)
Definition: ParticleIdUtils.hh:800
Cut operator||(const Cut &aptr, const Cut &bptr)
double abscharge(int pid)
Return the EM charge (as floating point)
Definition: ParticleIdUtils.hh:871
Cut operator&&(const Cut &aptr, const Cut &bptr)
int abspid(const Particle &p)
Unbound function access to abs PID code.
Definition: ParticleUtils.hh:26
Cut operator,(const Cut &, const Cut &)=delete
Quantity
Available categories of cut objects.
Definition: Cuts.hh:58
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:365
Cut operator|(const Cut &aptr, const Cut &bptr)
Logical OR operation on two cuts.