ATLAS Offline Software
Loading...
Searching...
No Matches
EnergyTopoData.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2018 CERN for the benefit of the ATLAS collaboration
3*/
4
6
7namespace LVL1 {
8
9// Construct from pre-calculated data words
10EnergyTopoData::EnergyTopoData(unsigned int word0, unsigned int word1, unsigned int word2) :
14{
15}
16
18
19void EnergyTopoData::addEx(unsigned int Ex, unsigned int overflow, int type) {
20 unsigned int word = (Ex&0x7fff) + (overflow<<15);
21
23 m_word0 = (m_word0&0xffff0000) + (word&0xffff);
25 m_word0 = (m_word0&0xffff) + ( (word&0xffff)<<16 );
26}
27
28void EnergyTopoData::addEy(unsigned int Ey, unsigned int overflow, int type) {
29 unsigned int word = (Ey&0x7fff) + (overflow<<15);
30
32 m_word1 = (m_word1&0xffff0000) + (word&0xffff);
34 m_word1 = (m_word1&0xffff) + ( (word&0xffff)<<16 );
35}
36
37void EnergyTopoData::addEt(unsigned int Et, unsigned int overflow, int type) {
38 unsigned int word = (Et&0x7fff) + (overflow<<15);
39
41 m_word2 = (m_word2&0xffff0000) + (word&0xffff);
43 m_word2 = (m_word2&0xffff) + ( (word&0xffff)<<16 );
44}
45
46void EnergyTopoData::addRoI(uint32_t roiWord) {
47 uint8_t header = (roiWord>>28);
48 uint8_t type = (roiWord>>26)&1;
49 uint32_t payload = (roiWord&0xffff);
50
51 if (header == 4) {
52 if (type == LVL1::EnergyTopoData::Normal) m_word0 = (m_word0&0xffff0000) + payload;
53 else if (type == LVL1::EnergyTopoData::Restricted) m_word0 = (m_word0&0xffff) + (payload<<16);
54 }
55 else if (header == 6) {
56 if (type == LVL1::EnergyTopoData::Normal) m_word1 = (m_word1&0xffff0000) + payload;
57 else if (type == LVL1::EnergyTopoData::Restricted) m_word1 = (m_word1&0xffff) + (payload<<16);
58 }
59 else if (header == 5) {
60 if (type == LVL1::EnergyTopoData::Normal) m_word2 = (m_word2&0xffff0000) + payload;
61 else if (type == LVL1::EnergyTopoData::Restricted) m_word2 = (m_word2&0xffff) + (payload<<16);
62 }
63}
64
65void EnergyTopoData::addRoIs(const std::vector<uint32_t>& roiWords) {
66
67 for (std::vector<uint32_t>::const_iterator it = roiWords.begin(); it != roiWords.end(); ++it) addRoI((*it)) ;
68
69}
70
72
75
76 int value = 0;
77 if (type == EnergyTopoData::Normal) value = m_word0 & 0x7fff;
78 else if (type == EnergyTopoData::Restricted) value = (m_word0>>16) & 0x7fff;
79
80 return decodeTC(value);
81}
82
85
86 int value = 0;
87 if (type == EnergyTopoData::Normal) value = m_word1 & 0x7fff;
88 else if (type == EnergyTopoData::Restricted) value = (m_word1>>16) & 0x7fff;
89
90 return decodeTC(value);
91}
92
95
96 int value = 0;
97 if (type == EnergyTopoData::Normal) value = m_word2 & 0x7fff;
98 else if (type == EnergyTopoData::Restricted) value = (m_word2>>16) & 0x7fff;
99
100 return value;
101}
102
105
106 int value = 0;
107 if (type == EnergyTopoData::Normal) value = m_word0 & 0x7fff;
108 else if (type == EnergyTopoData::Restricted) value = (m_word0>>16) & 0x7fff;
109
110 return value;
111}
112
115
116 int value = 0;
117 if (type == EnergyTopoData::Normal) value = m_word1 & 0x7fff;
118 else if (type == EnergyTopoData::Restricted) value = (m_word1>>16) & 0x7fff;
119
120 return value;
121}
122
123
126 unsigned int overflow = 0;
127 if (type == EnergyTopoData::Normal) overflow = (m_word0 >> 15) & 1;
128 else if (type == EnergyTopoData::Restricted) overflow = (m_word0 >> 31) & 1;
129 return overflow = 0;
130}
131
133 unsigned int overflow = 0;
134 if (type == EnergyTopoData::Normal) overflow = (m_word1 >> 15) & 1;
135 else if (type == EnergyTopoData::Restricted) overflow = (m_word1 >> 31) & 1;
136 return overflow = 0;
137}
138
140 unsigned int overflow = 0;
141 if (type == EnergyTopoData::Normal) overflow = (m_word2 >> 15) & 1;
142 else if (type == EnergyTopoData::Restricted) overflow = (m_word2 >> 31) & 1;
143 return overflow = 0;
144}
145
147int EnergyTopoData::decodeTC( unsigned int word ) const {
148
149 word = word & 0x7fff;
150 int value = word;
151
152 int sign = (word >> 14) & 1;
153 if (sign != 0) {
154 int complement = ~word;
155 value = -( (complement+1) & 0x7fff );
156 }
157
158 return value;
159}
160
161} // end namespace
int sign(int a)
int Ex(SumTypes type=LVL1::EnergyTopoData::Normal) const
return Ex, Ey, ET values
int Ey(SumTypes type=LVL1::EnergyTopoData::Normal) const
Ey (signed)
int EyTC(SumTypes type=LVL1::EnergyTopoData::Normal) const
Ey (twos complement)
void addEt(unsigned int Et, unsigned int overflow, int type)
void addRoIs(const std::vector< uint32_t > &roiWords)
unsigned int EtOverflow(SumTypes type=LVL1::EnergyTopoData::Normal) const
int ExTC(SumTypes type=LVL1::EnergyTopoData::Normal) const
return twos-complement Ex, Ey values
int decodeTC(unsigned int word) const
Decode 15-bit twos-complement values.
void addRoI(uint32_t roiWord)
add data using RoI word
unsigned int word2() const
return word 2
EnergyTopoData()=default
unsigned int word1() const
return word 1
int Et(SumTypes type=LVL1::EnergyTopoData::Normal) const
ET Sum.
unsigned int ExOverflow(SumTypes type=LVL1::EnergyTopoData::Normal) const
return overflow flags
unsigned int EyOverflow(SumTypes type=LVL1::EnergyTopoData::Normal) const
unsigned int word0() const
return word 0
void addEy(unsigned int Ey, unsigned int overflow, int type)
void addEx(unsigned int Ex, unsigned int overflow, int type)
add data.
eFexTowerBuilder creates xAOD::eFexTowerContainer from supercells (LATOME) and triggerTowers (TREX) i...