CMS 3D CMS Logo

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() [1/2]

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.

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  }

References chunks_, and mps_fire::i.

◆ ~InputFile()

InputFile::~InputFile ( )

Definition at line 1426 of file FedRawDataInputSource.cc.

1426  {
1427  if (rawFd_ != -1)
1428  close(rawFd_);
1429 
1430  if (deleteFile_ && !fileName_.empty()) {
1432  try {
1433  //sometimes this fails but file gets deleted
1434  LogDebug("FedRawDataInputSource:InputFile") << "Deleting input file -:" << fileName_;
1436  return;
1437  } catch (const std::filesystem::filesystem_error& ex) {
1438  edm::LogError("FedRawDataInputSource:InputFile")
1439  << " - deleteFile BOOST FILESYSTEM ERROR CAUGHT -: " << ex.what() << ". Trying again.";
1440  } catch (std::exception& ex) {
1441  edm::LogError("FedRawDataInputSource:InputFile")
1442  << " - deleteFile std::exception CAUGHT -: " << ex.what() << ". Trying again.";
1443  }
1445  }
1446 }

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

◆ InputFile() [2/2]

InputFile::InputFile ( std::string &  name)
inline

Definition at line 256 of file FedRawDataInputSource.h.

256 : fileName_(name) {}

Member Function Documentation

◆ advance()

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

Definition at line 1372 of file FedRawDataInputSource.cc.

1372  {
1373  //wait for chunk
1374 
1375  while (!waitForChunk(currentChunk_)) {
1377  usleep(100000);
1379  if (parent_->exceptionState())
1380  parent_->threadError();
1381  }
1382 
1383  dataPosition = chunks_[currentChunk_]->buf_ + chunkPosition_;
1384  size_t currentLeft = chunks_[currentChunk_]->size_ - chunkPosition_;
1385 
1386  if (currentLeft < size) {
1387  //we need next chunk
1388  while (!waitForChunk(currentChunk_ + 1)) {
1390  usleep(100000);
1392  if (parent_->exceptionState())
1393  parent_->threadError();
1394  }
1395  //copy everything to beginning of the first chunk
1396  dataPosition -= chunkPosition_;
1397  assert(dataPosition == chunks_[currentChunk_]->buf_);
1398  memmove(chunks_[currentChunk_]->buf_, chunks_[currentChunk_]->buf_ + chunkPosition_, currentLeft);
1399  memcpy(chunks_[currentChunk_]->buf_ + currentLeft, chunks_[currentChunk_ + 1]->buf_, size - currentLeft);
1400  //set pointers at the end of the old data position
1401  bufferPosition_ += size;
1402  chunkPosition_ = size - currentLeft;
1403  currentChunk_++;
1404  return true;
1405  } else {
1406  chunkPosition_ += size;
1407  bufferPosition_ += size;
1408  return false;
1409  }
1410 }

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().

◆ moveToPreviousChunk()

void InputFile::moveToPreviousChunk ( const size_t  size,
const size_t  offset 
)
inline

Definition at line 1412 of file FedRawDataInputSource.cc.

1412  {
1413  //this will fail in case of events that are too large
1415  assert(size - offset < chunks_[currentChunk_]->size_);
1416  memcpy(chunks_[currentChunk_ - 1]->buf_ + offset, chunks_[currentChunk_]->buf_ + chunkPosition_, size);
1417  chunkPosition_ += size;
1418  bufferPosition_ += size;
1419 }

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

◆ rewindChunk()

void InputFile::rewindChunk ( const size_t  size)
inline

Definition at line 1421 of file FedRawDataInputSource.cc.

1421  {
1422  chunkPosition_ -= size;
1423  bufferPosition_ -= size;
1424 }

References bufferPosition_, chunkPosition_, and findQualityFiles::size.

◆ waitForChunk()

bool InputFile::waitForChunk ( unsigned int  chunkid)
inline

Definition at line 258 of file FedRawDataInputSource.h.

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

References chunks_.

Referenced by advance().

Member Data Documentation

◆ bufferPosition_

uint32_t InputFile::bufferPosition_ = 0

Definition at line 226 of file FedRawDataInputSource.h.

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

◆ chunkPosition_

uint32_t InputFile::chunkPosition_ = 0

Definition at line 227 of file FedRawDataInputSource.h.

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

◆ chunks_

tbb::concurrent_vector<InputChunk*> InputFile::chunks_

Definition at line 224 of file FedRawDataInputSource.h.

Referenced by advance(), InputFile(), moveToPreviousChunk(), and waitForChunk().

◆ currentChunk_

unsigned int InputFile::currentChunk_ = 0

Definition at line 228 of file FedRawDataInputSource.h.

Referenced by advance(), and moveToPreviousChunk().

◆ deleteFile_

bool InputFile::deleteFile_

Definition at line 216 of file FedRawDataInputSource.h.

Referenced by ~InputFile().

◆ fileName_

std::string InputFile::fileName_

Definition at line 215 of file FedRawDataInputSource.h.

Referenced by ~InputFile().

◆ fileSize_

uint64_t InputFile::fileSize_

Definition at line 218 of file FedRawDataInputSource.h.

◆ lumi_

unsigned int InputFile::lumi_

Definition at line 214 of file FedRawDataInputSource.h.

◆ nChunks_

uint32_t InputFile::nChunks_

Definition at line 220 of file FedRawDataInputSource.h.

◆ nEvents_

int InputFile::nEvents_

Definition at line 221 of file FedRawDataInputSource.h.

◆ nProcessed_

unsigned int InputFile::nProcessed_

Definition at line 222 of file FedRawDataInputSource.h.

◆ parent_

FedRawDataInputSource* InputFile::parent_

Definition at line 212 of file FedRawDataInputSource.h.

Referenced by advance().

◆ rawFd_

int InputFile::rawFd_

Definition at line 217 of file FedRawDataInputSource.h.

Referenced by ~InputFile().

◆ rawHeaderSize_

uint16_t InputFile::rawHeaderSize_

Definition at line 219 of file FedRawDataInputSource.h.

◆ status_

evf::EvFDaqDirector::FileStatus InputFile::status_

Definition at line 213 of file FedRawDataInputSource.h.

mps_fire.i
i
Definition: mps_fire.py:428
InputFile::parent_
FedRawDataInputSource * parent_
Definition: FedRawDataInputSource.h:212
InputFile::fileName_
std::string fileName_
Definition: FedRawDataInputSource.h:215
evf::FastMonState::inWaitChunk
Definition: FastMonitoringService.h:92
FedRawDataInputSource::setMonState
void setMonState(evf::FastMonState::InputState state)
Definition: FedRawDataInputSource.cc:1362
evf::FastMonState::inChunkReceived
Definition: FastMonitoringService.h:93
FedRawDataInputSource::threadError
void threadError()
Definition: FedRawDataInputSource.cc:1357
mps_update.status
status
Definition: mps_update.py:68
InputFile::fileSize_
uint64_t fileSize_
Definition: FedRawDataInputSource.h:218
cms::cuda::assert
assert(be >=bs)
InputFile::nEvents_
int nEvents_
Definition: FedRawDataInputSource.h:221
InputFile::rawHeaderSize_
uint16_t rawHeaderSize_
Definition: FedRawDataInputSource.h:219
InputFile::lumi_
unsigned int lumi_
Definition: FedRawDataInputSource.h:214
InputFile::bufferPosition_
uint32_t bufferPosition_
Definition: FedRawDataInputSource.h:226
InputFile::chunkPosition_
uint32_t chunkPosition_
Definition: FedRawDataInputSource.h:227
InputFile::currentChunk_
unsigned int currentChunk_
Definition: FedRawDataInputSource.h:228
dt4ml_dqm_sourceclient-live_cfg.filePath
filePath
CUSTOMIZE FOR ML.
Definition: dt4ml_dqm_sourceclient-live_cfg.py:45
FedRawDataInputSource::exceptionState
bool exceptionState()
Definition: FedRawDataInputSource.h:68
cppFunctionSkipper.exception
exception
Definition: cppFunctionSkipper.py:10
LogDebug
#define LogDebug(id)
Definition: MessageLogger.h:233
edm::LogError
Log< level::Error, false > LogError
Definition: MessageLogger.h:123
InputFile::rawFd_
int rawFd_
Definition: FedRawDataInputSource.h:217
InputFile::nProcessed_
unsigned int nProcessed_
Definition: FedRawDataInputSource.h:222
InputFile::chunks_
tbb::concurrent_vector< InputChunk * > chunks_
Definition: FedRawDataInputSource.h:224
MatrixUtil.remove
def remove(d, key, TELL=False)
Definition: MatrixUtil.py:219
Skims_PA_cff.name
name
Definition: Skims_PA_cff.py:17
InputFile::status_
evf::EvFDaqDirector::FileStatus status_
Definition: FedRawDataInputSource.h:213
InputFile::nChunks_
uint32_t nChunks_
Definition: FedRawDataInputSource.h:220
castor_dqm_sourceclient_file_cfg.path
path
Definition: castor_dqm_sourceclient_file_cfg.py:37
nEvents
UInt_t nEvents
Definition: hcalCalib.cc:40
hltrates_dqm_sourceclient-live_cfg.offset
offset
Definition: hltrates_dqm_sourceclient-live_cfg.py:82
InputFile::waitForChunk
bool waitForChunk(unsigned int chunkid)
Definition: FedRawDataInputSource.h:258
lumi
Definition: LumiSectionData.h:20
InputFile::deleteFile_
bool deleteFile_
Definition: FedRawDataInputSource.h:216
class-composition.parent
parent
Definition: class-composition.py:98
findQualityFiles.size
size
Write out results.
Definition: findQualityFiles.py:443