1 #ifndef IOPool_Streamer_RecoEventOutputModuleForFU_h
2 #define IOPool_Streamer_RecoEventOutputModuleForFU_h
11 #include "boost/filesystem.hpp"
13 #include "../interface/JsonMonitorable.h"
14 #include "../interface/FastMonitor.h"
15 #include "../interface/JSONSerializer.h"
20 template<
typename Consumer>
37 virtual void start()
const;
38 virtual void stop()
const;
49 smpath_ = runDirectory.string();
50 edm::LogInfo(
"RecoEventOutputModuleForFU") <<
"Writing .dat files to "
56 bool foundOpenDir =
false;
57 if (boost::filesystem::is_directory(openPath))
60 std::cout <<
"<open> FU dir not found. Creating..."
62 boost::filesystem::create_directories(openPath);
67 std::auto_ptr<Consumer>
c_;
83 template<
typename Consumer>
85 edm::StreamerOutputModuleBase(ps),
87 stream_label_(ps.getParameter<std::
string>(
"@module_label")),
88 baseDir_(ps.getUntrackedParameter<std::
string>(
"baseDir",
"")),
101 vector<JsonMonitorable*> monParams;
109 template<
typename Consumer>
112 template<
typename Consumer>
116 std::cout <<
"RecoEventOutputModuleForFU: start() method " << std::endl;
120 std::cout <<
"RecoEventOutputModuleForFU, initializing streams. init stream: "
121 << initFileName << std::endl;
123 c_->setInitMessageFile(initFileName);
127 template<
typename Consumer>
133 template<
typename Consumer>
136 c_->doOutputHeader(init_message);
140 template<
typename Consumer>
144 c_->doOutputEvent(msg);
147 template<
typename Consumer>
152 Consumer::fillDescription(desc);
154 ->setComment(
"Top level output directory");
155 descriptions.
add(
"streamerOutput", desc);
164 template<
typename Consumer>
166 std::cout <<
"RecoEventOutputModuleForFU : begin lumi " << std::endl;
168 c_->setOutputFile(openDatFilePath_.string());
169 filelist_ = openDatFilePath_.filename().string();
172 template<
typename Consumer>
174 std::cout <<
"RecoEventOutputModuleForFU : end lumi " << std::endl;
175 c_->closeOutputFile();
176 processed_.value() = fms_->getEventsProcessedForLumi(ls.
luminosityBlock());
177 if(processed_.value()!=0){
182 FILE *
src = fopen(openDatFilePath_.string().c_str(),
"r");
183 if(des != 0 && src !=0){
184 while((b=fgetc(src))!= EOF){
185 fputc((
unsigned char)b,des);
193 remove(openDatFilePath_.string().c_str());
196 if(processed_.value()!=0){
197 jsonMonitor_->snap(
false,
"");
200 jsonMonitor_->outputFullHistoDataPoint(outputJsonNameStream);
204 accepted_.value() = 0;
virtual void stop() const
static void fillDescription(ParameterSetDescription &desc)
ParameterDescriptionBase * addUntracked(U const &iLabel, T const &value)
virtual void doOutputEvent(EventMsgBuilder const &msg) const
std::string getOutputDefPath() 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
boost::shared_ptr< FastMonitor > jsonMonitor_
void setName(string name)
evf::FastMonitoringService * fms_
std::string events_base_filename_
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
std::string stream_label_
std::auto_ptr< Consumer > c_
void add(std::string const &label, ParameterSetDescription const &psetDescription)
virtual void start() const
boost::filesystem::path openDatFilePath_
virtual void endLuminosityBlock(edm::LuminosityBlockPrincipal const &, edm::ModuleCallingContext const *)