-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathdisplay-channels.cpp
More file actions
68 lines (51 loc) · 2 KB
/
display-channels.cpp
File metadata and controls
68 lines (51 loc) · 2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
#include <pineappl_capi.h>
#include <cstddef>
#include <iomanip>
#include <iostream>
#include <string>
#include <vector>
int main(int argc, char* argv[]) {
std::string filename = "drell-yan-rap-ll.pineappl.lz4";
switch (argc) {
case 2:
filename = argv[1];
case 1:
break;
default:
std::cout << "Usage: " << argv[0] << " [grid]\n";
}
// read the grid from a file
auto* grid = pineappl_grid_read(filename.c_str());
// How many convolutions are there?
auto n_conv = pineappl_grid_convolutions_len(grid);
// extract all channels
auto* channels = pineappl_grid_channels(grid);
// how many channels are there?
auto channel_count = pineappl_channels_count(channels);
for (std::size_t channel = 0; channel != channel_count; ++channel) {
// print channel index
std::cout << std::setw(4) << channel << ' ';
// how many partonic combinations does this channel have?
auto combinations = pineappl_channels_combinations(channels, channel);
std::vector<double> factors(combinations);
std::vector<int> pids(n_conv * combinations);
// read out the channel with index given by `channel`, writing the particle identifiers into
// `pids` and the corresponding factors into `factors`
pineappl_channels_entry(channels, channel, pids.data(), factors.data());
for (std::size_t combination = 0; combination != combinations; ++combination) {
auto factor = factors.at(combination);
auto pida = pids.at(2 * combination + 0);
auto pidb = pids.at(2 * combination + 1);
if (combination != 0) {
std::cout << " + ";
}
// print factor and particle ids
std::cout << factor << " x (" << std::setw(3) << pida << ',' << std::setw(4) << pidb
<< ")";
}
std::cout << '\n';
}
// release memory
pineappl_channels_delete(channels);
pineappl_grid_delete(grid);
}