ECCE @ EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
PHNodeIOManager.h
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file PHNodeIOManager.h
1 #ifndef PHOOL_PHNODEIOMANAGER_H
2 #define PHOOL_PHNODEIOMANAGER_H
3 
4 // Declaration of class PHNodeIOManager
5 // Purpose: manages file IO for PHIODataNodes
6 // Author: Matthias Messer
7 
8 #include "PHIOManager.h"
9 
10 #include "phool.h"
11 
12 #include <cstddef>
13 #include <map>
14 #include <string>
15 
16 class PHCompositeNode;
17 class TBranch;
18 class TFile;
19 class TObject;
20 class TTree;
21 
23 {
24  public:
26  PHNodeIOManager(const std::string &, const PHAccessType = PHReadOnly);
27  PHNodeIOManager(const std::string &, const std::string &, const PHAccessType = PHReadOnly);
28  PHNodeIOManager(const std::string &, const PHAccessType, const PHTreeType);
29  ~PHNodeIOManager() override;
30 
31  void closeFile() override;
32  bool write(PHCompositeNode *) override;
33  void print() const override;
34 
35  bool setFile(const std::string &, const std::string &, const PHAccessType = PHReadOnly);
36  PHCompositeNode *read(PHCompositeNode * = nullptr, size_t = 0);
37  bool read(size_t requestedEvent);
38  int readSpecific(size_t requestedEvent, const std::string &objectName);
39  void selectObjectToRead(const std::string &objectName, bool readit);
40  bool isSelected(const std::string &objectName);
41  int isFunctional() const { return isFunctionalFlag; }
42  bool SetCompressionLevel(const int level);
43  double GetBytesWritten();
44  std::map<std::string, TBranch *> *GetBranchMap();
45 
46  bool write(TObject **, const std::string &, int buffersize, int splitlevel);
47  bool NodeExist(const std::string &nodename);
48 
49  private:
50  int FillBranchMap();
52  bool readEventFromFile(size_t requestedEvent);
53  std::string getBranchClassName(TBranch *);
54 
55  TFile *file = nullptr;
56  TTree *tree = nullptr;
57  std::string TreeName = "T";
60  std::map<std::string, TBranch *> fBranches;
61  std::map<std::string, bool> objectToRead;
62 
63  int isFunctionalFlag = 0; // flag to tell if that object initialized properly
64 };
65 
66 #endif