ATLAS Offline Software
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 
15 using namespace std;
16 
17 //----------------------------------------------------------------------------//
18 SectorLogicReadOut::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;
30  m_counter32ok = SLROOrig.m_counter32ok;
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  //
65  deleteSLBody();
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...
97  deleteSLBody();
98  // then initialize the data members.
99  initialize();
100 } // end-of-SectorLogicReadOut::reset()
101 //----------------------------------------------------------------------------//
102 void 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;
133  return hit;
134  } else {
135  return 0xefac;
136  }
137 } // end-of-SectorLogicReadOut::readSLHitCurrent
138 //----------------------------------------------------------------------------//
140  if (!m_BodyCounter) {
141  SLROData *temp = m_Body;
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;
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 " +
179  }
180 }
181 //----------------------------------------------------------------------------//
183  if (!m_counter32ok) doCounter32();
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 //----------------------------------------------------------------------------//
265 void 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()
beamspotman.r
def r
Definition: beamspotman.py:676
temp
Definition: JetEventDict.h:21
SectorLogicReadOut::s_nLinks
static constexpr ubit16 s_nLinks
Definition: SectorLogicReadOut.h:77
SectorLogicReadOut::m_Footer
ubit16 m_Footer
Definition: SectorLogicReadOut.h:89
SectorLogicReadOut::readSLHitCurrent
ubit16 readSLHitCurrent()
Definition: SectorLogicReadOut.cxx:129
SectorLogicReadOut::numberOfHitWords
ubit16 numberOfHitWords()
Definition: SectorLogicReadOut.h:29
SectorLogicReadOut::m_Body
SLROData * m_Body
Definition: SectorLogicReadOut.h:90
SectorLogicReadOut::SLROData::next
SLROData * next
Definition: SectorLogicReadOut.h:69
index
Definition: index.py:1
SectorLogicReadOut
Definition: SectorLogicReadOut.h:17
SectorLogicReadOut::m_numberOfWordsInBody
ubit16 m_numberOfWordsInBody
Definition: SectorLogicReadOut.h:93
RODword
uint32_t RODword
Definition: Lvl1Def.h:18
SectorLogicReadOut::display
void display(std::ostream &stream)
Definition: SectorLogicReadOut.cxx:265
SectorLogicReadOut::doCounter32
void doCounter32()
Definition: SectorLogicReadOut.cxx:158
SectorLogicReadOut::padTriggerRate
float padTriggerRate(ubit16 padAddress)
Definition: SectorLogicReadOut.cxx:182
SectorLogicReadOut::m_numberOfWordsInFrag
ubit16 m_numberOfWordsInFrag
Definition: SectorLogicReadOut.h:92
SectorLogicReadOut::topSLBody
void topSLBody()
Definition: SectorLogicReadOut.h:31
SectorLogicReadOut::m_BodyCurr
SLROData * m_BodyCurr
Definition: SectorLogicReadOut.h:74
SectorLogicReadOut::topSLBodyCounters
void topSLBodyCounters()
Definition: SectorLogicReadOut.h:32
BaseObject.h
SectorLogicReadOut::initialize
void initialize()
Definition: SectorLogicReadOut.cxx:83
AthenaPoolTestWrite.stream
string stream
Definition: AthenaPoolTestWrite.py:12
SectorLogicReadOut::s_nGates
static constexpr ubit16 s_nGates
Definition: SectorLogicReadOut.h:76
SectorLogicReadOut::m_BodyLast
SLROData * m_BodyLast
Definition: SectorLogicReadOut.h:73
python.utils.AtlRunQueryDQUtils.p
p
Definition: AtlRunQueryDQUtils.py:210
SectorLogicReadOut::m_hit
ubit16 m_hit[s_nLinks][s_nGates]
Definition: SectorLogicReadOut.h:79
lumiFormat.i
int i
Definition: lumiFormat.py:85
SectorLogicReadOut::readSLCounterCurrent
ubit16 readSLCounterCurrent()
Definition: SectorLogicReadOut.cxx:139
SectorLogicReadOut::opl
ubit16 opl(ubit16 indexLink, ubit16 indexGate)
Definition: SectorLogicReadOut.cxx:220
SectorLogicReadOut::makeNewHit
void makeNewHit(ubit16 newHit)
Definition: SectorLogicReadOut.cxx:113
SectorLogicReadOut::m_BodyCounter
SLROData * m_BodyCounter
Definition: SectorLogicReadOut.h:91
SectorLogicReadOut::getCounter32
RODword getCounter32(ubit16 index)
Definition: SectorLogicReadOut.cxx:169
SectorLogicReadOut::writeRecord
void writeRecord(ubit16 newHit, bool last)
Definition: SectorLogicReadOut.cxx:102
SectorLogicReadOut::m_numberOfWordsInCounters
ubit16 m_numberOfWordsInCounters
Definition: SectorLogicReadOut.h:94
Hardware
@ Hardware
Definition: BaseObject.h:11
SectorLogicReadOut::checkFragment
bool checkFragment()
Definition: SectorLogicReadOut.cxx:285
SectorLogicReadOut::m_Header
ubit16 m_Header
Definition: SectorLogicReadOut.h:88
ActsTrk::to_string
std::string to_string(const DetectorType &type)
Definition: GeometryDefs.h:34
BaseObject
Definition: BaseObject.h:13
SectorLogicReadOut::SectorLogicReadOut
SectorLogicReadOut()
Definition: SectorLogicReadOut.cxx:18
SectorLogicReadOut::oveta
ubit16 oveta(ubit16 indexLink, ubit16 indexGate)
Definition: SectorLogicReadOut.cxx:238
SectorLogicReadOut::s_numberOfDecodedCounters
static const ubit16 s_numberOfDecodedCounters
Definition: SectorLogicReadOut.h:82
SectorLogicReadOut::doHit
void doHit()
Definition: SectorLogicReadOut.cxx:195
SectorLogicReadOut::reset
void reset()
Definition: SectorLogicReadOut.cxx:93
SectorLogicReadOut::ovphi
ubit16 ovphi(ubit16 indexLink, ubit16 indexGate)
Definition: SectorLogicReadOut.cxx:229
SectorLogicReadOut::m_counter32
std::array< RODword, s_numberOfDecodedCounters > m_counter32
Definition: SectorLogicReadOut.h:84
DeMoScan.index
string index
Definition: DeMoScan.py:364
SectorLogicReadOut::bcid
ubit16 bcid(ubit16 indexLink, ubit16 indexGate)
Definition: SectorLogicReadOut.cxx:256
SectorLogicReadOut::cmadd
ubit16 cmadd(ubit16 indexLink, ubit16 indexGate)
Definition: SectorLogicReadOut.cxx:202
SectorLogicReadOut::m_hitok
bool m_hitok
Definition: SectorLogicReadOut.h:87
SectorLogicReadOut::deleteSLBody
void deleteSLBody()
Definition: SectorLogicReadOut.cxx:68
SectorLogicReadOut.h
SectorLogicReadOut::res
ubit16 res(ubit16 indexLink, ubit16 indexGate)
Definition: SectorLogicReadOut.cxx:247
extractSporadic.q
list q
Definition: extractSporadic.py:98
SectorLogicReadOut::~SectorLogicReadOut
~SectorLogicReadOut()
Definition: SectorLogicReadOut.cxx:60
SectorLogicReadOut::SLROData
Definition: SectorLogicReadOut.h:67
SectorLogicReadOut::m_counter32ok
bool m_counter32ok
Definition: SectorLogicReadOut.h:86
SectorLogicReadOut::s_numberOfDataCounters
static const ubit16 s_numberOfDataCounters
Definition: SectorLogicReadOut.h:81
ubit16
unsigned short int ubit16
Definition: RpcByteStreamEncoder.h:20
SectorLogicReadOut::SLROData::hit
ubit16 hit
Definition: SectorLogicReadOut.h:68
SectorLogicReadOut::m_counter16
std::array< ubit16, s_numberOfDataCounters > m_counter16
Definition: SectorLogicReadOut.h:83
readCCLHist.float
float
Definition: readCCLHist.py:83
SectorLogicReadOut::m_numberOfWordsInSLHits
ubit16 m_numberOfWordsInSLHits
Definition: SectorLogicReadOut.h:95
SectorLogicReadOut::ptid
ubit16 ptid(ubit16 indexLink, ubit16 indexGate)
Definition: SectorLogicReadOut.cxx:211