]>
Commit | Line | Data |
---|---|---|
bf000c32 | 1 | //____________________________________________________________________ |
2 | // | |
3 | // $Id$ | |
4 | // | |
5 | // Test I/O of ALiFMDMap | |
6 | // | |
9b48326f | 7 | /** @defgroup MAPIO_TEST Map I/O test |
8 | @ingroup FMD_script | |
9 | */ | |
bf000c32 | 10 | //____________________________________________________________________ |
9b48326f | 11 | /** @ingroup MAPIO_test |
12 | */ | |
8f6ee336 | 13 | void |
14 | WriteTree() | |
15 | { | |
16 | TFile* file = TFile::Open("map.root", "RECREATE"); | |
17 | TTree* tree = new TTree("T", "T"); | |
18 | AliFMDFloatMap* m = new AliFMDFloatMap(1, 1, 1, 3); | |
19 | tree->Branch("map", "AliFMDFloatMap", &m); | |
20 | for (int i = 0; i < 3; i++) m->operator()(1,'I',0,i) = i + 1; | |
21 | tree->Fill(); | |
22 | file->Write(); | |
23 | file->Close(); | |
24 | } | |
25 | ||
bf000c32 | 26 | //____________________________________________________________________ |
9b48326f | 27 | /** @ingroup MAPIO_test |
28 | */ | |
8f6ee336 | 29 | void |
30 | ReadTree() | |
31 | { | |
32 | TFile* file = TFile::Open("map.root", "READ"); | |
33 | TTree* tree = static_cast<TTree*>(file->Get("T")); | |
34 | AliFMDFloatMap* m = 0; | |
35 | tree->SetBranchAddress("map", &m); | |
36 | tree->GetEntry(0); | |
37 | for (int i = 0; i < 3; i++) { | |
38 | std::cout << "Map(1,'I',0," << i << "): " << m->operator()(1,'I',0,i) | |
39 | << std::endl; | |
40 | } | |
41 | file->Close(); | |
42 | } | |
43 | ||
44 | ||
bf000c32 | 45 | //____________________________________________________________________ |
9b48326f | 46 | /** @ingroup MAPIO_test |
47 | */ | |
8f6ee336 | 48 | void |
49 | WriteMap() | |
50 | { | |
51 | TFile* file = TFile::Open("map.root", "RECREATE"); | |
52 | AliFMDFloatMap* m = new AliFMDFloatMap(1, 1, 1, 3); | |
53 | for (int i = 0; i < 3; i++) m->operator()(1,'I',0,i) = i + 1; | |
54 | m.Write("map"); | |
55 | file->Close(); | |
56 | } | |
57 | ||
bf000c32 | 58 | //____________________________________________________________________ |
9b48326f | 59 | /** @ingroup MAPIO_test |
60 | @return */ | |
61 | void | |
8f6ee336 | 62 | ReadMap() |
63 | { | |
64 | TFile* file = TFile::Open("map.root", "READ"); | |
65 | AliFMDFloatMap* m = static_cast<AliFMDFloatMap*>(file->Get("map")); | |
66 | std::cout << "Got map " << map << std::endl; | |
67 | for (int i = 0; i < 3; i++) { | |
68 | std::cout << "Map(1,'I',0," << i << "): " << m->operator()(1,'I',0,i) | |
69 | << std::endl; | |
70 | } | |
71 | file->Close(); | |
72 | } | |
73 | ||
74 | ||
bf000c32 | 75 | //____________________________________________________________________ |
9b48326f | 76 | /** @ingroup MAPIO_test |
77 | */ | |
8f6ee336 | 78 | void |
79 | TestMapIO() | |
80 | { | |
81 | WriteMap(); | |
82 | ReadMap(); | |
83 | WriteTree(); | |
84 | ReadTree(); | |
85 | } | |
bf000c32 | 86 | |
87 | //____________________________________________________________________ | |
88 | // | |
89 | // EOF | |
90 | // |