class Rivet::ProjectionHandler

Rivet::ProjectionHandler

The projection handler is a central repository for projections to be used in a Rivet analysis run. More…

#include <ProjectionHandler.hh>

Public Types

Name
enumProjDepth { SHALLOW, DEEP}
Enum to specify depth of projection search.
typedef set< ProjHandle >ProjHandles
Typedef for a vector of Projection pointers.
typedef map< string, ProjHandle >NamedProjs
Typedef for the structure used to contain named projections for a particular containing Analysis or Projection.

Public Functions

Name
~ProjectionHandler() =default
Private destructor means no inheritance from this class.
ProjectionHandler &operator=(const ProjectionHandler & ) =delete
The assignment operator is hidden.
ProjectionHandler(const ProjectionHandler & ) =delete
The copy constructor is hidden.
ProjectionHandler() =default
The standard constructor.
ProjectionHandler &getInstance()
const Projection &registerProjection(const ProjectionApplier & parent, const Projection & proj, const string & name)
Attach and retrieve a projection as a reference.
boolhasProjection(const ProjectionApplier & parent, const string & name) const
Check if there is a name projection registered by parent.
const Projection &getProjection(const ProjectionApplier & parent, const string & name) const
set< const Projection * >getChildProjections(const ProjectionApplier & parent, ProjDepth depth =SHALLOW) const

Public Attributes

Name
std::mutexmtx
Singleton creation function.

Friends

Name
classProjectionApplier
ProjectionApplier’s destructor needs to trigger cleaning up the proj handler repo.

Detailed Description

class Rivet::ProjectionHandler;

The projection handler is a central repository for projections to be used in a Rivet analysis run.

Without centralised projections, it can be hard to know which of an equivalent set of projections will be run on a particular event. In turn, this may mean that certain projections in the chain can go out of scope unexpectedly. There were originally also the issues that projections may need to be held as member pointers to an abstract base class, since post-construction setup is needed; that projections contained pointers to their own dependency chain, which could go out of scope; and that projection members could be modified after being applied to an event which, due to the caching model, would have unpredictable consequences.

By centralising all the projections, these issues are eliminated, as well as allowing analysis classes to contain fewer data members (since projections are now better accessed by name than by storing a data member reference or pointer).

The core of the ProjectionHandler design is that it is a singleton class, essentially a wrapper around a map of Projection*, indexed by a hash of the registering object and its local name for the registered projection.

Public Types Documentation

enum ProjDepth

EnumeratorValueDescription
SHALLOW
DEEP

Enum to specify depth of projection search.

typedef ProjHandles

typedef set<ProjHandle> Rivet::ProjectionHandler::ProjHandles;

Typedef for a vector of Projection pointers.

typedef NamedProjs

typedef map<string, ProjHandle> Rivet::ProjectionHandler::NamedProjs;

Typedef for the structure used to contain named projections for a particular containing Analysis or Projection.

Public Functions Documentation

function ~ProjectionHandler

~ProjectionHandler() =default

Private destructor means no inheritance from this class.

function operator=

ProjectionHandler & operator=(
    const ProjectionHandler & 
) =delete

The assignment operator is hidden.

function ProjectionHandler

ProjectionHandler(
    const ProjectionHandler & 
) =delete

The copy constructor is hidden.

function ProjectionHandler

ProjectionHandler() =default

The standard constructor.

function getInstance

static inline ProjectionHandler & getInstance()

function registerProjection

const Projection & registerProjection(
    const ProjectionApplier & parent,
    const Projection & proj,
    const string & name
)

Attach and retrieve a projection as a reference.

function hasProjection

bool hasProjection(
    const ProjectionApplier & parent,
    const string & name
) const

Check if there is a name projection registered by parent.

function getProjection

const Projection & getProjection(
    const ProjectionApplier & parent,
    const string & name
) const

Retrieve a named projection for the given parent. Returning as a reference is partly to discourage ProjectionApplier classes from storing pointer members to the registered projections, since that can lead to problems and there is no need to do so.

function getChildProjections

set< const Projection * > getChildProjections(
    const ProjectionApplier & parent,
    ProjDepth depth =SHALLOW
) const

Get child projections for the given parent. By default this will just return the projections directly contained by the parent, but the depth argument can be changed to do a deep retrieval, which will recurse through the whole projection chain. In this case, there is no protection against getting stuck in a circular projection dependency loop.

Public Attributes Documentation

variable mtx

static std::mutex mtx;

Singleton creation function.

Friends

friend ProjectionApplier

friend class ProjectionApplier(
    ProjectionApplier 
);

ProjectionApplier’s destructor needs to trigger cleaning up the proj handler repo.


Updated on 2022-08-07 at 20:17:17 +0100