ATLAS Offline Software
Loading...
Searching...
No Matches
SectorLogicReadOut.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
3*/
4
6
7#include <cstring>
8#include <fstream>
9#include <iomanip>
10#include <iostream>
11#include <stdexcept>
12
14
15using namespace std;
16
17//----------------------------------------------------------------------------//
18SectorLogicReadOut::SectorLogicReadOut() : BaseObject(Hardware, "SectorLogicReadOut") { initialize(); } // end-of-SectorLogicReadOut
19//----------------------------------------------------------------------------//
21 //
22 // copy constructor
23 //
24 m_Header = SLROOrig.m_Header;
25 m_Footer = SLROOrig.m_Footer;
31 m_hitok = SLROOrig.m_hitok;
32 for (ubit16 i = 0; i < s_numberOfDataCounters; i++) { m_counter16[i] = SLROOrig.m_counter16[i]; }
33 for (ubit16 i = 0; i < s_numberOfDecodedCounters; i++) { m_counter32[i] = SLROOrig.m_counter32[i]; }
34 for (int i = 0; i < s_nLinks; ++i) {
35 for (int j = 0; j < s_nGates; ++j) { m_hit[i][j] = SLROOrig.m_hit[i][j]; }
36 }
37 //
38 // Copy Dynamic structure
39 //
40 SLROData *q = 0;
41 SLROData *r = 0;
42 SLROData *p = SLROOrig.m_Body;
43 ubit16 cnter = 0;
44 while (p) {
45 q = new SLROData;
46 q->hit = p->hit;
47 q->next = 0;
48 if (!cnter) {
49 m_Body = q;
50 // if(cnter==(nGates*nLinks)) m_BodyCounter = q;
51 } else
52 r->next = q;
53 cnter++;
54 r = q;
55 p = p->next;
56 } // end-of-while
57 m_BodyLast = r;
58} // end-of-SectorLogicReadOut
59//----------------------------------------------------------------------------//
61 //
62 // delete the SLROData dynamic structure used to describe Body part
63 // of the event fragment.
64 //
66}
67//----------------------------------------------------------------------------//
69 SLROData *p{nullptr}, *q{nullptr};
70 p = m_Body;
71 while (p) {
72 q = p;
73 p = p->next;
74 delete q;
75 } // end-of-while
76 m_Body = 0;
77 m_BodyLast = 0;
78 m_BodyCurr = 0;
79 m_BodyCounter = 0;
81} // end-of-deleteSLBody
82//----------------------------------------------------------------------------//
84 // initialize check flags
85 //
87 for (int i = 0; i < s_nLinks; ++i) {
88 for (int j = 0; j < s_nGates; ++j) { m_hit[i][j] = 0; }
89 }
90
91} // end-of-initialize
92//----------------------------------------------------------------------------//
94 //
95 // reset the data structure to host a new fragment;
96 // first delete the dinamyc structure...
98 // then initialize the data members.
99 initialize();
100} // end-of-SectorLogicReadOut::reset()
101//----------------------------------------------------------------------------//
102void SectorLogicReadOut::writeRecord(ubit16 thisRecord, bool last) {
103 if (m_numberOfWordsInFrag == 0) {
104 m_Header = thisRecord;
105 } else if (m_numberOfWordsInFrag && !last) {
106 makeNewHit(thisRecord);
107 } else {
108 m_Footer = thisRecord;
109 }
111} // end-of-void SectorLogicReadOut
112//----------------------------------------------------------------------------//
114 SLROData *p;
115 p = new SLROData;
116 p->hit = newHit;
117 p->next = 0;
118 if (!m_Body) {
119 m_Body = p;
120 } else {
121 m_BodyLast->next = p;
122 } // end-of-if
123 m_BodyLast = p;
127} // end-of-SectorLogicReadOut::makeNewHit
128//----------------------------------------------------------------------------//
130 if (m_BodyCurr) {
131 ubit16 hit = m_BodyCurr->hit;
132 m_BodyCurr = m_BodyCurr->next;
133 return hit;
134 } else {
135 return 0xefac;
136 }
137} // end-of-SectorLogicReadOut::readSLHitCurrent
138//----------------------------------------------------------------------------//
140 if (!m_BodyCounter) {
142 for (ubit16 i = 0; i < numberOfHitWords(); i++) {
143 if (temp->next) temp = temp->next;
144 }
145 if (temp) m_BodyCounter = temp;
147 }
148 //
149 if (m_BodyCurr) {
150 ubit16 hit = m_BodyCurr->hit;
151 m_BodyCurr = m_BodyCurr->next;
152 return hit;
153 } else {
154 return 0xcafe;
155 }
156} // end-of-SectorLogicReadOut::readSLCounterCurrent
157//----------------------------------------------------------------------------//
160 for (ubit16 i = 0; i < m_numberOfWordsInCounters; i++) { m_counter16[i] = readSLCounterCurrent() & 0x1fff; }
161 //
162 ubit16 j = 0;
163 for (ubit16 i = 0; i < s_numberOfDecodedCounters; i++) {
164 m_counter32[i] = (m_counter16[j] | (m_counter16[j + 1] << 13) | (m_counter16[j + 2] << 26));
165 j += 3;
166 }
167} // end-of-SectorLogicReadOut::doCounter32()
168//----------------------------------------------------------------------------//
170 if (!m_counter32ok) {
171 doCounter32();
172 m_counter32ok = true;
173 }
175 return m_counter32[index];
176 } else {
177 throw std::out_of_range("SectorLogicReadout::getCounter32: index=" + std::to_string(index) + " is larger than " +
178 std::to_string(s_numberOfDecodedCounters));
179 }
180}
181//----------------------------------------------------------------------------//
184 //
185 // units are kHz
186 //
187 static const float convertToTriggerRate = 160314.74 / 4.0; // units are kHz
188 if (padAddress < ((s_numberOfDecodedCounters - 3) / 2)) {
189 return convertToTriggerRate * (float(m_counter32[padAddress * 2 + 1]) / float(m_counter32[padAddress * 2 + 0]));
190 } else {
191 throw std::out_of_range("SectorLogicReadout::padTrigger: input padAddress=" + std::to_string(padAddress) + " is not possible");
192 }
193}
194//----------------------------------------------------------------------------//
196 topSLBody();
197 for (ubit16 j = 0; j < s_nGates; j++) {
198 for (ubit16 i = 0; i < s_nLinks; i++) { m_hit[i][j] = readSLHitCurrent(); } // end-of-for(ubit16 i
199 } // end-of-for(ubit16 j
200} // end-of-SectorLogicReadOut::doHit()
201//----------------------------------------------------------------------------//
203 if (!m_hitok) doHit();
204 if (indexLink < s_nLinks && indexGate < s_nGates) {
205 return (m_hit[indexLink][indexGate]) & 0x3;
206 } else {
207 throw std::out_of_range("SectorLogicReadout::cmid: indexLink or indexGate out of range");
208 }
209} // end-of-SectorLogicReadOut::cmid(ubit16 indexLink, ubit16 indexGate)
210//----------------------------------------------------------------------------//
212 if (!m_hitok) doHit();
213 if (indexLink < s_nLinks && indexGate < s_nGates) {
214 return (m_hit[indexLink][indexGate] >> 2) & 0x7;
215 } else {
216 throw std::out_of_range("SectorLogicReadout::ptid: indexLink or indexGate out of range");
217 }
218} // end-of-SectorLogicReadOut::ptid(ubit16 indexLink, ubit16 indexGate)
219//----------------------------------------------------------------------------//
221 if (!m_hitok) doHit();
222 if (indexLink < s_nLinks && indexGate < s_nGates) {
223 return (m_hit[indexLink][indexGate] >> 5) & 0x1;
224 } else {
225 throw std::out_of_range("SectorLogicReadout::opl: indexLink or indexGate out of range");
226 }
227} // end-of-SectorLogicReadOut::opl(ubit16 indexLink, ubit16 indexGate)
228//----------------------------------------------------------------------------//
230 if (!m_hitok) doHit();
231 if (indexLink < s_nLinks && indexGate < s_nGates) {
232 return (m_hit[indexLink][indexGate] >> 6) & 0x1;
233 } else {
234 throw std::out_of_range("SectorLogicReadout::ovphi: indexLink or indexGate out of range");
235 }
236} // end-of-SectorLogicReadOut::ovphi(ubit16 indexLink, ubit16 indexGate)
237//----------------------------------------------------------------------------//
239 if (!m_hitok) doHit();
240 if (indexLink < s_nLinks && indexGate < s_nGates) {
241 return (m_hit[indexLink][indexGate] >> 7) & 0x1;
242 } else {
243 throw std::out_of_range("SectorLogicReadout::oveta: indexLink or indexGate out of range");
244 }
245} // end-of-SectorLogicReadOut::oveta(ubit16 indexLink, ubit16 indexGate)
246//----------------------------------------------------------------------------//
248 if (!m_hitok) doHit();
249 if (indexLink < s_nLinks && indexGate < s_nGates) {
250 return (m_hit[indexLink][indexGate] >> 8) & 0x1;
251 } else {
252 throw std::out_of_range("SectorLogicReadout::res : indexLink or indexGate out of range");
253 }
254} // end-of-SectorLogicReadOut::res(ubit16 indexLink, ubit16 indexGate)
255//----------------------------------------------------------------------------//
257 if (!m_hitok) doHit();
258 if (indexLink < s_nLinks && indexGate < s_nGates) {
259 return (m_hit[indexLink][indexGate] >> 9) & 0x7;
260 } else {
261 throw std::out_of_range("SectorLogicReadout::bcid: indexLink or indexGate out of range");
262 }
263} // end-of-SectorLogicReadOut::bcid(ubit16 indexLink, ubit16 indexGate)
264//----------------------------------------------------------------------------//
265void SectorLogicReadOut::display(std::ostream &stream) {
266 stream << " **** Sector Logic ReadOut Fragment ****" << std::endl;
267 stream << " SectorLogic: number of Hits :" << m_numberOfWordsInSLHits << std::endl;
268 stream << " SectorLogic: number of Counters:" << m_numberOfWordsInCounters << std::endl;
269 stream << " SectorLogic: Header " << std::hex << m_Header << std::dec << std::endl;
270 for (ubit16 i = 0; i < m_numberOfWordsInSLHits; i++) {
271 stream << " SectorLogic: hit " << (i + 1) << " ==> " << std::hex << readSLHitCurrent() << std::dec << std::endl;
272 }
273 stream << " SectorLogic: Footer " << std::hex << m_Footer << std::dec << std::endl;
274 for (ubit16 i = 0; i < m_numberOfWordsInCounters; i++) {
275 stream << " SectorLogic: counter " << (i + 1) << " ==> " << std::hex << readSLCounterCurrent() << std::dec << std::endl;
276 }
277 for (int i = 0; i < s_numberOfDecodedCounters; i++) {
278 stream << " SectorLogic: Counter32 " << (i + 1) << " ==> "
279 << " = " << std::hex << getCounter32(i) << std::dec << std::endl;
280 }
281 stream << " SectorLogic: Pad 0 trigger rate: " << padTriggerRate(0) << " kHz" << std::endl;
282 stream << " SectorLogic: Pad 1 trigger rate: " << padTriggerRate(1) << " kHz" << std::endl;
283} // end-of-void SectorLogicReadOut::display
284//----------------------------------------------------------------------------//
287} // end-of-void SectorLogicReadOut::checkFragment()
@ Hardware
Definition BaseObject.h:11
uint32_t RODword
Definition Lvl1Def.h:18
unsigned short int ubit16
BaseObject(ObjectType, const std::string &)
Definition BaseObject.cxx:7
ubit16 ptid(ubit16 indexLink, ubit16 indexGate)
ubit16 oveta(ubit16 indexLink, ubit16 indexGate)
ubit16 opl(ubit16 indexLink, ubit16 indexGate)
ubit16 ovphi(ubit16 indexLink, ubit16 indexGate)
std::array< RODword, s_numberOfDecodedCounters > m_counter32
void display(std::ostream &stream)
float padTriggerRate(ubit16 padAddress)
ubit16 cmadd(ubit16 indexLink, ubit16 indexGate)
ubit16 bcid(ubit16 indexLink, ubit16 indexGate)
RODword getCounter32(ubit16 index)
static const ubit16 s_numberOfDataCounters
std::array< ubit16, s_numberOfDataCounters > m_counter16
static constexpr ubit16 s_nLinks
ubit16 m_hit[s_nLinks][s_nGates]
static const ubit16 s_numberOfDecodedCounters
void makeNewHit(ubit16 newHit)
ubit16 res(ubit16 indexLink, ubit16 indexGate)
void writeRecord(ubit16 newHit, bool last)
static constexpr ubit16 s_nGates
int r
Definition globals.cxx:22
Definition index.py:1
STL namespace.