18 const static unsigned int ttdc = 1414808643;
19 const static unsigned int taes = 1413563731;
25 static bool const is_a_tty = isatty(1);
32 ioctl(1, TIOCGWINSZ, &sz);
44 inline std::ostream&
operator <<(std::ostream& stream,
const hit_t& hit)
46 return stream <<
"C: "
47 << std::setfill(
' ') << std::setw(2)
48 << (
unsigned int) hit.channel
51 << std::setfill(
' ') << std::setw(6)
52 << ntohl(hit.timestamp)
55 << std::setfill(
' ') << std::setw(6)
56 << (
unsigned int) hit.ToT;
63 std::cout <<
"InfoWord: yes\n"
64 << *static_cast<const InfoWord* const>(static_cast<const void* const>(
70 std::cout <<
"InfoWord: no\n";
78 for (
unsigned i = 0; i < nhits; ++i) {
79 if (hits[i].channel < 0 || hits[i].channel > 30) {
82 ++summary[hits[i].channel];
88 for (
unsigned i = 0; i < summary.size(); ++i) {
89 std::cout <<
"CH" << std::setfill(
'0') << std::setw(2) << i
90 <<
": " << std::setfill(
' ') << std::setw(4) << summary[i] <<
' ';
92 if ((i + 1) %
n == 0) {
100 std::cout <<
"wrong channels: " << wrong <<
'\n';
106 const unsigned int nhits =
buffer_size /
sizeof(hit_t);
108 std::cout <<
"Number of hits: " << nhits <<
'\n';
110 const hit_t*
const hits = static_cast<const hit_t* const>(
111 static_cast<const void* const>(buffer)
115 const int printing = 20 > nhits ? nhits : 20;
118 for (
int i = 0; i < printing; ++i)
121 << std::setfill(
'0') << std::setw(2)
126 if ((i + 1) %
n == 0)
149 stream.read((
char*) &header,
sizeof(header));
151 if (stream.gcount() !=
sizeof(header))
156 std::cout <<
"Counter: " << ++count <<
'\n';
159 assert(header.FrameLength -
sizeof(header) >= 0 &&
"Wrong frame length.");
161 std::size_t
const payload_size = header.FrameLength -
sizeof(header);
163 if (payload.capacity() < payload_size)
165 payload.resize(payload_size);
168 stream.read((
char*) payload.data(), payload_size);
170 if (static_cast<std::size_t>(stream.gcount()) != payload_size)
175 if (header.DataType ==
ttdc) {
177 }
else if (header.DataType ==
taes) {
180 std::cout <<
"Unknown data type\n";
187 int main(
int argc,
char* argv[])
191 if (strcmp(argv[1],
"-h") == 0)
193 std::cout <<
"Usage: " << argv[0] <<
" [-h] [filename]\n"
195 <<
"-h shows this help\n"
196 <<
"filename: if specified reads from file, otherwise stdin is used\n";
213 std::ifstream input_file(argv[1], std::ios::binary);