ATLAS Offline Software
Public Member Functions | Private Member Functions | Private Attributes | List of all members
Buffer Class Reference
Collaboration diagram for Buffer:

Public Member Functions

 Buffer (std::unique_ptr< EventStorage::DataReader > &&reader, size_t size)
 
std::optional< std::reference_wrapper< const Event > > peek () const
 
Event next ()
 
unsigned int eventsInFile ()
 
const EventStorage::DataReader & reader () const
 

Private Member Functions

void sort ()
 
EventStorage::DRError fillBuffer ()
 

Private Attributes

std::unique_ptr< EventStorage::DataReader > m_reader
 
size_t m_size {0}
 
std::vector< Eventm_events
 

Detailed Description

Definition at line 114 of file trigbs_orderedMerge.cxx.

Constructor & Destructor Documentation

◆ Buffer()

Buffer::Buffer ( std::unique_ptr< EventStorage::DataReader > &&  reader,
size_t  size 
)
inline

Definition at line 140 of file trigbs_orderedMerge.cxx.

141  : m_reader(std::move(reader)), m_size(size) {
142  fillBuffer();
143  if (s_debugLogging) {
144  std::cout << "Constructed a Buffer with " << m_events.size() << " events loaded, global_id range: ["
145  << m_events.front().frag.global_id() << ", " << m_events.back().frag.global_id() << "]" << std::endl;
146  }
147  }

Member Function Documentation

◆ eventsInFile()

unsigned int Buffer::eventsInFile ( )
inline

Definition at line 159 of file trigbs_orderedMerge.cxx.

159  {
160  return m_reader->eventsInFile();
161  }

◆ fillBuffer()

EventStorage::DRError Buffer::fillBuffer ( )
inlineprivate

Definition at line 124 of file trigbs_orderedMerge.cxx.

124  {
125  while (m_reader->good() && m_events.size() < m_size) {
126  char* blobChars{nullptr};
127  unsigned int blobCharsSize{0};
128  if (const EventStorage::DRError err_code = m_reader->getData(blobCharsSize, &blobChars); err_code != EventStorage::DRError::DROK) {
129  std::cerr << "Error code " << err_code << " from EventStorage::DataReader::getData" << std::endl;
130  return err_code;
131  }
132  const uint32_t* blobWords = reinterpret_cast<const uint32_t*>(blobChars);
133  m_events.emplace_back(std::unique_ptr<const uint32_t[]>(blobWords));
134  }
135  sort();
136  return EventStorage::DRError::DROK;
137  }

◆ next()

Event Buffer::next ( )
inline

Definition at line 152 of file trigbs_orderedMerge.cxx.

152  {
153  Event event{std::move(m_events[0].blob)};
154  m_events[0].blob.reset();
155  m_events.erase(m_events.begin());
156  fillBuffer();
157  return event;
158  }

◆ peek()

std::optional<std::reference_wrapper<const Event> > Buffer::peek ( ) const
inline

Definition at line 148 of file trigbs_orderedMerge.cxx.

148  {
149  if (m_events.empty()) {return std::nullopt;}
150  return m_events.at(0);
151  }

◆ reader()

const EventStorage::DataReader& Buffer::reader ( ) const
inline

Definition at line 162 of file trigbs_orderedMerge.cxx.

162  {
163  return *m_reader;
164  }

◆ sort()

void Buffer::sort ( )
inlineprivate

Definition at line 119 of file trigbs_orderedMerge.cxx.

119  {
120  std::sort(m_events.begin(), m_events.end(), [](const Event& a, const Event& b){
121  return a.frag.global_id() < b.frag.global_id();
122  });
123  }

Member Data Documentation

◆ m_events

std::vector<Event> Buffer::m_events
private

Definition at line 118 of file trigbs_orderedMerge.cxx.

◆ m_reader

std::unique_ptr<EventStorage::DataReader> Buffer::m_reader
private

Definition at line 116 of file trigbs_orderedMerge.cxx.

◆ m_size

size_t Buffer::m_size {0}
private

Definition at line 117 of file trigbs_orderedMerge.cxx.


The documentation for this class was generated from the following file:
xAOD::uint32_t
setEventNumber uint32_t
Definition: EventInfo_v1.cxx:127
Event
Definition: trigbs_orderedMerge.cxx:42
Buffer::sort
void sort()
Definition: trigbs_orderedMerge.cxx:119
Buffer::m_reader
std::unique_ptr< EventStorage::DataReader > m_reader
Definition: trigbs_orderedMerge.cxx:116
python.setupRTTAlg.size
int size
Definition: setupRTTAlg.py:39
event
POOL::TEvent event(POOL::TEvent::kClassAccess)
Buffer::m_size
size_t m_size
Definition: trigbs_orderedMerge.cxx:117
Buffer::reader
const EventStorage::DataReader & reader() const
Definition: trigbs_orderedMerge.cxx:162
plotBeamSpotMon.b
b
Definition: plotBeamSpotMon.py:77
Buffer::fillBuffer
EventStorage::DRError fillBuffer()
Definition: trigbs_orderedMerge.cxx:124
a
TList * a
Definition: liststreamerinfos.cxx:10
std::sort
void sort(typename std::reverse_iterator< DataModel_detail::iterator< DVL > > beg, typename std::reverse_iterator< DataModel_detail::iterator< DVL > > end, const Compare &comp)
Specialization of sort for DataVector/List.
Definition: DVL_algorithms.h:623
Buffer::m_events
std::vector< Event > m_events
Definition: trigbs_orderedMerge.cxx:118
CaloCondBlobAlgs_fillNoiseFromASCII.blob
blob
Definition: CaloCondBlobAlgs_fillNoiseFromASCII.py:96