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 };
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 };
65 FILE* AlphaMatrixFile[4][64]{};
69 for (
int Ros = 1; Ros < 5; ++Ros) {
70 for (
int Drawer = 0; Drawer < 64; ++Drawer) {
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");
78 std::string filestr(buff);
83 if (
file.size() == 0) {
87 AlphaMatrixFile[Ros - 1][Drawer] = fopen(
file.c_str(),
"r");
89 if (AlphaMatrixFile[Ros - 1][Drawer] == NULL) {
91 return StatusCode::FAILURE;
94 FILE* alpha_file = AlphaMatrixFile[Ros - 1][Drawer];
99 const char* TOKENS = {
" \t\n" };
102 char* saveptr =
nullptr;
103 for (
int line = 0; line < dima; line++) {
104 if (fgets(buff,
sizeof(buff), alpha_file) != NULL) {
106 for (
int column = 0; column < dima; column++) {
108 if (*buff ==
'!' || *buff ==
'*')
continue;
111 if (
const char* word = strtok_r(column==0 ? buff :
nullptr, TOKENS, &saveptr))
118 int chcolumn = column;
122 chline = PmtToChannelBarrel[line] - 1;
123 chcolumn = PmtToChannelBarrel[column] - 1;
125 chline = PmtToChannelExtendedBarrel[line] - 1;
126 chcolumn = PmtToChannelExtendedBarrel[column] - 1;
140 FILE* MeanFile[4][64];
142 for (
int Ros = 1; Ros < 5; ++Ros) {
143 for (
int Drawer = 0; Drawer < 64; ++Drawer) {
146 sprintf(Rosstr,
"LBA");
148 sprintf(Rosstr,
"LBC");
150 sprintf(Rosstr,
"EBA");
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) {
160 MeanFile[Ros - 1][Drawer] = fopen(
file.c_str(),
"r");
162 if (MeanFile[Ros - 1][Drawer] == NULL) {
164 return StatusCode::FAILURE;
168 FILE* mean_file = MeanFile[Ros - 1][Drawer];
174 const char* TOKENS = {
" \t\n" };
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++) {
183 if (*buff ==
'!' || *buff ==
'*')
continue;
186 if (
const char* word = strtok_r(Sample==0 ? buff :
nullptr, TOKENS, &saveptr))
195 if (Ros < 3) chline = PmtToChannelBarrel[line] - 1;
196 else chline = PmtToChannelExtendedBarrel[line] - 1;
208 for (
int Ros = 1; Ros < 5; ++Ros) {
209 for (
int Drawer = 0; Drawer < 64; ++Drawer) {
210 for (
int Channel = 0; Channel < 48; ++Channel) {
211 for (
int Sample = 0; Sample < nSamples; ++Sample) {
221 FILE* Sample3RMSFile[4][64];
223 for (
int Ros = 1; Ros < 5; ++Ros) {
224 for (
int Drawer = 0; Drawer < 64; ++Drawer) {
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");
232 std::string filestr(buff);
234 if (
file.size() == 0) {
238 Sample3RMSFile[Ros - 1][Drawer] = fopen(
file.c_str(),
"r");
240 if (Sample3RMSFile[Ros - 1][Drawer] == NULL) {
242 return StatusCode::FAILURE;
246 FILE* rms_file = Sample3RMSFile[Ros - 1][Drawer];
253 const char* TOKENS = {
" \t\n" };
256 for (
int line = 0; line < dima; line++) {
257 if (fgets(buff,
sizeof(buff), rms_file) != NULL) {
260 if (*buff ==
'!' || *buff ==
'*')
continue;
263 char* saveptr =
nullptr;
264 if ((word = strtok_r(buff, TOKENS, &saveptr)) == NULL) pippo = 0;
265 else pippo = atof(word);
271 if (Ros < 3) chline = PmtToChannelBarrel[line] - 1;
272 else chline = PmtToChannelExtendedBarrel[line] - 1;
288 ATH_MSG_INFO(
"Initialization completed successfully" );
290 return StatusCode::SUCCESS;
297 const EventContext &ctx = Gaudi::Hive::currentContext();
311 SelectAllObject<TileDigitsContainer>::const_iterator digItr = selAll.
begin();
312 SelectAllObject<TileDigitsContainer>::const_iterator lastDig = selAll.
end();
315 for (; digItr != lastDig; ++digItr) {
317 int Ros = tileHWID->
ros(adc_HWID);
318 int Drawer = tileHWID->
drawer(adc_HWID);
319 int Channel = tileHWID->
channel(adc_HWID);
320 OriginalDigits[Ros - 1][Drawer][Channel] = (*digItr);
325 int adc = tileHWID->
adc(adc_HWID);
328 for (
int Sample = 0; Sample < nSamples; ++Sample) {
335 const int nSamples = 7;
337 float NewSamples[4][64][48][nSamples];
339 auto a = std::make_unique<Arrays>();
340 for (
int Ros = 1; Ros < 5; ++Ros) {
341 for (
int Drawer = 0; Drawer < 64; ++Drawer) {
342 for (
int Channel = 0; Channel < 48; ++Channel) {
343 for (
int Sample = 0; Sample < nSamples; ++Sample) {
344 a->NewSamples[Ros - 1][Drawer][Channel][Sample] =
345 ((OriginalDigits[Ros - 1][Drawer][Channel])->samples())[Sample];
352 for (
int Ros = 1; Ros < 5; ++Ros) {
353 for (
int Drawer = 0; Drawer < 64; ++Drawer) {
354 for (
int Channel = 0; Channel < 48; ++Channel) {
355 if (OriginalDigits[Ros - 1][Drawer][Channel]) {
356 int nSamples = (OriginalDigits[Ros - 1][Drawer][Channel])->nsamples();
357 std::vector<float> digits(nSamples);
358 for (
int jCh = 0; jCh < 48; ++jCh) {
359 if (OriginalDigits[Ros - 1][Drawer][jCh]) {
361 && fabs(((OriginalDigits[Ros - 1][Drawer][jCh])->samples())[3]
365 for (
int Sample = 0; Sample < nSamples; ++Sample)
366 a->NewSamples[Ros - 1][Drawer][Channel][Sample] =
367 a->NewSamples[Ros - 1][Drawer][Channel][Sample]
369 * (((OriginalDigits[Ros - 1][Drawer][jCh])->samples())[Sample]
381 auto outputDigitsContainer = std::make_unique<TileMutableDigitsContainer>();
382 ATH_CHECK( outputDigitsContainer->status() );
385 for (
int Ros = 1; Ros < 5; ++Ros) {
386 for (
int Drawer = 0; Drawer < 64; ++Drawer) {
387 for (
int Channel = 0; Channel < 48; ++Channel) {
388 if (OriginalDigits[Ros - 1][Drawer][Channel]) {
389 int nSamples = (OriginalDigits[Ros - 1][Drawer][Channel])->nsamples();
390 std::vector<float> digits(nSamples);
391 for (
int Sample = 0; Sample < nSamples; ++Sample) {
392 digits[Sample] =
a->NewSamples[Ros - 1][Drawer][Channel][Sample];
395 (OriginalDigits[Ros - 1][Drawer][Channel])->adc_HWID(), digits);
396 ATH_CHECK( outputDigitsContainer->push_back(NewDigits) );
408 return StatusCode::SUCCESS;