ATLAS Offline Software
InnerDetector
InDetCalibAlgs
TRT_CalibAlgs
scripts
TRTCalib_StrawStatus_merge.cxx
Go to the documentation of this file.
1
/*
2
Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
3
*/
4
5
#include "
CxxUtils/checker_macros.h
"
6
ATLAS_NO_CHECK_FILE_THREAD_SAFETY
;
7
8
#include <iostream>
9
#include <iomanip>
10
#include <string>
11
#include <fstream>
12
#include <sstream>
13
#include <map>
14
#include <set>
15
#include <vector>
16
#include <unistd.h>
17
18
using namespace
std;
19
20
int
main
(
int
argc
,
char
*
argv
[])
21
{
22
23
int
nfiles =
argc
- 2;
24
cout <<
" TRT_StrawStatus_merge. nfiles= "
<< nfiles << endl;
25
26
// nBarrelStraws (= 1642) + nEndcapStraws (= 3840) = 5482
27
// 6 index refers to categories of accumulation: last index: 0 - all hits, 1 - hits on track, 2 - all HT (TR) hits, 3 - HT (TR) hits on track
28
// 32 refers to the phi coordinate index
29
int
accumulateHits[32][5482][6];
30
31
int
nevents
= 0;
// we first need to read the first line in each file to get the total number of events
32
for
(
int
irun = 0; irun < nfiles; irun++)
33
{
34
std::string
filename
=
argv
[irun + 2];
35
printf(
"reading file %s \n"
,
filename
.c_str());
// debug printout
36
FILE *
f
= fopen(
filename
.c_str(),
"r"
);
37
if
(
f
==
nullptr
)
38
{
39
fprintf(
stderr
,
" - file %s missing\n"
,
filename
.c_str());
40
exit
(1);
41
}
42
int
tmp
[10];
43
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);
44
nevents
+=
tmp
[8];
45
fclose(
f
);
46
}
47
printf(
"read %d events from %d files\n"
,
nevents
, nfiles);
48
49
FILE *
fout
= fopen(
argv
[1],
"w"
);
// The output merged file.
50
if
(
fout
==
nullptr
)
51
{
52
fprintf(
stderr
,
"could not open file %s for writing, EXIT"
,
argv
[1]);
53
exit
(1);
54
}
55
printf(
"writing to merged file: %s\n"
,
argv
[1]);
56
for
(
int
i
= 0;
i
< 8;
i
++)
57
fprintf(
fout
,
"%d "
, 0);
58
fprintf(
fout
,
"%d\n"
,
nevents
);
// write total number of events in the first line
59
60
for
(
int
side
= 0;
side
< 2;
side
++)
61
{
// merge separately on the two sides
62
63
cout <<
" reset status for all straws on side "
<<
side
* 2 - 1 << endl;
64
for
(
int
j = 0; j < 32; j++)
65
for
(
int
k
= 0;
k
< 5482;
k
++)
66
for
(
int
m
= 0;
m
< 6;
m
++)
67
accumulateHits[j][
k
][
m
] = 0;
68
69
for
(
int
irun = 0; irun < nfiles; irun++)
70
{
// loop again over input files
71
char
filename
[1000];
72
sprintf(
filename
,
"%s"
,
argv
[irun + 2]);
73
FILE *
f
= fopen(
filename
,
"r"
);
74
if
(!
f
)
75
continue
;
76
int
tmp
[10];
77
int
count
(0);
78
// read the first line in this file
79
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);
80
// read the rest of the lines in this file
81
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)
82
{
83
84
if
(
tmp
[0] < 0 &&
side
== 1)
85
continue
;
// only count A side
86
if
(
tmp
[0] > 0 &&
side
== 0)
87
continue
;
// only count C side
88
count
++;
89
90
for
(
int
k
= 0;
k
< 6;
k
++)
91
accumulateHits[
tmp
[1]][
tmp
[2]][
k
] +=
tmp
[3 +
k
];
92
}
93
fclose(
f
);
94
printf(
"read %7d lines from file %s \n"
,
count
,
argv
[irun + 2]);
95
}
// end loop over input files
96
97
// write counts to merged output file
98
for
(
int
j = 0; j < 32; j++)
99
for
(
int
k
= 0;
k
< 5482;
k
++)
100
{
101
int
bec
= 2 *
side
- 1;
102
if
(
k
>= 1642)
103
bec
*= 2;
104
fprintf(
fout
,
"%d %d %d"
,
bec
, j,
k
);
105
for
(
int
m
= 0;
m
< 6;
m
++)
106
fprintf(
fout
,
" %d"
, accumulateHits[j][
k
][
m
]);
107
fprintf(
fout
,
"\n"
);
108
}
109
}
// end loop over the two sides
110
111
fclose(
fout
);
112
printf(
"closed merged file: %s\n"
,
argv
[1]);
113
exit
(0);
114
}
python.SystemOfUnits.m
int m
Definition:
SystemOfUnits.py:91
ParticleGun_SamplingFraction.bec
int bec
Definition:
ParticleGun_SamplingFraction.py:89
main
int main(int argc, char *argv[])
Definition:
TRTCalib_StrawStatus_merge.cxx:20
get_generator_info.stderr
stderr
Definition:
get_generator_info.py:40
XMLtoHeader.count
count
Definition:
XMLtoHeader.py:85
TRT::Hit::side
@ side
Definition:
HitInfo.h:83
lumiFormat.i
int i
Definition:
lumiFormat.py:85
LArCellNtuple.argv
argv
Definition:
LArCellNtuple.py:152
dqt_zlumi_alleff_HIST.fout
fout
Definition:
dqt_zlumi_alleff_HIST.py:59
hist_file_dump.f
f
Definition:
hist_file_dump.py:135
DQHistogramMergeRegExp.argc
argc
Definition:
DQHistogramMergeRegExp.py:20
DeMoUpdate.tmp
string tmp
Definition:
DeMoUpdate.py:1167
calibdata.exit
exit
Definition:
calibdata.py:236
CaloCellTimeCorrFiller.filename
filename
Definition:
CaloCellTimeCorrFiller.py:24
ATLAS_NO_CHECK_FILE_THREAD_SAFETY
ATLAS_NO_CHECK_FILE_THREAD_SAFETY
Definition:
TRTCalib_StrawStatus_merge.cxx:6
LArG4GenerateShowerLib.nevents
nevents
Definition:
LArG4GenerateShowerLib.py:19
checker_macros.h
Define macros for attributes used to control the static checker.
fitman.k
k
Definition:
fitman.py:528
Generated on Wed Jan 8 2025 21:20:45 for ATLAS Offline Software by
1.8.18