BmnRoot 26.10.0-18-g4e3414f9
Software framework of the BM@N experiment
Loading...
Searching...
No Matches
tango_gem_trip.C
Go to the documentation of this file.
1// macro for printing TANGO data for GEM stations tripped in runs
2
3// map: № Tango channel -> GEMs Z-order (starts from 0)
4vector<int> map_channel_run5{1, 3, 0, 5, 2, 6, 4, 7};
5vector<int> map_channel_run6_b1529{1, 3, 0, 5, 2, 6, 4};
6vector<int> map_channel_run6_a1529{1, 3, 0, 5, 6, 4, 2};
7// mod_2 top GEMs: vmon_1 - М6, vmon_2 - М10, vmon_3 - М7, vmon_4 - М9, vmon_5 - М5, vmon_6 - М8, vmon_7 - М11 (vmon_8 -
8// small GEM) mod_0 bottom GEMs: vmon_1 - М16, vmon_2 - М15, vmon_3 - М14, vmon_4 - М12, vmon_5 - М18, vmon_6 - М13,
9// vmon_7 - М17
10vector<pair<const char*, const char*>> map_channel_run8 = {
11 {"mod_2", "vmon_1"}, {"mod_2", "vmon_2"}, {"mod_2", "vmon_3"}, {"mod_2", "vmon_4"}, {"mod_2", "vmon_5"},
12 {"mod_2", "vmon_6"}, {"mod_2", "vmon_7"}, {"mod_0", "vmon_1"}, {"mod_0", "vmon_2"}, {"mod_0", "vmon_3"},
13 {"mod_0", "vmon_4"}, {"mod_0", "vmon_5"}, {"mod_0", "vmon_6"}, {"mod_0", "vmon_7"}};
14
15void tango_gem_trip(int period = 6, int run = 1529, bool isShowOnlyTrip = false)
16{
17 // get run time
18 UniRun* pRun = UniRun::GetRun(period, run);
19 if (pRun == nullptr) {
20 cout << "Macro finished with errors: no experimental run was found for period = " << period << ", run = " << run
21 << endl;
22 exit(-1);
23 }
24
25 TString strStartDate = pRun->GetStartDatetime().AsSQLString();
26 TDatime* endDate = pRun->GetEndDatetime();
27 if (endDate == nullptr) {
28 cout << "Macro finished with errors: no end datetime in the database for period = " << period
29 << ", run = " << run << endl;
30 delete pRun;
31 exit(-2);
32 }
33 TString strEndDate = endDate->AsSQLString();
34 delete pRun;
35
36 if (period >= 8) {
37 switch (period) {
38 case 8: {
39 const char* detector_name = "gem";
40 vector<TangoData*> vecTangoData;
41 for (const auto& current_channel : map_channel_run8) {
42 // cout<<"detector_name = "<<detector_name<<", parameter name = "<<current_channel.second<<", member
43 // name = "<<current_channel.first<<endl;
44 // TangoData stores array of TangoTimeParameter* (parameter's values) for all time points
45 TangoData* db_tango = new TangoData(strStartDate.Data(), strEndDate.Data(), detector_name,
46 current_channel.second, current_channel.first);
47 vecTangoData.push_back(db_tango);
48 if (db_tango->GetTangoData() == nullptr) {
49 cout << "Macro finished with errors" << endl;
50 exit(-3);
51 }
52 }
53
54 // console output
56 // graph output
58
59 for (const auto& tango_data : vecTangoData)
60 delete tango_data;
61 vecTangoData.clear();
62
63 break;
64 }
65 default: {
66 cout << "Period " << period << " is not supported" << endl;
67 exit(-4);
68 }
69 }
70 } else {
71 const char* detector_name = "gem";
72 const char* parameter_name = "trip";
73 vector<int>* map_channel = nullptr;
74 switch (period) {
75 case 5:
76 map_channel = &map_channel_run5;
77 break;
78 case 6: {
79 if (run < 1529)
80 map_channel = &map_channel_run6_b1529;
81 else
82 map_channel = &map_channel_run6_a1529;
83 break;
84 }
85 default:
86 cout << "Macro finished with errors: no channel map was found for the period " << period << endl;
87 exit(-3);
88 }
89
91 bool condition_value = 1;
92
93 TangoData db_tango(strStartDate.Data(), strEndDate.Data(), detector_name, parameter_name);
94 if (db_tango.GetTangoData() == nullptr) {
95 cout << "Macro finished with errors" << endl;
96 exit(-1);
97 }
98
99 // TObjArray stores array of TangoTimeIntervals ((for all channels)): time intervals satisfying the condition
100 // ((TObjArray*)tango_data->At(0))->At(2) -> TangoTimeInterval*: third time interval satisfying the condition
101 // for the first channel 0
102 TObjArray* tango_intervals = db_tango.SearchTangoIntervals(condition, condition_value, map_channel);
103 if (tango_intervals == nullptr) {
104 cout << "Macro finished with errors" << endl;
105 exit(-4);
106 }
107
108 // console output
109 cout << "Information on " << parameter_name << " parameter for " << detector_name << " (period = " << period
110 << ", run = " << run << "):" << endl;
111 db_tango.PrintTangoIntervalConsole(tango_intervals, "GEM Z-order", isShowOnlyTrip);
112 cout << endl;
113
114 delete tango_intervals;
115 }
116}
117
118void tango_gem_trip(int period, bool isShowOnlyTrip = false)
119{
120 UniqueRunNumber* run_numbers;
121 int run_count = UniRunPeriod::GetRunNumbers(run_numbers, period);
122 if (run_count <= 0)
123 return;
124
125 for (int i = 0; i < run_count; i++)
126 tango_gem_trip(run_numbers[i].period_number, run_numbers[i].run_number, isShowOnlyTrip);
127
128 cout << "Macro finished successfully" << endl;
129}
int i
Definition P4_F32vec4.h:22
const char * AsSQLString() const
const char * Data() const
TObjArray * SearchTangoIntervals(enumConditions condition=conditionEqual, double value=1, std::vector< int > *mapChannel=nullptr)
Function SearchTangoIntervals gets time intervals for defined condition on the parameter values (e....
static void PrintTangoArrayConsole(std::vector< TangoData * > vecTangoData)
@ conditionEqual
Definition TangoData.h:91
TObjArray * GetTangoData()
Definition TangoData.h:141
static int PrintTangoArrayMultiGraph(std::vector< TangoData * > vecTangoData, const char *y_axis="parameter", bool is3D=false)
void PrintTangoIntervalConsole(TObjArray *tango_intervals, TString channel_name="Channel", bool isShowOnlyExists=false)
Function displays (in console) time intervals obtained from Tango for a defined condition Parameters:...
static int GetRunNumbers(UniqueRunNumber *&run_numbers, int period_number)
get numbers of runs existing in the Database for a selected period
UniRun.h Class for the table: run_.
Definition UniRun.h:21
static UniRun * GetRun(int period_number, int run_number)
get run from the database
Definition UniRun.cxx:161
TDatime * GetEndDatetime()
get end datetime of the current run
Definition UniRun.h:101
TDatime GetStartDatetime()
get start datetime of the current run
Definition UniRun.h:99
vector< pair< const char *, const char * > > map_channel_run8
vector< int > map_channel_run6_a1529
vector< int > map_channel_run5
void tango_gem_trip(int period=6, int run=1529, bool isShowOnlyTrip=false)
vector< int > map_channel_run6_b1529