10int main(
int argc,
char** argv)
14 std::cout <<
"Usage: " << argv[0] <<
" <odb file> <root file(s)>" << std::endl;
18 std::ifstream odbFile(argv[1]);
21 std::string runComment;
23 std::string subString;
26 uint32_t runStart = 0;
29 while(std::getline(odbFile, line)) {
34 if(line ==
"[/Experiment/Run parameters]") {
35 std::cout <<
"found line " << line << std::endl;
36 std::getline(odbFile, line);
37 runComment = line.substr(25, std::string::npos);
38 std::cout <<
"got run comment '" << runComment <<
"' from line " << line << std::endl;
39 std::getline(odbFile, line);
40 runTitle = line.substr(27, std::string::npos);
41 std::cout <<
"got run title '" << runTitle <<
"' from line " << line << std::endl;
54 if(line ==
"[/Runinfo]") {
55 std::cout <<
"found line " << line << std::endl;
56 std::getline(odbFile, line);
57 std::getline(odbFile, line);
58 std::getline(odbFile, line);
59 subString = line.substr(25, std::string::npos);
60 runNumber = std::stoi(subString);
61 std::cout <<
"got run number " << runNumber <<
" from substring '" << subString <<
"' from line " << line << std::endl;
62 std::getline(odbFile, line);
63 std::getline(odbFile, line);
64 std::getline(odbFile, line);
65 std::getline(odbFile, line);
66 std::getline(odbFile, line);
67 subString = line.substr(39, std::string::npos);
68 runStart = std::stoi(subString);
69 std::cout <<
"got run start " << runStart <<
" from substring '" << subString <<
"' from line " << line << std::endl;
70 std::getline(odbFile, line);
71 std::getline(odbFile, line);
72 subString = line.substr(38, std::string::npos);
73 runStop = std::stoi(subString);
74 std::cout <<
"got run stop " << runStop <<
" from substring '" << subString <<
"' from line " << line << std::endl;
81 std::cout <<
"old run info:" << std::endl;
90 for(
int i = 2; i < argc; ++i) {
93 std::size_t dot = line.rfind(
'_');
94 std::size_t underscore = line.rfind(
'.');
95 std::size_t start = line.rfind(
"fragment");
96 if(start != std::string::npos) {
99 start = line.rfind(
"analysis");
100 if(start != std::string::npos) {
103 std::cerr <<
"malformed file name(" << line <<
"), should contain either 'fragment' or 'analysis'" << std::endl;
108 if(start < underscore && underscore < dot && dot != std::string::npos) {
110 subString = line.substr(start, underscore - start);
111 runNumber = std::stoi(subString);
112 std::cout <<
"got run number " << runNumber <<
" from substring '" << subString <<
"' from line " << line << std::endl;
114 std::cerr <<
"Mismatch between the run number of this file (" << runNumber <<
") and the run number in the ODB (" <<
TRunInfo::RunNumber() <<
"), skipping " << line << std::endl;
117 subString = line.substr(underscore + 1, dot - underscore - 1);
118 subRunNumber = std::stoi(subString);
119 std::cout <<
"got sub run number " << runNumber <<
" from substring '" << subString <<
"' from line " << line << std::endl;
121 std::cout <<
"new run info:" << std::endl;
124 auto* fileRunInfo =
static_cast<TRunInfo*
>(f.Get(
"RunInfo"));
125 if(fileRunInfo ==
nullptr) {
126 std::cout <<
"no run info found in " << line << std::endl;
128 std::cout <<
"run info found in " << line <<
": " << std::endl;
129 fileRunInfo->Print();
131 runInfo->Write(
"RunInfo", TObject::kOverwrite);
134 std::cerr <<
"malformed file name, expected 'path/<fragment or analysis>#####_###.root', not " << line << std::endl;