ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
InnerDetector
InDetConditions
SCT_ConditionsData
src
SCT_Chip.cxx
Go to the documentation of this file.
1
/*
2
Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration
3
*/
4
5
#include "
SCT_ConditionsData/SCT_Chip.h
"
6
7
#include <sstream>
8
9
// Default constructor: chip has id 0, config = 0 and all strips good.
10
SCT_Chip::SCT_Chip
():
11
m_id
(0),
12
m_config
(0),
m_in
(0),
m_out
(0),
m_end
(false),
m_master
(false) {
13
m_mask
.set();
14
}
15
16
// Construct a chip from the id, config and masks
17
SCT_Chip::SCT_Chip
(
short
id
,
short
config, uint32_t mask0, uint32_t mask1, uint32_t mask2, uint32_t
mask3
):
18
m_id
(
id
),
19
m_config
(config) {
20
m_in
=
m_config
.test(
IN_BIT
) ? 1 : 0;
21
m_out
=
m_config
.test(
OUT_BIT
) ? 1 : 0;
22
m_end
=
m_config
.test(
END_BIT
);
23
m_master
= !
m_config
.test(
MASTER_BIT
);
// Master bit is 0 if master
24
initializeMaskFromInts
(mask0, mask1, mask2,
mask3
);
25
}
26
27
// Initialise chip mask (int version)
28
bool
SCT_Chip::initializeMaskFromInts
(uint32_t mask0, uint32_t mask1, uint32_t mask2, uint32_t
mask3
){
29
bool
successfulInitialization(
true
);
30
uint32_t subWords[
nSubwords
]={mask0,mask1,mask2,
mask3
};
31
// Put the integers into 32 bit bitsets
32
std::bitset<lenSubword> subBinary;
33
for
(
unsigned
int
i{0}; i!=
nSubwords
; ++i) {
34
subBinary = subWords[i];
35
// Put the four bitsets together in one 128 bit bitset (private member data)
36
for
(
unsigned
int
j{0}; j!=
lenSubword
; ++j) {
37
m_mask
[i*
lenSubword
+j]=subBinary[j];
38
}
39
}
40
return
successfulInitialization;
41
}
42
43
// Initialise chip mask from string in format "0xffffffff 0xffffffff 0xffffffff 0xffffffff"
44
// with the rightmost nibble being the least significant
45
bool
SCT_Chip::initializeMaskFromString
(
const
std::string &maskString){
46
bool
successfulInitialization(
true
);
47
std::istringstream formatStream(maskString);
48
uint32_t subWords[
nSubwords
];
49
50
// Parse into four 32-bit integers (there must be a better way!)
51
// As a very basic check, we enable exceptions on the hex conversion.
52
formatStream.exceptions(std::ios_base::badbit|std::ios_base::failbit);
53
54
try
{
55
formatStream >> std::hex >> subWords[
nSubwords
-1]
56
>> std::hex >> subWords[
nSubwords
-2]
57
>> std::hex >> subWords[
nSubwords
-3]
58
>> std::hex >> subWords[
nSubwords
-4];
59
}
catch
(
const
std::ios_base::failure&) {
60
std::cerr <<
"The SCT_ChipMask code has failed to convert the received string to a mask; the received string is: "
;
61
std::cerr << maskString << std::endl;
62
successfulInitialization =
false
;
63
}
64
65
initializeMaskFromInts
(subWords[0], subWords[1], subWords[2], subWords[3]);
66
return
successfulInitialization;
67
}
68
69
// Check if channel is masked
70
bool
SCT_Chip::channelIsMasked
(
const
unsigned
int
channelNumber)
const
{
71
return
!(
m_mask
.test(channelNumber));
72
}
73
74
// Number of masked channels
75
unsigned
int
SCT_Chip::numberOfMaskedChannels
()
const
{
76
return
nBitsMask
-
m_mask
.count();
77
}
78
79
// Add masked channels to the bad strip vector
80
void
SCT_Chip::appendBadStripsToVector
(std::vector<int> & maskedChannelVector)
const
{
81
for
(
unsigned
int
thisChann(0);thisChann !=
nBitsMask
; ++thisChann){
82
if
(
channelIsMasked
(thisChann)) maskedChannelVector.push_back(thisChann);
83
}
84
}
mask3
static const uint32_t mask3
Definition
PixelByteStreamModuleMask.h:57
SCT_Chip.h
Header file storing infomration on the SCT chips: id, config, mask.
SCT_Chip::m_id
short m_id
Chip Id.
Definition
SCT_Chip.h:78
SCT_Chip::m_mask
std::bitset< nBitsMask > m_mask
Chip strip mask.
Definition
SCT_Chip.h:84
SCT_Chip::numberOfMaskedChannels
unsigned int numberOfMaskedChannels() const
Number of masked channels.
Definition
SCT_Chip.cxx:75
SCT_Chip::m_in
short m_in
Active input port.
Definition
SCT_Chip.h:80
SCT_Chip::m_master
bool m_master
Is chip a master.
Definition
SCT_Chip.h:83
SCT_Chip::channelIsMasked
bool channelIsMasked(const unsigned int channelNumber) const
Gives status of channel at channelNumber.
Definition
SCT_Chip.cxx:70
SCT_Chip::initializeMaskFromString
bool initializeMaskFromString(const std::string &maskString)
Initialize channel mask from a string.
Definition
SCT_Chip.cxx:45
SCT_Chip::SCT_Chip
SCT_Chip()
Default constructor.
Definition
SCT_Chip.cxx:10
SCT_Chip::initializeMaskFromInts
bool initializeMaskFromInts(uint32_t mask0, uint32_t mask1, uint32_t mask2, uint32_t mask3)
Initialize channel mask from four ins (as in DB).
Definition
SCT_Chip.cxx:28
SCT_Chip::m_config
std::bitset< nBitsConfig > m_config
Chip configuration mask.
Definition
SCT_Chip.h:79
SCT_Chip::IN_BIT
@ IN_BIT
Definition
SCT_Chip.h:75
SCT_Chip::OUT_BIT
@ OUT_BIT
Definition
SCT_Chip.h:75
SCT_Chip::END_BIT
@ END_BIT
Definition
SCT_Chip.h:75
SCT_Chip::MASTER_BIT
@ MASTER_BIT
Definition
SCT_Chip.h:75
SCT_Chip::lenSubword
@ lenSubword
Definition
SCT_Chip.h:71
SCT_Chip::nSubwords
@ nSubwords
Definition
SCT_Chip.h:71
SCT_Chip::nBitsMask
@ nBitsMask
Definition
SCT_Chip.h:71
SCT_Chip::id
short id() const
Chip Id.
Definition
SCT_Chip.h:42
SCT_Chip::m_out
short m_out
Active output port.
Definition
SCT_Chip.h:81
SCT_Chip::m_end
bool m_end
Is chip an end.
Definition
SCT_Chip.h:82
SCT_Chip::appendBadStripsToVector
void appendBadStripsToVector(std::vector< int > &maskedChannelVector) const
Append masked channels' numbers to a user-supplied vector.
Definition
SCT_Chip.cxx:80
Generated on
for ATLAS Offline Software by
1.17.0