FairShip
Loading...
Searching...
No Matches
VectorMCPointSource.h
Go to the documentation of this file.
1// SPDX-License-Identifier: LGPL-3.0-or-later
2// SPDX-FileCopyrightText: Copyright CERN for the benefit of the SHiP
3// Collaboration
4
5#ifndef SHIPDATA_VECTORMCPOINTSOURCE_H_
6#define SHIPDATA_VECTORMCPOINTSOURCE_H_
7
8#include "FairDataSourceI.h"
9#include "FairRootManager.h"
10
17template <typename PointType>
18class VectorMCPointSource : public FairDataSourceI {
19 public:
21 explicit VectorMCPointSource(TString branchName)
22 : FairDataSourceI(branchName) {}
23
24 InitStatus Init() override {
25 fVec = FairRootManager::Instance()
26 ->InitObjectAs<const std::vector<PointType>*>(
27 GetBranchName().Data());
28 if (!fVec) {
29 return kERROR;
30 }
31 return kSUCCESS;
32 }
33
34 int GetNData() override { return fVec ? fVec->size() : 0; }
35
36 TObject* GetData(int index) override {
37 return const_cast<PointType*>(&(*fVec)[index]);
38 }
39
40 double GetTime(int index) override { return (*fVec)[index].GetTime(); }
41
42 void Reset() override {}
43
44 private:
45 const std::vector<PointType>* fVec = nullptr;
46};
47
48#endif // SHIPDATA_VECTORMCPOINTSOURCE_H_
VectorMCPointSource()=default
TObject * GetData(int index) override
const std::vector< PointType > * fVec
VectorMCPointSource(TString branchName)
InitStatus Init() override
double GetTime(int index) override