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;
105 if (fgets(
buff,
sizeof(
buff), alpha_file) != NULL) {
109 if (*
buff ==
'!' || *
buff ==
'*')
continue;
112 if (
const char* word = strtok_r(
column==0 ?
buff :
nullptr, TOKENS, &saveptr))
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");
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;
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) {
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" };
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();
316 for (; digItr != lastDig; ++digItr) {
318 int Ros = tileHWID->
ros(adc_HWID);
319 int Drawer = tileHWID->
drawer(adc_HWID);
321 OriginalDigits[Ros - 1][Drawer][
Channel] = (*digItr);
326 int adc = tileHWID->
adc(adc_HWID);
329 for (
int Sample = 0; Sample <
nSamples; ++Sample) {
337 float NewSamples[4][64][48][
nSamples];
338 for (
int Ros = 1; Ros < 5; ++Ros) {
339 for (
int Drawer = 0; Drawer < 64; ++Drawer) {
341 for (
int Sample = 0; Sample <
nSamples; ++Sample) {
342 NewSamples[Ros - 1][Drawer][
Channel][Sample] =
343 ((OriginalDigits[Ros - 1][Drawer][
Channel])->samples())[Sample];
350 for (
int Ros = 1; Ros < 5; ++Ros) {
351 for (
int Drawer = 0; Drawer < 64; ++Drawer) {
353 if (OriginalDigits[Ros - 1][Drawer][
Channel]) {
355 std::vector<float> digits(
nSamples);
356 for (
int jCh = 0; jCh < 48; ++jCh) {
357 if (OriginalDigits[Ros - 1][Drawer][jCh]) {
359 && fabs(((OriginalDigits[Ros - 1][Drawer][jCh])->samples())[3]
363 for (
int Sample = 0; Sample <
nSamples; ++Sample)
364 NewSamples[Ros - 1][Drawer][
Channel][Sample] =
365 NewSamples[Ros - 1][Drawer][
Channel][Sample]
367 * (((OriginalDigits[Ros - 1][Drawer][jCh])->samples())[Sample]
380 auto outputDigitsContainer = std::make_unique<TileMutableDigitsContainer>();
381 ATH_CHECK( outputDigitsContainer->status() );
384 for (
int Ros = 1; Ros < 5; ++Ros) {
385 for (
int Drawer = 0; Drawer < 64; ++Drawer) {
387 if (OriginalDigits[Ros - 1][Drawer][
Channel]) {
389 std::vector<float> digits(
nSamples);
390 for (
int Sample = 0; Sample <
nSamples; ++Sample) {
391 digits[Sample] = NewSamples[Ros - 1][Drawer][
Channel][Sample];
394 (OriginalDigits[Ros - 1][Drawer][
Channel])->adc_HWID(), digits);
395 ATH_CHECK( outputDigitsContainer->push_back(NewDigits[Ros - 1][Drawer][
Channel]) );
407 return StatusCode::SUCCESS;
416 return StatusCode::SUCCESS;