rivet is hosted by Hepforge, IPPP Durham
Rivet 4.0.0
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
39
42
45
47 virtual unique_ptr<Projection> clone() const = 0;
48
50 virtual ~Projection() = default;
51
53 virtual Projection& operator = (const Projection&) = delete;
54
56 Projection(const Projection&) = default;
57
59
60
62 virtual std::string name() const {
63 return _name;
64 }
65
67 bool valid() const {
68 return _isValid;
69 }
70
72 bool failed() const {
73 return !valid();
74 }
75
78
83 virtual void project(const Event& e) = 0;
84
104 virtual CmpState compare(const Projection& p) const = 0;
105
111 bool before(const Projection& p) const;
112
114
115
116
117 // /// @name Beam configuration
118 // /// @todo Does it really make sense to restrict Projections to particular beam configs? Do we use this in practice?
119 // /// @{
120
121 // /// Return the allowed beam pairs on which this projection can operate, not
122 // /// including recursion. Derived classes should ensure that all contained
123 // /// projections are registered in the @a _projections set for the beam
124 // /// constraint chaining to work.
125 // /// @todo Remove the beam constraints system from projections.
126 // virtual const std::set<PdgIdPair> beamPairs() const;
127
128
129 // /// Add a colliding beam pair.
130 // /// @todo This deserves a better name!
131 // Projection& addPdgIdPair(PdgId beam1, PdgId beam2) {
132 // _beamPairs.insert(PdgIdPair(beam1, beam2));
133 // return *this;
134 // }
135
136 // /// @}
137
138
139 protected:
140
142 Log& getLog() const {
143 string logname = "Rivet.Projection." + name();
144 return Log::getLog(logname);
145 }
146
148 void setName(const std::string& name) {
149 _name = name;
150 }
151
153 void fail() {
154 _isValid = false;
155 }
156
159 Cmp<Projection> mkNamedPCmp(const Projection& otherparent, const std::string& pname) const;
160
165 Cmp<Projection> mkPCmp(const Projection& otherparent, const std::string& pname) const;
166
167
168 private:
169
172 string _name;
173
175 bool _isValid;
176
177 };
178
179
180}
181
182
184inline bool std::less<const Rivet::Projection *>::operator()(const Rivet::Projection* x,
185 const Rivet::Projection* y) const {
186 return x->before(*y);
187}
188
189
190#endif
191
192
193#include "Rivet/Event.hh"
194#include "Rivet/Particle.hh"
195#include "Rivet/Tools/Cmp.hh"
196
197
200#define RIVET_DEFAULT_PROJ_CLONE(clsname) \
201 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)
Common base class for Projection and Analysis, used for internal polymorphism.
Definition ProjectionApplier.hh:22
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.
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:67
void setName(const std::string &name)
Used by derived classes to set their name.
Definition Projection.hh:148
virtual std::string name() const
Get the name of the projection.
Definition Projection.hh:62
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:142
friend class Cmp< Projection >
The Cmp specialization for Projection is a friend.
Definition Projection.hh:36
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:72
void fail()
Set the projection in an unvalid state.
Definition Projection.hh:153
Definition MC_CENT_PPB_Projections.hh:10