Project
Loading...
Searching...
No Matches
CrateMasks.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
16
17#include "MIDRaw/CrateMasks.h"
18
19#include <fstream>
20#include <sstream>
21#include <string>
22#include <algorithm>
23
24namespace o2
25{
26namespace mid
27{
28
29CrateMasks::CrateMasks() : mActiveBoards()
30{
32 for (uint16_t ioffset = 0; ioffset < crateparams::sNGBTs; ioffset += crateparams::sNGBTsPerSide) {
33 // Crate 1
34 mActiveBoards[0 + ioffset] = 0xFF;
35 mActiveBoards[1 + ioffset] = 0xFF;
36
37 // Crate 2
38 mActiveBoards[2 + ioffset] = 0xFF;
39 mActiveBoards[3 + ioffset] = 0x7F;
40
41 // Crate 2-3
42 mActiveBoards[4 + ioffset] = 0x7F;
43 mActiveBoards[5 + ioffset] = 0x7F;
44
45 // Crate 3
46 mActiveBoards[6 + ioffset] = 0xFF;
47 mActiveBoards[7 + ioffset] = 0x7F;
48
49 // Crate 4
50 mActiveBoards[8 + ioffset] = 0xFF;
51 mActiveBoards[9 + ioffset] = 0xFF;
52
53 // Crate 5
54 mActiveBoards[10 + ioffset] = 0xFF;
55 mActiveBoards[11 + ioffset] = 0xFF;
56
57 // Crate 6
58 mActiveBoards[12 + ioffset] = 0xFF;
59 mActiveBoards[13 + ioffset] = 0xFF;
60
61 // Crate 7
62 mActiveBoards[14 + ioffset] = 0xFF;
63 mActiveBoards[15 + ioffset] = 0x1;
64 }
65}
66
67CrateMasks::CrateMasks(const char* filename) : mActiveBoards()
68{
70 load(filename);
71}
72
73bool CrateMasks::load(const char* filename)
74{
80 mActiveBoards.fill(0);
81 std::ifstream inFile(filename);
82 if (!inFile.is_open()) {
83 return false;
84 }
85 std::string line, token;
86 while (std::getline(inFile, line)) {
87 if (std::count(line.begin(), line.end(), ' ') < 1) {
88 continue;
89 }
90 if (line.find('#') < line.find(' ')) {
91 continue;
92 }
93 std::stringstream ss;
94 ss << line;
95 std::getline(ss, token, ' ');
96 uint16_t feeId = std::atoi(token.c_str());
97 std::getline(ss, token, ' ');
98 uint8_t mask = static_cast<uint8_t>(std::strtol(token.c_str(), nullptr, 16));
99 mActiveBoards[feeId] = mask;
100 }
101 inFile.close();
102 return true;
103}
104
105void CrateMasks::write(const char* filename) const
106{
108 std::ofstream outFile(filename);
109 for (uint16_t igbt = 0; igbt < crateparams::sNGBTs; ++igbt) {
110 outFile << igbt << " " << mActiveBoards[igbt] << std::endl;
111 }
112 outFile.close();
113}
114
115} // namespace mid
116} // namespace o2
MID crate masks.
void write(const char *filename) const
GLint GLuint mask
Definition glcorearb.h:291
uint8_t itsSharedClusterMap uint8_t
a couple of static helper functions to create timestamp values for CCDB queries or override obsolete ...
std::string filename()