R3BROOT
R3B analysis software
Loading...
Searching...
No Matches
R3BDetParRootFileIo.cxx
Go to the documentation of this file.
2#include "R3BException.h"
3#include "R3BParRootFileIo.h"
4#include <FairDetParIo.h>
5#include <FairParSet.h>
6#include <FairRuntimeDb.h>
7#include <fairlogger/Logger.h>
8#include <string_view>
9
10namespace R3B
11{
12 auto DetParRootFileIo::init(FairParSet* par) -> bool
13 {
14 auto par_name = std::string_view{ par->GetName() };
15
16 if (file_io_ == nullptr)
17 {
18 throw R3B::logic_error("ParRootFileIo is nullptr!");
19 }
20
21 auto is_ok = file_io_->read_parameter(par);
22 if (not is_ok)
23 {
24 LOGP(error, "Failed to initialize the parameter {:?}", par_name);
25 return false;
26 }
27
28 par->setChanged();
29 LOGP(info, "Parameter {:?} is initialized successfully", par_name);
30 return true;
31 }
32
33 auto DetParRootFileIo::write(FairParSet* par) -> int
34 {
35
36 if (file_io_ == nullptr)
37 {
38 throw R3B::logic_error("ParRootFileIo is nullptr!");
39 }
40 auto cycle_num = file_io_->write_parameter(par);
41 par->setChanged(false);
42 FairRuntimeDb::instance()->setVersionsChanged(true);
43 return cycle_num;
44 }
45
46} // namespace R3B
auto init(FairParSet *par) -> bool override
auto write(FairParSet *par) -> int override