source: trunk/MagicSoft/Mars/mbase/MWriteRootFile.h@ 1028

Last change on this file since 1028 was 1014, checked in by tbretz, 23 years ago
*** empty log message ***
  • Property svn:executable set to *
File size: 2.4 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(const char *cname, const char *tname=NULL, const char *ttitle=NULL)
32 : fTree(NULL), fBranch(NULL), fContainer(NULL)
33 {
34 Init(tname, ttitle);
35 fContName = cname;
36 }
37
38 MRootFileBranch(MParContainer *cont, const char *tname=NULL, const char *ttitle=NULL)
39 : fTree(NULL), fBranch(NULL), fContName("")
40 {
41 Init(tname, ttitle);
42 fContainer = cont;
43 }
44
45 TTree *GetTree() const { return fTree; }
46 MParContainer *GetContainer() const { return fContainer; }
47 void *GetAddress() { return &fContainer; }
48 TBranch *GetBranch() const { return fBranch; }
49 const char *GetContName() const { return fContName; }
50
51 void SetContainer(MParContainer *cont) { fContainer = cont; }
52 void SetTree(TTree *tree) { fTree = tree; }
53
54 ClassDef(MRootFileBranch, 0) // Storage container for MWriteRootFile to store TBranch informations
55};
56
57class MWriteRootFile : public MWriteFile
58{
59private:
60 TFile *fOut;
61
62 TObjArray fBranches;
63 TObjArray fTrees;
64
65 void CheckAndWrite() const;
66 Bool_t IsFileOpen() const;
67 Bool_t GetContainer(MParList *pList);
68 const char *GetFileName() const;
69
70public:
71 MWriteRootFile(const char *fname,
72 const Option_t *opt="RECREATE",
73 const char *ftitle="Untitled",
74 const Int_t comp=9,
75 const char *name=NULL,
76 const char *title=NULL);
77 ~MWriteRootFile();
78
79
80 void AddContainer(const char *cname,
81 const char *tname=NULL, const char *ttitle=NULL);
82 void AddContainer(MParContainer *cont,
83 const char *tname=NULL, const char *ttitle=NULL);
84
85
86 void Print(Option_t *t=NULL) const;
87
88 ClassDef(MWriteRootFile, 0) // Class to write one container to a root file
89};
90
91#endif
Note: See TracBrowser for help on using the repository browser.