127 for (
int i = 0; i < 2; i++)
128 for (
int j = 0; j < 32; j++)
129 for (
int k = 0; k < 5482; k++)
135 std::string filename =
"/afs/cern.ch/user/i/idcalib/w0/TRT_Calibration/tmp/Tier0/StrawStatusCode/TRT_StrawStatus_ExcludedStraws_2023.txt";
137 FILE *f = fopen(filename.c_str(),
"r");
140 std::cout <<
"TRT_StrawStatusReport::initializePermanentlyDead() ERROR: failed to open the input file " << filename << std::endl;
141 std::cout <<
"TRT_StrawStatusReport::initializePermanentlyDead() ERROR: you need to fix the file name / link, WILL CRASH THE CODE NOW" << std::endl;
144 while (fscanf(f,
"%d %d %d %d %d %d\n", tmp, tmp + 1, tmp + 2, tmp + 3, tmp + 4, tmp + 5) == 6)
147 strawMap map(tmp[0], tmp[1], tmp[4], tmp[3], tmp[2]);
151 deadStraws[(tmp[0] > 0) ? 0 : 1][tmp[1]][map.straw()] = tmp[5];
155 std::cout <<
"read " <<
count <<
" permanently excluded straws from file " << filename << std::endl;
165 std::cout <<
"simpleAnalysis: reading file " << filename << std::endl;
166 FILE *f = fopen(filename.c_str(),
"r");
168 int countlines(0), nevents(0), tmp[9];
170 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)
173 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)
178 if (nevents == 0)
continue;
181 double occupancy = 1. * tmp[3] / nevents;
182 double HToccupancy = 1. * tmp[5] / nevents;
183 double efficiency = (tmp[4] + tmp[7] > 0) ? (1. * tmp[4] / (tmp[4] + tmp[7])) : 0.;
192 if (HToccupancy > 0.5 )
skip = 51;
193 if (HToccupancy < 0.0001)
skip = 52;
195 if (occupancy > 0.99 )
skip = 11;
197 if (tmp[3] == 0 )
skip = 12;
200 if (
deadStraws[(tmp[0] > 0) ? 0 : 1][tmp[1]][tmp[2]] == 1)
214 std::cout <<
"read ONE straw permanently masked is ALIVE!!! " << tmp[0] <<
", " << tmp[1] <<
", " << tmp[2] <<
", hits: " << tmp[3] <<
", occ: " << occupancy <<
", eff: " <<
efficiency << std::endl;
221 std::cout <<
"read " << countlines <<
" lines from file " << filename <<
", N events: " << nevents << std::endl;
235 int countDeadStraws[] = {0, 0};
236 int breakDownOfDeadStraws[100][2];
237 for (
int i = 0; i < 100; i++)
238 for (
int j = 0; j < 2; j++)
239 breakDownOfDeadStraws[i][j] = 0;
241 std::string filename =
"output/athenaFormat_runDependentInactiveStraws_run" + std::to_string(
run) +
".txt";
242 std::cout << filename << endl;
243 FILE *
fout = fopen(filename.c_str(),
"w");
246 for (
int i = 0; i < 2; i++)
248 for (
int j = 0; j < 32; j++)
250 for (
int k = 0; k < 5482; k++)
255 int side = (i != 0 ? -1 : 1);
267 fprintf(
fout,
"%2d %2d %2d %2d %2d %2d\n", side, j, map.strawWithinLayer(), map.strawLayer(), map.layer(), 1);
274 fprintf(
fout,
"%2d %2d %2d %2d %2d %2d\n", side, j, map.strawWithinLayer(), map.strawLayer(), map.layer(), 1);
280 breakDownOfDeadStraws[
deadStraws[i][j][k]][(k < 1642) ? 0 : 1]++;
282 countDeadStraws[(fabs(side) == 1) ? 0 : 1]++;
289 printf(
"found %d newly dead straws compared to %s \n",
count, filename.c_str());
290 printf(
"N dead straws in TRT barrel: %4d or %4.1lf%%\n", countDeadStraws[0], (100. * countDeadStraws[0]) / (64. * 1642));
291 printf(
"N dead straws in TRT end-caps: %4d or %4.1lf%%\n", countDeadStraws[1], (100. * countDeadStraws[1]) / (64. * 20 * 192));
292 printf(
"overall: %4.2lf%%\n", 100. *
count / 350848.);
296 std::cout <<
"criteria barrel end-cap" << std::endl;
297 for (
int i = 2; i < 100; i++)
298 if (breakDownOfDeadStraws[i][0] + breakDownOfDeadStraws[i][1])
299 printf(
"%2d %4d %4d\n", i, breakDownOfDeadStraws[i][0], breakDownOfDeadStraws[i][1]);
312 std::string filename =
"output/athenaFormat_DeadBoards_run" + std::to_string(
run) +
".txt";
313 std::cout << filename << endl;
314 FILE *
fout = fopen(filename.c_str(),
"w");
317 for (
int i = 0; i < 2; i++)
319 for (
int j = 0; j < 32; j++)
321 std::vector<int> allStrawsOnBoard[29];
322 std::vector<int> deadStrawsOnBoard[29];
323 std::vector<int> newDeadStrawsOnBoard[29];
325 for (
int k = 0; k < 5482; k++)
327 int side = (i != 0 ? -1 : 1);
332 int board = map.TTCgroup();
338 if (board <0)
continue;
339 allStrawsOnBoard[board].push_back(k);
341 deadStrawsOnBoard[board].push_back(k);
343 newDeadStrawsOnBoard[board].push_back(k);
346 for (
int board = 0; board < 29; ++board)
348 if (allStrawsOnBoard[board].size() == deadStrawsOnBoard[board].size())
352 for (
unsigned int it = 0; it < deadStrawsOnBoard[board].size(); it++)
354 int k = deadStrawsOnBoard[board].at(it);
355 int side = (i != 0 ? -1 : 1);
359 fprintf(
fout,
"%2d %2d %2d %2d %2d %2d\n", side, j, map.strawWithinLayer(), map.strawLayer(), map.layer(), 1);
363 if (allStrawsOnBoard[board].size() == newDeadStrawsOnBoard[board].size())
366 int side = (i != 0 ? -1 : 1);
367 std::cout <<
"found a new dead board!!! " << std::endl;
368 std::cout <<
"See TRT_StrawMap.h for board ID info " << std::endl;
369 std::cout <<
"side: " << side <<
", phi: " << j <<
", board ID: " << board << std::endl
384 FILE *f = fopen(filename.c_str(),
"r");
386 int count(0), nevents(0), tmp[9];
387 FILE *
fout = fopen(
"TRT_StrawStatusReport.txt",
"w");
389 printf (
"Cannot open output file");
392 fprintf(
fout,
"%d %d %d %d %d %lf %lf %lf %2d\n", 0, 0, 0, 0,
run, 0., 0., 0., 0);
394 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)
397 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)
402 if (nevents == 0)
continue;
405 double occupancy = 1. * tmp[3] / nevents;
406 double HToccupancy = 1. * tmp[5] / nevents;
407 double efficiency = (tmp[4] + tmp[7] > 0) ? (1. * tmp[4] / (tmp[4] + tmp[7])) : 0.;
409 int side = int(tmp[0]);
414 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());
417 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="")