PandaRoot
PndSTDInputContainer< T > Class Template Reference

PndSTDInputContainer implementation of PndInputContainerI<T> for FairRootManager and std::vector<T> More...

#include <PndSTDInputContainer.h>

Inheritance diagram for PndSTDInputContainer< T >:
PndInputContainerI< T > PndContainerI< T >

Public Member Functions

 PndSTDInputContainer ()
 Construct a new PndSTDInputContainer object. More...
 
virtual ~PndSTDInputContainer ()
 Destroy the PndSTDInputContainer object. More...
 
virtual Bool_t Init (const TString &t_branchname) final
 Retrieve t_branchname as std::vector<T> const * from FairRootManager. More...
 
virtual T const * GetElement (Int_t t_idx) const final
 Get the t_idx Element. More...
 
virtual ssize_t GetSize () const final
 Get the number of elements. More...
 
void SetData (std::vector< T > const *t_container)
 Set the Data. More...
 
std::vector< T > const * GetData ()
 Get the Data. More...
 
- Public Member Functions inherited from PndInputContainerI< T >
 PndInputContainerI ()
 Construct a new PndInputContainerI object. More...
 
virtual T const * GetConstElementPtr (Int_t t_index) const
 Get the Element object at t_index. More...
 
std::vector< T const * > GetVector () const
 return vector of ptrs pointing at internal data, to be used to access data independent of underlying data container More...
 
- Public Member Functions inherited from PndContainerI< T >
 PndContainerI ()
 Construct a new PndContainerI object. More...
 
virtual ~PndContainerI ()
 Destroy the PndContainerI object. More...
 
std::vector< T const * > GetVectorOfPtrToConst () const
 return vector of const ptrs pointing at internal data, to be used to access data independent of underlying data container More...
 
const TString & GetBranchName () const
 Get the BranchName. More...
 

Additional Inherited Members

- Protected Attributes inherited from PndContainerI< T >
TString fBranchName {""}
 

Detailed Description

template<class T>
class PndSTDInputContainer< T >

PndSTDInputContainer implementation of PndInputContainerI<T> for FairRootManager and std::vector<T>

Input data retrieved from FairRootManager is immutable (std::vector<T> const *)

Template Parameters
T

Definition at line 39 of file PndSTDInputContainer.h.

Constructor & Destructor Documentation

◆ PndSTDInputContainer()

template<class T >
PndSTDInputContainer< T >::PndSTDInputContainer ( )
inline

Construct a new PndSTDInputContainer object.

Definition at line 45 of file PndSTDInputContainer.h.

◆ ~PndSTDInputContainer()

template<class T >
virtual PndSTDInputContainer< T >::~PndSTDInputContainer ( )
inlinevirtual

Destroy the PndSTDInputContainer object.

Definition at line 50 of file PndSTDInputContainer.h.

50 {};

Member Function Documentation

◆ GetData()

template<class T >
std::vector<T> const* PndSTDInputContainer< T >::GetData ( )
inline

Get the Data.

Returns
std::vector<T> const*

Definition at line 116 of file PndSTDInputContainer.h.

116 { return fSTD; }

◆ GetElement()

template<class T >
virtual T const* PndSTDInputContainer< T >::GetElement ( Int_t  t_idx) const
inlinefinalvirtual

Get the t_idx Element.

Parameters
t_idx
Returns
T const *

Implements PndInputContainerI< T >.

Definition at line 83 of file PndSTDInputContainer.h.

84  {
85  if (fSTD != nullptr) {
86  return &(fSTD->at(t_idx));
87  }
88 
89  return nullptr;
90  }

◆ GetSize()

template<class T >
virtual ssize_t PndSTDInputContainer< T >::GetSize ( ) const
inlinefinalvirtual

Get the number of elements.

Returns
ssize_t

Implements PndContainerI< T >.

Definition at line 97 of file PndSTDInputContainer.h.

98  {
99  if (fSTD != nullptr) {
100  return fSTD->size();
101  }
102  return 0;
103  }

◆ Init()

template<class T >
virtual Bool_t PndSTDInputContainer< T >::Init ( const TString &  t_branchname)
inlinefinalvirtual

Retrieve t_branchname as std::vector<T> const * from FairRootManager.

Parameters
t_branchname

Implements PndContainerI< T >.

Definition at line 57 of file PndSTDInputContainer.h.

References PndContainerI< T >::fBranchName.

58  {
59  this->fBranchName = t_branchname;
60  FairRootManager *ioman = FairRootManager::Instance();
61  if (ioman == nullptr) {
62  throw std::runtime_error("FairRootManager::Instance() returned nullptr");
63  } else {
64  this->fSTD = ioman->InitObjectAs<std::vector<T> const *>(t_branchname);
65  if (this->fSTD == nullptr) {
66  // throw std::runtime_error(
67  // ("PndSTDInputContainer<" + TString{T().ClassName()} + ">::Init(" + t_branchname + "): No " + TString{T().ClassName()} + " array with name " + t_branchname + " found!")
68  // .Data());
69  LOG(error) << "PndSTDInputContainer<" << T().ClassName() << ">::Init(" << t_branchname << "): No " << T().ClassName() << " array with name " << t_branchname << " found!";
70  return kFALSE;
71  }
72  }
73  LOG(INFO) << "virtual Bool_t PndSTDInputContainer::Init(const TString &t_branchname) final successful";
74  return kTRUE;
75  }
TString fBranchName
Definition: PndContainerI.h:84

◆ SetData()

template<class T >
void PndSTDInputContainer< T >::SetData ( std::vector< T > const *  t_container)
inline

Set the Data.

Parameters
t_container

Definition at line 109 of file PndSTDInputContainer.h.

109 { fSTD = t_container; }

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