rest-for-physics / rest-for-physics/rawlib
Implementation of common TRestRawToSignalProcesss::FRead
Open
@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
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.