PandaRoot
PndTCAConstContainer.h
Go to the documentation of this file.
1 //****************************************************************************
2 //* This file is part of PandaRoot. *
3 //* *
4 //* PandaRoot is distributed under the terms of the *
5 //* GNU General Public License (GPL) version 3, *
6 //* copied verbatim in the file "LICENSE". *
7 //* *
8 //* Copyright (C) 2006 - 2024 FAIR GmbH and copyright holders of PandaRoot *
9 //* The copyright holders are listed in the file "COPYRIGHTHOLDERS". *
10 //* The authors are listed in the file "AUTHORS". *
11 //****************************************************************************
12 
27 #ifndef PNDTCACONSTCONTAINER_HH
28 #define PNDTCACONSTCONTAINER_HH
29 
30 #include <stdexcept>
31 #include <vector>
32 
33 #include "TClonesArray.h"
34 #include "TString.h"
35 
36 #include "FairLogger.h"
37 #include "FairRootManager.h"
38 
39 #include "PndConstContainerI.h"
40 
49 template <class T>
51  public:
57 
62  virtual ~PndTCAConstContainer(){};
63 
70  virtual T const *GetElement(Int_t t_idx) const final
71  {
72  if (fTCA != nullptr) {
73  return static_cast<T *>(fTCA->At(t_idx));
74  }
75  return nullptr;
76  }
77 
83  virtual ssize_t GetSize() const final
84  {
85  if (fTCA != nullptr) {
86  return fTCA->GetEntriesFast();
87  }
88  return 0;
89  }
90 
96  void SetTCA(TClonesArray *t_tca) { fTCA = t_tca; }
97 
103  TClonesArray *GetTCA() { return fTCA; }
104 
105  protected:
106  TClonesArray *fTCA{nullptr};
107 };
108 
109 #endif /*PNDTCAConstContainer_HH*/
PndTCAConstContainer()
Construct a new PndTCAConstContainer object.
void SetTCA(TClonesArray *t_tca)
Set the TClonesArray address.
virtual ~PndTCAConstContainer()
Destroy the PndTCAConstContainer object.
virtual ssize_t GetSize() const final
Get the number of elements.
TClonesArray * GetTCA()
Get the TClonesArray address.
PndTCAConstContainer implementation of PndConstContainerI<T> for FairRootManager and TClonesArray...
virtual T const * GetElement(Int_t t_idx) const final
Get pointer to the t_idx-th element.