Project
Loading...
Searching...
No Matches
DigitSampler.cxx
Go to the documentation of this file.
1// Copyright 2019-2020 CERN and copyright holders of ALICE O2.
2// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders.
3// All rights not expressly granted are reserved.
4//
5// This software is distributed under the terms of the GNU General Public
6// License v3 (GPL Version 3), copied verbatim in the file "COPYING".
7//
8// In applying this license CERN does not waive the privileges and immunities
9// granted to it by virtue of its status as an Intergovernmental Organization
10// or submit itself to any jurisdiction.
11
12#include "DigitSampler.h"
13#include <istream>
14#include "DigitFileFormat.h"
15#include <iostream>
18#include <fmt/format.h>
19#include "DigitSamplerImpl.h"
20
21namespace o2::mch::io
22{
23
24DigitSampler::DigitSampler(std::istream& in) : mInput{in}
25{
26 mFileFormat = readDigitFileFormat(mInput);
27 mImpl = impl::createDigitSamplerImpl(mFileFormat.fileVersion);
28}
29
30DigitSampler::~DigitSampler() = default;
31
32bool DigitSampler::read(std::vector<Digit>& digits,
33 std::vector<ROFRecord>& rofs)
34{
35 digits.clear();
36 rofs.clear();
37 bool ok = mImpl->read(mInput, digits, rofs);
38 return ok;
39}
40
41void DigitSampler::rewind()
42{
43 mImpl->rewind(mInput);
44}
45
46void DigitSampler::count() const
47{
48 if (mCountDone) {
49 return;
50 }
51 mImpl->count(mInput, mNofTimeFrames, mNofROFs, mNofDigits);
52 mCountDone = true;
53}
54
55size_t DigitSampler::nofTimeFrames() const
56{
57 count();
58 return mNofTimeFrames;
59}
60
61size_t DigitSampler::nofROFs() const
62{
63 count();
64 return mNofROFs;
65}
66
67size_t DigitSampler::nofDigits() const
68{
69 count();
70 return mNofDigits;
71}
72
73} // namespace o2::mch::io
Definition of the MCH ROFrame record.
GLint GLsizei count
Definition glcorearb.h:399
std::unique_ptr< DigitSamplerImpl > createDigitSamplerImpl(int version)
DigitFileFormat readDigitFileFormat(std::istream &in)
std::vector< Digit > digits