CGEM BOSS 6.6.5.f
BESIII Offline Software System
Loading...
Searching...
No Matches
Event/RootCnvSvc/RootCnvSvc-04-01-15/RootCnvSvc/RootInterface.h
Go to the documentation of this file.
1#ifndef ROOTINTERFACE_H
2#define ROOTINTERFACE_H
3/*
4 *Description:Interface for all Root I/O needed by the RootCnvSvc
5 *Based on the RootInterface of Glast.
6 */
7#include "TObject.h"
8#include <vector>
9#include "GaudiKernel/MsgStream.h"
10#include "GaudiKernel/IService.h"
11/////////////////////////////////////////////////////////////////////////////
12
13class TTree;
14class TClonesArray;
15class TFile;
16class TList;
17
18
19class RootInterface {
20
21 public:
22
23 RootInterface (MsgStream log);
24 virtual ~RootInterface();
25 virtual StatusCode finalize();
26
27 /// singleton behaviour
28static RootInterface* Instance(MsgStream log);
29 /// check if all the files is over 2005-11-28
30 virtual bool checkEndOfTree();
31 virtual bool getENDFILE(){ return m_ENDFILE;}
32 /// add input tree to the list
33 virtual StatusCode addInput(const std::string& treename,const std::string& file);
34 /// add output tree to the list
35 virtual StatusCode addOutput(const std::string& treename,const std::string& file,int splitx, int bufsize, int compression);
36 /// create a branch in this tree
37 virtual StatusCode createBranch(const std::string& tree,const std::string& branch ,const char *classname,void *addr,int & branchnr);
38
39 /// set branch address
40 virtual StatusCode setBranchAddress(const std::string treename, const std::string branchname, void *addr,int& nb);
41 /// get entry from this branch
42 virtual StatusCode getBranchEntry( int nr, int entry,int& nb);
43
44 /// get entry from this branch with addr
45 virtual StatusCode getBranchEntry( int nr, int entry, void * addr, int& nb);
46
47
48 /// get EOF flag
49 virtual bool getEOF() { return m_EOF;}
50 /// get nr of entries
51 virtual Int_t getEntries() { return m_entries;}
52 /// fill in all trees
53 virtual StatusCode fillTrees();
54
55 virtual std::string getCurrentFileName() { return m_currentFileName;}
56
57 virtual std::vector<int> getTotEvtNo();
58 virtual std::string getJobOptions();
59 virtual std::string getDecayOptions();
60 virtual void printJobInfo(TFile* file, int level);
61
62 private:
63 /// get treenr from treename
64 virtual StatusCode getTreeNr(const std::string treename, unsigned int& treenr,bool doAdd=false);
65 /// get tree
66 virtual TTree* getTree(const std::string treename);
67 /// get tree from other files 2005-11-28
68 virtual TTree* getOtherTree(const std::string treename);
69 /// create this tree
70 virtual StatusCode createTree(unsigned int treenr, const std::string treename);
71 /// parallel vectors
72
73 /// vector of other trees created from others files 2005-11-28
74 std::vector<TTree *> m_otherTrees;
75 /// vector of input files
76 std::vector<TFile *> inputFiles;
77 ///files 2005-11-28
78 std::vector<std::string> m_fileNames;
79 std::string m_currentFileName;
80 ///the number of the using files 2005-11-29
81 int m_fileNum;
82 ///signed the tree is end 2005-11-30
83 bool m_ENDFILE;
84 /// vector of treenames used
85 std::vector<std::string> m_treenames;
86 /// vector of input filenames used
87 std::vector<std::string> m_inputFilenames;
88 /// vector of output filenames used
89 std::vector<std::string> m_outputFilenames;
90 /// vector of input trees
91 std::vector<TTree *> m_inputTrees;
92 /// vector of output trees
93 std::vector<TTree *> m_outputTrees;
94 /// vector of input files
95 std::vector<TFile *> m_inputFiles;
96 /// vector of output files
97 std::vector<TFile *> m_outputFiles;
98 /// vector of splitmodes
99 std::vector<int> m_splitModes;
100 /// vector of buffer sizes
101 std::vector<int> m_bufSizes;
102 /// vector of compression levels
103 std::vector<int> m_compressionLevels;
104
105
106 /// array of branch pointers for writing
107 TClonesArray *m_branches;
108
109 /// array of branch pointers for reading
110 TClonesArray *m_branchesRead;
111
112 /// EOF flag
113 bool m_EOF;
114
115 /// number of entries (<0 if not yet known)
116 Int_t m_entries;
117
118 /// instance of message stream transmitted at construction
119 MsgStream log;
120
121 /// static singleton pointer
122 static RootInterface *m_rootInterface;
123
124 std::vector<std::string> m_jobOptions;
125 std::string m_bossVer;
126 std::string m_decayOptions;
127 std::vector<int> m_totEvtNo;
128
129 // tianhl add for besvis
130 private:
131 std::vector<std::string> m_single_treenames;
132 std::vector<std::string> m_single_outputFileNames;
133 std::vector<TFile *> m_single_outputFiles;
134 std::vector<TTree *> m_single_outputTrees;
135 std::vector<int> m_single_splitModes;
136 std::vector<int> m_single_bufSizes;
137 std::vector<int> m_single_compressionLevels;
138
139 public:
140 virtual StatusCode f_addOutput(const std::string& treename,
141 const std::string& file,
142 int splitx = 1, int bufsize = 64000,
143 int compression = 1);
144 virtual StatusCode f_createTree(unsigned int treenr,
145 const std::string treename);
146 virtual StatusCode f_createBranch(const std::string& treename,
147 const std::string& branchname,
148 const char *classname,
149 void *addr,int & branchnr);
150 virtual StatusCode f_getTreeNr(const std::string treename,
151 unsigned int& treenr,bool doAdd=false);
152 virtual StatusCode f_fillTrees();
153 virtual StatusCode f_finalize();
154
155};
156
157#endif
virtual StatusCode addInput(const std::string &treename, const std::string &file)
add input tree to the list
virtual StatusCode createBranch(const std::string &tree, const std::string &branch, const char *classname, void *addr, int &branchnr)
create a branch in this tree
RootInterface(MsgStream log)
virtual StatusCode finalize()
virtual StatusCode f_finalize()
virtual StatusCode f_createTree(unsigned int treenr, const std::string treename)
virtual StatusCode addOutput(const std::string &treename, const std::string &file, int splitx, int bufsize, int compression)
add output tree to the list
virtual std::string getJobOptions()
virtual StatusCode f_fillTrees()
virtual std::vector< int > getTotEvtNo()
virtual StatusCode setBranchAddress(const std::string treename, const std::string branchname, void *addr, int &nb)
set branch address
virtual ~RootInterface()
virtual StatusCode f_createBranch(const std::string &treename, const std::string &branchname, const char *classname, void *addr, int &branchnr)
virtual StatusCode getBranchEntry(int nr, int entry, void *addr, int &nb)
get entry from this branch with addr
virtual StatusCode fillTrees()
fill in all trees
virtual std::string getDecayOptions()
virtual StatusCode getBranchEntry(int nr, int entry, int &nb)
get entry from this branch
virtual void printJobInfo(TFile *file, int level)
virtual StatusCode f_getTreeNr(const std::string treename, unsigned int &treenr, bool doAdd=false)
virtual StatusCode f_addOutput(const std::string &treename, const std::string &file, int splitx=1, int bufsize=64000, int compression=1)
virtual bool checkEndOfTree()
check if all the files is over 2005-11-28
static RootInterface * Instance(MsgStream log)
singleton behaviour