5 #include "Rivet/Config/RivetCommon.hh" 6 #include "Rivet/Particle.hh" 7 #include "Rivet/Projection.hh" 29 Event(
const GenEvent* ge,
const vector<size_t>& indices = {},
bool strip =
false)
30 : _weightIndices(indices), _genevent_original(ge) {
33 if ( strip ) _strip(_genevent);
39 Event(
const GenEvent& ge,
const vector<size_t>& indices = {},
bool strip =
false)
40 : _weightIndices(indices), _genevent_original(&ge), _genevent(ge) {
41 if ( strip ) _strip(_genevent);
47 : _weightIndices(e._weightIndices),
48 _genevent_original(e._genevent_original),
49 _genevent(e._genevent)
59 const GenEvent*
genEvent()
const {
return &_genevent; }
65 ParticlePair
beams()
const;
92 template <
typename FN>
101 std::valarray<double>
weights()
const;
104 DEPRECATED(
"Event weight does not need to be included anymore. For compatibility, it's always == 1 now.")
125 template <
typename PROJ>
128 static bool docaching =
getEnvParam(
"RIVET_CACHE_PROJECTIONS",
true);
130 log << Log::TRACE <<
"Applying projection " << &p <<
" (" << p.name() <<
") -> comparing to projections " << _projections << std::endl;
135 std::set<const Projection*>::const_iterator old = std::begin(_projections);
136 std::uintptr_t recpp =
reinterpret_cast<std::uintptr_t
>(cpp);
137 for (; old != _projections.end(); ++old)
138 if (reinterpret_cast<std::uintptr_t>(*old) == recpp)
break;
139 if (old != _projections.end()) {
140 log << Log::TRACE <<
"Equivalent projection found -> returning already-run projection " << *old << std::endl;
142 return pcast<PROJ>(pRef);
144 log << Log::TRACE <<
"No equivalent projection in the already-run list -> projecting now" << std::endl;
146 log << Log::TRACE <<
"Applying projection " << &p <<
" (" << p.name() <<
") WITHOUT projection caching & comparison" << std::endl;
152 if (docaching) _projections.insert(pp);
158 template <
typename PROJ>
160 if (!pp)
throw Error(
"Event::applyProjection(PROJ*): Projection pointer is null.");
170 void _init(
const GenEvent& ge);
174 void _strip(GenEvent & ge);
187 const std::vector<size_t> _weightIndices;
195 const GenEvent* _genevent_original;
206 mutable GenEvent _genevent;
210 mutable Particles _particles;
213 mutable std::set<ConstProjectionPtr> _projections;
const GenEvent * originalGenEvent() const
The generated event obtained from an external event generator.
Definition: Event.hh:62
Particles allParticles(const FN &f) const
All the raw GenEvent particles, wrapped in Rivet::Particle objects, but with a selection function app...
Definition: Event.hh:93
Definition: MC_Cent_pPb.hh:10
T getEnvParam(const std::string name, const T &fallback)
Get a parameter from a named environment variable, with automatic type conversion.
Definition: Utils.hh:667
double asqrtS() const
Get the beam centre-of-mass energy per nucleon.
const Particles & allParticles() const
All the raw GenEvent particles, wrapped in Rivet::Particle objects.
static Log & getLog(const std::string &name)
Jets filter_select(const Jets &jets, const Cut &c)
Filter a jet collection in-place to the subset that passes the supplied Cut.
Definition: JetUtils.hh:160
Event(const GenEvent &ge, const vector< size_t > &indices={}, bool strip=false)
Definition: Event.hh:39
Particles allParticles(const Cut &c) const
All the raw GenEvent particles, wrapped in Rivet::Particle objects, but with a Cut applied...
Definition: Event.hh:85
const PROJ & applyProjection(PROJ *pp) const
Add a projection p to this Event by pointer.
Definition: Event.hh:159
Event(const GenEvent *ge, const vector< size_t > &indices={}, bool strip=false)
Constructor from a HepMC GenEvent pointer.
Definition: Event.hh:29
ParticlePair beams() const
Get the beam particles.
const GenEvent * genEvent() const
The generated event obtained from an external event generator.
Definition: Event.hh:59
Logging system for controlled & formatted writing to stdout.
Definition: Logging.hh:10
Generic runtime Rivet error.
Definition: Exceptions.hh:12
virtual void project(const Event &e)=0
double sqrtS() const
Get the beam centre-of-mass energy.
Representation of a HepMC event, and enabler of Projection caching.
Definition: Event.hh:22
const PROJ & applyProjection(PROJ &p) const
Add a projection p to this Event.
Definition: Event.hh:126
Event(const Event &e)
Copy constructor.
Definition: Event.hh:46
std::valarray< double > weights() const
The generation weight associated with the event.
double weight() const
Obsolete weight method. Always returns 1 now.
Definition: Event.hh:105
Base class for all Rivet projections.
Definition: Projection.hh:29