source: trunk/MagicSoft/MarsOctober/mbase/MFileDescr.cc@ 528

Last change on this file since 528 was 447, checked in by harald, 24 years ago
Bringing the sources for the octobertest under CVS controll. (november, 3rd, 2000)
  • Property svn:executable set to *
File size: 3.0 KB
Line 
1#include "MFileDescr.h"
2
3#include <iostream.h>
4
5#include <TFile.h>
6#include <TTree.h>
7
8#include "MParContainer.h"
9
10void MRootFileIn::SetAddress(MParContainer **obj)
11{
12 pBranchIn->SetAddress(obj);
13}
14
15void MRootFileIn::GetEvent(Int_t n)
16{
17 pTreeIn->GetEvent(n);
18}
19
20void MRootFileOut::SetAddress(MParContainer **obj)
21{
22 pBranchOut->SetAddress(obj);
23}
24
25void MRootFileOut::Fill()
26{
27 pTreeOut->Fill();
28}
29
30MRootFileIn::MRootFileIn(TFile *f, const char *fName, const char *cname)
31{
32 //
33 // Open the tree in the input file with the same name than
34 // this instance
35 //
36 cout << "Open Tree: " << fName << "... " << flush;
37 pTreeIn = (TTree *) f->Get(fName);
38
39 if (!pTreeIn)
40 cout << "WARNING: Cannot open tree " << fName << "." << endl;
41
42 //
43 // Open the branch in the tree with the same name than
44 // the ClassName of the objects in the buffer
45 //
46 cout << "Branch: " << cname << "... " << flush;
47 pBranchIn = pTreeIn->GetBranch(cname);
48
49 if (!pBranchIn)
50 cout << "WARNING: Cannot open branch " << cname << "." << endl;
51 else
52 cout << "Done." << endl;
53
54 cout << endl;
55
56 //
57 // get number events in branch
58 //
59 // nEvts = pTreeIn->GetEntries();
60}
61
62MRootFileOut::MRootFileOut(const char *fName, const char *cname, MParContainer **obj)
63{
64 //
65 // Open the tree in the output file with the same name than
66 // the this instance
67 //
68 cout << "Create Tree: " << fName << "... " << flush;
69 TTree *pTreeOut = new TTree(fName, ""/*fTitle*/);
70
71 if (!pTreeOut)
72 cout << "WARNING: Cannot open tree " << fName << "." << endl;
73
74
75 //
76 // Create the branch in the tree with the same name than
77 // the ClassName of the objects in the buffer
78 //
79 cout << "Branch: " << cname << "... " << flush;
80 pBranchOut = pTreeOut->Branch("TEST", cname, obj, 100000, 10);
81
82 if (!pBranchOut)
83 cout << "WARNING: Cannot open branch " << cname << "." << endl;
84 else
85 cout << "Done." << endl;
86
87 cout << endl;
88}
89
90MMagicFileIn::MMagicFileIn(const char *fname)
91{
92 fin = new fstream(fname, ios::in);
93 if (!fin)
94 cout << "Warning: Cannot open file '" << fname << "' for reading." << endl;
95}
96
97MMagicFileIn::~MMagicFileIn()
98{
99 if (fin)
100 delete fin;
101}
102
103void MMagicFileIn::SetAddress(MParContainer **obj)
104{
105 fContainer = *obj;
106}
107
108void MMagicFileIn::GetEvent(Int_t n)
109{
110 if (n!=0)
111 cout << "Warning: You cannot seek inside a Magic file <n ignored>" << endl;
112
113 fContainer->GetEventFromMagicFile(*fin);
114}
115
116MMagicFileOut::MMagicFileOut(const char *fname, MParContainer **obj)
117{
118 fout = new fstream(fname, ios::out);
119 //fFile = fopen(fname, "w");
120 if (!fout)
121 cout << "Warning: Cannot open file '" << fname << "' for writing." << endl;
122}
123
124MMagicFileOut::~MMagicFileOut()
125{
126 if (fout)
127 delete fout;
128}
129
130void MMagicFileOut::SetAddress(MParContainer **obj)
131{
132 fContainer = *obj;
133}
134
135void MMagicFileOut::Fill()
136{
137 fContainer->PutEventToMagicFile(*fout);
138}
Note: See TracBrowser for help on using the repository browser.