Rivet API documentation

Rivet 4.1.3
Projection.hh
1// -*- C++ -*-
2#ifndef RIVET_Projection_HH
3 #define RIVET_Projection_HH
4
5 #include "Rivet/Projection.fhh"
6 #include "Rivet/ProjectionApplier.hh"
7 #include "Rivet/ProjectionHandler.hh"
8 #include "Rivet/Config/RivetCommon.hh"
9 #include "Rivet/Tools/Cuts.hh"
10// NOTE: Cmp.hh, Event.hh and Particle.hh included at the bottom
11
12namespace Rivet {
13
14
15 // Forward declaration
16 class Event;
17
18
30 public:
31
33 friend class Event;
34
36 friend class Cmp<Projection>;
37
38
41
44
46 virtual unique_ptr<Projection> clone() const = 0;
47
49 virtual ~Projection() = default;
50
52 virtual Projection& operator=(const Projection&) = delete;
53
55 Projection(const Projection&) = default;
56
58
59
61 virtual std::string name() const {
62 return _name;
63 }
64
66 bool valid() const {
67 return _isValid;
68 }
69
71 bool failed() const {
72 return !valid();
73 }
74
77
82 virtual void project(const Event& e) = 0;
83
103 virtual CmpState compare(const Projection& p) const = 0;
104
110 bool before(const Projection& p) const;
111
113
114
115 // /// @name Beam configuration
116 // /// @todo Does it really make sense to restrict Projections to particular beam configs? Do we use this in practice?
117 // /// @{
118
119 // /// Return the allowed beam pairs on which this projection can operate, not
120 // /// including recursion. Derived classes should ensure that all contained
121 // /// projections are registered in the @a _projections set for the beam
122 // /// constraint chaining to work.
123 // /// @todo Remove the beam constraints system from projections.
124 // virtual const std::set<PdgIdPair> beamPairs() const;
125
126
127 // /// Add a colliding beam pair.
128 // /// @todo This deserves a better name!
129 // Projection& addPdgIdPair(PdgId beam1, PdgId beam2) {
130 // _beamPairs.insert(PdgIdPair(beam1, beam2));
131 // return *this;
132 // }
133
134 // /// @}
135
136
137 protected:
138
140 Log& getLog() const {
141 string logname = "Rivet.Projection." + name();
142 return Log::getLog(logname);
143 }
144
146 void setName(const std::string& name) {
147 _name = name;
148 }
149
151 void fail() {
152 _isValid = false;
153 }
154
157 Cmp<Projection> mkNamedPCmp(const Projection& otherparent, const std::string& pname) const;
158
163 Cmp<Projection> mkPCmp(const Projection& otherparent, const std::string& pname) const;
164
165
166 private:
167
170 string _name;
171
173 bool _isValid;
174 };
175
176
177}
178
179
181inline bool std::less<const Rivet::Projection*>::operator()(const Rivet::Projection* x,
182 const Rivet::Projection* y) const {
183 return x->before(*y);
184}
185
186
187#endif
188
189
190#include "Rivet/Event.hh"
191#include "Rivet/Particle.hh"
192#include "Rivet/Tools/Cmp.hh"
193
194
197#define RIVET_DEFAULT_PROJ_CLONE(clsname) \
198 virtual unique_ptr<Projection> clone() const { return unique_ptr<Projection>(new clsname(*this)); }
Representation of a HepMC event, and enabler of Projection caching.
Definition Event.hh:22
Logging system for controlled & formatted writing to stdout.
Definition Logging.hh:10
static Log & getLog(const std::string &name)
ProjectionApplier()
Constructor.
Base class for all Rivet projections.
Definition Projection.hh:29
Projection(const Projection &)=default
Explicit (but not careful!) copy construction (required for clone()).
Projection()
The default constructor.
friend class Event
Event is a friend.
Definition Projection.hh:33
virtual Projection & operator=(const Projection &)=delete
Suppress copy assignment.
virtual CmpState compare(const Projection &p) const =0
virtual unique_ptr< Projection > clone() const =0
Clone on the heap.
Cmp< Projection > mkPCmp(const Projection &otherparent, const std::string &pname) const
bool valid() const
Get the state of the projetion.
Definition Projection.hh:66
void setName(const std::string &name)
Used by derived classes to set their name.
Definition Projection.hh:146
virtual std::string name() const
Get the name of the projection.
Definition Projection.hh:61
bool before(const Projection &p) const
Log & getLog() const
Get a Log object based on the getName() property of the calling projection object.
Definition Projection.hh:140
virtual ~Projection()=default
Virtual destructor for safe inheritability.
Cmp< Projection > mkNamedPCmp(const Projection &otherparent, const std::string &pname) const
virtual void project(const Event &e)=0
bool failed() const
Get the state of the projetion.
Definition Projection.hh:71
void fail()
Set the projection in an unvalid state.
Definition Projection.hh:151
double p(const ParticleBase &p)
Unbound function access to p.
Definition ParticleBaseUtils.hh:819
Definition LHCbCommon.hh:9