File indexing completed on 2025-08-06 08:17:26
0001 #ifndef PHOOL_PHNODEIOMANAGER_H
0002 #define PHOOL_PHNODEIOMANAGER_H
0003
0004
0005
0006
0007
0008 #include "PHIOManager.h"
0009
0010 #include "phool.h"
0011
0012 #include <cstddef>
0013 #include <cstdint>
0014 #include <limits>
0015 #include <map>
0016 #include <string>
0017
0018 class PHCompositeNode;
0019 class TBranch;
0020 class TFile;
0021 class TObject;
0022 class TTree;
0023
0024 class PHNodeIOManager : public PHIOManager
0025 {
0026 public:
0027 PHNodeIOManager() = default;
0028 PHNodeIOManager(const std::string &, const PHAccessType = PHReadOnly);
0029 PHNodeIOManager(const std::string &, const std::string &, const PHAccessType = PHReadOnly);
0030 PHNodeIOManager(const std::string &, const PHAccessType, const PHTreeType);
0031 ~PHNodeIOManager() override;
0032
0033
0034 void closeFile() override;
0035 bool write(PHCompositeNode *) override;
0036 void print() const override;
0037
0038 bool setFile(const std::string &, const std::string &, const PHAccessType = PHReadOnly);
0039 PHCompositeNode *read(PHCompositeNode * = nullptr, size_t = 0);
0040 bool read(size_t requestedEvent);
0041 int readSpecific(size_t requestedEvent, const std::string &objectName);
0042 void selectObjectToRead(const std::string &objectName, bool readit);
0043 bool isSelected(const std::string &objectName);
0044 int isFunctional() const { return isFunctionalFlag; }
0045 bool SetCompressionSetting(const int level);
0046 uint64_t GetBytesWritten();
0047 uint64_t GetFileSize();
0048 std::map<std::string, TBranch *> *GetBranchMap();
0049
0050 bool write(TObject **, const std::string &, int nodebuffersize, int nodesplitlevel);
0051 bool NodeExist(const std::string &nodename);
0052
0053 void SplitLevel(const int split) { splitlevel = split; }
0054 void BufferSize(const int size) { buffersize = size; }
0055 int SplitLevel() const { return splitlevel; }
0056 int BufferSize() const { return buffersize; }
0057 void DisableReadCache();
0058
0059 private:
0060 int FillBranchMap();
0061 PHCompositeNode *reconstructNodeTree(PHCompositeNode *);
0062 bool readEventFromFile(size_t requestedEvent);
0063 static std::string getBranchClassName(TBranch *);
0064
0065 TFile *file{nullptr};
0066 TTree *tree{nullptr};
0067 std::string TreeName{"T"};
0068 int accessMode{PHReadOnly};
0069 int m_CompressionSetting{505};
0070 int isFunctionalFlag{0};
0071 int buffersize{std::numeric_limits<int>::min()};
0072 int splitlevel{std::numeric_limits<int>::min()};
0073 std::map<std::string, TBranch *> fBranches;
0074 std::map<std::string, bool> objectToRead;
0075 };
0076
0077 #endif