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(), uint32_t fileSize=0, uint32_t nChunks=0, int nEvents=0, FedRawDataInputSource *parent=0)
 
 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)
 

Public Attributes

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

Detailed Description

Definition at line 209 of file FedRawDataInputSource.h.

Constructor & Destructor Documentation

InputFile::InputFile ( evf::EvFDaqDirector::FileStatus  status,
unsigned int  lumi = 0,
std::string const &  name = std::string(),
uint32_t  fileSize = 0,
uint32_t  nChunks = 0,
int  nEvents = 0,
FedRawDataInputSource parent = 0 
)
inline

Definition at line 225 of file FedRawDataInputSource.h.

References mps_fire::i.

226  :
227  parent_(parent),
228  status_(status),
229  lumi_(lumi),
230  fileName_(name),
231  fileSize_(fileSize),
232  nChunks_(nChunks),
233  nEvents_(nEvents),
234  nProcessed_(0)
235  {
236  for (unsigned int i=0;i<nChunks;i++)
237  chunks_.push_back(nullptr);
238  }
unsigned int lumi_
evf::EvFDaqDirector::FileStatus status_
FedRawDataInputSource * parent_
unsigned int nProcessed_
std::string fileName_
tbb::concurrent_vector< InputChunk * > chunks_
UInt_t nEvents
Definition: hcalCalib.cc:42
InputFile::InputFile ( std::string &  name)
inline

Definition at line 240 of file FedRawDataInputSource.h.

240 :fileName_(name) {}
std::string fileName_

Member Function Documentation

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

Definition at line 1275 of file FedRawDataInputSource.cc.

References findQualityFiles::size.

Referenced by FedRawDataInputSource::getNextEvent().

1276 {
1277  //wait for chunk
1278  while (!waitForChunk(currentChunk_)) {
1279  usleep(100000);
1281  }
1282 
1283  dataPosition = chunks_[currentChunk_]->buf_+ chunkPosition_;
1284  size_t currentLeft = chunks_[currentChunk_]->size_ - chunkPosition_;
1285 
1286  if (currentLeft < size) {
1287 
1288  //we need next chunk
1289  while (!waitForChunk(currentChunk_+1)) {
1290  usleep(100000);
1292  }
1293  //copy everything to beginning of the first chunk
1294  dataPosition-=chunkPosition_;
1295  assert(dataPosition==chunks_[currentChunk_]->buf_);
1296  memmove(chunks_[currentChunk_]->buf_, chunks_[currentChunk_]->buf_+chunkPosition_, currentLeft);
1297  memcpy(chunks_[currentChunk_]->buf_ + currentLeft, chunks_[currentChunk_+1]->buf_, size - currentLeft);
1298  //set pointers at the end of the old data position
1300  chunkPosition_=size-currentLeft;
1301  currentChunk_++;
1302  return true;
1303  }
1304  else {
1307  return false;
1308  }
1309 }
size
Write out results.
uint32_t chunkPosition_
FedRawDataInputSource * parent_
uint32_t bufferPosition_
bool waitForChunk(unsigned int chunkid)
unsigned int currentChunk_
tbb::concurrent_vector< InputChunk * > chunks_
void InputFile::moveToPreviousChunk ( const size_t  size,
const size_t  offset 
)
inline

Definition at line 1311 of file FedRawDataInputSource.cc.

References findQualityFiles::size.

Referenced by FedRawDataInputSource::getNextEvent().

1312 {
1313  //this will fail in case of events that are too large
1314  assert(size < chunks_[currentChunk_]->size_ - chunkPosition_);
1315  assert(size - offset < chunks_[currentChunk_]->size_);
1319 }
size
Write out results.
uint32_t chunkPosition_
uint32_t bufferPosition_
unsigned int currentChunk_
tbb::concurrent_vector< InputChunk * > chunks_
void InputFile::rewindChunk ( const size_t  size)
inline

Definition at line 1321 of file FedRawDataInputSource.cc.

References findQualityFiles::size.

Referenced by FedRawDataInputSource::getNextEvent().

1321  {
1324 }
size
Write out results.
uint32_t chunkPosition_
uint32_t bufferPosition_
bool InputFile::waitForChunk ( unsigned int  chunkid)
inline

Definition at line 242 of file FedRawDataInputSource.h.

References PFRecoTauDiscriminationByIsolation_cfi::offset, and findQualityFiles::size.

Referenced by FedRawDataInputSource::getNextEvent().

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

Member Data Documentation

uint32_t InputFile::bufferPosition_ = 0

Definition at line 221 of file FedRawDataInputSource.h.

Referenced by FedRawDataInputSource::getNextEvent().

uint32_t InputFile::chunkPosition_ = 0
tbb::concurrent_vector<InputChunk*> InputFile::chunks_
unsigned int InputFile::currentChunk_ = 0
std::string InputFile::fileName_
uint32_t InputFile::fileSize_
unsigned int InputFile::lumi_

Definition at line 212 of file FedRawDataInputSource.h.

Referenced by FedRawDataInputSource::getNextEvent().

uint32_t InputFile::nChunks_

Definition at line 215 of file FedRawDataInputSource.h.

Referenced by FedRawDataInputSource::getNextEvent().

int InputFile::nEvents_

Definition at line 216 of file FedRawDataInputSource.h.

Referenced by FedRawDataInputSource::getNextEvent().

unsigned int InputFile::nProcessed_
FedRawDataInputSource* InputFile::parent_

Definition at line 210 of file FedRawDataInputSource.h.

Referenced by FedRawDataInputSource::getNextEvent().

evf::EvFDaqDirector::FileStatus InputFile::status_

Definition at line 211 of file FedRawDataInputSource.h.

Referenced by FedRawDataInputSource::getNextEvent().