Project
Loading...
Searching...
No Matches
DigitFileFormat.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 "DigitFileFormat.h"
13#include <fmt/format.h>
14#include <iostream>
15#include <algorithm>
16#include <string>
17#include <stdexcept>
18
19namespace o2::mch::io
20{
21
22std::array<DigitFileFormat, 5> digitFileFormats = {
23 DigitFileFormat{2305844383603244847}, /* v0 */
24 DigitFileFormat{1224998065220435759}, /* v1 */
25 DigitFileFormat{63069292639436591}, /* v2 */
26 DigitFileFormat{1215990797246349103}, /* v3 */
27 DigitFileFormat{1234022787941941039}}; /* v4 */
28
29std::ostream& operator<<(std::ostream& os, const DigitFileFormat& dff)
30{
31 os << fmt::format(
32 "[ file version {} digit version {} size {} "
33 "rof version {} size {} hasRof {} run2ids {} ] formatWord {}",
34 dff.fileVersion,
35 dff.digitVersion,
36 dff.digitSize,
37 dff.rofVersion,
38 dff.rofSize,
39 static_cast<bool>(dff.hasRof),
40 static_cast<bool>(dff.run2ids),
41 dff.format);
42 return os;
43}
44
45bool operator==(const DigitFileFormat& dff1, const DigitFileFormat& dff2)
46{
47 return dff1.format == dff2.format;
48}
49
50bool operator!=(const DigitFileFormat& dff1, const DigitFileFormat& dff2)
51{
52 return !(dff1 == dff2);
53}
54
55/* Read the file format from the stream.
56*
57* Every digit file should start with 8 bytes of format identifier.
58*/
60{
61 uint64_t fileFormat{0};
62 in.read(reinterpret_cast<char*>(&fileFormat), sizeof(uint64_t));
63 if (in.gcount() < sizeof(DigitFileFormat)) {
64 throw std::ios_base::failure("could not get a valid digit file format in this stream (too short)");
65 }
66 DigitFileFormat df{fileFormat};
67 if (!isValid(df)) {
68 throw std::ios_base::failure("could not get a valid digit file format in this stream");
69 }
70 return df;
71}
72
74{
75 auto exists = std::find(digitFileFormats.begin(),
76 digitFileFormats.end(), dff);
77 return exists != digitFileFormats.end();
78}
79} // namespace o2::mch::io
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 Show standalone event Run event generator maximum time bin of continuous for triggered for automatic continuous for automatic continuous triggered uint64_t
std::array< DigitFileFormat, 5 > digitFileFormats
DigitFileFormat readDigitFileFormat(std::istream &in)
bool operator!=(const observer_ptr< W1 > &p1, const observer_ptr< W2 > &p2)
std::ostream & operator<<(std::ostream &stream, o2::InteractionRecord const &ir)
bool operator==(const observer_ptr< W1 > &p1, const observer_ptr< W2 > &p2)
bool isValid(std::string alias)