PandaRoot
PndInputContainer< T > Class Template Reference

#include <PndInputContainer.h>

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

Public Member Functions

 PndInputContainer ()
 Construct a new PndInputContainer object. More...
 
virtual ~PndInputContainer ()
 Destroy the PndInputContainer object. More...
 
virtual Bool_t Init (const TString &t_branchname)
 Init internal data. More...
 
Bool_t TryTCA (const TString &t_branchname)
 Tries to find a registered TClonesArray with name t_branchname. Returns kTRUE on success. More...
 
Bool_t TrySTD (const TString &t_branchname)
 Tries to find a registered const std::vector<T>* with name t_branchname. Returns kTRUE on success. More...
 
virtual ssize_t GetSize () const final
 Get the number of members in internal data. More...
 
virtual T const * GetElement (Int_t t_index) const final
 Get the Element object at t_index. 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...
 

Protected Attributes

std::unique_ptr< PndInputContainerI< T > > fImp {nullptr}
 
- Protected Attributes inherited from PndContainerI< T >
TString fBranchName {""}
 

Detailed Description

template<class T>
class PndInputContainer< T >

Definition at line 24 of file PndInputContainer.h.

Constructor & Destructor Documentation

◆ PndInputContainer()

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

Construct a new PndInputContainer object.

Parameters
constTString &t_foldername : Name of folder
Bool_tt_persistency : Should date be stored to file

Definition at line 33 of file PndInputContainer.h.

◆ ~PndInputContainer()

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

Destroy the PndInputContainer object.

Definition at line 39 of file PndInputContainer.h.

39 {};

Member Function Documentation

◆ GetElement()

template<class T>
virtual T const* PndInputContainer< T >::GetElement ( Int_t  t_index) const
inlinefinalvirtual

Get the Element object at t_index.

Parameters
t_index
Returns
T*

Implements PndInputContainerI< T >.

Definition at line 126 of file PndInputContainer.h.

127  {
128  if (this->fImp != nullptr) {
129  return this->fImp->GetElement(t_index);
130  }
131  return nullptr;
132  }
std::unique_ptr< PndInputContainerI< T > > fImp

◆ GetSize()

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

Get the number of members in internal data.

Returns
ssize_t

Implements PndContainerI< T >.

Definition at line 112 of file PndInputContainer.h.

Referenced by TestInTask::Exec(), and TestPeekTask::Exec().

113  {
114  if (this->fImp != nullptr) {
115  return this->fImp->GetSize();
116  }
117  return 0;
118  }
std::unique_ptr< PndInputContainerI< T > > fImp

◆ Init()

template<class T>
virtual Bool_t PndInputContainer< T >::Init ( const TString &  t_branchname)
inlinevirtual

Init internal data.

Parameters
constTString &t_branchname - Name of databranch that is to be fetched

Implements PndContainerI< T >.

Definition at line 46 of file PndInputContainer.h.

Referenced by TestInTask::Init(), and TestPeekTask::Init().

47  {
48  this->fBranchName = t_branchname;
49  this->fImp.reset(nullptr);
50 
51  Bool_t success = TryTCA(t_branchname);
52  if (!success) {
53  success = TrySTD(t_branchname);
54  }
55  if (!success) {
56  this->fImp.reset(nullptr);
57  // throw std::runtime_error(
58  // ("PndInputContainer<" + TString{T().ClassName()} + ">::Init(" + t_branchname + "): No " + TString{T().ClassName()} + " array with name " + t_branchname +
59  // "found!").Data());
60  LOG(error) << "PndInputContainer<" << T().ClassName() << ">::Init(" << t_branchname << "): No " << T().ClassName() << " array with name " << t_branchname << " found!";
61  }
62  return success;
63  }
Bool_t TrySTD(const TString &t_branchname)
Tries to find a registered const std::vector<T>* with name t_branchname. Returns kTRUE on success...
TString fBranchName
Definition: PndContainerI.h:84
Bool_t TryTCA(const TString &t_branchname)
Tries to find a registered TClonesArray with name t_branchname. Returns kTRUE on success.
std::unique_ptr< PndInputContainerI< T > > fImp

◆ TrySTD()

template<class T>
Bool_t PndInputContainer< T >::TrySTD ( const TString &  t_branchname)
inline

Tries to find a registered const std::vector<T>* with name t_branchname. Returns kTRUE on success.

Parameters
t_branchname
Returns
Bool_t

Definition at line 90 of file PndInputContainer.h.

Referenced by PndInputContainer< BSEmcMCPoint >::Init().

91  {
92  if (FairRootManager::Instance()->CheckBranch(t_branchname) ==
93  0) { // This test is required here, as you get a segmentation violation if you try to access a not existing branch t_branchname via std
94  return kFALSE;
95  }
96  this->fImp.reset(new PndSTDInputContainer<T>{});
97  Bool_t success = this->fImp->Init(t_branchname);
98  if (!success) {
99  LOG(debug) << "No std::vector<T> branch called " << t_branchname << " registered with the FairRootManager.";
100  this->fImp.reset(nullptr);
101  } else {
102  LOG(debug) << "Found std::vector<T> TClonesArray branch called " << t_branchname << " registered with the FairRootManager.";
103  }
104  return success;
105  }
PndSTDInputContainer implementation of PndInputContainerI<T> for FairRootManager and std::vector<T> ...
std::unique_ptr< PndInputContainerI< T > > fImp

◆ TryTCA()

template<class T>
Bool_t PndInputContainer< T >::TryTCA ( const TString &  t_branchname)
inline

Tries to find a registered TClonesArray with name t_branchname. Returns kTRUE on success.

Parameters
t_branchname
Returns
Bool_t

Definition at line 71 of file PndInputContainer.h.

Referenced by PndInputContainer< BSEmcMCPoint >::Init().

72  {
73  this->fImp.reset(new PndTCAInputContainer<T>{});
74  Bool_t success = this->fImp->Init(t_branchname);
75  if (!success) {
76  LOG(debug) << "No TClonesArray branch called " << t_branchname << " registered with the FairRootManager. ";
77  this->fImp.reset(nullptr);
78  } else {
79  LOG(debug) << "Found input TClonesArray branch called " << t_branchname << " registered with the FairRootManager.";
80  }
81  return success;
82  }
PndTCAInputContainer implementation of PndInputContainerI<T> for FairRootManager and TClonesArray...
std::unique_ptr< PndInputContainerI< T > > fImp

Member Data Documentation

◆ fImp


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