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