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

Last change on this file since 2057 was 2002, checked in by tbretz, 22 years ago
*** empty log message ***
File size: 2.8 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 void SetBranch(TBranch *branch) { fBranch = branch; }
60
61 ClassDef(MRootFileBranch, 1) // Storage container for MWriteRootFile to store TBranch informations
62};
63
64class MWriteRootFile : public MWriteFile
65{
66private:
67 TFile *fOut;
68
69 TObjArray fBranches;
70 TObjArray fTrees; //!
71
72 //UInt_t fNumEvents; //! Number of events written in a run
73
74 void CheckAndWrite() const;
75 Bool_t IsFileOpen() const;
76 Bool_t GetContainer(MParList *pList);
77 const char *GetFileName() const;
78
79 void StreamPrimitive(ofstream &out) const;
80 //Bool_t ReInit(MParList *pList);
81
82 enum {
83 kIsNewTree = BIT(15)
84 };
85
86public:
87 MWriteRootFile();
88 MWriteRootFile(const char *fname,
89 const Option_t *opt="RECREATE",
90 const char *ftitle="Untitled",
91 const Int_t comp=9,
92 const char *name=NULL,
93 const char *title=NULL);
94 ~MWriteRootFile();
95
96
97 void AddContainer(const char *cname,
98 const char *tname=NULL, const char *ttitle=NULL);
99 void AddContainer(MParContainer *cont,
100 const char *tname=NULL, const char *ttitle=NULL);
101
102
103 void Print(Option_t *t=NULL) const;
104
105 ClassDef(MWriteRootFile, 1) // Task to write data into a root file
106};
107
108#endif
Note: See TracBrowser for help on using the repository browser.