Rivet  1.8.3
JetAlg.hh
1 // -*- C++ -*-
2 #ifndef RIVET_JetAlg_HH
3 #define RIVET_JetAlg_HH
4 
5 #include "Rivet/Projection.hh"
6 #include "Rivet/Projections/FinalState.hh"
7 #include "Rivet/Projections/VisibleFinalState.hh"
8 #include "Rivet/Particle.hh"
9 #include "Rivet/Jet.hh"
10 
11 namespace Rivet {
12 
13 
14  inline bool cmpMomByPt(const FourMomentum& a, const FourMomentum& b) {
15  return a.pT() > b.pT();
16  }
17  inline bool cmpMomByAscPt(const FourMomentum& a, const FourMomentum& b) {
18  return a.pT() < b.pT();
19  }
20  inline bool cmpMomByP(const FourMomentum& a, const FourMomentum& b) {
21  return a.vector3().mod() > b.vector3().mod();
22  }
23  inline bool cmpMomByAscP(const FourMomentum& a, const FourMomentum& b) {
24  return a.vector3().mod() < b.vector3().mod();
25  }
26  inline bool cmpMomByEt(const FourMomentum& a, const FourMomentum& b) {
27  return a.Et() > b.Et();
28  }
29  inline bool cmpMomByAscEt(const FourMomentum& a, const FourMomentum& b) {
30  return a.Et() < b.Et();
31  }
32  inline bool cmpMomByE(const FourMomentum& a, const FourMomentum& b) {
33  return a.E() > b.E();
34  }
35  inline bool cmpMomByAscE(const FourMomentum& a, const FourMomentum& b) {
36  return a.E() < b.E();
37  }
38  inline bool cmpMomByDescPseudorapidity(const FourMomentum& a, const FourMomentum& b) {
39  return a.pseudorapidity() > b.pseudorapidity();
40  }
41  inline bool cmpMomByAscPseudorapidity(const FourMomentum& a, const FourMomentum& b) {
42  return a.pseudorapidity() < b.pseudorapidity();
43  }
44  inline bool cmpMomByDescAbsPseudorapidity(const FourMomentum& a, const FourMomentum& b) {
45  return fabs(a.pseudorapidity()) > fabs(b.pseudorapidity());
46  }
47  inline bool cmpMomByAscAbsPseudorapidity(const FourMomentum& a, const FourMomentum& b) {
48  return fabs(a.pseudorapidity()) < fabs(b.pseudorapidity());
49  }
50  inline bool cmpMomByDescRapidity(const FourMomentum& a, const FourMomentum& b) {
51  return a.rapidity() > b.rapidity();
52  }
53  inline bool cmpMomByAscRapidity(const FourMomentum& a, const FourMomentum& b) {
54  return a.rapidity() < b.rapidity();
55  }
56  inline bool cmpMomByDescAbsRapidity(const FourMomentum& a, const FourMomentum& b) {
57  return fabs(a.rapidity()) > fabs(b.rapidity());
58  }
59  inline bool cmpMomByAscAbsRapidity(const FourMomentum& a, const FourMomentum& b) {
60  return fabs(a.rapidity()) < fabs(b.rapidity());
61  }
62 
63 
65  class JetAlg : public Projection {
66  public:
67 
69  JetAlg(const FinalState& fs);
70 
71  JetAlg() {};
72 
74  virtual const Projection* clone() const = 0;
75 
77  virtual ~JetAlg() { }
78 
85  void useInvisibles(bool useinvis=true) {
86  _useInvisibles = useinvis;
87  }
88 
91  virtual Jets jets(double ptmin=0.0, double ptmax=MAXDOUBLE,
92  double rapmin=-MAXDOUBLE, double rapmax=MAXDOUBLE,
93  RapScheme rapscheme=PSEUDORAPIDITY) const {
94  const Jets rawjets = _jets(ptmin);
95  Jets rtn;
96  MSG_DEBUG("Raw jet size (with pTmin cut = " << ptmin/GeV << "GeV) = " << rawjets.size());
97  foreach (const Jet& j, rawjets) {
98  const FourMomentum pj = j.momentum();
99  if (!inRange(pj.pT(), ptmin, ptmax)) continue;
100  if (rapscheme == PSEUDORAPIDITY && !inRange(pj.eta(), rapmin, rapmax)) continue;
101  if (rapscheme == RAPIDITY && !inRange(pj.rapidity(), rapmin, rapmax)) continue;
102  rtn += j;
103  }
104  return rtn;
105  }
106 
109  template <typename F>
110  Jets jets(F sorter, double ptmin, double ptmax,
111  double rapmin, double rapmax,
112  RapScheme rapscheme) const {
113  Jets js = jets(ptmin, ptmax, rapmin, rapmax, rapscheme);
114  if (sorter != 0) {
115  std::sort(js.begin(), js.end(), sorter);
116  }
117  return js;
118  }
119 
122  Jets jetsByPt(double ptmin=0.0, double ptmax=MAXDOUBLE,
123  double rapmin=-MAXDOUBLE, double rapmax=MAXDOUBLE,
124  RapScheme rapscheme=PSEUDORAPIDITY) const {
125  return jets(cmpJetsByPt, ptmin, ptmax, rapmin, rapmax, rapscheme);
126  }
127 
130  Jets jetsByP(double ptmin=0.0, double ptmax=MAXDOUBLE,
131  double rapmin=-MAXDOUBLE, double rapmax=MAXDOUBLE,
132  RapScheme rapscheme=PSEUDORAPIDITY) const {
133  return jets(cmpJetsByP, ptmin, ptmax, rapmin, rapmax, rapscheme);
134  }
135 
138  Jets jetsByE(double ptmin=0.0, double ptmax=MAXDOUBLE,
139  double rapmin=-MAXDOUBLE, double rapmax=MAXDOUBLE,
140  RapScheme rapscheme=PSEUDORAPIDITY) const {
141  return jets(cmpJetsByE, ptmin, ptmax, rapmin, rapmax, rapscheme);
142  }
143 
146  Jets jetsByEt(double ptmin=0.0, double ptmax=MAXDOUBLE,
147  double rapmin=-MAXDOUBLE, double rapmax=MAXDOUBLE,
148  RapScheme rapscheme=PSEUDORAPIDITY) const {
149  return jets(cmpJetsByEt, ptmin, ptmax, rapmin, rapmax, rapscheme);
150  }
151 
152 
153  protected:
154 
159  virtual Jets _jets(double ptmin) const = 0;
160 
161 
162  public:
163 
165  virtual size_t size() const = 0;
166 
168  virtual void reset() = 0;
169 
170  typedef Jet entity_type;
171  typedef Jets collection_type;
172 
174  collection_type entities() const { return jets(); }
175 
177  virtual void calc(const ParticleVector& ps) = 0;
178 
179 
180  protected:
181 
183  virtual void project(const Event& e) = 0;
184 
186  virtual int compare(const Projection& p) const = 0;
187 
188 
189  protected:
190 
192  bool _useInvisibles;
193 
194  };
195 
196 
197 }
198 
199 #endif
bool cmpJetsByEt(const Jet &a, const Jet &b)
Use this so that highest is at the front of the list.
Definition: Jet.hh:205
collection_type entities() const
Template-usable interface common to FinalState.
Definition: JetAlg.hh:174
virtual void project(const Event &e)=0
Perform the projection on the Event.
bool inRange(NUM value, NUM low, NUM high, RangeBoundary lowbound=CLOSED, RangeBoundary highbound=OPEN)
Determine if value is in the range low to high, for floating point numbers.
Definition: MathUtils.hh:109
bool cmpJetsByE(const Jet &a, const Jet &b)
Compare jets by (descending - usual sorting for HEP) Use this so that highest is at the front of th...
Definition: Jet.hh:216
bool cmpJetsByP(const Jet &a, const Jet &b)
Compare jets by descending momentum, .
Definition: Jet.hh:195
Jets jetsByEt(double ptmin=0.0, double ptmax=MAXDOUBLE, double rapmin=-MAXDOUBLE, double rapmax=MAXDOUBLE, RapScheme rapscheme=PSEUDORAPIDITY) const
Definition: JetAlg.hh:146
double eta() const
Synonym for pseudorapidity.
Definition: Vector4.hh:134
const FourMomentum & momentum() const
Get equivalent single momentum four-vector.
Definition: Jet.hh:105
std::vector< Jet > Jets
Typedef for a collection of Jet objects.
Definition: Jet.hh:177
virtual void reset()=0
Clear the projection.
double pT() const
Calculate the transverse momentum .
Definition: Vector4.hh:410
Jets jets(F sorter, double ptmin, double ptmax, double rapmin, double rapmax, RapScheme rapscheme) const
Definition: JetAlg.hh:110
Definition: Event.hh:22
void useInvisibles(bool useinvis=true)
Include invisible particles in jet construction. The default behaviour is that jets are only construc...
Definition: JetAlg.hh:85
Jets jetsByPt(double ptmin=0.0, double ptmax=MAXDOUBLE, double rapmin=-MAXDOUBLE, double rapmax=MAXDOUBLE, RapScheme rapscheme=PSEUDORAPIDITY) const
Definition: JetAlg.hh:122
bool cmpJetsByPt(const Jet &a, const Jet &b)
Compare jets by (descending - usual sorting for HEP) Use this so that highest is at the front of th...
Definition: Jet.hh:185
virtual ~JetAlg()
Destructor.
Definition: JetAlg.hh:77
Jets jetsByE(double ptmin=0.0, double ptmax=MAXDOUBLE, double rapmin=-MAXDOUBLE, double rapmax=MAXDOUBLE, RapScheme rapscheme=PSEUDORAPIDITY) const
Definition: JetAlg.hh:138
virtual Jets jets(double ptmin=0.0, double ptmax=MAXDOUBLE, double rapmin=-MAXDOUBLE, double rapmax=MAXDOUBLE, RapScheme rapscheme=PSEUDORAPIDITY) const
Definition: JetAlg.hh:91
virtual int compare(const Projection &p) const =0
Compare projections.
Project out all final-state particles in an event. Probably the most important projection in Rivet! ...
Definition: FinalState.hh:14
RapScheme
Enum for rapidity variable to be used in calculating , applying rapidity cuts, etc.
Definition: MathHeader.hh:60
virtual size_t size() const =0
Number of jets.
std::vector< Particle > ParticleVector
Typedef for a vector of Particle objects.
Definition: Particle.fhh:14
virtual void calc(const ParticleVector &ps)=0
Do the calculation locally (no caching).
Representation of a clustered jet of particles.
Definition: Jet.hh:12
Jets jetsByP(double ptmin=0.0, double ptmax=MAXDOUBLE, double rapmin=-MAXDOUBLE, double rapmax=MAXDOUBLE, RapScheme rapscheme=PSEUDORAPIDITY) const
Definition: JetAlg.hh:130
Base class for all Rivet projections.
Definition: Projection.hh:28
double rapidity() const
Calculate the rapidity.
Definition: Vector4.hh:400
Specialized version of the FourVector with momentum/energy functionality.
Definition: Vector4.hh:324
Abstract base class for projections which can return a set of Jets.
Definition: JetAlg.hh:65
virtual const Projection * clone() const =0
Clone on the heap.