13 gSystem->ExpandPathName(list_file_path);
15 list<string> file_list;
16 ifstream list_file(list_file_path.
Data());
18 while (getline(list_file, s)) {
20 if (s.find_first_not_of(
" \t\r\n") == string::npos)
22 file_list.push_back(s);
24 if (file_list.empty()) {
25 cout <<
"WARNING: There are no files in the list of the input text file: " << list_file_path << endl;
28 cout <<
"Total file records in the input text file: " << file_list.size() << endl << endl;
30 int period_number = -1, removed_raw_files = 0, removed_runs = 0;
31 unordered_set<int> run_list;
33 for (
auto const& cur_file_path : file_list) {
36 cout <<
"Current file of the list: " << file_name << endl;
39 if (raw_files ==
nullptr)
46 if (period_number == -1)
50 cout <<
"ERROR: there are different period numbers for the files (" << period_number <<
"<>"
57 cout <<
"Removing raw file: " << curRawFile->
GetFilePath() << endl;
65 for (
int current_run : run_list) {
66 cout <<
"Current run: " << current_run << endl;
69 if ((raw_files !=
nullptr) and (raw_files->
GetEntries() == 0)) {
70 cout <<
"Removing period:run = " << period_number <<
":" << current_run << endl;
78 << (isTest ?
"Would remove " :
"Removed ") << removed_raw_files <<
" raw files and " << removed_runs <<
" runs"
94 gSystem->ExpandPathName(bad_run_file);
97 ifstream list_file(bad_run_file.
Data());
99 while (getline(list_file, s)) {
101 int i_run_number = std::stoi(s);
102 run_list.push_back(i_run_number);
103 }
catch (
const std::invalid_argument&) {
104 cerr <<
"ERROR: Line is not a valid number: \"" << s <<
"\"\n";
106 }
catch (
const std::out_of_range&) {
107 cerr <<
"Warning: Line " << s <<
": number is out of range\n";
111 if (run_list.empty()) {
112 cout <<
"WARNING: There are no runs in the list of the input text file: " << bad_run_file << endl;
115 cout <<
"Total run records in the input text file: " << run_list.size() << endl << endl;
117 int removed_runs = 0;
119 for (
int current_run : run_list) {
120 cout <<
"Current run: " << current_run << endl;
125 if ((raw_files !=
nullptr) and (raw_files->
GetEntries() == 0)) {
126 cout <<
"Removing period:run = " << period_number <<
":" << current_run << endl;
133 cout << endl << (isTest ?
"Would remove " :
"Removed ") << removed_runs <<
" runs" << endl;
149 gSystem->ExpandPathName(good_run_file);
152 unordered_set<int> run_list;
153 ifstream list_file(good_run_file.
Data());
155 while (getline(list_file, s)) {
157 int i_run_number = std::stoi(s);
158 run_list.insert(i_run_number);
159 }
catch (
const std::invalid_argument&) {
160 cerr <<
"ERROR: Line is not a valid number: \"" << s <<
"\"\n";
162 }
catch (
const std::out_of_range&) {
163 cerr <<
"Warning: Line " << s <<
": number is out of range\n";
167 if (run_list.empty()) {
168 cout <<
"WARNING: There are no runs in the list of the input text file: " << good_run_file << endl;
171 cout <<
"Total run records in the input text file: " << run_list.size() << endl << endl;
176 if (run_count <= 0) {
177 cout <<
"ERROR: runs do not exist in the Database for period " << period_number << endl;
181 int nfound_runs = 0, removed_runs = 0;
182 for (
int i = 0;
i < run_count;
i++) {
183 if (run_list.find(run_numbers[
i].
run_number) != run_list.end())
185 cout <<
"Run " << run_numbers[
i].
run_number <<
" is not in the list" << endl;
191 if ((raw_files !=
nullptr) and (raw_files->
GetEntries() == 0)) {
201 int missing_runs = 0;
202 for (
int current_run : run_list) {
204 cout <<
"Run " << current_run <<
" is missing" << endl;
209 if (nfound_runs + missing_runs > 0)
212 cout <<
"Found " << nfound_runs <<
" odd runs" << endl;
214 cout << (isTest ?
"Would remove " :
"Removed ") << removed_runs <<
" runs" << endl;
215 cout <<
"Found " << missing_runs <<
" missing runs" << endl;
R__EXTERN TSystem * gSystem
Int_t GetEntries() const override
TObject * At(Int_t idx) const override
const char * Data() const
/home/soul/bmnroot/database/uni_db1/UniRawFile.h Class for the table: raw_file
TString GetFilePath()
get file path of the current raw file
int GetRunNumber()
get run number of the current raw file
int GetFileId()
get file id of the current raw file
static TObjArray * GetRawFiles(int period_number, int run_number)
get array of raw files (UniRawFile*) corresponding to the period:run number ordered by start_event as...
static int DeleteRawFile(int file_id)
delete raw file from the database
int GetPeriodNumber()
get period number of the current raw file
static int GetRunNumbers(UniqueRunNumber *&run_numbers, int period_number)
get numbers of runs existing in the Database for a selected period
static int DeleteRun(int period_number, int run_number)
delete run from the database
static int CheckRunExists(int period_number, int run_number)
check run exists in the database: 1- true, 0 - false, <0 - database operation error
string get_file_name_with_ext(string path)
int remove_runs(TString bad_run_file, int period_number=9, bool isTest=true)
int remove_odd_runs(TString good_run_file, int period_number=9, bool isTest=true)
int remove_raw_files(TString list_file_path, bool isTest=true)