7 #include "../interface/FileIO.h"
15 #include <boost/tokenizer.hpp>
25 data_.reset(
new unsigned char [evtBufSize]);
45 data_.reset(
new unsigned char[size]);
59 std::auto_ptr<unsigned char>
data_;
67 numWriters_(ps.getUntrackedParameter<unsigned int>(
"numWriters",1))
68 ,eventBufferSize_(ps.getUntrackedParameter<unsigned int>(
"eventBufferSize",30))
69 ,sharedMode_(ps.getUntrackedParameter<bool>(
"sharedMode",
true))
70 ,lumiSubdirectoriesMode_(ps.getUntrackedParameter<bool>(
"lumiSubdirectoriesMode",
true))
71 ,debug_(ps.getUntrackedParameter<bool>(
"debug",
false))
88 vector<JsonMonitorable*> lumiMonParams;
92 lumiMon_ =
new DataPointMonitor(lumiMonParams,
"/home/aspataru/cmssw/CMSSW_6_1_0_pre4/src/EventFilter/Utilities/plugins/budef.jsd");
130 unsigned long dataSize)
152 std::ostringstream lsdir;
153 lsdir <<
"ls" << std::setfill(
'0') << std::setw(6) << ls <<
"/";
162 boost::char_separator<char> sep(
".");
163 boost::tokenizer<boost::char_separator<char>> tokens(name, sep);
165 fileBase=*tokens.begin();
166 for (
auto tok_iter = tokens.begin(); tok_iter != tokens.end(); ++tok_iter) {
167 fileSuffix=*tok_iter;
183 std::ostringstream ostr;
184 ostr <<
destinationDir_ <<
"/EoLS_" << std::setfill(
'0') << std::setw(6) << ls <<
".json";
185 int outfd_ = open(ostr.str().c_str(), O_WRONLY | O_CREAT, S_IRWXU);
186 if(outfd_!=0){close(outfd_); outfd_=0;}
192 string path = ostr.str();
193 FileIO::writeStringToFile(path, output);
204 bool queuing =
false;
205 unsigned int freeId = 0xffff;
214 if (!queuing) usleep(100000);
216 assert(freeId!=0xff);
217 EventPool[freeId]->putNewEvent((
unsigned char*)buffer,size);
231 bool queuing =
false;
232 unsigned int freeId = 0xffff;
241 if (!queuing) usleep(100000);
243 assert(freeId!=0xff);
260 for (
unsigned int i=0;
i<instances;
i++)
262 std::ostringstream instanceName;
263 instanceName << fileBase <<
"_" <<
i;
265 instanceName <<
"." << suffix;
270 currentVal->
setName(
"NEvents");
276 vector<JsonMonitorable*> lumiMonParams;
293 std::cout <<
"opening file for writing " << fileName.c_str() << std::endl;
294 int outfd_ = open(fileName.c_str(), O_WRONLY | O_CREAT, S_IRWXU);
297 <<
"Error opening FED Raw Data event output file: " << fileName
298 <<
": " << strerror(errno) <<
"\n";
300 std::auto_ptr<std::ofstream> ost_;
301 ost_.reset(
new std::ofstream(fileName.c_str(), std::ios_base::binary |
std::ios_base::out));
303 if (!ost_->is_open()) {
305 <<
"Error opening FED Raw Data event output file: " << fileName <<
"\n";
336 boost::shared_array<unsigned char> * sharedBuf =
EventPool[qid]->getSharedBuffer();
338 ost_->write((
const char*) frd.startAddress(),frd.size());
343 throw cms::Exception(
"RawEventFileWriterForBU",
"doOutputEventFragment")
344 <<
"Error writing FED Raw Data event data to "
345 <<
fileName_ <<
". Possibly the output disk "
346 <<
"is full?" << std::endl;
357 throw cms::Exception(
"RawEventFileWriterForBU",
"doOutputEventFragment")
358 <<
"Error writing FED Raw Data event data to "
359 <<
fileName_ <<
". Possibly the output disk "
360 <<
"is full?" << std::endl;
363 if(outfd_!=0){ close(outfd_); outfd_=0;}
369 <<
" status " << fretval <<
" errno " << strerror(errno) << std::endl;
376 std::stringstream ss;
378 string path = ss.str();
379 FileIO::writeStringToFile(path, output);
381 std::cout <<
"Wrote JSON input file: " << path << std::endl;
void doOutputEvent(FRDEventMsgView const &msg)
MTRawEventFileWriterForBU(edm::ParameterSet const &ps)
void initialize(std::string const &destinationDir, std::string const &name, int ls)
unsigned int getSize() const
void putNewEvent(boost::shared_array< unsigned char > &msg)
unsigned int getBufSize() const
void threadRunner(std::string fileName, unsigned int instance)
static PFTauRenderPlugin instance
std::vector< fwriter::EventContainer * > EventPool
std::string destinationDir_
unsigned char * fileHeader_
void doOutputEventFragment(unsigned char *dataPtr, unsigned long dataSize)
void putNewEvent(unsigned char *addr, unsigned int size)
~MTRawEventFileWriterForBU()
std::string lumiSectionSubDir_
uint8 * startAddress() const
void setName(string name)
EventContainer(unsigned int evtBufSize)
unsigned int writtenSize_
void queueEvent(const char *buffer, unsigned long size)
unsigned int eventBufferSize_
std::deque< unsigned int > queuedIds
bool lumiSubdirectoriesMode_
boost::shared_array< unsigned char > * getSharedBuffer()
std::auto_ptr< unsigned char > data_
boost::shared_array< unsigned char > shared_data_
Binary serialize(const T &payload, bool packingOnly=false)
DataPointMonitor * lumiMon_
volatile std::atomic< bool > shutdown_flag false
std::deque< unsigned int > freeIds
unsigned char * getBuffer() const
std::vector< DataPointMonitor * > perFileMonitors_
tuple size
Write out results.
void dispatchThreads(std::string fileBase, unsigned int instances, std::string suffix)
std::vector< IntJ * > perFileCounters_
void snap(DataPoint &outputDataPoint)