R3BROOT
R3B analysis software
Loading...
Searching...
No Matches
ex_test.cxx
Go to the documentation of this file.
1#include <FairRtdbRun.h>
2#include <R3BEventHeader.h>
5#include <R3BShared.h>
6#include <TFile.h>
7#include <TTree.h>
8#include <iostream>
9#include <map>
10#include <range/v3/view.hpp>
11#include <vector>
12
13// void Read()
14// {
15
16// auto vec = std::make_unique<std::vector<R3BPaddleTamexMappedData2>>();
17// auto rootFile = R3B::make_rootfile("test.root", "READ");
18// // auto dataTree = std::make_unique<TTree>("evt", "data tree");
19
20// auto* dataTree = rootFile->Get<TTree>("evt");
21// if (dataTree == nullptr)
22// {
23// return;
24// }
25
26// dataTree->Print();
27// auto* ptr = vec.get();
28// auto res = dataTree->SetBranchAddress("mappedData", &ptr);
29
30// std::cout << "res: " << res << std::endl;
31// if (res != 0)
32// {
33// return;
34// }
35
36// for (const auto entry : ranges::iota_view(0, dataTree->GetEntries()))
37// {
38// dataTree->GetEntry(entry);
39// std::cout << "-----------------" << std::endl;
40// for (const auto& item : *vec)
41// {
42// std::cout << "info:" << item.barID << std::endl;
43// }
44// }
45// }
46// void ReadMap()
47// {
48
49// auto map = std::make_unique<std::map<int, R3BPaddleTamexMappedData2>>();
50// auto rootFile = R3B::make_rootfile("test.root", "READ");
51// // auto dataTree = std::make_unique<TTree>("evt", "data tree");
52
53// auto* dataTree = rootFile->Get<TTree>("evt");
54// if (dataTree == nullptr)
55// {
56// return;
57// }
58
59// dataTree->Print();
60// auto* ptr = map.get();
61// auto res = dataTree->SetBranchAddress("mappedData", &ptr);
62
63// std::cout << "res: " << res << std::endl;
64// if (res != 0)
65// {
66// return;
67// }
68
69// for (const auto entry : ranges::iota_view(0, dataTree->GetEntries()))
70// {
71// dataTree->GetEntry(entry);
72// std::cout << "-----------------" << std::endl;
73// for (const auto& [key, item] : *map)
74// {
75// std::cout << "key:" << key << std::endl;
76// std::cout << "info:" << item.barID << std::endl;
77// }
78// }
79// }
80
81// void Write()
82// {
83// auto rootFile = R3B::make_rootfile("test.root", "RECREATE");
84// auto dataTree = std::make_unique<TTree>("evt", "data tree");
85
86// auto myMap = std::map<int, R3BPaddleTamexMappedData2>{};
87
88// const auto mapSize = 5;
89// const auto entrySize = 10;
90
91// dataTree->Branch("mappedData", &myMap);
92
93// for (const auto _ : ranges::iota_view(0, entrySize))
94// {
95// for (const auto key : ranges::iota_view(0, mapSize))
96// {
97// auto mapData = R3BPaddleTamexMappedData2{};
98// mapData.barID = key + 10;
99// myMap.insert({ key, mapData });
100// }
101// dataTree->Fill();
102// myMap.clear();
103// }
104// dataTree->Print();
105// dataTree->Show(3);
106// dataTree->Write();
107// }
108
109auto main() -> int
110{
111 // Write();
112 // ReadMap();
113 // auto rootFile = R3B::make_rootfile("test.root", "RECREATE");
114
115 // auto lists = std::make_unique<TList>();
116 // for (auto count : ranges::iota_view(0, 10))
117 // {
118 // auto run = std::make_unique<FairRtdbRun>(100 + count, 2);
119 // lists->Add(run.release());
120 // }
121 // rootFile->WriteObject(lists.get(), "a list");
122
123 return 0;
124}
auto main() -> int
Definition ex_test.cxx:109