Heavy ion Analysis Libriares
Loading...
Searching...
No Matches
IOManager.h
1/*
2 * IOManager.h
3 *
4 * Created on: 10 maj 2022
5 * Author: Daniel Wielanek
6 * E-mail: daniel.wielanek@gmail.com
7 * Warsaw University of Technology, Faculty of Physics
8 */
9#ifndef HAL_FEATURES_IO_STEER_IOMANAGER_H_
10#define HAL_FEATURES_IO_STEER_IOMANAGER_H_
11
12#include <TList.h>
13#include <TObject.h>
14#include <TString.h>
15
16class TList;
17class TChain;
18class TFile;
19namespace Hal {
20 class InputDataInfo;
21}
26namespace Hal {
27 class Package;
28 class MagField;
29 class BranchInfo : public TObject {
30 public:
31 enum class EFlag { kInActive, kInPassive, kOut, kVirtual, kNull };
32
33 private:
34 TString fBrName = {""};
35 TObject* fPointer = {nullptr};
36 EFlag fFlag = {EFlag::kNull};
37
38 public:
39 BranchInfo(TString name = "", TObject* pointer = nullptr, EFlag used = EFlag::kNull) :
40 fBrName(name), fPointer(pointer), fFlag(used) {}
41 BranchInfo(const BranchInfo& other) : TObject(other), fBrName(other.fBrName), fPointer(other.fPointer), fFlag(other.fFlag) {}
42 EFlag GetFlag() const { return fFlag; }
43 TString GetBranchName() const { return fBrName; }
44 void SetFlag(EFlag Flag = EFlag::kNull) { fFlag = Flag; }
45 void SetBranchName(const TString name) { fBrName = name; }
46 TObject* GetPointer() const { return fPointer; }
47 void SetPointer(TObject* pointer = nullptr) { fPointer = pointer; }
48 virtual ~BranchInfo() {};
49 ClassDef(BranchInfo, 1)
50 };
51
52 class IOManager : public TObject {
53 public:
54 private:
55 MagField* fField = {nullptr};
56 std::vector<TString> fBranchNameList;
57
58 protected:
59 InputDataInfo* fDataInfo = {nullptr};
63 std::vector<Hal::BranchInfo> fBranches;
70 void AddBranch(TString name, TObject* object, BranchInfo::EFlag flag);
76 BranchInfo FindBranch(TString name) const;
84 virtual void RegisterInternal(const char* name, const char* folderName, TNamed* obj, Bool_t toFile) = 0;
92 virtual void RegisterInternal(const char* name, const char* Foldername, TCollection* obj, Bool_t toFile) = 0;
93 virtual Bool_t InitInternal() = 0;
94
95 public:
96 IOManager() : fField(nullptr), fBranchNameList() {};
106 virtual Int_t GetEntries() const = 0;
113 virtual Int_t GetEntry(Int_t i, Int_t flag) = 0;
118 Bool_t Init();
123 virtual void SetField(MagField* field) { fField = field; };
128 virtual void SetOutput(TString /*name*/) {};
133 virtual MagField* GetField() const { return fField; };
141 void Register(const char* name, const char* folderName, TNamed* obj, Bool_t toFile);
149 void Register(const char* name, const char* Foldername, TCollection* obj, Bool_t toFile);
155 virtual void SetInChain(TChain* tempChain, Int_t ident = -1) = 0;
159 virtual void UpdateBranches() {};
165 BranchInfo::EFlag GetBranchStatus(const char* BrName);
171 virtual TObject* GetObject(const char* BrName);
176 void ActivateBranch(TString brName);
181 TString GetSourceName() const;
186 std::vector<TString> GetBranchNameList() {
188 return fBranchNameList;
189 };
193 void PrintInfo();
197 virtual void FillTree() = 0;
201 virtual void CloseManager() {};
206 virtual TList* GetBranchesList() const;
211 Int_t GetNFiles() const;
217 std::vector<TString> GetFilesNames(Int_t entry = 0) const;
222 Int_t GetFriendsLevel() const;
227 void AddFile(TString name);
233 void AddFriend(TString friendName, Int_t level);
237 virtual void LockUnusedBranches() {};
242 TString GetFirstDataFileName() const;
248 TString GetFirstFriendFileName(Int_t level) const;
254 std::vector<TString> GetFileNameList(Int_t level) const;
255 virtual ~IOManager();
256 ClassDef(IOManager, 1)
257 };
258
259} /* namespace Hal */
260
261#endif /* HAL_FEATURES_IO_STEER_IOMANAGER_H_ */
Int_t GetFriendsLevel() const
virtual TList * GetBranchesList() const
virtual void UpdateBranches()
Definition IOManager.h:159
Int_t GetNFiles() const
virtual void CloseManager()
Definition IOManager.h:201
virtual void LockUnusedBranches()
Definition IOManager.h:237
virtual void SetInChain(TChain *tempChain, Int_t ident=-1)=0
virtual void RegisterInternal(const char *name, const char *Foldername, TCollection *obj, Bool_t toFile)=0
BranchInfo::EFlag GetBranchStatus(const char *BrName)
Definition IOManager.cxx:68
virtual Int_t GetEntries() const =0
void ActivateBranch(TString brName)
std::vector< TString > GetFileNameList(Int_t level) const
TString GetFirstDataFileName() const
std::vector< TString > GetBranchNameList()
Definition IOManager.h:186
virtual void SetOutput(TString)
Definition IOManager.h:128
virtual Int_t GetEntry(Int_t i, Int_t flag)=0
std::vector< TString > GetFilesNames(Int_t entry=0) const
virtual MagField * GetField() const
Definition IOManager.h:133
virtual void SetField(MagField *field)
Definition IOManager.h:123
void AddFriend(TString friendName, Int_t level)
std::vector< Hal::BranchInfo > fBranches
Definition IOManager.h:63
BranchInfo FindBranch(TString name) const
Definition IOManager.cxx:41
void Register(const char *name, const char *folderName, TNamed *obj, Bool_t toFile)
Definition IOManager.cxx:50
void AddFile(TString name)
TString GetSourceName() const
void AddBranch(TString name, TObject *object, BranchInfo::EFlag flag)
Definition IOManager.cxx:33
TString GetFirstFriendFileName(Int_t level) const
virtual void FillTree()=0
virtual TObject * GetObject(const char *BrName)
Definition IOManager.cxx:77
virtual void RegisterInternal(const char *name, const char *folderName, TNamed *obj, Bool_t toFile)=0