source: trunk/MagicSoft/Mars/mfileio/MWriteRootFile.h@ 1804

Last change on this file since 1804 was 1664, checked in by tbretz, 22 years ago
*** empty log message ***
File size: 2.6 KB
Line 
1#ifndef MARS_MWriteRootFile
2#define MARS_MWriteRootFile
3
4#ifndef MARS_MWriteFile
5#include "MWriteFile.h"
6#endif
7#ifndef ROOT_TObjArray
8#include <TObjArray.h>
9#endif
10
11class TFile;
12class TTree;
13class TBranch;
14
15class MRootFileBranch : public TNamed
16{
17private:
18 TTree *fTree; //!
19 TBranch *fBranch; //!
20
21 MParContainer *fContainer;
22 TString fContName;
23
24 void Init(const char *name, const char *title)
25 {
26 SetName(name?name:"");
27 SetTitle(title?title:"");
28 }
29
30public:
31 MRootFileBranch() : fTree(NULL), fBranch(NULL), fContainer(NULL)
32 {
33 Init(NULL, NULL);
34 fContName = "";
35 }
36
37 MRootFileBranch(const char *cname, const char *tname=NULL, const char *ttitle=NULL)
38 : fTree(NULL), fBranch(NULL), fContainer(NULL)
39 {
40 Init(tname, ttitle);
41 fContName = cname;
42 }
43
44 MRootFileBranch(MParContainer *cont, const char *tname=NULL, const char *ttitle=NULL)
45 : fTree(NULL), fBranch(NULL), fContName("")
46 {
47 Init(tname, ttitle);
48 fContainer = cont;
49 }
50
51 TTree *GetTree() const { return fTree; }
52 MParContainer *GetContainer() const { return fContainer; }
53 void *GetAddress() { return &fContainer; }
54 TBranch *GetBranch() const { return fBranch; }
55 const char *GetContName() const { return fContName; }
56
57 void SetContainer(MParContainer *cont) { fContainer = cont; }
58 void SetTree(TTree *tree) { fTree = tree; }
59
60 ClassDef(MRootFileBranch, 1) // Storage container for MWriteRootFile to store TBranch informations
61};
62
63class MWriteRootFile : public MWriteFile
64{
65private:
66 TFile *fOut;
67
68 TObjArray fBranches;
69 TObjArray fTrees; //!
70
71 void CheckAndWrite() const;
72 Bool_t IsFileOpen() const;
73 Bool_t GetContainer(MParList *pList);
74 const char *GetFileName() const;
75
76 void StreamPrimitive(ofstream &out) const;
77
78public:
79 MWriteRootFile();
80 MWriteRootFile(const char *fname,
81 const Option_t *opt="RECREATE",
82 const char *ftitle="Untitled",
83 const Int_t comp=9,
84 const char *name=NULL,
85 const char *title=NULL);
86 ~MWriteRootFile();
87
88
89 void AddContainer(const char *cname,
90 const char *tname=NULL, const char *ttitle=NULL);
91 void AddContainer(MParContainer *cont,
92 const char *tname=NULL, const char *ttitle=NULL);
93
94
95 void Print(Option_t *t=NULL) const;
96
97 ClassDef(MWriteRootFile, 1) // Task to write data into a root file
98};
99
100#endif
Note: See TracBrowser for help on using the repository browser.