CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros 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(), uint32_t fileSize=0, uint32_t nChunks=0, unsigned 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_
 
unsigned int nEvents_
 
unsigned int nProcessed_
 
FedRawDataInputSourceparent_
 
evf::EvFDaqDirector::FileStatus status_
 

Detailed Description

Definition at line 194 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,
unsigned int  nEvents = 0,
FedRawDataInputSource parent = 0 
)
inline

Definition at line 210 of file FedRawDataInputSource.h.

References chunks_, and i.

211  :
212  parent_(parent),
213  status_(status),
214  lumi_(lumi),
215  fileName_(name),
216  fileSize_(fileSize),
217  nChunks_(nChunks),
218  nEvents_(nEvents),
219  nProcessed_(0)
220  {
221  for (unsigned int i=0;i<nChunks;i++)
222  chunks_.push_back(nullptr);
223  }
unsigned int lumi_
int i
Definition: DBlmapReader.cc:9
tuple lumi
Definition: fjr2json.py:35
evf::EvFDaqDirector::FileStatus status_
FedRawDataInputSource * parent_
unsigned int nProcessed_
std::string fileName_
tbb::concurrent_vector< InputChunk * > chunks_
tuple status
Definition: ntuplemaker.py:245
UInt_t nEvents
Definition: hcalCalib.cc:42
unsigned int nEvents_
InputFile::InputFile ( std::string &  name)
inline

Definition at line 225 of file FedRawDataInputSource.h.

Member Function Documentation

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

Definition at line 1083 of file FedRawDataInputSource.cc.

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

Referenced by FedRawDataInputSource::getNextEvent().

1084 {
1085  //wait for chunk
1086  while (!waitForChunk(currentChunk_)) {
1087  usleep(100000);
1089  }
1090 
1091  dataPosition = chunks_[currentChunk_]->buf_+ chunkPosition_;
1092  size_t currentLeft = chunks_[currentChunk_]->size_ - chunkPosition_;
1093 
1094  if (currentLeft < size) {
1095 
1096  //we need next chunk
1097  while (!waitForChunk(currentChunk_+1)) {
1098  usleep(100000);
1100  }
1101  //copy everything to beginning of the first chunk
1102  dataPosition-=chunkPosition_;
1103  assert(dataPosition==chunks_[currentChunk_]->buf_);
1104  memmove(chunks_[currentChunk_]->buf_, chunks_[currentChunk_]->buf_+chunkPosition_, currentLeft);
1105  memcpy(chunks_[currentChunk_]->buf_ + currentLeft, chunks_[currentChunk_+1]->buf_, size - currentLeft);
1106  //set pointers at the end of the old data position
1108  chunkPosition_=size-currentLeft;
1109  currentChunk_++;
1110  return true;
1111  }
1112  else {
1115  return false;
1116  }
1117 }
uint32_t chunkPosition_
FedRawDataInputSource * parent_
uint32_t bufferPosition_
bool waitForChunk(unsigned int chunkid)
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 1119 of file FedRawDataInputSource.cc.

References bufferPosition_, chunkPosition_, chunks_, currentChunk_, findQualityFiles::size, and edm::size_().

Referenced by FedRawDataInputSource::getNextEvent().

1120 {
1121  //this will fail in case of events that are too large
1123  assert(size - offset < chunks_[currentChunk_]->size_);
1127 }
uint32_t chunkPosition_
uint32_t bufferPosition_
unsigned int offset(bool)
unsigned int currentChunk_
tbb::concurrent_vector< InputChunk * > chunks_
size_(0)
Definition: OwnArray.h:181
tuple size
Write out results.
void InputFile::rewindChunk ( const size_t  size)
inline

Definition at line 1129 of file FedRawDataInputSource.cc.

References bufferPosition_, chunkPosition_, and findQualityFiles::size.

Referenced by FedRawDataInputSource::getNextEvent().

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

Definition at line 227 of file FedRawDataInputSource.h.

References chunks_.

Referenced by advance(), and FedRawDataInputSource::getNextEvent().

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

Member Data Documentation

uint32_t InputFile::bufferPosition_ = 0
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 197 of file FedRawDataInputSource.h.

Referenced by FedRawDataInputSource::getNextEvent().

uint32_t InputFile::nChunks_

Definition at line 200 of file FedRawDataInputSource.h.

Referenced by FedRawDataInputSource::getNextEvent().

unsigned int InputFile::nEvents_

Definition at line 201 of file FedRawDataInputSource.h.

Referenced by FedRawDataInputSource::getNextEvent().

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

Definition at line 195 of file FedRawDataInputSource.h.

Referenced by advance(), and FedRawDataInputSource::getNextEvent().

evf::EvFDaqDirector::FileStatus InputFile::status_

Definition at line 196 of file FedRawDataInputSource.h.

Referenced by FedRawDataInputSource::getNextEvent().