ATLAS Offline Software
CTPResult.icc
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2018 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 // tdaq-common includes for CTP format definition
6 //#include "CTPfragment/CTPdataformat.h"
7 #include "CTPfragment/CTPdataformatVersion.h"
8 
9 // STL includes
10 #include <numeric>
11 #include <functional>
12 
13 // inline implementations for CTPResult class
14 
15 inline const ROIB::Header& ROIB::CTPResult::header() const {
16  return m_CTPResultHeader;
17 }
18 
19 inline const ROIB::Trailer& ROIB::CTPResult::trailer() const {
20  return m_CTPResultTrailer;
21 }
22 
23 inline const std::vector<ROIB::CTPRoI>& ROIB::CTPResult::roIVec() const {
24  return m_CTPResultRoIVec;
25 }
26 
27 inline bool ROIB::CTPResult::isValid() const {
28  return (m_CTPResultHeader.size() != 0 && m_CTPResultTrailer.size() != 0);
29 }
30 
31 inline bool ROIB::CTPResult::isComplete() const {
32  return isValid() && m_CTPResultRoIVec.size() >= (m_ctpDataformat.getNumberTimeWords() +
33  ((m_useRoIB) ? m_ctpDataformat.getRoIBwordsPerBunch():m_ctpDataformat.getDAQwordsPerBunch()));
34 }
35 
36 inline const std::vector<ROIB::CTPRoI> ROIB::CTPResult::TBP() const {
37  // adding some safety protection by restriction index range
38  return std::vector<ROIB::CTPRoI>(m_CTPResultRoIVec.begin() +
39  std::min(m_CTPResultRoIVec.size(),
40  static_cast<size_t>(((m_useRoIB) ? m_ctpDataformat.getRoIBTBPpos():m_l1aBunch*m_ctpDataformat.getDAQwordsPerBunch()+m_ctpDataformat.getTBPpos()))),
41  m_CTPResultRoIVec.begin() +
42  std::min(m_CTPResultRoIVec.size(),
43  static_cast<size_t>(((m_useRoIB) ? m_ctpDataformat.getRoIBTBPpos():m_l1aBunch*m_ctpDataformat.getDAQwordsPerBunch()+m_ctpDataformat.getTBPpos())+m_ctpDataformat.getTBPwords())));
44 }
45 
46 inline const std::vector<ROIB::CTPRoI> ROIB::CTPResult::TAP() const {
47  // adding some safety protection by restriction index range
48  return std::vector<ROIB::CTPRoI>(m_CTPResultRoIVec.begin() +
49  std::min(m_CTPResultRoIVec.size(), static_cast<size_t>(m_l1aBunch*m_ctpDataformat.getDAQwordsPerBunch() + m_ctpDataformat.getTAPpos())),
50  m_CTPResultRoIVec.begin() +
51  std::min(m_CTPResultRoIVec.size(), static_cast<size_t>(m_ctpDataformat.getTAPpos()+((m_useRoIB) ? m_ctpDataformat.getRoIBTAPwords():m_l1aBunch*m_ctpDataformat.getDAQwordsPerBunch()+m_ctpDataformat.getTAPwords()))));
52 }
53 
54 inline const std::vector<ROIB::CTPRoI> ROIB::CTPResult::TAV() const {
55  // adding some safety protection by restriction index range
56  return std::vector<ROIB::CTPRoI>(m_CTPResultRoIVec.begin() +
57  std::min(m_CTPResultRoIVec.size(), static_cast<size_t>(((m_useRoIB) ? m_ctpDataformat.getRoIBTAVpos():m_l1aBunch*m_ctpDataformat.getDAQwordsPerBunch()+m_ctpDataformat.getTAVpos()))),
58  m_CTPResultRoIVec.begin() +
59  std::min(m_CTPResultRoIVec.size(), static_cast<size_t>(((m_useRoIB) ? m_ctpDataformat.getRoIBTAVpos():m_l1aBunch*m_ctpDataformat.getDAQwordsPerBunch()+m_ctpDataformat.getTAVpos())+ m_ctpDataformat.getTAVwords())));
60 }
61 
62 inline bool ROIB::CTPResult::acceptBP() const {
63  // adding some safety protection by restriction index range
64 
65  for (size_t i(std::min(m_CTPResultRoIVec.size(),static_cast<size_t>(((m_useRoIB) ? m_ctpDataformat.getRoIBTBPpos():m_l1aBunch*m_ctpDataformat.getDAQwordsPerBunch()+m_ctpDataformat.getTBPpos()))));
66  i < std::min(m_CTPResultRoIVec.size(),
67  static_cast<size_t>(((m_useRoIB) ? m_ctpDataformat.getRoIBTBPpos():m_l1aBunch*m_ctpDataformat.getDAQwordsPerBunch()+m_ctpDataformat.getTBPpos())+m_ctpDataformat.getTBPwords()));
68  ++i) {
69  if (m_CTPResultRoIVec[i].roIWord() != 0) return true;
70  }
71 
72  return false;
73 }
74 
75 inline bool ROIB::CTPResult::acceptAP() const {
76  // adding some safety protection by restriction index range
77 
78  for (size_t i(std::min(m_CTPResultRoIVec.size(), static_cast<size_t>(m_l1aBunch*m_ctpDataformat.getDAQwordsPerBunch()+m_ctpDataformat.getTAPpos())));
79  i < std::min(m_CTPResultRoIVec.size(),
80  static_cast<size_t>(m_l1aBunch*m_ctpDataformat.getDAQwordsPerBunch()+m_ctpDataformat.getTAPpos()+((m_useRoIB) ? m_ctpDataformat.getRoIBTAPwords():m_ctpDataformat.getTAPwords())));
81  ++i) {
82  if (m_CTPResultRoIVec[i].roIWord() != 0) return true;
83  }
84 
85  return false;
86 }
87 
88 inline bool ROIB::CTPResult::acceptAV() const {
89  // adding some safety protection by restriction index range
90 
91  for (size_t i(std::min(m_CTPResultRoIVec.size(),
92  static_cast<size_t>(((m_useRoIB) ? m_ctpDataformat.getRoIBTAVpos():m_l1aBunch*m_ctpDataformat.getDAQwordsPerBunch()+m_ctpDataformat.getTAVpos()))));
93  i < std::min(m_CTPResultRoIVec.size(),
94  static_cast<size_t>(((m_useRoIB) ? m_ctpDataformat.getRoIBTAVpos():m_l1aBunch*m_ctpDataformat.getDAQwordsPerBunch()+m_ctpDataformat.getTAVpos())+m_ctpDataformat.getTAVwords()));
95  ++i) {
96  if (m_CTPResultRoIVec[i].roIWord() != 0) return true;
97  }
98 
99  return false;
100 }