CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
List of all members | Public Member Functions | Public Attributes
InputFile Struct Reference

#include <FedRawDataInputSource.h>

Public Member Functions

bool advance (unsigned char *&dataPosition, const size_t size)
 
 InputFile (evf::EvFDaqDirector::FileStatus status, unsigned int lumi=0, std::string const &name=std::string(), bool deleteFile=true, int rawFd=-1, uint64_t fileSize=0, uint16_t rawHeaderSize=0, uint32_t nChunks=0, int nEvents=0, FedRawDataInputSource *parent=nullptr)
 
 InputFile (std::string &name)
 
void moveToPreviousChunk (const size_t size, const size_t offset)
 
void rewindChunk (const size_t size)
 
bool waitForChunk (unsigned int chunkid)
 
 ~InputFile ()
 

Public Attributes

uint32_t bufferPosition_ = 0
 
uint32_t chunkPosition_ = 0
 
tbb::concurrent_vector
< InputChunk * > 
chunks_
 
unsigned int currentChunk_ = 0
 
bool deleteFile_
 
std::string fileName_
 
uint64_t fileSize_
 
unsigned int lumi_
 
uint32_t nChunks_
 
int nEvents_
 
unsigned int nProcessed_
 
FedRawDataInputSourceparent_
 
int rawFd_
 
uint16_t rawHeaderSize_
 
evf::EvFDaqDirector::FileStatus status_
 

Detailed Description

Definition at line 211 of file FedRawDataInputSource.h.

Constructor & Destructor Documentation

InputFile::InputFile ( evf::EvFDaqDirector::FileStatus  status,
unsigned int  lumi = 0,
std::string const &  name = std::string(),
bool  deleteFile = true,
int  rawFd = -1,
uint64_t  fileSize = 0,
uint16_t  rawHeaderSize = 0,
uint32_t  nChunks = 0,
int  nEvents = 0,
FedRawDataInputSource parent = nullptr 
)
inline

Definition at line 230 of file FedRawDataInputSource.h.

References chunks_, and mps_fire::i.

240  : parent_(parent),
241  status_(status),
242  lumi_(lumi),
243  fileName_(name),
244  deleteFile_(deleteFile),
245  rawFd_(rawFd),
246  fileSize_(fileSize),
247  rawHeaderSize_(rawHeaderSize),
248  nChunks_(nChunks),
249  nEvents_(nEvents),
250  nProcessed_(0) {
251  for (unsigned int i = 0; i < nChunks; i++)
252  chunks_.push_back(nullptr);
253  }
unsigned int lumi_
list status
Definition: mps_update.py:107
evf::EvFDaqDirector::FileStatus status_
uint16_t rawHeaderSize_
FedRawDataInputSource * parent_
list lumi
Definition: dqmdumpme.py:53
unsigned int nProcessed_
std::string fileName_
tbb::concurrent_vector< InputChunk * > chunks_
InputFile::~InputFile ( )

Definition at line 1438 of file FedRawDataInputSource.cc.

References deleteFile_, cppFunctionSkipper::exception, fileName_, dt4ml_dqm_sourceclient-live_cfg::filePath, LogDebug, fed_dqm_sourceclient-live_cfg::path, rawFd_, and MatrixUtil::remove().

1438  {
1439  if (rawFd_ != -1)
1440  close(rawFd_);
1441 
1442  if (deleteFile_ && !fileName_.empty()) {
1444  try {
1445  //sometimes this fails but file gets deleted
1446  LogDebug("FedRawDataInputSource:InputFile") << "Deleting input file -:" << fileName_;
1448  return;
1449  } catch (const std::filesystem::filesystem_error& ex) {
1450  edm::LogError("FedRawDataInputSource:InputFile")
1451  << " - deleteFile BOOST FILESYSTEM ERROR CAUGHT -: " << ex.what() << ". Trying again.";
1452  } catch (std::exception& ex) {
1453  edm::LogError("FedRawDataInputSource:InputFile")
1454  << " - deleteFile std::exception CAUGHT -: " << ex.what() << ". Trying again.";
1455  }
1457  }
1458 }
Log< level::Error, false > LogError
std::string fileName_
#define LogDebug(id)
InputFile::InputFile ( std::string &  name)
inline

Definition at line 256 of file FedRawDataInputSource.h.

Member Function Documentation

bool InputFile::advance ( unsigned char *&  dataPosition,
const size_t  size 
)
inline

Definition at line 1384 of file FedRawDataInputSource.cc.

References cms::cuda::assert(), bufferPosition_, chunkPosition_, chunks_, currentChunk_, FedRawDataInputSource::exceptionState(), evf::FastMonState::inChunkReceived, evf::FastMonState::inWaitChunk, parent_, FedRawDataInputSource::setMonState(), findQualityFiles::size, FedRawDataInputSource::threadError(), and waitForChunk().

1384  {
1385  //wait for chunk
1386 
1387  while (!waitForChunk(currentChunk_)) {
1389  usleep(100000);
1391  if (parent_->exceptionState())
1392  parent_->threadError();
1393  }
1394 
1395  dataPosition = chunks_[currentChunk_]->buf_ + chunkPosition_;
1396  size_t currentLeft = chunks_[currentChunk_]->size_ - chunkPosition_;
1397 
1398  if (currentLeft < size) {
1399  //we need next chunk
1400  while (!waitForChunk(currentChunk_ + 1)) {
1402  usleep(100000);
1404  if (parent_->exceptionState())
1405  parent_->threadError();
1406  }
1407  //copy everything to beginning of the first chunk
1408  dataPosition -= chunkPosition_;
1409  assert(dataPosition == chunks_[currentChunk_]->buf_);
1410  memmove(chunks_[currentChunk_]->buf_, chunks_[currentChunk_]->buf_ + chunkPosition_, currentLeft);
1411  memcpy(chunks_[currentChunk_]->buf_ + currentLeft, chunks_[currentChunk_ + 1]->buf_, size - currentLeft);
1412  //set pointers at the end of the old data position
1413  bufferPosition_ += size;
1414  chunkPosition_ = size - currentLeft;
1415  currentChunk_++;
1416  return true;
1417  } else {
1418  chunkPosition_ += size;
1419  bufferPosition_ += size;
1420  return false;
1421  }
1422 }
uint32_t chunkPosition_
assert(be >=bs)
FedRawDataInputSource * parent_
uint32_t bufferPosition_
bool waitForChunk(unsigned int chunkid)
void setMonState(evf::FastMonState::InputState state)
unsigned int currentChunk_
tbb::concurrent_vector< InputChunk * > chunks_
tuple size
Write out results.
void InputFile::moveToPreviousChunk ( const size_t  size,
const size_t  offset 
)
inline

Definition at line 1424 of file FedRawDataInputSource.cc.

References cms::cuda::assert(), bufferPosition_, chunkPosition_, chunks_, currentChunk_, and findQualityFiles::size.

1424  {
1425  //this will fail in case of events that are too large
1427  assert(size - offset < chunks_[currentChunk_]->size_);
1428  memcpy(chunks_[currentChunk_ - 1]->buf_ + offset, chunks_[currentChunk_]->buf_ + chunkPosition_, size);
1429  chunkPosition_ += size;
1430  bufferPosition_ += size;
1431 }
uint32_t chunkPosition_
assert(be >=bs)
uint32_t bufferPosition_
unsigned int currentChunk_
tbb::concurrent_vector< InputChunk * > chunks_
tuple size
Write out results.
void InputFile::rewindChunk ( const size_t  size)
inline

Definition at line 1433 of file FedRawDataInputSource.cc.

References bufferPosition_, chunkPosition_, and findQualityFiles::size.

1433  {
1434  chunkPosition_ -= size;
1435  bufferPosition_ -= size;
1436 }
uint32_t chunkPosition_
uint32_t bufferPosition_
tuple size
Write out results.
bool InputFile::waitForChunk ( unsigned int  chunkid)
inline

Definition at line 258 of file FedRawDataInputSource.h.

References chunks_.

Referenced by advance().

258  {
259  //some atomics to make sure everything is cache synchronized for the main thread
260  return chunks_[chunkid] != nullptr && chunks_[chunkid]->readComplete_;
261  }
tbb::concurrent_vector< InputChunk * > chunks_

Member Data Documentation

uint32_t InputFile::bufferPosition_ = 0

Definition at line 226 of file FedRawDataInputSource.h.

Referenced by advance(), moveToPreviousChunk(), and rewindChunk().

uint32_t InputFile::chunkPosition_ = 0
tbb::concurrent_vector<InputChunk*> InputFile::chunks_
unsigned int InputFile::currentChunk_ = 0

Definition at line 228 of file FedRawDataInputSource.h.

Referenced by advance(), and moveToPreviousChunk().

bool InputFile::deleteFile_

Definition at line 216 of file FedRawDataInputSource.h.

Referenced by ~InputFile().

std::string InputFile::fileName_
uint64_t InputFile::fileSize_
unsigned int InputFile::lumi_

Definition at line 214 of file FedRawDataInputSource.h.

uint32_t InputFile::nChunks_

Definition at line 220 of file FedRawDataInputSource.h.

int InputFile::nEvents_

Definition at line 221 of file FedRawDataInputSource.h.

unsigned int InputFile::nProcessed_

Definition at line 222 of file FedRawDataInputSource.h.

FedRawDataInputSource* InputFile::parent_

Definition at line 212 of file FedRawDataInputSource.h.

Referenced by advance().

int InputFile::rawFd_
uint16_t InputFile::rawHeaderSize_
evf::EvFDaqDirector::FileStatus InputFile::status_

Definition at line 213 of file FedRawDataInputSource.h.