BmnRoot
26.10.0-18-g4e3414f9
Software framework of the BM@N experiment
Toggle main menu visibility
Loading...
Searching...
No Matches
check_missing_files.C
Go to the documentation of this file.
1
#include "
../../../services/function_set.h
"
2
3
#include <algorithm>
4
5
// function for checking files from a list in the given text file,
6
// whether the corresponding run is missing in the Electronic Logbook
7
// returns the success code: 0 - without errors, error_code - otherwise
8
int
check_missing_files
(
TString
list_file_path,
int
period_number)
9
{
10
gSystem
->ExpandPathName(list_file_path);
11
12
list<string> file_list;
13
ifstream list_file(list_file_path.
Data
());
14
string
s;
15
while
(getline(list_file, s))
16
file_list.push_back(s);
17
if
(file_list.empty()) {
18
cout <<
"WARNING: There are no files in the list of the input text file: "
<< list_file_path << endl;
19
return
0;
20
}
21
cout <<
"Total records in the input text file: "
<< file_list.size() << endl;
22
23
vector<string> missing_files;
24
vector<string> existing_files;
25
for
(
auto
const
& cur_file_path : file_list) {
26
string
file_name_wo_ext =
get_file_name
(cur_file_path);
27
// parse a run number from the name
28
string
str_run_number =
find_first_number
(file_name_wo_ext);
29
if
(str_run_number ==
""
) {
30
cout <<
"ERROR: No run number found in the file name: "
<< cur_file_path <<
", skipping.."
<< endl;
31
continue
;
32
}
33
int
run_number = stoi(str_run_number);
34
35
// search records with the run number in the Electronic Logbook
36
TObjArray
* pRecords =
ElogRecord::GetRecords
(period_number, run_number);
37
if
(pRecords->
IsEmpty
())
38
missing_files.push_back(cur_file_path);
39
else
40
existing_files.push_back(cur_file_path);
41
}
// while file list
42
43
// print the resulting lists in alphabetical order
44
sort(missing_files.begin(), missing_files.end());
45
sort(existing_files.begin(), existing_files.end());
46
47
if
(!missing_files.empty()) {
48
cout << endl <<
"Files not corresponding any run in the logbook:"
<< endl;
49
for
(
auto
const
& cur_file_path : missing_files)
50
cout << cur_file_path << endl;
51
cout << endl;
52
}
53
if
(!existing_files.empty()) {
54
cout << endl <<
"Files for runs described in the logbook:"
<< endl;
55
for
(
auto
const
& cur_file_path : existing_files)
56
cout << cur_file_path << endl;
57
cout << endl;
58
}
59
60
return
0;
61
}
gSystem
R__EXTERN TSystem * gSystem
check_missing_files
int check_missing_files(TString list_file_path, int period_number)
Definition
check_missing_files.C:8
ElogRecord::GetRecords
static TObjArray * GetRecords(int period_number, int run_number, int findNeighbourRun=0)
get array of ElogRecord-s for a given or a neighbour run (the same period) from the database if findN...
Definition
ElogRecord.cxx:1215
TObjArray
TObjArray::IsEmpty
Bool_t IsEmpty() const override
TString
TString::Data
const char * Data() const
find_first_number
string find_first_number(string const &str, bool isOnlyPositive=true)
Definition
function_set.h:471
get_file_name
string get_file_name(string path)
Definition
function_set.h:772
function_set.h
database
examples
elog_db
check_missing_files.C
Generated on
for BmnRoot by
1.17.0