CMS 3D CMS Logo

List of all members | Public Member Functions | Private Attributes
evf::GlobalEvFOutputEventWriter Class Reference

Public Member Functions

bool close ()
 
void discardedCheck ()
 
void doOutputEvent (EventMsgBuilder const &msg)
 
void doOutputEventAsync (std::unique_ptr< EventMsgBuilder > msg, edm::WaitingTaskHolder iHolder)
 
uint32 get_adler32 () const
 
unsigned long getAccepted () const
 
std::string const & getFilePath () const
 
 GlobalEvFOutputEventWriter (std::string const &filePath, unsigned int ls)
 
void incAccepted ()
 
edm::SerialTaskQueuequeue ()
 
void throttledCheck ()
 
 ~GlobalEvFOutputEventWriter ()
 

Private Attributes

std::atomic< unsigned long > accepted_
 
bool discarded_ = false
 
std::string filePath_
 
const unsigned ls_
 
edm::propagate_const< std::unique_ptr< StreamerOutputFile > > stream_writer_events_
 
edm::SerialTaskQueue writeQueue_
 

Detailed Description

Definition at line 44 of file GlobalEvFOutputModule.cc.

Constructor & Destructor Documentation

◆ GlobalEvFOutputEventWriter()

evf::GlobalEvFOutputEventWriter::GlobalEvFOutputEventWriter ( std::string const &  filePath,
unsigned int  ls 
)
inlineexplicit

Definition at line 46 of file GlobalEvFOutputModule.cc.

◆ ~GlobalEvFOutputEventWriter()

evf::GlobalEvFOutputEventWriter::~GlobalEvFOutputEventWriter ( )
inline

Definition at line 49 of file GlobalEvFOutputModule.cc.

49 {}

Member Function Documentation

◆ close()

bool evf::GlobalEvFOutputEventWriter::close ( void  )
inline

Definition at line 51 of file GlobalEvFOutputModule.cc.

References discarded_, ls_, and stream_writer_events_.

Referenced by esMonitoring.AsyncLineReaderMixin::handle_close(), and esMonitoring.FDJsonServer::handle_close().

51  {
52  stream_writer_events_->close();
53  return (discarded_ || edm::Service<evf::EvFDaqDirector>()->lumisectionDiscarded(ls_));
54  }
edm::propagate_const< std::unique_ptr< StreamerOutputFile > > stream_writer_events_

◆ discardedCheck()

void evf::GlobalEvFOutputEventWriter::discardedCheck ( )
inline

Definition at line 98 of file GlobalEvFOutputModule.cc.

References discarded_, and ls_.

Referenced by doOutputEventAsync().

98  {
99  if (!discarded_ && edm::Service<evf::EvFDaqDirector>()->lumisectionDiscarded(ls_)) {
100  edm::LogWarning("FedRawDataInputSource") << "Detected that the lumisection is discarded -: " << ls_;
101  discarded_ = true;
102  }
103  }
Log< level::Warning, false > LogWarning

◆ doOutputEvent()

void evf::GlobalEvFOutputEventWriter::doOutputEvent ( EventMsgBuilder const &  msg)
inline

Definition at line 56 of file GlobalEvFOutputModule.cc.

References incAccepted(), mps_check::msg, and stream_writer_events_.

Referenced by doOutputEventAsync().

56  {
57  EventMsgView eview(msg.startAddress());
58  stream_writer_events_->write(eview);
59  incAccepted();
60  }
tuple msg
Definition: mps_check.py:286
edm::propagate_const< std::unique_ptr< StreamerOutputFile > > stream_writer_events_

◆ doOutputEventAsync()

void evf::GlobalEvFOutputEventWriter::doOutputEventAsync ( std::unique_ptr< EventMsgBuilder msg,
edm::WaitingTaskHolder  iHolder 
)
inline

Definition at line 62 of file GlobalEvFOutputModule.cc.

References discarded_, discardedCheck(), doOutputEvent(), edm::WaitingTaskHolder::group(), watchdog::group, incAccepted(), eostools::move(), mps_check::msg, edm::SerialTaskQueue::push(), throttledCheck(), createJobs::tmp, and writeQueue_.

62  {
65  if (discarded_) {
66  incAccepted();
67  msg.reset();
68  return;
69  }
70  auto group = iHolder.group();
71  writeQueue_.push(*group, [holder = std::move(iHolder), msg = msg.release(), this]() {
72  try {
73  std::unique_ptr<EventMsgBuilder> own(msg);
74  doOutputEvent(*msg); //msg is written and discarded at this point
75  } catch (...) {
76  auto tmp = holder;
77  tmp.doneWaiting(std::current_exception());
78  }
79  });
80  }
void push(oneapi::tbb::task_group &, const T &iAction)
asynchronously pushes functor iAction into queue
void doOutputEvent(EventMsgBuilder const &msg)
oneapi::tbb::task_group * group() const noexcept
tuple msg
Definition: mps_check.py:286
tmp
align.sh
Definition: createJobs.py:716
def move(src, dest)
Definition: eostools.py:511

◆ get_adler32()

uint32 evf::GlobalEvFOutputEventWriter::get_adler32 ( ) const
inline

Definition at line 105 of file GlobalEvFOutputModule.cc.

References stream_writer_events_.

105 { return stream_writer_events_->adler32(); }
edm::propagate_const< std::unique_ptr< StreamerOutputFile > > stream_writer_events_

◆ getAccepted()

unsigned long evf::GlobalEvFOutputEventWriter::getAccepted ( ) const
inline

Definition at line 109 of file GlobalEvFOutputModule.cc.

References accepted_.

109 { return accepted_; }
std::atomic< unsigned long > accepted_

◆ getFilePath()

std::string const& evf::GlobalEvFOutputEventWriter::getFilePath ( ) const
inline

Definition at line 107 of file GlobalEvFOutputModule.cc.

References filePath_.

◆ incAccepted()

void evf::GlobalEvFOutputEventWriter::incAccepted ( )
inline

Definition at line 110 of file GlobalEvFOutputModule.cc.

References accepted_.

Referenced by doOutputEvent(), and doOutputEventAsync().

110 { accepted_++; }
std::atomic< unsigned long > accepted_

◆ queue()

edm::SerialTaskQueue& evf::GlobalEvFOutputEventWriter::queue ( )
inline

Definition at line 112 of file GlobalEvFOutputModule.cc.

References writeQueue_.

112 { return writeQueue_; }

◆ throttledCheck()

void evf::GlobalEvFOutputEventWriter::throttledCheck ( )
inline

Definition at line 82 of file GlobalEvFOutputModule.cc.

References discarded_, svgfig::load(), ls_, and edm::shutdown_flag.

Referenced by doOutputEventAsync().

82  {
83  unsigned int counter = 0;
84  while (edm::Service<evf::EvFDaqDirector>()->inputThrottled() && !discarded_) {
85  if (edm::shutdown_flag.load(std::memory_order_relaxed))
86  break;
87  if (!(counter % 100))
88  edm::LogWarning("FedRawDataInputSource") << "Input throttled detected, writing is paused...";
89  usleep(100000);
90  counter++;
91  if (edm::Service<evf::EvFDaqDirector>()->lumisectionDiscarded(ls_)) {
92  edm::LogWarning("FedRawDataInputSource") << "Detected that the lumisection is discarded -: " << ls_;
93  discarded_ = true;
94  }
95  }
96  }
volatile std::atomic< bool > shutdown_flag
def load(fileName)
Definition: svgfig.py:547
Log< level::Warning, false > LogWarning

Member Data Documentation

◆ accepted_

std::atomic<unsigned long> evf::GlobalEvFOutputEventWriter::accepted_
private

Definition at line 117 of file GlobalEvFOutputModule.cc.

Referenced by getAccepted(), and incAccepted().

◆ discarded_

bool evf::GlobalEvFOutputEventWriter::discarded_ = false
private

◆ filePath_

std::string evf::GlobalEvFOutputEventWriter::filePath_
private

Definition at line 115 of file GlobalEvFOutputModule.cc.

Referenced by getFilePath().

◆ ls_

const unsigned evf::GlobalEvFOutputEventWriter::ls_
private

Definition at line 116 of file GlobalEvFOutputModule.cc.

Referenced by close(), discardedCheck(), and throttledCheck().

◆ stream_writer_events_

edm::propagate_const<std::unique_ptr<StreamerOutputFile> > evf::GlobalEvFOutputEventWriter::stream_writer_events_
private

Definition at line 118 of file GlobalEvFOutputModule.cc.

Referenced by close(), doOutputEvent(), and get_adler32().

◆ writeQueue_

edm::SerialTaskQueue evf::GlobalEvFOutputEventWriter::writeQueue_
private

Definition at line 119 of file GlobalEvFOutputModule.cc.

Referenced by doOutputEventAsync(), and queue().