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 201 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 220 of file FedRawDataInputSource.h.

230  : parent_(parent),
231  status_(status),
232  lumi_(lumi),
233  fileName_(name),
234  deleteFile_(deleteFile),
235  rawFd_(rawFd),
236  fileSize_(fileSize),
237  rawHeaderSize_(rawHeaderSize),
238  nChunks_(nChunks),
239  nEvents_(nEvents),
240  nProcessed_(0) {
241  for (unsigned int i = 0; i < nChunks; i++)
242  chunks_.push_back(nullptr);
243  }

References chunks_, and mps_fire::i.

◆ ~InputFile()

InputFile::~InputFile ( )

Definition at line 1378 of file FedRawDataInputSource.cc.

1378  {
1379  if (rawFd_ != -1)
1380  close(rawFd_);
1381 
1382  if (deleteFile_ && !fileName_.empty()) {
1384  try {
1385  //sometimes this fails but file gets deleted
1386  LogDebug("FedRawDataInputSource:InputFile") << "Deleting input file -:" << fileName_;
1388  return;
1389  } catch (const boost::filesystem::filesystem_error& ex) {
1390  edm::LogError("FedRawDataInputSource:InputFile")
1391  << " - deleteFile BOOST FILESYSTEM ERROR CAUGHT -: " << ex.what() << ". Trying again.";
1392  } catch (std::exception& ex) {
1393  edm::LogError("FedRawDataInputSource:InputFile")
1394  << " - deleteFile std::exception CAUGHT -: " << ex.what() << ". Trying again.";
1395  }
1397  }
1398 }

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 246 of file FedRawDataInputSource.h.

246 : fileName_(name) {}

Member Function Documentation

◆ advance()

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

Definition at line 1329 of file FedRawDataInputSource.cc.

1329  {
1330  //wait for chunk
1331  while (!waitForChunk(currentChunk_)) {
1332  usleep(100000);
1333  if (parent_->exceptionState())
1334  parent_->threadError();
1335  }
1336 
1337  dataPosition = chunks_[currentChunk_]->buf_ + chunkPosition_;
1338  size_t currentLeft = chunks_[currentChunk_]->size_ - chunkPosition_;
1339 
1340  if (currentLeft < size) {
1341  //we need next chunk
1342  while (!waitForChunk(currentChunk_ + 1)) {
1343  usleep(100000);
1344  if (parent_->exceptionState())
1345  parent_->threadError();
1346  }
1347  //copy everything to beginning of the first chunk
1348  dataPosition -= chunkPosition_;
1349  assert(dataPosition == chunks_[currentChunk_]->buf_);
1350  memmove(chunks_[currentChunk_]->buf_, chunks_[currentChunk_]->buf_ + chunkPosition_, currentLeft);
1351  memcpy(chunks_[currentChunk_]->buf_ + currentLeft, chunks_[currentChunk_ + 1]->buf_, size - currentLeft);
1352  //set pointers at the end of the old data position
1353  bufferPosition_ += size;
1354  chunkPosition_ = size - currentLeft;
1355  currentChunk_++;
1356  return true;
1357  } else {
1358  chunkPosition_ += size;
1359  bufferPosition_ += size;
1360  return false;
1361  }
1362 }

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

◆ moveToPreviousChunk()

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

Definition at line 1364 of file FedRawDataInputSource.cc.

1364  {
1365  //this will fail in case of events that are too large
1367  assert(size - offset < chunks_[currentChunk_]->size_);
1368  memcpy(chunks_[currentChunk_ - 1]->buf_ + offset, chunks_[currentChunk_]->buf_ + chunkPosition_, size);
1369  chunkPosition_ += size;
1370  bufferPosition_ += size;
1371 }

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 1373 of file FedRawDataInputSource.cc.

1373  {
1374  chunkPosition_ -= size;
1375  bufferPosition_ -= size;
1376 }

References bufferPosition_, chunkPosition_, and findQualityFiles::size.

◆ waitForChunk()

bool InputFile::waitForChunk ( unsigned int  chunkid)
inline

Definition at line 248 of file FedRawDataInputSource.h.

248  {
249  //some atomics to make sure everything is cache synchronized for the main thread
250  return chunks_[chunkid] != nullptr && chunks_[chunkid]->readComplete_;
251  }

References chunks_.

Referenced by advance().

Member Data Documentation

◆ bufferPosition_

uint32_t InputFile::bufferPosition_ = 0

Definition at line 216 of file FedRawDataInputSource.h.

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

◆ chunkPosition_

uint32_t InputFile::chunkPosition_ = 0

Definition at line 217 of file FedRawDataInputSource.h.

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

◆ chunks_

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

Definition at line 214 of file FedRawDataInputSource.h.

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

◆ currentChunk_

unsigned int InputFile::currentChunk_ = 0

Definition at line 218 of file FedRawDataInputSource.h.

Referenced by advance(), and moveToPreviousChunk().

◆ deleteFile_

bool InputFile::deleteFile_

Definition at line 206 of file FedRawDataInputSource.h.

Referenced by ~InputFile().

◆ fileName_

std::string InputFile::fileName_

Definition at line 205 of file FedRawDataInputSource.h.

Referenced by ~InputFile().

◆ fileSize_

uint64_t InputFile::fileSize_

Definition at line 208 of file FedRawDataInputSource.h.

◆ lumi_

unsigned int InputFile::lumi_

Definition at line 204 of file FedRawDataInputSource.h.

◆ nChunks_

uint32_t InputFile::nChunks_

Definition at line 210 of file FedRawDataInputSource.h.

◆ nEvents_

int InputFile::nEvents_

Definition at line 211 of file FedRawDataInputSource.h.

◆ nProcessed_

unsigned int InputFile::nProcessed_

Definition at line 212 of file FedRawDataInputSource.h.

◆ parent_

FedRawDataInputSource* InputFile::parent_

Definition at line 202 of file FedRawDataInputSource.h.

Referenced by advance().

◆ rawFd_

int InputFile::rawFd_

Definition at line 207 of file FedRawDataInputSource.h.

Referenced by ~InputFile().

◆ rawHeaderSize_

uint16_t InputFile::rawHeaderSize_

Definition at line 209 of file FedRawDataInputSource.h.

◆ status_

evf::EvFDaqDirector::FileStatus InputFile::status_

Definition at line 203 of file FedRawDataInputSource.h.

mps_fire.i
i
Definition: mps_fire.py:355
InputFile::parent_
FedRawDataInputSource * parent_
Definition: FedRawDataInputSource.h:202
InputFile::fileName_
std::string fileName_
Definition: FedRawDataInputSource.h:205
FedRawDataInputSource::threadError
void threadError()
Definition: FedRawDataInputSource.cc:1324
mps_update.status
status
Definition: mps_update.py:69
InputFile::fileSize_
uint64_t fileSize_
Definition: FedRawDataInputSource.h:208
cms::cuda::assert
assert(be >=bs)
InputFile::nEvents_
int nEvents_
Definition: FedRawDataInputSource.h:211
InputFile::rawHeaderSize_
uint16_t rawHeaderSize_
Definition: FedRawDataInputSource.h:209
InputFile::lumi_
unsigned int lumi_
Definition: FedRawDataInputSource.h:204
InputFile::bufferPosition_
uint32_t bufferPosition_
Definition: FedRawDataInputSource.h:216
InputFile::chunkPosition_
uint32_t chunkPosition_
Definition: FedRawDataInputSource.h:217
InputFile::currentChunk_
unsigned int currentChunk_
Definition: FedRawDataInputSource.h:218
dt4ml_dqm_sourceclient-live_cfg.filePath
filePath
CUSTOMIZE FOR ML.
Definition: dt4ml_dqm_sourceclient-live_cfg.py:39
FedRawDataInputSource::exceptionState
bool exceptionState()
Definition: FedRawDataInputSource.h:62
cppFunctionSkipper.exception
exception
Definition: cppFunctionSkipper.py:10
LogDebug
#define LogDebug(id)
Definition: MessageLogger.h:670
edm::LogError
Definition: MessageLogger.h:183
InputFile::rawFd_
int rawFd_
Definition: FedRawDataInputSource.h:207
InputFile::nProcessed_
unsigned int nProcessed_
Definition: FedRawDataInputSource.h:212
InputFile::chunks_
tbb::concurrent_vector< InputChunk * > chunks_
Definition: FedRawDataInputSource.h:214
MatrixUtil.remove
def remove(d, key, TELL=False)
Definition: MatrixUtil.py:212
Skims_PA_cff.name
name
Definition: Skims_PA_cff.py:17
InputFile::status_
evf::EvFDaqDirector::FileStatus status_
Definition: FedRawDataInputSource.h:203
InputFile::nChunks_
uint32_t nChunks_
Definition: FedRawDataInputSource.h:210
castor_dqm_sourceclient_file_cfg.path
path
Definition: castor_dqm_sourceclient_file_cfg.py:37
nEvents
UInt_t nEvents
Definition: hcalCalib.cc:41
hltrates_dqm_sourceclient-live_cfg.offset
offset
Definition: hltrates_dqm_sourceclient-live_cfg.py:78
InputFile::waitForChunk
bool waitForChunk(unsigned int chunkid)
Definition: FedRawDataInputSource.h:248
lumi
Definition: LumiSectionData.h:20
InputFile::deleteFile_
bool deleteFile_
Definition: FedRawDataInputSource.h:206
class-composition.parent
parent
Definition: class-composition.py:88
findQualityFiles.size
size
Write out results.
Definition: findQualityFiles.py:443