51 LOG(info) <<
"Raw file reader init ";
55 std::string inFileName = ic.
options().
get<std::string>(
"raw-file");
56 mInputFile.open(inFileName, std::ios::binary);
57 if (!mInputFile.is_open()) {
58 throw std::invalid_argument(
"Cannot open input file \"" + inFileName +
"\"");
61 auto stop = [
this]() {
62 LOG(info) <<
"stop file reader";
63 this->mInputFile.close();
75 char* outBuffer{
nullptr};
77 int numberOfFrames = 0;
78 LOG(info) <<
"Sleep 1 sec for sync";
83 mInputFile.read((
char*)(&rdh),
sizeof(
RDH));
84 if (mInputFile.fail()) {
92 auto rdhHeaderSize = o2::raw::RDHUtils::getHeaderSize(rdh);
94 if (rdhVersion < 6 || rdhHeaderSize != 64) {
95 LOG(info) <<
"Old or corrupted raw file, abort !";
98 auto frameSize = o2::raw::RDHUtils::getOffsetToNext(rdh);
99 LOG(
debug) <<
"frameSize=" << frameSize;
100 if (frameSize < rdhHeaderSize) {
101 LOG(info) <<
"Wrong Frame size - frameSize too small: " << frameSize;
106 LOG(
debug) <<
"Process page " << numberOfFrames <<
" dim = " << frameSize;
108 outBuffer = (
char*)realloc(outBuffer,
bufSize + frameSize);
109 if (outBuffer ==
nullptr) {
110 LOG(info) <<
"Buffer allocation error. Abort !";
114 memcpy(outBuffer, &rdh, rdhHeaderSize);
115 mInputFile.read(outBuffer + rdhHeaderSize, frameSize - rdhHeaderSize);
116 if (mInputFile.fail()) {
128 mExTimer.
logMes(
"End of file ! Number of frames processed = " +
std::to_string(numberOfFrames));
137 std::vector<o2::framework::InputSpec> inputs;
143 Options{{
"raw-file", VariantType::String,
"", {
"Raw input file name"}},
144 {
"print", VariantType::Bool,
false, {
"verbose output"}}}};
A raw page parser for DPL input.
T get(const char *key) const
void snapshot(const Output &spec, T const &object)
ServiceRegistryRef services()
ConfigParamRegistry const & options()
DataAllocator & outputs()
The data allocator is used to allocate memory for the output data.
ServiceRegistryRef services()
The services registry associated with this processing context.
virtual void stop()
This is invoked on stop.
virtual void endOfStream(EndOfStreamContext &context)
This is invoked whenever we have an EndOfStream event.
void stop()
stop : stops the timer
void elapseMes(std::string const message)
void start()
start : starts the timer
void logMes(std::string const message)
void init(framework::InitContext &ic) final
void run(framework::ProcessingContext &pc) final
Defining PrimaryVertex explicitly as messageable.
@ Me
Only quit this data processor.
std::vector< ConfigParamSpec > Options
std::vector< OutputSpec > Outputs
o2::framework::DataProcessorSpec getReadRawFileSpec(std::string inputSpec="HMP/RAWDATA")
a couple of static helper functions to create timestamp values for CCDB queries or override obsolete ...
std::string to_string(gsl::span< T, Size > span)
static constexpr int getVersion()
get numeric version of the RDH
LOG(info)<< "Compressed in "<< sw.CpuTime()<< " s"