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 };
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 };
66 FILE* AlphaMatrixFile[4][64]{};
70 for (
int Ros = 1; Ros < 5; ++Ros) {
71 for (
int Drawer = 0; Drawer < 64; ++Drawer) {
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");
79 std::string filestr(buff);
84 if (
file.size() == 0) {
88 AlphaMatrixFile[Ros - 1][Drawer] = fopen(
file.c_str(),
"r");
90 if (AlphaMatrixFile[Ros - 1][Drawer] == NULL) {
92 return StatusCode::FAILURE;
95 FILE* alpha_file = AlphaMatrixFile[Ros - 1][Drawer];
100 const char* TOKENS = {
" \t\n" };
103 char* saveptr =
nullptr;
104 for (
int line = 0; line < dima; line++) {
105 if (fgets(buff,
sizeof(buff), alpha_file) != NULL) {
107 for (
int column = 0; column < dima; column++) {
109 if (*buff ==
'!' || *buff ==
'*')
continue;
112 if (
const char* word = strtok_r(column==0 ? buff :
nullptr, TOKENS, &saveptr))
119 int chcolumn = column;
123 chline = PmtToChannelBarrel[line] - 1;
124 chcolumn = PmtToChannelBarrel[column] - 1;
126 chline = PmtToChannelExtendedBarrel[line] - 1;
127 chcolumn = PmtToChannelExtendedBarrel[column] - 1;
141 FILE* MeanFile[4][64];
143 for (
int Ros = 1; Ros < 5; ++Ros) {
144 for (
int Drawer = 0; Drawer < 64; ++Drawer) {
147 sprintf(Rosstr,
"LBA");
149 sprintf(Rosstr,
"LBC");
151 sprintf(Rosstr,
"EBA");
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) {
161 MeanFile[Ros - 1][Drawer] = fopen(
file.c_str(),
"r");
163 if (MeanFile[Ros - 1][Drawer] == NULL) {
165 return StatusCode::FAILURE;
169 FILE* mean_file = MeanFile[Ros - 1][Drawer];
175 const char* TOKENS = {
" \t\n" };
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++) {
184 if (*buff ==
'!' || *buff ==
'*')
continue;
187 if (
const char* word = strtok_r(Sample==0 ? buff :
nullptr, TOKENS, &saveptr))
196 if (Ros < 3) chline = PmtToChannelBarrel[line] - 1;
197 else chline = PmtToChannelExtendedBarrel[line] - 1;
209 for (
int Ros = 1; Ros < 5; ++Ros) {
210 for (
int Drawer = 0; Drawer < 64; ++Drawer) {
211 for (
int Channel = 0; Channel < 48; ++Channel) {
212 for (
int Sample = 0; Sample < nSamples; ++Sample) {
222 FILE* Sample3RMSFile[4][64];
224 for (
int Ros = 1; Ros < 5; ++Ros) {
225 for (
int Drawer = 0; Drawer < 64; ++Drawer) {
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");
233 std::string filestr(buff);
235 if (
file.size() == 0) {
239 Sample3RMSFile[Ros - 1][Drawer] = fopen(
file.c_str(),
"r");
241 if (Sample3RMSFile[Ros - 1][Drawer] == NULL) {
243 return StatusCode::FAILURE;
247 FILE* rms_file = Sample3RMSFile[Ros - 1][Drawer];
254 const char* TOKENS = {
" \t\n" };
257 for (
int line = 0; line < dima; line++) {
258 if (fgets(buff,
sizeof(buff), rms_file) != NULL) {
261 if (*buff ==
'!' || *buff ==
'*')
continue;
264 char* saveptr =
nullptr;
265 if ((word = strtok_r(buff, TOKENS, &saveptr)) == NULL) pippo = 0;
266 else pippo = atof(word);
272 if (Ros < 3) chline = PmtToChannelBarrel[line] - 1;
273 else chline = PmtToChannelExtendedBarrel[line] - 1;
289 ATH_MSG_INFO(
"Initialization completed successfully" );
291 return StatusCode::SUCCESS;
298 const EventContext &ctx = Gaudi::Hive::currentContext();
312 SelectAllObject<TileDigitsContainer>::const_iterator digItr = selAll.
begin();
313 SelectAllObject<TileDigitsContainer>::const_iterator lastDig = selAll.
end();
316 for (; digItr != lastDig; ++digItr) {
318 int Ros = tileHWID->
ros(adc_HWID);
319 int Drawer = tileHWID->
drawer(adc_HWID);
320 int Channel = tileHWID->
channel(adc_HWID);
321 OriginalDigits[Ros - 1][Drawer][Channel] = (*digItr);
326 int adc = tileHWID->
adc(adc_HWID);
329 for (
int Sample = 0; Sample < nSamples; ++Sample) {
336 const int nSamples = 7;
338 float NewSamples[4][64][48][nSamples];
340 auto a = std::make_unique<Arrays>();
341 for (
int Ros = 1; Ros < 5; ++Ros) {
342 for (
int Drawer = 0; Drawer < 64; ++Drawer) {
343 for (
int Channel = 0; Channel < 48; ++Channel) {
344 for (
int Sample = 0; Sample < nSamples; ++Sample) {
345 a->NewSamples[Ros - 1][Drawer][Channel][Sample] =
346 ((OriginalDigits[Ros - 1][Drawer][Channel])->samples())[Sample];
353 for (
int Ros = 1; Ros < 5; ++Ros) {
354 for (
int Drawer = 0; Drawer < 64; ++Drawer) {
355 for (
int Channel = 0; Channel < 48; ++Channel) {
356 if (OriginalDigits[Ros - 1][Drawer][Channel]) {
357 int nSamples = (OriginalDigits[Ros - 1][Drawer][Channel])->nsamples();
358 std::vector<float> digits(nSamples);
359 for (
int jCh = 0; jCh < 48; ++jCh) {
360 if (OriginalDigits[Ros - 1][Drawer][jCh]) {
362 && fabs(((OriginalDigits[Ros - 1][Drawer][jCh])->samples())[3]
366 for (
int Sample = 0; Sample < nSamples; ++Sample)
367 a->NewSamples[Ros - 1][Drawer][Channel][Sample] =
368 a->NewSamples[Ros - 1][Drawer][Channel][Sample]
370 * (((OriginalDigits[Ros - 1][Drawer][jCh])->samples())[Sample]
382 auto outputDigitsContainer = std::make_unique<TileMutableDigitsContainer>();
383 ATH_CHECK( outputDigitsContainer->status() );
386 for (
int Ros = 1; Ros < 5; ++Ros) {
387 for (
int Drawer = 0; Drawer < 64; ++Drawer) {
388 for (
int Channel = 0; Channel < 48; ++Channel) {
389 if (OriginalDigits[Ros - 1][Drawer][Channel]) {
390 int nSamples = (OriginalDigits[Ros - 1][Drawer][Channel])->nsamples();
391 std::vector<float> digits(nSamples);
392 for (
int Sample = 0; Sample < nSamples; ++Sample) {
393 digits[Sample] =
a->NewSamples[Ros - 1][Drawer][Channel][Sample];
396 (OriginalDigits[Ros - 1][Drawer][Channel])->adc_HWID(), digits);
397 ATH_CHECK( outputDigitsContainer->push_back(NewDigits) );
409 return StatusCode::SUCCESS;