ATLAS Offline Software
Loading...
Searching...
No Matches
RPCReadOut.h
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
3*/
4
5#ifndef TrigT1RPChardware_RPCReadOut_H
6#define TrigT1RPChardware_RPCReadOut_H
7
8#include <array>
9#include <iostream>
10
12
14public:
15 RPCReadOut() = default;
16 ~RPCReadOut() = default;
17
18 ubit16 getWord() const { return m_word; };
19 char field() const { return m_field; };
20
21protected:
22 // create a 16 bits word of the CMA frame structure , starting from the fields:
23 // ubit16 set16Bits(const ubit16 num, const ubit16 *pos, const ubit16 *val);
24 // get the fields of the 16 bits word of the CMA frame structure:
25 // ubit16 get16Bits(const ubit16 num, const ubit16 pos, const ubit16 val);
26
27 ubit16 m_word{0xffff};
28 char m_field{0};
29
30 inline ubit16 set16Bits(const ubit16 n, const ubit16 *pos, const ubit16 *val) const {
31 ubit16 output = 0;
32 ubit16 p = 0, v = 0;
33 for (ubit16 i = 0; i < n; i++) {
34 v = *(val + i);
35 p = *(pos + i);
36 output = output | (v << p);
37 } // end-of-for
38 return output;
39 } // end-of-MatrixReadOutStructure::set16Bits
40 template <size_t n> ubit16 set16Bits(const std::array<ubit16, n> &pos, const std::array<ubit16, n> &val) const {
41 ubit16 output = 0;
42 for (size_t i = 0; i < n; ++i) { output |= (val[i] << pos[i]); }
43 return output;
44 }
45
46 //---------------------------------------------------------------------------//
47 inline ubit16 get16Bits(const ubit16 input, const ubit16 position, const ubit16 length) const {
48 ubit16 output = 0;
49 ubit16 CMfield = 0;
50 for (ubit16 i = 0; i < length; i++) { CMfield = CMfield | 1 << (position + i); }
51 output = (input & CMfield) >> position;
52 return output;
53 } // end-of-MatrixReadOutStructure::get16Bits
54
55 static constexpr ubit16 s_last2bitsON{0xc000};
56 static constexpr ubit16 s_last4bitsON{0xf000};
57 static constexpr ubit16 s_first8bitsON{0};
58};
59#endif
double length(const pvec &v)
unsigned short int ubit16
ubit16 set16Bits(const std::array< ubit16, n > &pos, const std::array< ubit16, n > &val) const
Definition RPCReadOut.h:40
static constexpr ubit16 s_last2bitsON
Definition RPCReadOut.h:55
static constexpr ubit16 s_last4bitsON
Definition RPCReadOut.h:56
RPCReadOut()=default
char field() const
Definition RPCReadOut.h:19
ubit16 get16Bits(const ubit16 input, const ubit16 position, const ubit16 length) const
Definition RPCReadOut.h:47
ubit16 set16Bits(const ubit16 n, const ubit16 *pos, const ubit16 *val) const
Definition RPCReadOut.h:30
~RPCReadOut()=default
ubit16 getWord() const
Definition RPCReadOut.h:18
ubit16 m_word
Definition RPCReadOut.h:27
char m_field
Definition RPCReadOut.h:28
static constexpr ubit16 s_first8bitsON
Definition RPCReadOut.h:57