]> git.uio.no Git - u/mrichter/AliRoot.git/blob - FMD/scripts/TestMapIO.C
0. General code clean-up, including messages, and the like.
[u/mrichter/AliRoot.git] / FMD / scripts / TestMapIO.C
1 //____________________________________________________________________
2 //
3 // $Id$
4 //
5 // Test I/O of ALiFMDMap
6 //
7 //____________________________________________________________________
8 void 
9 WriteTree()
10 {
11   TFile* file = TFile::Open("map.root", "RECREATE");
12   TTree* tree = new TTree("T", "T");
13   AliFMDFloatMap* m = new AliFMDFloatMap(1, 1, 1, 3);
14   tree->Branch("map", "AliFMDFloatMap", &m);
15   for (int i = 0; i < 3; i++) m->operator()(1,'I',0,i) = i + 1;
16   tree->Fill();
17   file->Write();
18   file->Close();
19 }
20
21 //____________________________________________________________________
22 void 
23 ReadTree()
24 {
25   TFile* file = TFile::Open("map.root", "READ");
26   TTree* tree = static_cast<TTree*>(file->Get("T"));
27   AliFMDFloatMap* m = 0;
28   tree->SetBranchAddress("map", &m);
29   tree->GetEntry(0);
30   for (int i = 0; i < 3; i++) {
31     std::cout << "Map(1,'I',0," << i << "): " << m->operator()(1,'I',0,i)
32               << std::endl;
33   }
34   file->Close();
35 }
36
37   
38 //____________________________________________________________________
39 void
40 WriteMap() 
41 {
42   TFile* file = TFile::Open("map.root", "RECREATE");
43   AliFMDFloatMap* m = new AliFMDFloatMap(1, 1, 1, 3);
44   for (int i = 0; i < 3; i++) m->operator()(1,'I',0,i) = i + 1;
45   m.Write("map");
46   file->Close();
47 }
48
49 //____________________________________________________________________
50 ReadMap() 
51 {
52   TFile* file = TFile::Open("map.root", "READ");
53   AliFMDFloatMap* m = static_cast<AliFMDFloatMap*>(file->Get("map"));
54   std::cout << "Got map " << map << std::endl;
55   for (int i = 0; i < 3; i++) {
56     std::cout << "Map(1,'I',0," << i << "): " << m->operator()(1,'I',0,i)
57               << std::endl;
58   }
59   file->Close();
60 }
61
62
63 //____________________________________________________________________
64 void
65 TestMapIO()
66 {
67   WriteMap();
68   ReadMap();
69   WriteTree();
70   ReadTree();
71 }
72
73 //____________________________________________________________________
74 //
75 // EOF
76 //