JANA2
C++ framework for multi-threaded data processing
JEvent Class Reference
Inheritance diagram for JEvent:
[legend]
Collaboration diagram for JEvent:
[legend]

Public Member Functions

 JEvent (JApplication *aApplication=nullptr)
 
void SetFactorySet (JFactorySet *aFactorySet)
 
JFactorySetGetFactorySet () const
 
JFactoryGetFactory (const std::string &object_name, const std::string &tag) const
 GetFactory() should be used with extreme care because it subverts the JEvent abstraction. More...
 
std::vector< JFactory * > GetAllFactories () const
 GetAllFactories() should be used with extreme care because it subverts the JEvent abstraction. More...
 
template<class T >
JFactoryT< T > * GetFactory (const std::string &tag="", bool throw_on_missing=false) const
 GetFactory() should be used with extreme care because it subverts the JEvent abstraction. More...
 
template<class T >
std::vector< JFactoryT< T > * > GetFactoryAll (bool throw_on_missing=false) const
 GetFactoryAll returns all JFactoryT's for type T (each corresponds to a different tag). More...
 
template<class T >
JFactoryT< T > * Get (const T **item, const std::string &tag="") const
 C-style getters. More...
 
template<class T >
JFactoryT< T > * Get (std::vector< const T * > &vec, const std::string &tag="", bool strict=true) const
 
template<class T >
void GetAll (std::vector< const T * > &vec) const
 GetAll returns all JObjects of (child) type T, regardless of tag.
 
template<class T >
const T * GetSingle (const std::string &tag="") const
 C++ style getters. More...
 
template<class T >
const T * GetSingleStrict (const std::string &tag="") const
 GetSingleStrict conveniently returns one item from inside the JFactory. More...
 
template<class T >
std::vector< const T * > Get (const std::string &tag="", bool strict=true) const
 
template<class T >
JFactoryT< T >::PairType GetIterators (const std::string &aTag="") const
 
template<class T >
std::vector< const T * > GetAll () const
 GetAll returns all JObjects of (child) type T, regardless of tag.
 
template<class T >
std::map< std::pair< std::string, std::string >, std::vector< T * > > GetAllChildren () const
 
template<class T >
JFactoryT< T > * GetSingle (const T *&t, const char *tag="", bool exception_if_not_one=true) const
 
template<class T >
JFactoryT< T > * Insert (T *item, const std::string &aTag="") const
 Insert() allows an EventSource to insert items directly into the JEvent, removing the need for user-extended JEvents and/or JEventSource::GetObjects(...) Repeated calls to Insert() will append to the previous data rather than overwrite it, which saves the user from having to allocate a throwaway vector and requires less error handling.
 
template<class T >
JFactoryT< T > * Insert (const std::vector< T * > &items, const std::string &tag="") const
 
void SetRunNumber (int32_t aRunNumber)
 
void SetEventNumber (uint64_t aEventNumber)
 
void SetJApplication (JApplication *app)
 
void SetJEventSource (JEventSource *aSource)
 
void SetDefaultTags (std::map< std::string, std::string > aDefaultTags)
 
void SetSequential (bool isSequential)
 
int32_t GetRunNumber () const
 
uint64_t GetEventNumber () const
 
JApplicationGetJApplication () const
 
JEventSourceGetJEventSource () const
 
JCallGraphRecorderGetJCallGraphRecorder () const
 
JInspectorGetJInspector () const
 
void Inspect () const
 
bool GetSequential () const
 
JEventLevel GetLevel () const
 
void SetLevel (JEventLevel level)
 
void SetEventIndex (int event_index)
 
int64_t GetEventIndex () const
 
bool HasParent (JEventLevel level) const
 
const JEventGetParent (JEventLevel level) const
 
void SetParent (std::shared_ptr< JEvent > *parent)
 
std::shared_ptr< JEvent > * ReleaseParent (JEventLevel level)
 
void Release ()
 
void Reset ()
 
template<class S >
std::map< std::pair< std::string, std::string >, std::vector< S * > > GetAllChildren () const
 

Friends

class JEventPool
 

Member Function Documentation

◆ Get()

template<class T >
JFactoryT< T > * JEvent::Get ( const T **  destination,
const std::string &  tag = "" 
) const

C-style getters.

Get conveniently returns one item from inside the JFactory. This should be used when the data in question is optional and the caller wants to examine the result and decide how to proceed. The caller should embed this inside an if-block. Get updates the destination out parameter and returns a pointer to the enclosing JFactory.

  • If the factory is missing, GetSingle throws an exception.
  • If the factory exists but contains no items, GetSingle updates the destination to point to nullptr.
  • If the factory contains exactly one item, GetSingle updates the destination to point to that item.
  • If the factory contains more than one item, GetSingle updates the destination to point to the first time.

Referenced by GetSingle().

◆ GetAllFactories()

std::vector< JFactory * > JEvent::GetAllFactories ( ) const
inline

GetAllFactories() should be used with extreme care because it subverts the JEvent abstraction.

Most historical uses of GetFactory are far better served by JMultifactory

◆ GetFactory() [1/2]

JFactory * JEvent::GetFactory ( const std::string &  object_name,
const std::string &  tag 
) const
inline

GetFactory() should be used with extreme care because it subverts the JEvent abstraction.

Most historical uses of GetFactory are far better served by JMultifactory

◆ GetFactory() [2/2]

template<class T >
JFactoryT< T > * JEvent::GetFactory ( const std::string &  tag = "",
bool  throw_on_missing = false 
) const
inline

GetFactory() should be used with extreme care because it subverts the JEvent abstraction.

Most historical uses of GetFactory are far better served by JMultifactory.

◆ GetFactoryAll()

template<class T >
std::vector< JFactoryT< T > * > JEvent::GetFactoryAll ( bool  throw_on_missing = false) const
inline

GetFactoryAll returns all JFactoryT's for type T (each corresponds to a different tag).

This is useful when there are many different tags, or the tags are unknown, and the user wishes to examine them all together.

◆ GetSingle() [1/2]

template<class T >
const T * JEvent::GetSingle ( const std::string &  tag = "") const

C++ style getters.

GetSingle conveniently returns one item from inside the JFactory. This should be used when the data in question is optional and the caller wants to examine the result and decide how to proceed. The caller should embed this inside an if-block.

  • If the factory is missing, GetSingle throws an exception
  • If the factory exists but contains no items, GetSingle returns nullptr
  • If the factory contains more than one item, GetSingle returns the first item

◆ GetSingle() [2/2]

template<class T >
JFactoryT< T > * JEvent::GetSingle ( const T *&  t,
const char *  tag = "",
bool  exception_if_not_one = true 
) const

This is a convenience method that can be used to get a pointer to the single object of type T from the specified factory. It simply calls the Get(vector<...>) method and copies the first pointer into "t" (or NULL if something other than 1 object is returned).

This is intended to address the common situation in which there is an interest in the event if and only if there is exactly 1 object of type T. If the event has no objects of that type or more than 1 object of that type (for the specified factory) then an exception of type "unsigned long" is thrown with the value being the number of objects of type T. You can supress the exception by setting exception_if_not_one to false. In that case, you will have to check if t==NULL to know if the call succeeded.

References Get().

◆ GetSingleStrict()

template<class T >
const T * JEvent::GetSingleStrict ( const std::string &  tag = "") const

GetSingleStrict conveniently returns one item from inside the JFactory.

This should be used when the data in question is mandatory, and its absence indicates an error which should stop execution. The caller does not need to embed this in an if- or try-catch block; it can be a one-liner.

  • If the factory is missing, GetSingleStrict throws an exception
  • If the factory exists but contains no items, GetSingleStrict throws an exception
  • If the factory contains more than one item, GetSingleStrict throws an exception

The documentation for this class was generated from the following file: