1 #ifndef IOPool_Streamer_RecoEventOutputModuleForFU_h 2 #define IOPool_Streamer_RecoEventOutputModuleForFU_h 10 #include <boost/filesystem.hpp> 11 #include <boost/algorithm/string.hpp> 23 template<
typename Consumer>
41 virtual void start()
override;
42 virtual void stop()
override;
51 std::auto_ptr<Consumer>
c_;
75 template<
typename Consumer>
92 outBuf_(new unsigned char[1024*1024])
101 <<
"Underscore character is reserved can not be used for stream names in FFF, but was detected in stream name -: " <<
stream_label_;
105 boost::algorithm::to_lower(stream_label_lo);
106 auto streampos = stream_label_lo.rfind(
"stream");
107 if (streampos !=0 && streampos!=std::string::npos)
109 <<
"stream (case-insensitive) sequence was found in stream suffix. This is reserved and can not be used for names in FFF based HLT, but was detected in stream name";
114 template<
typename Consumer>
119 LogDebug(
"RecoEventOutputModuleForFU") <<
"writing .dat files to -: " << baseRunDir;
147 std::stringstream tmpss,ss;
148 tmpss << baseRunDir <<
"/open/" <<
"output_" << getpid() <<
".jsd";
149 ss << baseRunDir <<
"/" <<
"output_" << getpid() <<
".jsd";
155 if (
stat (outJsonDefName.c_str(), &fstat) != 0) {
156 LogDebug(
"RecoEventOutputModuleForFU") <<
"writing output definition file -: " << outJsonDefName;
160 boost::filesystem::rename(outTmpJsonDefName,outJsonDefName);
181 template<
typename Consumer>
184 template<
typename Consumer>
190 edm::LogInfo(
"RecoEventOutputModuleForFU") <<
"start() method, initializing streams. init stream -: " 192 c_->setInitMessageFile(openInitFileName);
197 template<
typename Consumer>
204 template<
typename Consumer>
208 c_->doOutputHeader(init_message);
212 stat(openIniFileName.c_str(), &istat);
215 uint32_t adlera=1,adlerb=0;
216 FILE *
src = fopen(openIniFileName.c_str(),
"r");
217 while (readInput<istat.st_size)
219 size_t toRead= readInput+1024*1024 < istat.st_size ? 1024*1024 : istat.st_size-readInput;
230 uint32_t adler32c = (adlerb << 16) | adlera;
231 if (adler32c !=
c_->get_adler32_ini()) {
232 throw cms::Exception(
"RecoEventOutputModuleForFU") <<
"Checksum mismatch of ini file -: " << openIniFileName
233 <<
" expected:" <<
c_->get_adler32_ini() <<
" obtained:" << adler32c;
241 template<
typename Consumer>
245 c_->doOutputEvent(msg);
248 template<
typename Consumer>
253 Consumer::fillDescription(desc);
268 template<
typename Consumer>
277 template<
typename Consumer>
287 template<
typename Consumer>
293 c_->closeOutputFile();
294 bool abortFlag =
false;
298 edm::LogInfo(
"RecoEventOutputModuleForFU") <<
"output suppressed";
313 uint32_t mergedAdler32=1;
315 if (!
stat(deschecksum.c_str(), &istat)) {
317 cf = fopen(deschecksum.c_str(),
"r");
318 if (!cf)
throw cms::Exception(
"RecoEventOutputModuleForFU") <<
"Unable to open checksum file -: " << deschecksum.c_str();
319 fscanf(cf,
"%u",&mergedAdler32);
322 else edm::LogWarning(
"RecoEventOutputModuleForFU") <<
"Checksum file size is empty -: "<< deschecksum.c_str();
331 while (readInput<istat.st_size) {
332 size_t toRead= readInput+1024*1024 < istat.st_size ? 1024*1024 : istat.st_size-readInput;
342 cf = fopen(deschecksum.c_str(),
"w");
343 if (!cf)
throw cms::Exception(
"RecoEventOutputModuleForFU") <<
"Unable to open or rewind checksum file for writing -:" << deschecksum.c_str();
348 fprintf(cf,
"%u",mergedAdler32);
356 throw cms::Exception(
"RecoEventOutputModuleForFU") <<
"Adler32 checksum mismatch after reading file -: " 362 filesize = istat.st_size;
virtual void start() override
void addLegendItem(std::string const &name, std::string const &type, std::string const &operation)
static void fillDescription(ParameterSetDescription &desc)
virtual void endLuminosityBlock(edm::LuminosityBlockForOutput const &) override
jsoncollector::IntJ accepted_
unsigned int getEventsProcessedForLumi(unsigned int lumi, bool *abortFlag=0)
static const std::string BINARYOR
jsoncollector::StringJ mergeType_
boost::shared_ptr< jsoncollector::FastMonitor > jsonMonitor_
static const std::string ADLER32
jsoncollector::IntJ filesize_
static const std::string SUM
static bool serialize(JsonSerializable *pObj, std::string &output)
jsoncollector::IntJ hltErrorEvents_
virtual ~RecoEventOutputModuleForFU()
virtual void doOutputEvent(EventMsgBuilder const &msg) override
RecoEventOutputModuleForFU(edm::ParameterSet const &ps)
LuminosityBlockNumber_t luminosityBlock() const
void addDefault(ParameterSetDescription const &psetDescription)
jsoncollector::IntJ fileAdler32_
virtual void setName(std::string name)
jsoncollector::StringJ filelist_
static const std::string MERGE
evf::FastMonitoringService * fms_
boost::filesystem::path openDatChecksumFilePath_
jsoncollector::StringJ transferDestination_
virtual void doOutputHeader(InitMsgBuilder const &init_message) override
static void writeStringToFile(std::string const &filename, std::string &content)
static const std::string CAT
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
void Adler32(char const *data, size_t len, uint32_t &a, uint32_t &b)
StreamerOutputModuleBase(ParameterSet const &ps)
std::string stream_label_
jsoncollector::IntJ errorEvents_
jsoncollector::IntJ retCodeMask_
jsoncollector::DataPointDefinition outJsonDef_
std::auto_ptr< Consumer > c_
virtual void stop() override
virtual void beginJob() override
jsoncollector::IntJ processed_
jsoncollector::StringJ inputFiles_
void setDefaultGroup(std::string const &group)
virtual void beginLuminosityBlock(edm::LuminosityBlockForOutput const &) override
boost::filesystem::path openDatFilePath_
static const std::string SAME