44 {
45
46
47 int PmtToChannelBarrel[48] = {
48 1, 2, 3, 4, 5, 6, 7, 8,
49 9, 10, 11, 12, 13, 14, 15, 16,
50 17, 18, 19, 20, 21, 22, 23, 24,
51 27, 26, 25, 30, 29, 28, 33, 32,
52 31, 36, 35, 34, 39, 38, 37, 42,
53 41, 40, 45, 44, 43, 48, 47, 46 };
54
55 int PmtToChannelExtendedBarrel[48] = {
56 1, 2, 3, 4, 5, 6, 7, 8,
57 9, 10, 11, 12, 13, 14, 15, 16,
58 17, 18, 19, 20, 21, 22, 23, 24,
59 27, 26, 25, 31, 32, 28, 33, 29,
60 30, 36, 35, 34, 44, 38, 37, 43,
61 42, 41, 45, 39, 40, 48, 47, 46 };
62
64
65
66 FILE* AlphaMatrixFile[4][64]{};
67 char Rosstr[10];
69
70 for (int Ros = 1; Ros < 5; ++Ros) {
71 for (int Drawer = 0; Drawer < 64; ++Drawer) {
72
73 if (Ros == 1) sprintf(Rosstr, "LBA");
74 else if (Ros == 2) sprintf(Rosstr, "LBC");
75 else if (Ros == 3) sprintf(Rosstr, "EBA");
76 else sprintf(Rosstr, "EBC");
77
79 std::string filestr(buff);
81
82
83
84 if (
file.size() == 0) {
86 } else {
88 AlphaMatrixFile[Ros - 1][Drawer] = fopen(
file.c_str(),
"r");
89 }
90 if (AlphaMatrixFile[Ros - 1][Drawer] == NULL) {
92 return StatusCode::FAILURE;
93 }
95 FILE* alpha_file = AlphaMatrixFile[Ros - 1][Drawer];
96
97
98
99
100 const char* TOKENS = { " \t\n" };
101
102 int dima = 48;
103 char* saveptr = nullptr;
104 for (
int line = 0;
line < dima;
line++) {
105 if (fgets(buff, sizeof(buff), alpha_file) != NULL) {
108
109 if (*buff == '!' || *buff == '*') continue;
110
111 double pippo = 0;
112 if (const char* word = strtok_r(column==0 ? buff : nullptr, TOKENS, &saveptr))
113 {
115 }
116
120
122 if (Ros < 3) {
123 chline = PmtToChannelBarrel[
line] - 1;
124 chcolumn = PmtToChannelBarrel[
column] - 1;
125 } else {
126 chline = PmtToChannelExtendedBarrel[
line] - 1;
127 chcolumn = PmtToChannelExtendedBarrel[
column] - 1;
128 }
129 }
131 }
132 }
133 }
134 fclose(alpha_file);
135 }
136 }
137
139
141 FILE* MeanFile[4][64];
142
143 for (int Ros = 1; Ros < 5; ++Ros) {
144 for (int Drawer = 0; Drawer < 64; ++Drawer) {
145
146 if (Ros == 1)
147 sprintf(Rosstr, "LBA");
148 else if (Ros == 2)
149 sprintf(Rosstr, "LBC");
150 else if (Ros == 3)
151 sprintf(Rosstr, "EBA");
152 else
153 sprintf(Rosstr, "EBC");
154 sprintf(buff,
"%s%s%02d.txt",
m_meanFilePrefix.c_str(), Rosstr, Drawer + 1);
155 std::string filestr(buff);
157 if (
file.size() == 0) {
159 } else {
161 MeanFile[Ros - 1][Drawer] = fopen(
file.c_str(),
"r");
162 }
163 if (MeanFile[Ros - 1][Drawer] == NULL) {
165 return StatusCode::FAILURE;
166 }
167
169 FILE* mean_file = MeanFile[Ros - 1][Drawer];
170
171
172
173
174
175 const char* TOKENS = { " \t\n" };
176
177 int dima = 48;
178 char* saveptr = nullptr;
179 for (
int line = 0;
line < dima;
line++) {
180 if (fgets(buff, sizeof(buff), mean_file) != NULL) {
182 for (
int Sample = 0; Sample <
nSamples; Sample++) {
183
184 if (*buff == '!' || *buff == '*') continue;
185
186 double pippo = 0;
187 if (const char* word = strtok_r(Sample==0 ? buff : nullptr, TOKENS, &saveptr))
188 {
190 }
191
194
196 if (Ros < 3) chline = PmtToChannelBarrel[
line] - 1;
197 else chline = PmtToChannelExtendedBarrel[
line] - 1;
198 }
200 }
201 }
202 }
203 fclose(mean_file);
204 }
205 }
206 } else {
207
209 for (int Ros = 1; Ros < 5; ++Ros) {
210 for (int Drawer = 0; Drawer < 64; ++Drawer) {
212 for (
int Sample = 0; Sample <
nSamples; ++Sample) {
213
215 }
216 }
217 }
218 }
219 }
220
221
222 FILE* Sample3RMSFile[4][64];
223
224 for (int Ros = 1; Ros < 5; ++Ros) {
225 for (int Drawer = 0; Drawer < 64; ++Drawer) {
226
227 if (Ros == 1) sprintf(Rosstr, "LBA");
228 else if (Ros == 2) sprintf(Rosstr, "LBC");
229 else if (Ros == 3) sprintf(Rosstr, "EBA");
230 else sprintf(Rosstr, "EBC");
231
233 std::string filestr(buff);
235 if (
file.size() == 0) {
237 } else {
239 Sample3RMSFile[Ros - 1][Drawer] = fopen(
file.c_str(),
"r");
240 }
241 if (Sample3RMSFile[Ros - 1][Drawer] == NULL) {
243 return StatusCode::FAILURE;
244 }
245
247 FILE* rms_file = Sample3RMSFile[Ros - 1][Drawer];
248
249
250
251
252
253 char* word;
254 const char* TOKENS = { " \t\n" };
255
256 int dima = 48;
257 for (
int line = 0;
line < dima;
line++) {
258 if (fgets(buff, sizeof(buff), rms_file) != NULL) {
260
261 if (*buff == '!' || *buff == '*') continue;
262
263 double pippo;
264 char* saveptr = nullptr;
265 if ((word = strtok_r(buff, TOKENS, &saveptr)) == NULL) pippo = 0;
266 else pippo =
atof(word);
267
270
272 if (Ros < 3) chline = PmtToChannelBarrel[
line] - 1;
273 else chline = PmtToChannelExtendedBarrel[
line] - 1;
274 }
276 }
277 }
278 fclose(rms_file);
279 }
280 }
281
284
287 }
288
289 ATH_MSG_INFO(
"Initialization completed successfully" );
290
291 return StatusCode::SUCCESS;
292}
#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.