1 #ifndef IOPool_Streamer_RecoEventOutputModuleForFU_h
2 #define IOPool_Streamer_RecoEventOutputModuleForFU_h
11 #include "boost/filesystem.hpp"
21 template<
typename Consumer>
38 virtual void start()
const;
39 virtual void stop()
const;
47 std::auto_ptr<Consumer>
c_;
65 template<
typename Consumer>
67 edm::StreamerOutputModuleBase(ps),
69 stream_label_(ps.getParameter<std::
string>(
"@module_label")),
77 outBuf_(new unsigned
char[1024*1024])
80 LogDebug(
"RecoEventOutputModuleForFU") <<
"writing .dat files to -: " << baseRunDir;
107 std::stringstream tmpss,
ss;
108 tmpss << baseRunDir <<
"/open/" <<
"output_" << getpid() <<
".jsd";
109 ss << baseRunDir <<
"/" <<
"output_" << getpid() <<
".jsd";
115 if (stat (outJsonDefName.c_str(), &fstat) != 0) {
116 LogDebug(
"RecoEventOutputModuleForFU") <<
"writing output definition file -: " << outJsonDefName;
119 FileIO::writeStringToFile(outTmpJsonDefName, content);
120 boost::filesystem::rename(outTmpJsonDefName,outJsonDefName);
136 template<
typename Consumer>
139 template<
typename Consumer>
144 edm::LogInfo(
"RecoEventOutputModuleForFU") <<
"start() method, initializing streams. init stream -: "
146 c_->setInitMessageFile(initFileName);
150 template<
typename Consumer>
157 template<
typename Consumer>
161 c_->doOutputHeader(init_message);
164 template<
typename Consumer>
168 c_->doOutputEvent(msg);
171 template<
typename Consumer>
176 Consumer::fillDescription(desc);
177 descriptions.
add(
"streamerOutput", desc);
180 template<
typename Consumer>
185 c_->setOutputFile(openDatFilePath_.string());
186 filelist_ = openDatFilePath_.filename().string();
189 template<
typename Consumer>
194 c_->closeOutputFile();
195 processed_.value() = fms_->getEventsProcessedForLumi(ls.
luminosityBlock());
196 if(processed_.value()!=0){
201 FILE *
src = fopen(openDatFilePath_.string().c_str(),
"r");
204 stat(openDatFilePath_.string().c_str(), &istat);
206 while (readInput<istat.st_size) {
207 unsigned long toRead= readInput+1024*1024 < istat.st_size ? 1024*1024 : istat.st_size-readInput;
208 fread(outBuf_,toRead,1,src);
209 fwrite(outBuf_,toRead,1,des);
225 remove(openDatFilePath_.string().c_str());
229 if(processed_.value()!=0){
233 jsonMonitor_->outputFullJSON(outputJsonNameStream,ls.
luminosityBlock());
237 accepted_.value() = 0;
void addLegendItem(std::string const &name, std::string const &type, std::string const &operation)
virtual void stop() const
static void fillDescription(ParameterSetDescription &desc)
virtual void doOutputEvent(EventMsgBuilder const &msg) const
virtual void doOutputHeader(InitMsgBuilder const &init_message) const
virtual void beginLuminosityBlock(edm::LuminosityBlockPrincipal const &, edm::ModuleCallingContext const *)
virtual ~RecoEventOutputModuleForFU()
RecoEventOutputModuleForFU(edm::ParameterSet const &ps)
LuminosityBlockNumber_t luminosityBlock() const
tuple path
else: Piece not in the list, fine.
boost::shared_ptr< FastMonitor > jsonMonitor_
virtual void setName(std::string name)
evf::FastMonitoringService * fms_
DataPointDefinition outJsonDef_
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
std::string stream_label_
std::auto_ptr< Consumer > c_
void add(std::string const &label, ParameterSetDescription const &psetDescription)
std::pair< Binary, Binary > serialize(const T &payload, bool packingOnly=false)
virtual void start() const
void setDefaultGroup(std::string const &group)
boost::filesystem::path openDatFilePath_
virtual void endLuminosityBlock(edm::LuminosityBlockPrincipal const &, edm::ModuleCallingContext const *)