PandaRoot
PndTCAOutputContainer< T > Class Template Reference

PndTCAOutputContainer implementation of PndOutputContainerI<T> for FairRootManager and TClonesArray. More...

#include <PndTCAOutputContainer.h>

Inheritance diagram for PndTCAOutputContainer< T >:
PndOutputContainerI< T > PndContainerI< T >

Public Member Functions

 PndTCAOutputContainer (const TString &t_foldername="", Bool_t t_persistency=kTRUE)
 Construct a new PndTCAOutputContainer object. More...
 
virtual ~PndTCAOutputContainer ()
 Destroy the PndTCAOutput Container object. More...
 
virtual Bool_t Init (const TString &t_branchname) final
 Register the data t_branchname in form of TClonesArray * with the FairRootManager. More...
 
virtual void Reset () final
 Delete all elements. More...
 
virtual T * CreateCopy (const T &t_element)
 Create a copy of t_element in the TClonesArray and return a pointer to it. More...
 
virtual void RemoveAt (Int_t t_index)
 remove the t_index-th element More...
 
virtual void Compress ()
 Compress. More...
 
virtual T * GetElement (Int_t t_idx) const final
 Get pointer to the t_idx-th element. More...
 
virtual ssize_t GetSize () const final
 Get the number of elements. More...
 
void SetTCA (TClonesArray *t_tca)
 Set the TClonesArray address. More...
 
TClonesArray * GetTCA ()
 Get the TClonesArray address. More...
 
- Public Member Functions inherited from PndOutputContainerI< T >
 PndOutputContainerI (const TString &t_foldername="", Bool_t t_persistency=kTRUE)
 Construct a new PndOutputContainerI object. More...
 
 fFolderName (t_foldername)
 
 fPersistency (t_persistency)
 
virtual ~PndOutputContainerI ()
 Destroy the PndOutputContainerI object. More...
 
virtual T const * GetConstElementPtr (Int_t t_index) const
 Get the Element object at t_index. More...
 
std::vector< T * > GetVector () const
 return vector of ptrs pointing at internal data, to be used to access data independent of underlying data container More...
 
void SetFolderName (const TString &t_foldername)
 Set the FolderName. More...
 
void SetPersistency (Bool_t t_persistency)
 Set the Persistency of the data. More...
 
const TString & GetFolderName () const
 Get the Folder Name. More...
 
Bool_t GetPersistency () const
 Get the Persistency of the data. 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

TClonesArray * fTCA {nullptr}
 
- Protected Attributes inherited from PndOutputContainerI< T >
TString fFolderName {""}
 
Bool_t fPersistency {kFALSE}
 
- Protected Attributes inherited from PndContainerI< T >
TString fBranchName {""}
 

Detailed Description

template<class T>
class PndTCAOutputContainer< T >

PndTCAOutputContainer implementation of PndOutputContainerI<T> for FairRootManager and TClonesArray.

Output data registered with FairRootManager as (TClonesArray *)

Template Parameters
T

Definition at line 36 of file PndTCAOutputContainer.h.

Constructor & Destructor Documentation

◆ PndTCAOutputContainer()

template<class T>
PndTCAOutputContainer< T >::PndTCAOutputContainer ( const TString &  t_foldername = "",
Bool_t  t_persistency = kTRUE 
)
inline

Construct a new PndTCAOutputContainer object.

Parameters
constTString &t_foldername = ""
Bool_tt_persistency = kTRUE

Definition at line 44 of file PndTCAOutputContainer.h.

44 : PndOutputContainerI<T>(t_foldername, t_persistency) {}

◆ ~PndTCAOutputContainer()

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

Destroy the PndTCAOutput Container object.

Definition at line 50 of file PndTCAOutputContainer.h.

50 {}

Member Function Documentation

◆ Compress()

template<class T>
virtual void PndTCAOutputContainer< T >::Compress ( )
inlinevirtual

Compress.

Reimplemented from PndOutputContainerI< T >.

Definition at line 128 of file PndTCAOutputContainer.h.

129  {
130  if (this->fTCA != nullptr) {
131  this->fTCA->Compress();
132  }
133  }

◆ CreateCopy()

template<class T>
virtual T* PndTCAOutputContainer< T >::CreateCopy ( const T &  t_element)
inlinevirtual

Create a copy of t_element in the TClonesArray and return a pointer to it.

Parameters
constT &t_element
Returns
T*

Implements PndOutputContainerI< T >.

Definition at line 101 of file PndTCAOutputContainer.h.

Referenced by TestOutWithTCATask::Exec(), and BSEmcExtractDigisFromWaveforms< BSEmcFwEndcapDigiPar >::Exec().

102  {
103  if (fTCA != nullptr) {
104  new ((*fTCA)[fTCA->GetEntriesFast()]) T{t_element};
105  } else {
106  LOG(ERROR) << "PndTCAOutputContainer::CreateCopy() no underlying std::vector";
107  return nullptr;
108  }
109  return GetElement(GetSize() - 1);
110  }
virtual ssize_t GetSize() const final
Get the number of elements.
virtual T * GetElement(Int_t t_idx) const final
Get pointer to the t_idx-th element.

◆ GetElement()

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

Get pointer to the t_idx-th element.

Parameters
Int_tt_idx
Returns
T*

Implements PndOutputContainerI< T >.

Definition at line 141 of file PndTCAOutputContainer.h.

Referenced by PndTCAOutputContainer< BSEmcDigi >::CreateCopy().

142  {
143  if (fTCA != nullptr) {
144  return static_cast<T *>(fTCA->At(t_idx));
145  }
146  return nullptr;
147  }

◆ GetSize()

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

Get the number of elements.

Returns
ssize_t

Implements PndContainerI< T >.

Definition at line 154 of file PndTCAOutputContainer.h.

Referenced by PndTCAOutputContainer< BSEmcDigi >::CreateCopy().

155  {
156  if (fTCA != nullptr) {
157  return fTCA->GetEntriesFast();
158  }
159  return 0;
160  }

◆ GetTCA()

template<class T>
TClonesArray* PndTCAOutputContainer< T >::GetTCA ( )
inline

Get the TClonesArray address.

Returns
TClonesArray *

Definition at line 174 of file PndTCAOutputContainer.h.

174 { return fTCA; }

◆ Init()

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

Register the data t_branchname in form of TClonesArray * with the FairRootManager.

Parameters
constTString &t_branchname

Implements PndContainerI< T >.

Definition at line 57 of file PndTCAOutputContainer.h.

Referenced by BSEmcExtractDigisFromWaveforms< BSEmcFwEndcapDigiPar >::Init(), and TestOutWithTCATask::Init().

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  if (ioman->CheckBranch(t_branchname) == 0) {
65  LOG(debug) << "Attempting to register " << t_branchname << " as a container for " << T().ClassName() << " in folder " << this->fFolderName;
66  this->fTCA = ioman->Register(t_branchname, T().ClassName(), this->fFolderName, this->fPersistency);
67  } else {
68  this->fTCA = dynamic_cast<TClonesArray *>(ioman->GetObject(t_branchname));
69  if (this->fTCA == nullptr) {
70  // throw std::runtime_error(
71  // ("PndTCAInputContainer<" + TString{T().ClassName()} + ">::Init(" + t_branchname + "): No " + TString{T().ClassName()} + " array with name " + t_branchname + "
72  // found!")
73  // .Data());
74  LOG(error) << "PndTCAOutputContainer<" << T().ClassName() << ">::Init(" << t_branchname << "): No " << T().ClassName() << " array with name " << t_branchname
75  << " already exists but could not be fetched!";
76 
77  return kFALSE;
78  }
79  LOG(debug) << "Found a branch already called " << t_branchname << ". Using this for container for " << T().ClassName() << " in folder " << this->fFolderName;
80  }
81  }
82  return kTRUE;
83  }
TString fBranchName
Definition: PndContainerI.h:84

◆ RemoveAt()

template<class T>
virtual void PndTCAOutputContainer< T >::RemoveAt ( Int_t  t_index)
inlinevirtual

remove the t_index-th element

Parameters
Int_tt_index

Implements PndOutputContainerI< T >.

Definition at line 117 of file PndTCAOutputContainer.h.

118  {
119  if (this->fTCA != nullptr) {
120  this->fTCA->RemoveAt(t_index);
121  }
122  }

◆ Reset()

template<class T>
virtual void PndTCAOutputContainer< T >::Reset ( )
inlinefinalvirtual

Delete all elements.

Implements PndOutputContainerI< T >.

Definition at line 89 of file PndTCAOutputContainer.h.

Referenced by TestOutWithTCATask::Exec(), and BSEmcExtractDigisFromWaveforms< BSEmcFwEndcapDigiPar >::Exec().

90  {
91  if (this->fTCA != nullptr) {
92  this->fTCA->Delete();
93  }
94  }

◆ SetTCA()

template<class T>
void PndTCAOutputContainer< T >::SetTCA ( TClonesArray *  t_tca)
inline

Set the TClonesArray address.

Parameters
TClonesArray*t_tca

Definition at line 167 of file PndTCAOutputContainer.h.

167 { fTCA = t_tca; }

Member Data Documentation

◆ fTCA


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