Project
Loading...
Searching...
No Matches
DigitIOV1.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 "DigitIOV1.h"
15#include "DigitD0.h"
16#include "DigitFileFormat.h"
17#include "DigitSampler.h"
18#include "IO.h"
19#include "IOStruct.h"
20#include "ROFRecordR0.h"
21#include <iostream>
22
23namespace o2::mch::io::impl
24{
25void DigitSamplerV1::count(std::istream& in, size_t& ntfs, size_t& nrofs, size_t& ndigits)
26{
27 rewind(in);
28 ndigits = 0;
29 nrofs = 0;
30 ntfs = 0;
31 std::pair<int, int> pairs;
32 std::pair<int, int> invalid{-1, -1};
33
34 while ((pairs = advanceOneEvent(in, 1)) != invalid) {
35 ndigits += pairs.second;
36 nrofs += pairs.first;
37 ++ntfs;
38 }
39 rewind(in);
40}
41
42bool DigitSamplerV1::read(std::istream& in,
43 std::vector<Digit>& digits,
44 std::vector<ROFRecord>& rofs)
45{
46 // note the input vectors are not cleared as this is the responsability
47 // of the calling class, if need be.
48
49 std::vector<ROFRecordR0> rofsr0;
50
51 bool ok = readBinaryStruct(in, rofsr0, "rofs");
52 if (!ok) {
53 return false;
54 }
55 for (auto r0 : rofsr0) {
56 ROFRecord r(r0.ir, r0.ref.getFirstEntry(), r0.ref.getEntries(), 4);
57 rofs.push_back(r);
58 }
59
60 std::vector<DigitD0> digitsd0;
61
62 ok = readBinaryStruct(in, digitsd0, "digits");
63 if (!ok) {
64 return false;
65 }
66
67 for (auto d0 : digitsd0) {
68 Digit d(d0.detID, d0.padID, d0.adc, d0.tfTime, d0.getNofSamples(), d0.isSaturated());
69 digits.push_back(d);
70 }
71 return true;
72}
73
74void DigitSamplerV1::rewind(std::istream& in)
75{
77}
78
79bool DigitSinkV1::write(std::ostream& out,
80 gsl::span<const Digit> digits,
81 gsl::span<const ROFRecord> rofs)
82{
83 if (rofs.empty()) {
84 return false;
85 }
86 std::vector<ROFRecordR0> rofsr0;
87 for (const auto& r : rofs) {
88 rofsr0.push_back(ROFRecordR0{r.getBCData(), {r.getFirstIdx(), r.getNEntries()}});
89 }
90 gsl::span<const ROFRecordR0> r0(rofsr0);
91
92 bool ok = writeBinaryStruct(out, r0);
93
94 std::vector<DigitD0> digitsd0;
95 for (const auto& d : digits) {
96 digitsd0.push_back(DigitD0{d.getTime(), d.getNofSamples(), d.getDetID(), d.getPadID(), d.getADC()});
97 digitsd0.back().setSaturated(d.isSaturated());
98 }
99 gsl::span<const DigitD0> d0(digitsd0);
100 ok &= writeBinaryStruct(out, d0);
101 return ok;
102}
103
104} // namespace o2::mch::io::impl
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
Definition of the MCH ROFrame record.
MCH digit implementation.
Definition Digit.h:31
void count(std::istream &in, size_t &ntfs, size_t &nrofs, size_t &ndigits) override
Definition DigitIOV1.cxx:25
bool read(std::istream &in, std::vector< Digit > &digits, std::vector< ROFRecord > &rofs) override
Definition DigitIOV1.cxx:42
void rewind(std::istream &in)
Definition DigitIOV1.cxx:74
GLboolean r
Definition glcorearb.h:1233
bool readBinaryStruct(std::istream &in, std::vector< T > &items, const char *itemName)
Definition IOStruct.h:35
std::pair< int, int > advanceOneEvent(std::istream &in, int fileFormatVersion)
Definition IO.cxx:48
bool writeBinaryStruct(std::ostream &os, gsl::span< const T > items)
Definition IOStruct.h:23
bool write(std::ostream &out, gsl::span< const Digit > digits, gsl::span< const ROFRecord > rofs) override
Definition DigitIOV1.cxx:79
std::vector< Digit > digits