21#include "boost/program_options.hpp"
23#include <fmt/format.h>
29#include <rapidjson/document.h>
30#include <rapidjson/stringbuffer.h>
31#include <rapidjson/writer.h>
65 std::optional<uint16_t>
cruId()
const
73 unsigned int mMaxNofRDHs;
76 std::optional<uint16_t> mCruId{std::nullopt};
89 q += (
v - newMean) * (
v -
mean);
97 os << fmt::format(
"MEAN {:7.3f} RMS {:7.3f} NSAMPLES {:5d} ",
s.mean,
s.rms,
s.n);
103 std::ifstream in(input.c_str(), std::ios::binary);
105 std::cout <<
"could not open file " << input <<
"\n";
108 constexpr size_t pageSize = 8192;
110 std::array<std::byte, pageSize>
buffer;
115 const auto patchPage = [&](gsl::span<std::byte> rdhBuffer) {
116 auto rdhPtr =
const_cast<void*
>(
reinterpret_cast<const void*
>(rdhBuffer.data()));
118 auto cruId = o2::raw::RDHUtils::getCRUID(rdhPtr);
119 if (opt.
cruId().has_value()) {
120 cruId = opt.
cruId().value();
123 auto endpoint = o2::raw::RDHUtils::getEndPointID(rdhPtr);
126 std::cout << nrdhs <<
"--\n";
132 std::map<std::string, int> uniqueDS;
133 std::map<std::string, int> uniqueChannel;
134 std::map<std::string, ChannelStat> statChannel;
138 const auto channelHandler =
142 auto ch = fmt::format(
"{}-CH{}",
s, channel);
144 auto& chanstat =
counters.statChannel[ch];
145 if (sc.isClusterSum()) {
146 chanstat.incr(sc.chargeSum);
148 for (
auto d = 0;
d < sc.nofSamples();
d++) {
149 chanstat.incr(sc.samples[
d]);
160 char* cbuffer =
reinterpret_cast<char*
>(&
buffer[0]);
162 const void* rdhPtr =
reinterpret_cast<const void*
>(&
buffer[0]);
172 auto readSize = o2::raw::RDHUtils::getOffsetToNext(rdhPtr) -
sizeof(
o2::header::RDHAny);
173 in.read(cpayload, readSize);
179 bytesRead += in.gcount();
190 std::cout <<
counters.ndigits <<
" digits seen - " << nrdhs <<
" RDHs seen - " << npages <<
" npages read\n";
191 std::cout <<
"#unique DS=" <<
counters.uniqueDS.size() <<
" #unique Channel=" <<
counters.uniqueChannel.size() <<
"\n";
199 rapidjson::StringBuffer
buffer;
200 rapidjson::Writer<rapidjson::StringBuffer> writer(
buffer);
202 writer.StartObject();
203 writer.Key(
"channels");
206 writer.StartObject();
208 writer.String(
s.first.c_str());
210 writer.Double(
s.second.mean);
212 writer.Double(
s.second.rms);
213 writer.Key(
"nof_samples");
214 writer.Int(
s.second.n);
219 std::cout <<
buffer.GetString() <<
"\n";
222int main(
int argc,
char* argv[])
225 std::vector<int> detElemIds;
226 std::string inputFile;
227 po::variables_map vm;
228 po::options_description
generic(
"Generic options");
229 unsigned int nrdhs{0};
231 bool userLogic{
false};
232 bool chargeSum{
false};
233 bool jsonOutput{
false};
236 generic.add_options()
237 (
"help,h",
"produce help message")
238 (
"input-file,i", po::value<std::string>(&inputFile)->required(),
"input file name")
239 (
"nrdhs,n", po::value<unsigned int>(&nrdhs),
"number of RDHs to go through")
240 (
"showRDHs,s",po::bool_switch(&
showRDHs),
"show RDHs")
241 (
"chargeSum,c",po::bool_switch(&chargeSum),
"charge sum format")
242 (
"json,j",po::bool_switch(&jsonOutput),
"output means and rms in json format")
243 (
"cru",po::value<uint16_t>(),
"force cruId")
247 po::options_description cmdline;
248 cmdline.add(generic);
250 po::store(po::command_line_parser(argc, argv).options(cmdline).run(), vm);
252 if (vm.count(
"help")) {
253 std::cout <<
generic <<
"\n";
259 }
catch (boost::program_options::error&
e) {
260 std::cout <<
"Error: " <<
e.what() <<
"\n";
266 if (vm.count(
"cru")) {
267 opt.
cruId(vm[
"cru"].as<uint16_t>());
270 auto statChannel =
rawdump(inputFile, opt);
unsigned short int uint16_t
Timeframe settings Average distance in cm of events merged into Randomize distance around average distance of merged events Simulate correct bunch interactions instead of placing only the average number of events A value[n] sets TFlen for[n] collisions in Number of bunches per trainsort Number of bunch trains Instantaneous interaction rate Do not simulate border Total number of collisions to be placed in the interior of all time Do not select random but walk over array of events in stride steps h Event generator settings h configStandalone Use CPU for GPU Force usage of the specified GPU device no CPU fallback Continue processing after an error s
Timeframe settings Average distance in cm of events merged into Randomize distance around average distance of merged events Simulate correct bunch interactions instead of placing only the average number of events A value[n] sets TFlen for[n] collisions in Number of bunches per trainsort Number of bunch trains Instantaneous interaction rate Do not simulate border Total number of collisions to be placed in the interior of all time Do not select random but walk over array of events in stride steps h Event generator settings h configStandalone Use CPU for GPU Force usage of the specified GPU device no CPU fallback Continue processing after an error First event to Number of events to Number of iterations to Number of iterations to Number of initial iterations excluded from const char Directory with events to Events directory is and not inside events Show standalone event Run event generator maximum time bin of continuous for triggered for automatic continuous for automatic continuous triggered uint64_t
Timeframe settings Average distance in cm of events merged into Randomize distance around average distance of merged events Simulate correct bunch interactions instead of placing only the average number of events A value[n] sets TFlen for[n] collisions in Number of bunches per trainsort Number of bunch trains Instantaneous interaction rate Do not simulate border Total number of collisions to be placed in the interior of all time Do not select random but walk over array of events in stride steps h Event generator settings h configStandalone Use CPU for GPU Force usage of the specified GPU device no CPU fallback Continue processing after an error First event to Number of events to Number of iterations to Number of iterations to Number of initial iterations excluded from const char e
Timeframe settings Average distance in cm of events merged into Randomize distance around average distance of merged events Simulate correct bunch interactions instead of placing only the average number of events A value[n] sets TFlen for[n] collisions in Number of bunches per trainsort Number of bunch trains Instantaneous interaction rate Do not simulate border Total number of collisions to be placed in the interior of all time Do not select random but walk over array of events in stride steps h Event generator settings h configStandalone Use CPU for GPU Force usage of the specified GPU device no CPU fallback Continue processing after an error First event to Number of events to Number of iterations to Number of iterations to Number of initial iterations excluded from const char Directory with events to Events directory is and not inside events d
std::optional< uint16_t > cruId() const
unsigned int maxNofRDHs() const
DumpOptions(unsigned int maxNofRDHs, bool showRDHs, bool jsonOutput)
GLint GLint GLsizei GLuint * counters
std::function< void(Page buffer)> PageDecoder
PageDecoder createPageDecoder(RawBuffer rdhBuffer, DecodedDataHandlers decodedDataHandlers)
will be called for each decoded Sampa packet and in case of decoding errors
std::string asString(const SampaCluster &sc)
int showRDHs(gsl::span< const std::byte > buffer)
Dump the RDHs found in the buffer.
std::ostream & operator<<(std::ostream &stream, o2::InteractionRecord const &ir)
SampaChannelHandler sampaChannelHandler
Piece of data for one Sampa channel.
static void setLinkID(H &rdh, uint8_t v, NOTPTR(H))
static void printRDH(const RDHv4 &rdh)
static void setFEEID(RDHv4 &rdh, uint16_t v)
coder decode(ctfImage, triggersD, clustersD)
std::vector< ChannelData > channels