21 #include <boost/filesystem.hpp> 22 #include <boost/algorithm/string.hpp> 29 : streamerCommon_(ps, selections),
43 LogDebug(
"EvFOutputModule") <<
"writing .dat files to -: " << baseRunDir;
72 std::stringstream tmpss,
ss;
73 tmpss << baseRunDir <<
"/open/" 74 <<
"output_" << getpid() <<
".jsd";
75 ss << baseRunDir <<
"/" 76 <<
"output_" << getpid() <<
".jsd";
82 if (
stat(outJsonDefName.c_str(), &fstat) != 0) {
83 LogDebug(
"EvFOutputModule") <<
"writing output definition file -: " << outJsonDefName;
87 boost::filesystem::rename(outTmpJsonDefName, outJsonDefName);
111 streamLabel_(ps.getParameter<
std::
string>(
"@module_label")),
119 throw cms::Exception(
"EvFOutputModule") <<
"Underscore character is reserved can not be used for stream names in " 120 "FFF, but was detected in stream name -: " 125 boost::algorithm::to_lower(streamLabelLow);
126 auto streampos = streamLabelLow.rfind(
"stream");
127 if (streampos != 0 && streampos != std::string::npos)
129 <<
"stream (case-insensitive) sequence was found in stream suffix. This is reserved and can not be used for " 130 "names in FFF based HLT, but was detected in stream name";
150 edm::LogInfo(
"EvFOutputModule") <<
"beginRun init stream -: " << openIniFileName;
153 uint32 preamble_adler32 = 1;
156 std::unique_ptr<InitMsgBuilder> init_message =
168 stream_writer_preamble.
write(view);
169 preamble_adler32 = stream_writer_preamble.
adler32();
170 stream_writer_preamble.
close();
173 stat(openIniFileName.c_str(), &istat);
176 uint32_t adlera = 1, adlerb = 0;
177 FILE*
src = fopen(openIniFileName.c_str(),
"r");
180 unsigned char* outBuf =
new unsigned char[1024 * 1024];
181 while (readInput < istat.st_size) {
182 size_t toRead = readInput + 1024 * 1024 < istat.st_size ? 1024 * 1024 : istat.st_size - readInput;
183 fread(outBuf, toRead, 1, src);
184 cms::Adler32((
const char*)outBuf, toRead, adlera, adlerb);
190 jsonWriter_->streamerCommon_.getSerializerBuffer()->clearHeaderBuffer();
196 uint32_t adler32c = (adlerb << 16) | adlera;
197 if (adler32c != preamble_adler32) {
198 throw cms::Exception(
"EvFOutputModule") <<
"Checksum mismatch of ini file -: " << openIniFileName
199 <<
" expected:" << preamble_adler32 <<
" obtained:" << adler32c;
217 return std::make_shared<EvFOutputEventWriter>(openDatFilePath);
225 std::unique_ptr<EventMsgBuilder>
msg =
jsonWriter_->streamerCommon_.serializeEvent(
227 lumiWriter->incAccepted();
228 lumiWriter->doOutputEvent(*msg);
232 auto lumiWriter = luminosityBlockCache(iLB.
index());
236 jsonWriter_->fileAdler32_.value() = lumiWriter->get_adler32();
237 jsonWriter_->accepted_.value() = lumiWriter->getAccepted();
239 bool abortFlag =
false;
242 edm::LogInfo(
"EvFOutputModule") <<
"Abort flag has been set. Output is suppressed";
249 stat(openDatFilePath.string().c_str(), &istat);
251 boost::filesystem::rename(
252 openDatFilePath.string().c_str(),
254 jsonWriter_->filelist_ = openDatFilePath.filename().string();
257 remove(lumiWriter->getFilePath().c_str());
void addLegendItem(std::string const &name, std::string const &type, std::string const &operation)
ParameterSetID const & mainParameterSetID() const
unsigned int getEventsProcessedForLumi(unsigned int lumi, bool *abortFlag=0)
EvFOutputModule(edm::ParameterSet const &ps)
std::unique_ptr< evf::EvFOutputJSONWriter > jsonWriter_
ModuleDescription const & description() const
static const std::string BINARYOR
std::vector< BranchIDList > BranchIDLists
edm::ParameterSet const & ps_
jsoncollector::IntJ fileAdler32_
ThinnedAssociationsHelper const * thinnedAssociationsHelper() const
BasicHandle getByToken(EDGetToken token, TypeID const &typeID) const
static const std::string ADLER32
static const std::string SUM
static bool serialize(JsonSerializable *pObj, std::string &output)
void write(const InitMsgBuilder &)
EvFOutputJSONWriter(edm::ParameterSet const &ps, edm::SelectedProducts const *selections, std::string const &streamLabel)
jsoncollector::DataPointDefinition outJsonDef_
jsoncollector::IntJ hltErrorEvents_
ParameterSetID selectorConfig() const
std::string const & moduleLabel() const
jsoncollector::StringJ inputFiles_
void beginRun(edm::RunForOutput const &run) override
LuminosityBlockIndex index() const
std::vector< std::pair< BranchDescription const *, EDGetToken > > SelectedProducts
LuminosityBlockForOutput const & getLuminosityBlock() const
LuminosityBlockNumber_t luminosityBlock() const
jsoncollector::IntJ retCodeMask_
void addDefault(ParameterSetDescription const &psetDescription)
static void fillDescription(ParameterSetDescription &desc)
virtual void setName(std::string name)
~EvFOutputModule() override
static const std::string MERGE
void globalEndLuminosityBlock(edm::LuminosityBlockForOutput const &iLB) override
SelectedProductsForBranchType const & keptProducts() const
static std::string const triggerResults
static void writeStringToFile(std::string const &filename, std::string &content)
static const std::string CAT
jsoncollector::IntJ processed_
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
void Adler32(char const *data, size_t len, uint32_t &a, uint32_t &b)
const ModuleDescription & moduleDescription() const
void write(edm::EventForOutput const &e) override
edm::EDGetTokenT< edm::TriggerResults > trToken_
jsoncollector::IntJ filesize_
jsoncollector::StringJ filelist_
jsoncollector::StringJ transferDestination_
std::shared_ptr< jsoncollector::FastMonitor > jsonMonitor_
void setDefaultGroup(std::string const &group)
static void fillDescription(ParameterSetDescription &desc)
jsoncollector::IntJ accepted_
std::shared_ptr< EvFOutputEventWriter > globalBeginLuminosityBlock(edm::LuminosityBlockForOutput const &iLB) const override
jsoncollector::StringJ mergeType_
jsoncollector::IntJ errorEvents_
Trig getTriggerResults(edm::EDGetTokenT< edm::TriggerResults > const &token, edm::EventForOutput const &e) const
BranchIDLists const * branchIDLists()
static const std::string SAME
evf::FastMonitoringService * fms_