43 {
44
45
46 static constexpr int PmtToChannelBarrel[48] = {
47 1, 2, 3, 4, 5, 6, 7, 8,
48 9, 10, 11, 12, 13, 14, 15, 16,
49 17, 18, 19, 20, 21, 22, 23, 24,
50 27, 26, 25, 30, 29, 28, 33, 32,
51 31, 36, 35, 34, 39, 38, 37, 42,
52 41, 40, 45, 44, 43, 48, 47, 46 };
53
54 static constexpr int PmtToChannelExtendedBarrel[48] = {
55 1, 2, 3, 4, 5, 6, 7, 8,
56 9, 10, 11, 12, 13, 14, 15, 16,
57 17, 18, 19, 20, 21, 22, 23, 24,
58 27, 26, 25, 31, 32, 28, 33, 29,
59 30, 36, 35, 34, 44, 38, 37, 43,
60 42, 41, 45, 39, 40, 48, 47, 46 };
61
63
64
65 FILE* AlphaMatrixFile[4][64]{};
66 char Rosstr[10];
68
69 for (int Ros = 1; Ros < 5; ++Ros) {
70 for (int Drawer = 0; Drawer < 64; ++Drawer) {
71
72 if (Ros == 1) sprintf(Rosstr, "LBA");
73 else if (Ros == 2) sprintf(Rosstr, "LBC");
74 else if (Ros == 3) sprintf(Rosstr, "EBA");
75 else sprintf(Rosstr, "EBC");
76
78 std::string filestr(buff);
80
81
82
83 if (
file.size() == 0) {
85 } else {
87 AlphaMatrixFile[Ros - 1][Drawer] = fopen(
file.c_str(),
"r");
88 }
89 if (AlphaMatrixFile[Ros - 1][Drawer] == NULL) {
91 return StatusCode::FAILURE;
92 }
94 FILE* alpha_file = AlphaMatrixFile[Ros - 1][Drawer];
95
96
97
98
99 const char* TOKENS = { " \t\n" };
100
101 int dima = 48;
102 char* saveptr = nullptr;
103 for (
int line = 0;
line < dima;
line++) {
104 if (fgets(buff, sizeof(buff), alpha_file) != NULL) {
107
108 if (*buff == '!' || *buff == '*') continue;
109
110 double pippo = 0;
111 if (const char* word = strtok_r(column==0 ? buff : nullptr, TOKENS, &saveptr))
112 {
114 }
115
119
121 if (Ros < 3) {
122 chline = PmtToChannelBarrel[
line] - 1;
123 chcolumn = PmtToChannelBarrel[
column] - 1;
124 } else {
125 chline = PmtToChannelExtendedBarrel[
line] - 1;
126 chcolumn = PmtToChannelExtendedBarrel[
column] - 1;
127 }
128 }
130 }
131 }
132 }
133 fclose(alpha_file);
134 }
135 }
136
138
140 FILE* MeanFile[4][64];
141
142 for (int Ros = 1; Ros < 5; ++Ros) {
143 for (int Drawer = 0; Drawer < 64; ++Drawer) {
144
145 if (Ros == 1)
146 sprintf(Rosstr, "LBA");
147 else if (Ros == 2)
148 sprintf(Rosstr, "LBC");
149 else if (Ros == 3)
150 sprintf(Rosstr, "EBA");
151 else
152 sprintf(Rosstr, "EBC");
153 sprintf(buff,
"%s%s%02d.txt",
m_meanFilePrefix.c_str(), Rosstr, Drawer + 1);
154 std::string filestr(buff);
156 if (
file.size() == 0) {
158 } else {
160 MeanFile[Ros - 1][Drawer] = fopen(
file.c_str(),
"r");
161 }
162 if (MeanFile[Ros - 1][Drawer] == NULL) {
164 return StatusCode::FAILURE;
165 }
166
168 FILE* mean_file = MeanFile[Ros - 1][Drawer];
169
170
171
172
173
174 const char* TOKENS = { " \t\n" };
175
176 int dima = 48;
177 char* saveptr = nullptr;
178 for (
int line = 0;
line < dima;
line++) {
179 if (fgets(buff, sizeof(buff), mean_file) != NULL) {
181 for (
int Sample = 0; Sample <
nSamples; Sample++) {
182
183 if (*buff == '!' || *buff == '*') continue;
184
185 double pippo = 0;
186 if (const char* word = strtok_r(Sample==0 ? buff : nullptr, TOKENS, &saveptr))
187 {
189 }
190
193
195 if (Ros < 3) chline = PmtToChannelBarrel[
line] - 1;
196 else chline = PmtToChannelExtendedBarrel[
line] - 1;
197 }
199 }
200 }
201 }
202 fclose(mean_file);
203 }
204 }
205 } else {
206
208 for (int Ros = 1; Ros < 5; ++Ros) {
209 for (int Drawer = 0; Drawer < 64; ++Drawer) {
211 for (
int Sample = 0; Sample <
nSamples; ++Sample) {
212
214 }
215 }
216 }
217 }
218 }
219
220
221 FILE* Sample3RMSFile[4][64];
222
223 for (int Ros = 1; Ros < 5; ++Ros) {
224 for (int Drawer = 0; Drawer < 64; ++Drawer) {
225
226 if (Ros == 1) sprintf(Rosstr, "LBA");
227 else if (Ros == 2) sprintf(Rosstr, "LBC");
228 else if (Ros == 3) sprintf(Rosstr, "EBA");
229 else sprintf(Rosstr, "EBC");
230
232 std::string filestr(buff);
234 if (
file.size() == 0) {
236 } else {
238 Sample3RMSFile[Ros - 1][Drawer] = fopen(
file.c_str(),
"r");
239 }
240 if (Sample3RMSFile[Ros - 1][Drawer] == NULL) {
242 return StatusCode::FAILURE;
243 }
244
246 FILE* rms_file = Sample3RMSFile[Ros - 1][Drawer];
247
248
249
250
251
252 char* word;
253 const char* TOKENS = { " \t\n" };
254
255 int dima = 48;
256 for (
int line = 0;
line < dima;
line++) {
257 if (fgets(buff, sizeof(buff), rms_file) != NULL) {
259
260 if (*buff == '!' || *buff == '*') continue;
261
262 double pippo;
263 char* saveptr = nullptr;
264 if ((word = strtok_r(buff, TOKENS, &saveptr)) == NULL) pippo = 0;
265 else pippo =
atof(word);
266
269
271 if (Ros < 3) chline = PmtToChannelBarrel[
line] - 1;
272 else chline = PmtToChannelExtendedBarrel[
line] - 1;
273 }
275 }
276 }
277 fclose(rms_file);
278 }
279 }
280
283
286 }
287
288 ATH_MSG_INFO(
"Initialization completed successfully" );
289
290 return StatusCode::SUCCESS;
291}
#define ATH_MSG_VERBOSE(x)
#define ATH_MSG_WARNING(x)
static std::string find_file(const std::string &logical_file_name, const std::string &search_path)
double atof(std::string_view str)
Converts a string into a double / float.