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(), uint64_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_
 
uint64_t fileSize_
 
unsigned int lumi_
 
uint32_t nChunks_
 
int nEvents_
 
unsigned int nProcessed_
 
FedRawDataInputSourceparent_
 
evf::EvFDaqDirector::FileStatus status_
 

Detailed Description

Definition at line 202 of file FedRawDataInputSource.h.

Constructor & Destructor Documentation

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

Definition at line 218 of file FedRawDataInputSource.h.

References mps_fire::i.

219  :
220  parent_(parent),
221  status_(status),
222  lumi_(lumi),
223  fileName_(name),
224  fileSize_(fileSize),
225  nChunks_(nChunks),
226  nEvents_(nEvents),
227  nProcessed_(0)
228  {
229  for (unsigned int i=0;i<nChunks;i++)
230  chunks_.push_back(nullptr);
231  }
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 233 of file FedRawDataInputSource.h.

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

Member Function Documentation

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

Definition at line 1221 of file FedRawDataInputSource.cc.

References findQualityFiles::size.

Referenced by FedRawDataInputSource::getNextEvent().

1222 {
1223  //wait for chunk
1224  while (!waitForChunk(currentChunk_)) {
1225  usleep(100000);
1227  }
1228 
1229  dataPosition = chunks_[currentChunk_]->buf_+ chunkPosition_;
1230  size_t currentLeft = chunks_[currentChunk_]->size_ - chunkPosition_;
1231 
1232  if (currentLeft < size) {
1233 
1234  //we need next chunk
1235  while (!waitForChunk(currentChunk_+1)) {
1236  usleep(100000);
1238  }
1239  //copy everything to beginning of the first chunk
1240  dataPosition-=chunkPosition_;
1241  assert(dataPosition==chunks_[currentChunk_]->buf_);
1242  memmove(chunks_[currentChunk_]->buf_, chunks_[currentChunk_]->buf_+chunkPosition_, currentLeft);
1243  memcpy(chunks_[currentChunk_]->buf_ + currentLeft, chunks_[currentChunk_+1]->buf_, size - currentLeft);
1244  //set pointers at the end of the old data position
1246  chunkPosition_=size-currentLeft;
1247  currentChunk_++;
1248  return true;
1249  }
1250  else {
1253  return false;
1254  }
1255 }
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 1257 of file FedRawDataInputSource.cc.

References findQualityFiles::size.

Referenced by FedRawDataInputSource::getNextEvent().

1258 {
1259  //this will fail in case of events that are too large
1260  assert(size < chunks_[currentChunk_]->size_ - chunkPosition_);
1261  assert(size - offset < chunks_[currentChunk_]->size_);
1265 }
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 1267 of file FedRawDataInputSource.cc.

References findQualityFiles::size.

Referenced by FedRawDataInputSource::getNextEvent().

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

Definition at line 235 of file FedRawDataInputSource.h.

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

Referenced by FedRawDataInputSource::getNextEvent().

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

Member Data Documentation

uint32_t InputFile::bufferPosition_ = 0

Definition at line 214 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_
uint64_t InputFile::fileSize_
unsigned int InputFile::lumi_

Definition at line 205 of file FedRawDataInputSource.h.

Referenced by FedRawDataInputSource::getNextEvent().

uint32_t InputFile::nChunks_

Definition at line 208 of file FedRawDataInputSource.h.

Referenced by FedRawDataInputSource::getNextEvent().

int InputFile::nEvents_

Definition at line 209 of file FedRawDataInputSource.h.

Referenced by FedRawDataInputSource::getNextEvent().

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

Definition at line 203 of file FedRawDataInputSource.h.

Referenced by FedRawDataInputSource::getNextEvent().

evf::EvFDaqDirector::FileStatus InputFile::status_

Definition at line 204 of file FedRawDataInputSource.h.

Referenced by FedRawDataInputSource::getNextEvent().