ARTEMIS-CRIB
 
Loading...
Searching...
No Matches
art::crib::util Namespace Reference

Functions

template<typename T >
std::enable_if_t< std::is_base_of_v< TObject, T >, std::variant< T **, TString > > GetInputObject (TEventCollection *col, const TString &name, const TString &expectedTypeName, const TString &elementTypeName="TObject")
 Retrieve an object from TEventCollection with type validation.
 
template<typename T >
std::enable_if_t< std::is_base_of_v< TObject, T >, std::variant< T *, TString > > GetParameterObject (TEventCollection *col, const TString &name, const TString &expectedTypeName, const TString &elementTypeName="art::TParameterObject")
 Retrieves a parameter object from a TEventCollection.
 

Function Documentation

◆ GetInputObject()

template<typename T >
std::enable_if_t< std::is_base_of_v< TObject, T >, std::variant< T **, TString > > art::crib::util::GetInputObject ( TEventCollection * col,
const TString & name,
const TString & expectedTypeName,
const TString & elementTypeName = "TObject" )

Retrieve an object from TEventCollection with type validation.

This function checks if the specified object exists in the TEventCollection and verifies that its type matches the expected ROOT class type. If the object is of type TClonesArray, it further checks that the elements of the array match the specified element type.

  • col->GetObjectRef(name) is used to retrieve the object reference.
  • If the object type does not match expectedTypeName, an error message is returned.
  • For TClonesArray, the element type is verified using GetClass.
Template Parameters
TExpected type of the object, must derive from TObject.
Parameters
colPointer to the TEventCollection.
nameName of the object in the collection.
expectedTypeNameExpected ROOT class name of the object.
elementTypeName(Optional) Expected type of elements if T is TClonesArray.
Returns
std::variant containing a pointer to the object if successful, or a TString with an error message.

Definition at line 44 of file TProcessorUtil.h.

◆ GetParameterObject()

template<typename T >
std::enable_if_t< std::is_base_of_v< TObject, T >, std::variant< T *, TString > > art::crib::util::GetParameterObject ( TEventCollection * col,
const TString & name,
const TString & expectedTypeName,
const TString & elementTypeName = "art::TParameterObject" )

Retrieves a parameter object from a TEventCollection.

Template Parameters
TThe type of the parameter object to retrieve. Must be derived from TObject. When T is TClonesArray, the element type is additionally validated.
Parameters
colPointer to the TEventCollection from which the parameter object is obtained.
nameName of the parameter object.
expectedTypeNameThe expected type name for the parameter object.
elementTypeName(Optional) For TClonesArray types, the expected type name for its elements (default is "art::TParameterObject").
Returns
A std::variant containing either:
  • A pointer to the parameter object of type T if successful, or
  • A TString error message indicating the failure reason.

The function retrieves the parameter object via col->GetInfo(name) and performs several checks:

  • If no object is found, an error message is returned.
  • The object is verified to inherit from the expected type.
  • If T is TClonesArray, the object's element type is also checked using its GetClass() method.

Definition at line 98 of file TProcessorUtil.h.

return to the guide