Project
Loading...
Searching...
No Matches
PadData.h
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#ifndef ALICEO2_FOCAL_PADDATA_H
12#define ALICEO2_FOCAL_PADDATA_H
13
14#include <array>
15#include <exception>
16#include <string>
17#include <vector>
18
19#include <gsl/span>
20
21#include "Rtypes.h"
22
24
25namespace o2::focal
26{
28{
29 public:
30 class IndexException : public std::exception
31 {
32 public:
33 IndexException() = default;
34 IndexException(int index, int maxindex) : std::exception(), mIndex(index), mMaxIndex(maxindex)
35 {
36 mMessage = "Invalid index " + std::to_string(mIndex) + ", max " + std::to_string(mMaxIndex);
37 }
38 ~IndexException() noexcept final = default;
39
40 const char* what() const noexcept final
41 {
42 return mMessage.data();
43 }
44 int getIndex() const { return mIndex; }
45 int getMaxIndex() const { return mMaxIndex; }
46
47 private:
48 int mIndex;
49 int mMaxIndex;
50 std::string mMessage;
51 };
52
53 static constexpr int NCHANNELS = 72;
54 static constexpr int NHALVES = 2;
55
56 ASICData() = default;
57 ASICData(ASICHeader firstheader, ASICHeader secondheader);
58
59 void setFirstHeader(ASICHeader header) { setHeader(header, 0); }
60 void setSecondHeader(ASICHeader header) { setHeader(header, 1); }
61 void setHeader(ASICHeader header, int index);
62
64 void setChannels(const gsl::span<const ASICChannel> channels);
65
68 void setCMN(ASICChannel data, int index);
69 void setCMNs(const gsl::span<const ASICChannel> channels);
70
73 void setCalib(ASICChannel data, int index);
74 void setCalibs(const gsl::span<const ASICChannel> channels);
75
76 ASICHeader getFirstHeader() const { return getHeader(0); }
77 ASICHeader getSecondHeader() const { return getHeader(1); }
78 ASICHeader getHeader(int index) const;
79 gsl::span<const ASICHeader> getHeaders() const;
80
81 gsl::span<const ASICChannel> getChannels() const;
82 ASICChannel getChannel(int index) const;
83
84 ASICChannel getFirstCalib() const { return getCalib(0); }
85 ASICChannel getSecondCalib() const { return getCalib(1); }
86 ASICChannel getCalib(int index) const;
87 gsl::span<const ASICChannel> getCalibs() const;
88
89 ASICChannel getFirstCMN() const { return getCMN(0); }
90 ASICChannel getSecondCMN() const { return getCMN(1); }
91 ASICChannel getCMN(int index) const;
92 gsl::span<const ASICChannel> getCMNs() const;
93
94 void reset();
95
96 private:
97 std::array<ASICHeader, NHALVES> mHeaders;
98 std::array<ASICChannel, NCHANNELS> mChannels;
99 std::array<ASICChannel, NHALVES> mCalibChannels;
100 std::array<ASICChannel, NHALVES> mCMNChannels;
101
102 ClassDefNV(ASICData, 1);
103};
104
106{
107 public:
108 ASICContainer() = default;
109 ~ASICContainer() = default;
110
111 const ASICData& getASIC() const { return mASIC; }
112 ASICData& getASIC() { return mASIC; }
113 gsl::span<const TriggerWord> getTriggerWords() const;
114 void appendTriggerWords(gsl::span<const TriggerWord> triggerwords);
115 void appendTriggerWord(TriggerWord triggerword);
116 void reset();
117
118 private:
119 ASICData mASIC;
120 std::vector<TriggerWord> mTriggerData;
121
122 ClassDefNV(ASICContainer, 1);
123};
124
126{
127 public:
128 class IndexException : public std::exception
129 {
130 public:
131 IndexException() = default;
132 IndexException(int index, int maxindex) : std::exception(), mIndex(index), mMaxIndex(maxindex)
133 {
134 mMessage = "Invalid index " + std::to_string(mIndex) + ", max " + std::to_string(mMaxIndex);
135 }
136 ~IndexException() noexcept final = default;
137 const char* what() const noexcept final
138 {
139 return mMessage.data();
140 }
141
142 int getIndex() const { return mIndex; }
143 int getMaxIndex() const { return mMaxIndex; }
144
145 private:
146 int mIndex;
147 int mMaxIndex;
148 std::string mMessage;
149 };
150 static constexpr int NASICS = 20;
151
152 PadData() = default;
153 ~PadData() = default;
154
155 const ASICContainer& operator[](int index) const { return getDataForASIC(index); }
157
158 const ASICContainer& getDataForASIC(int index) const;
160 void reset();
161
162 private:
163 std::array<ASICContainer, NASICS> mASICs;
164
165 ClassDefNV(PadData, 1);
166};
167
168} // namespace o2::focal
169#endif // ALICEO2_FOCAL_PADDATA_H
void appendTriggerWords(gsl::span< const TriggerWord > triggerwords)
Definition PadData.cxx:148
ASICData & getASIC()
Definition PadData.h:112
gsl::span< const TriggerWord > getTriggerWords() const
Definition PadData.cxx:143
const ASICData & getASIC() const
Definition PadData.h:111
void appendTriggerWord(TriggerWord triggerword)
Definition PadData.cxx:153
~IndexException() noexcept final=default
IndexException(int index, int maxindex)
Definition PadData.h:34
const char * what() const noexcept final
Definition PadData.h:40
ASICChannel getFirstCMN() const
Definition PadData.h:89
void setChannels(const gsl::span< const ASICChannel > channels)
Definition PadData.cxx:38
ASICChannel getFirstCalib() const
Definition PadData.h:84
void setSecondHeader(ASICHeader header)
Definition PadData.h:60
void setSecondCalib(ASICChannel data)
Definition PadData.h:72
void setFirstHeader(ASICHeader header)
Definition PadData.h:59
void setChannel(ASICChannel data, int index)
Definition PadData.cxx:30
gsl::span< const ASICChannel > getCalibs() const
Definition PadData.cxx:103
ASICChannel getSecondCMN() const
Definition PadData.h:90
ASICHeader getSecondHeader() const
Definition PadData.h:77
ASICHeader getFirstHeader() const
Definition PadData.h:76
ASICChannel getCalib(int index) const
Definition PadData.cxx:95
gsl::span< const ASICChannel > getCMNs() const
Definition PadData.cxx:116
ASICChannel getSecondCalib() const
Definition PadData.h:85
void setHeader(ASICHeader header, int index)
Definition PadData.cxx:22
ASICHeader getHeader(int index) const
Definition PadData.cxx:69
void setCalib(ASICChannel data, int index)
Definition PadData.cxx:56
void setCMN(ASICChannel data, int index)
Definition PadData.cxx:43
static constexpr int NHALVES
Definition PadData.h:54
gsl::span< const ASICHeader > getHeaders() const
Definition PadData.cxx:77
static constexpr int NCHANNELS
Definition PadData.h:53
void setCalibs(const gsl::span< const ASICChannel > channels)
Definition PadData.cxx:64
ASICChannel getChannel(int index) const
Definition PadData.cxx:87
void setSecondCMN(ASICChannel data)
Definition PadData.h:67
void setCMNs(const gsl::span< const ASICChannel > channels)
Definition PadData.cxx:51
void setFirstCMN(ASICChannel data)
Definition PadData.h:66
gsl::span< const ASICChannel > getChannels() const
Definition PadData.cxx:82
void setFirstCalib(ASICChannel data)
Definition PadData.h:71
ASICChannel getCMN(int index) const
Definition PadData.cxx:108
const char * what() const noexcept final
Definition PadData.h:137
~IndexException() noexcept final=default
IndexException(int index, int maxindex)
Definition PadData.h:132
const ASICContainer & getDataForASIC(int index) const
Definition PadData.cxx:171
ASICContainer & operator[](int index)
Definition PadData.h:156
static constexpr int NASICS
Definition PadData.h:150
const ASICContainer & operator[](int index) const
Definition PadData.h:155
GLuint index
Definition glcorearb.h:781
GLboolean * data
Definition glcorearb.h:298
Defining DataPointCompositeObject explicitly as copiable.
std::string to_string(gsl::span< T, Size > span)
Definition common.h:52
std::vector< ChannelData > channels