-
Notifications
You must be signed in to change notification settings - Fork 2
/
config.h
161 lines (120 loc) · 4.85 KB
/
config.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
#ifndef _config_h_
#define _config_h_
#include "FWCore/ParameterSet/interface/ParameterSet.h"
#include "FWCore/PythonParameterSet/interface/MakeParameterSets.h"
#include <vector>
#include <string>
using namespace std;
//----------------------------------------------------------------------------------------------------
struct SelectionRange
{
double x_min;
double x_max;
SelectionRange(double _xmi=0., double _xma=0.) : x_min(_xmi), x_max(_xma)
{
}
};
//----------------------------------------------------------------------------------------------------
struct Config
{
vector<string> input_files;
map<unsigned int, double> alignment_corrections_x;
bool aligned;
double n_si;
double cut1_a, cut1_c, cut1_si;
double cut2_a, cut2_c, cut2_si;
double cut3_a, cut3_c, cut3_si;
double cut4_a, cut4_c, cut4_si;
bool cut1_apply;
bool cut2_apply;
bool cut3_apply;
bool cut4_apply;
vector<string> matching_1d_reference_datasets;
map<unsigned int, SelectionRange> matching_1d_ranges;
map<unsigned int, SelectionRange> matching_1d_shift_ranges;
int LoadFrom(const string &f);
void Print(bool print_input_files=false) const;
};
//----------------------------------------------------------------------------------------------------
int Config::LoadFrom(const string &f_in)
{
map<unsigned int, string> rp_tags = {
{ 23, "L_2_F" },
{ 3, "L_1_F" },
{ 103, "R_1_F" },
{ 123, "R_2_F" }
};
const edm::ParameterSet& config = edm::readPSetsFrom(f_in)->getParameter<edm::ParameterSet>("config");
input_files = config.getParameter<vector<string>>("input_files");
const auto &acc = config.getParameter<edm::ParameterSet>("alignment_corrections");
for (const auto &p : rp_tags)
{
const auto &ps = acc.getParameter<edm::ParameterSet>("rp_" + p.second);
alignment_corrections_x[p.first] = ps.getParameter<double>("de_x");
}
aligned = config.getParameter<bool>("aligned");
n_si = config.getParameter<double>("n_si");
cut1_apply = config.getParameter<bool>("cut1_apply");
cut1_a = config.getParameter<double>("cut1_a");
cut1_c = config.getParameter<double>("cut1_c");
cut1_si = config.getParameter<double>("cut1_si");
cut2_apply = config.getParameter<bool>("cut2_apply");
cut2_a = config.getParameter<double>("cut2_a");
cut2_c = config.getParameter<double>("cut2_c");
cut2_si = config.getParameter<double>("cut2_si");
cut3_apply = config.getParameter<bool>("cut3_apply");
cut3_a = config.getParameter<double>("cut3_a");
cut3_c = config.getParameter<double>("cut3_c");
cut3_si = config.getParameter<double>("cut3_si");
cut4_apply = config.getParameter<bool>("cut4_apply");
cut4_a = config.getParameter<double>("cut4_a");
cut4_c = config.getParameter<double>("cut4_c");
cut4_si = config.getParameter<double>("cut4_si");
const auto &c_m1d = config.getParameter<edm::ParameterSet>("matching_1d");
matching_1d_reference_datasets = c_m1d.getParameter<vector<string>>("reference_datasets");
for (const auto &p : rp_tags)
{
const auto &ps = c_m1d.getParameter<edm::ParameterSet>("rp_" + p.second);
matching_1d_ranges[p.first] = SelectionRange(ps.getParameter<double>("x_min"), ps.getParameter<double>("x_max"));
matching_1d_shift_ranges[p.first] = SelectionRange(ps.getParameter<double>("sh_min"), ps.getParameter<double>("sh_max"));
}
return 0;
}
//----------------------------------------------------------------------------------------------------
void Config::Print(bool print_input_files) const
{
if (print_input_files)
{
printf("* input files\n");
for (const auto &f : input_files)
printf(" %s\n", f.c_str());
printf("\n");
}
printf("* dataset already aligned\n");
printf(" aligned = %u\n", aligned);
printf("\n");
printf("* alignment parameters\n");
for (const auto &p : alignment_corrections_x)
printf(" RP %u: de_x = %.3f mm\n", p.first, p.second);
printf("\n");
printf("* cuts\n");
printf(" n_si = %.3f\n", n_si);
printf(" cut1: apply = %u, a = %.3f, c = %.3f, si = %.3f\n", cut1_apply, cut1_a, cut1_c, cut1_si);
printf(" cut2: apply = %u, a = %.3f, c = %.3f, si = %.3f\n", cut2_apply, cut2_a, cut2_c, cut2_si);
printf(" cut3: apply = %u, a = %.3f, c = %.3f, si = %.3f\n", cut3_apply, cut3_a, cut3_c, cut3_si);
printf(" cut4: apply = %u, a = %.3f, c = %.3f, si = %.3f\n", cut4_apply, cut4_a, cut4_c, cut4_si);
printf("\n");
printf("* 1D matching\n");
printf(" reference datasets (%lu):\n", matching_1d_reference_datasets.size());
for (const auto &ds : matching_1d_reference_datasets)
printf(" %s\n", ds.c_str());
for (const auto &p : matching_1d_ranges)
{
const auto it_sh = matching_1d_shift_ranges.find(p.first);
printf(" RP %u: x_min = %.3f, x_max = %.3f, sh_min = %.3f, sh_max = %.3f\n",
p.first, p.second.x_min, p.second.x_max, it_sh->second.x_min, it_sh->second.x_max);
}
}
//----------------------------------------------------------------------------------------------------
Config cfg;
#endif