rest-for-physics / rest-for-physics/rawlib

Implementation of common TRestRawToSignalProcesss::FRead

Open
#108 2 comments 0 reactions 2 assignees View on GitHub

@juanangp is already working on this.

Since May 23, 2023.

enhancement
Dominant language
C++
Stars
2
Forks
4
PR merge metrics
No merged PRs in 30d

Description

We could perhaps simplify the code of external to raw signal processes if we introduce a template method inside TRestRawToSignalProcess::FRead.

Each time we read, it is required to increase the variable totalBytesRead. This could also be encapsulated in the base class. And probably totalBytesReaded could be made private.

For example:

    char buffer[CTAG_SZ];
    if (fread(buffer, sizeof(char), CTAG_SZ, fInputBinFile) != CTAG_SZ) {
        printf("Error: could not read first ACQ prefix.\n");
        exit(1);
    }
    totalBytesReaded += CTAG_SZ * sizeof(char);

could be replaced by:

char buffer[CTAG_SZ];
FRead( buffer, sizeof(char), CTAG_SZ);

For example:

    if (fread(&tmp, sizeof(int32_t), 1, fInputBinFile) != 1) {
        printf("Error: could not read timestamp.\n");
        exit(1);
    }
    totalBytesReaded += sizeof(int32_t);

could be replaced by:

int32_t tmp;
FRead( tmp, sizeof(int32_t), 1);

or even

int32_t tmp;
FReadOne( tmp, sizeof(int32_t));

or

tmp = FRead<int32_t>();

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.