BmnRoot 26.10.0-18-g4e3414f9
Software framework of the BM@N experiment
Loading...
Searching...
No Matches
test_FC.cpp
Go to the documentation of this file.
1#include "FileCatalogue.cxx"
2#include "FileCatalogue.h"
3
4#include <iostream>
5
6void printFileInfo(unique_ptr<FileInfo> fi)
7{
8 cout << " Metadata of your file " << endl;
9 cout << " version " << fi->Version << endl;
10 cout << " periodnumber " << fi->PeriodNumber << endl;
11 cout << " runnumber " << fi->RunNumber << endl;
12 cout << " runtype " << fi->RunType << endl;
13 cout << " startdate " << fi->StartDateTime << endl;
14 cout << " enddate " << fi->EndDateTime << endl;
15 cout << " beamparticle " << fi->BeamParticle << endl;
16 cout << " targetparticle " << fi->TargetParticle << endl;
17 cout << " energy " << fi->Energy << endl;
18 cout << " fieldvoltage " << fi->FieldVoltage << endl;
19 cout << " startevent " << fi->StartEvent << endl;
20 cout << " endevent " << fi->EndEvent << endl;
21 cout << " eventcount " << fi->EventCount << endl;
22 cout << " filesize " << fi->FileSize << endl;
23}
24
25static std::string timePointAsString(const std::chrono::system_clock::time_point& tp)
26{
27 std::time_t t = std::chrono::system_clock::to_time_t(tp);
28 std::string ts = std::ctime(&t);
29 ts.resize(ts.size() - 1);
30 return ts;
31}
32
33int main(void)
34{
35 /*
36 // Get filepaths by metadata
37 enum FileCondition::searchAttributes attr = FileCondition::kPeriodNumber;
38 enum FileCondition::matchCriteria criteria = FileCondition::kGreaterOrEqual;
39 int condValue = 15;
40 std::unique_ptr<FileCondition> fcond = std::make_unique<FileCondition>(attr, criteria, condValue);
41
42 vector<unique_ptr<FileCondition>> fconds;
43 fconds.push_back(std::move(fcond));
44
45 FileCatalogue *FC = new FileCatalogue();
46 vector<string> filepaths;
47 int res = FC->GetFileList(std::move(fconds), filepaths);
48 if (res)
49 cout << "Error: " << GetErrorString(-res) << endl;
50 cout << " Here's your filepaths: " << endl;
51 for (auto i : filepaths)
52 cout << i << endl;
53
54 // Get meta for specific file
55 string LFN = "/bmn.nica.jinr/exp/raw/run9/run_Top_9639_ev0_p24.data";
56 FileInfo fi;
57 int res = FC->GetFileInfo(LFN, fi);
58 if (res)
59 cout << "Error: " << GetErrorString(-res) << endl;
60 else
61 fi.Print();
62
63 // Add metadata to a file
64 string LFN = "/bmn.nica.jinr/user/i/isjiron/newone.data";
65 auto file_metadata = std::make_unique<FileInfo>();
66 file_metadata->TargetParticle = "xXx";
67 int res = FC->AddFileInfo(LFN, *file_metadata);
68 if (res) {
69 cout << "Smth went wrong. Error code: " << res << endl;
70 } else {
71 cout << "Metadata updated. " << endl;
72 }
73
74 int res = FC->FileCatalogConsistencyCheck();
75 int res = FC->GetConsistencyCheckStatus();
76 cout << "Current check ID is " << res << endl;
77
78 int* eos_missing_count = new int;
79 int* fc_missing_count = new int;
80 vector<string> *eos_missing = new vector<string>;
81 vector<string> *fc_missing = new vector<string>;
82 int result = FC->GetConsistencyCheckResults(*eos_missing_count, *fc_missing_count, *eos_missing, *fc_missing);
83
84 cout << " eos missing : " << endl;
85 for (auto & element : *eos_missing) {
86 cout << element << endl;
87 }
88 cout << " fc missing : " << endl;
89 for (auto & element : *fc_missing) {
90 cout << element << endl;
91 }
92 cout << " eos missing count " << *eos_missing_count << endl;
93 cout << " fc_missing count " << *fc_missing_count << endl;
94
95
96 // Download specific file by LFN (Logical File Name)
97 string bigInLFN = "/bmn.nica.jinr/exp/digi/run8/25.04.0/mpd_run_Top_8011_ev0_p0.root";
98 string inLFN = "/bmn.nica.jinr/user/i/isjiron/newone.data";
99 string outPath = "/Users/beeleph/tmp/fileFromFC.data";
100 int res = FC->GetFileLocal(inLFN, outPath);
101 cout << " res is - " << res << endl;
102
103 int res = FC->PrintMetadataFields();
104 int res = FC->AddMetadataField("test_file_field", "INT", false);
105 int res = FC->DeleteMetadataField("test_file_field");
106 cout << " res is - " << res << endl;
107*/
108 return 0;
109}
int main(void)
Definition test_FC.cpp:33
void printFileInfo(unique_ptr< FileInfo > fi)
Definition test_FC.cpp:6
static std::string timePointAsString(const std::chrono::system_clock::time_point &tp)
Definition test_FC.cpp:25