132 for (
int i = 0; i < 2; i++)
133 for (
int j = 0; j < 32; j++)
134 for (
int k = 0; k < 5482; k++)
140 std::string filename =
"/afs/cern.ch/user/i/idcalib/w0/TRT_Calibration/tmp/Tier0/StrawStatusCode/TRT_StrawStatus_ExcludedStraws_2023.txt";
142 FILE *f = fopen(filename.c_str(),
"r");
145 std::cout <<
"TRT_StrawStatusReport::initializePermanentlyDead() ERROR: failed to open the input file " << filename << std::endl;
146 std::cout <<
"TRT_StrawStatusReport::initializePermanentlyDead() ERROR: you need to fix the file name / link, WILL CRASH THE CODE NOW" << std::endl;
149 while (fscanf(f,
"%d %d %d %d %d %d\n", tmp, tmp + 1, tmp + 2, tmp + 3, tmp + 4, tmp + 5) == 6)
152 strawMap map(tmp[0], tmp[1], tmp[4], tmp[3], tmp[2]);
156 deadStraws[(tmp[0] > 0) ? 0 : 1][tmp[1]][map.straw()] = tmp[5];
160 std::cout <<
"read " <<
count <<
" permanently excluded straws from file " << filename << std::endl;
170 std::cout <<
"simpleAnalysis: reading file " << filename << std::endl;
171 FILE *f = fopen(filename.c_str(),
"r");
173 int countlines(0), nevents(0), tmp[9];
175 while (fscanf(f,
"%d %d %d %d %d %d %d %d %d\n", tmp, tmp + 1, tmp + 2, tmp + 3, tmp + 4, tmp + 5, tmp + 6, tmp + 7, tmp + 8) == 9)
178 if (tmp[0] == 0 && tmp[1] == 0 && tmp[2] == 0 && tmp[3] == 0 && tmp[4] == 0 && tmp[5] == 0 && tmp[6] == 0 && tmp[7] == 0)
183 if (nevents == 0)
continue;
186 double occupancy = 1. * tmp[3] / nevents;
187 double HToccupancy = 1. * tmp[5] / nevents;
188 double efficiency = (tmp[4] + tmp[7] > 0) ? (1. * tmp[4] / (tmp[4] + tmp[7])) : 0.;
197 if (HToccupancy > 0.5 )
skip = 51;
198 if (HToccupancy < 0.0001)
skip = 52;
200 if (occupancy > 0.99 )
skip = 11;
202 if (tmp[3] == 0 )
skip = 12;
205 if (
deadStraws[(tmp[0] > 0) ? 0 : 1][tmp[1]][tmp[2]] == 1)
219 std::cout <<
"read ONE straw permanently masked is ALIVE!!! " << tmp[0] <<
", " << tmp[1] <<
", " << tmp[2] <<
", hits: " << tmp[3] <<
", occ: " << occupancy <<
", eff: " <<
efficiency << std::endl;
226 std::cout <<
"read " << countlines <<
" lines from file " << filename <<
", N events: " << nevents << std::endl;
240 int countDeadStraws[] = {0, 0};
241 int breakDownOfDeadStraws[100][2];
242 for (
int i = 0; i < 100; i++)
243 for (
int j = 0; j < 2; j++)
244 breakDownOfDeadStraws[i][j] = 0;
246 std::string filename =
"output/athenaFormat_runDependentInactiveStraws_run" + std::to_string(
run) +
".txt";
247 std::cout << filename << endl;
248 FILE *
fout = fopen(filename.c_str(),
"w");
251 for (
int i = 0; i < 2; i++)
253 for (
int j = 0; j < 32; j++)
255 for (
int k = 0; k < 5482; k++)
260 int side = (i != 0 ? -1 : 1);
272 fprintf(
fout,
"%2d %2d %2d %2d %2d %2d\n", side, j, map.strawWithinLayer(), map.strawLayer(), map.layer(), 1);
279 fprintf(
fout,
"%2d %2d %2d %2d %2d %2d\n", side, j, map.strawWithinLayer(), map.strawLayer(), map.layer(), 1);
285 breakDownOfDeadStraws[
deadStraws[i][j][k]][(k < 1642) ? 0 : 1]++;
287 countDeadStraws[(fabs(side) == 1) ? 0 : 1]++;
294 printf(
"found %d newly dead straws compared to %s \n",
count, filename.c_str());
295 printf(
"N dead straws in TRT barrel: %4d or %4.1lf%%\n", countDeadStraws[0], (100. * countDeadStraws[0]) / (64. * 1642));
296 printf(
"N dead straws in TRT end-caps: %4d or %4.1lf%%\n", countDeadStraws[1], (100. * countDeadStraws[1]) / (64. * 20 * 192));
297 printf(
"overall: %4.2lf%%\n", 100. *
count / 350848.);
301 std::cout <<
"criteria barrel end-cap" << std::endl;
302 for (
int i = 2; i < 100; i++)
303 if (breakDownOfDeadStraws[i][0] + breakDownOfDeadStraws[i][1])
304 printf(
"%2d %4d %4d\n", i, breakDownOfDeadStraws[i][0], breakDownOfDeadStraws[i][1]);
317 std::string filename =
"output/athenaFormat_DeadBoards_run" + std::to_string(
run) +
".txt";
318 std::cout << filename << endl;
319 FILE *
fout = fopen(filename.c_str(),
"w");
322 for (
int i = 0; i < 2; i++)
324 for (
int j = 0; j < 32; j++)
326 std::vector<int> allStrawsOnBoard[29];
327 std::vector<int> deadStrawsOnBoard[29];
328 std::vector<int> newDeadStrawsOnBoard[29];
330 for (
int k = 0; k < 5482; k++)
332 int side = (i != 0 ? -1 : 1);
337 int board = map.TTCgroup();
343 if (board <0)
continue;
344 allStrawsOnBoard[board].push_back(k);
346 deadStrawsOnBoard[board].push_back(k);
348 newDeadStrawsOnBoard[board].push_back(k);
351 for (
int board = 0; board < 29; ++board)
353 if (allStrawsOnBoard[board].size() == deadStrawsOnBoard[board].size())
357 for (
unsigned int it = 0; it < deadStrawsOnBoard[board].size(); it++)
359 int k = deadStrawsOnBoard[board].at(it);
360 int side = (i != 0 ? -1 : 1);
364 fprintf(
fout,
"%2d %2d %2d %2d %2d %2d\n", side, j, map.strawWithinLayer(), map.strawLayer(), map.layer(), 1);
368 if (allStrawsOnBoard[board].size() == newDeadStrawsOnBoard[board].size())
371 int side = (i != 0 ? -1 : 1);
372 std::cout <<
"found a new dead board!!! " << std::endl;
373 std::cout <<
"See TRT_StrawMap.h for board ID info " << std::endl;
374 std::cout <<
"side: " << side <<
", phi: " << j <<
", board ID: " << board << std::endl
389 FILE *f = fopen(filename.c_str(),
"r");
391 int count(0), nevents(0), tmp[9];
392 FILE *
fout = fopen(
"TRT_StrawStatusReport.txt",
"w");
394 printf (
"Cannot open output file");
397 fprintf(
fout,
"%d %d %d %d %d %lf %lf %lf %2d\n", 0, 0, 0, 0,
run, 0., 0., 0., 0);
399 while (fscanf(f,
"%d %d %d %d %d %d %d %d %d\n", tmp, tmp + 1, tmp + 2, tmp + 3, tmp + 4, tmp + 5, tmp + 6, tmp + 7, tmp + 8) == 9)
402 if (tmp[0] == 0 && tmp[1] == 0 && tmp[2] == 0 && tmp[3] == 0 && tmp[4] == 0 && tmp[5] == 0 && tmp[6] == 0 && tmp[7] == 0)
407 if (nevents == 0)
continue;
410 double occupancy = 1. * tmp[3] / nevents;
411 double HToccupancy = 1. * tmp[5] / nevents;
412 double efficiency = (tmp[4] + tmp[7] > 0) ? (1. * tmp[4] / (tmp[4] + tmp[7])) : 0.;
414 int side = int(tmp[0]);
419 fprintf(
fout,
"%d %d %d %d %d %lf %lf %lf %2d\n", tmp[0], tmp[1], tmp[2],
deadStraws[(tmp[0] > 0) ? 0 : 1][tmp[1]][tmp[2]], tmp[4], occupancy, HToccupancy,
efficiency, map.layer());
422 std::cout <<
"reportResults: read " <<
count <<
" lines from file " << filename <<
", wrote to TRT_StrawStatusReport.txt" << std::endl;
void efficiency(std::vector< double > &bins, std::vector< double > &values, const std::vector< std::string > &files, const std::string &histname, const std::string &tplotname, const std::string &label="")