21 #include <boost/filesystem.hpp> 22 #include <boost/algorithm/string.hpp> 27 streamerCommon_(ps, selections),
43 LogDebug(
"EvFOutputModule") <<
"writing .dat files to -: " << baseRunDir;
72 std::stringstream tmpss,ss;
73 tmpss << baseRunDir <<
"/open/" <<
"output_" << getpid() <<
".jsd";
74 ss << baseRunDir <<
"/" <<
"output_" << getpid() <<
".jsd";
80 if (
stat (outJsonDefName.c_str(), &fstat) != 0) {
81 LogDebug(
"EvFOutputModule") <<
"writing output definition file -: " << outJsonDefName;
85 boost::filesystem::rename(outTmpJsonDefName,outJsonDefName);
109 streamLabel_(ps.getParameter<
std::
string>(
"@module_label")),
110 trToken_(consumes<
edm::TriggerResults>(
edm::InputTag(
"TriggerResults")))
119 <<
"Underscore character is reserved can not be used for stream names in FFF, but was detected in stream name -: " <<
streamLabel_;
123 boost::algorithm::to_lower(streamLabelLow);
124 auto streampos = streamLabelLow.rfind(
"stream");
125 if (streampos !=0 && streampos!=std::string::npos)
127 <<
"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";
152 edm::LogInfo(
"EvFOutputModule") <<
"beginRun init stream -: " << openIniFileName;
155 uint32 preamble_adler32 = 1;
158 std::unique_ptr<InitMsgBuilder> init_message =
166 stream_writer_preamble.
write(view);
167 preamble_adler32 = stream_writer_preamble.
adler32();
168 stream_writer_preamble.
close();
171 stat(openIniFileName.c_str(), &istat);
174 uint32_t adlera=1,adlerb=0;
175 FILE *
src = fopen(openIniFileName.c_str(),
"r");
178 unsigned char * outBuf =
new unsigned char[1024*1024];
179 while (readInput<istat.st_size)
181 size_t toRead= readInput+1024*1024 < istat.st_size ? 1024*1024 : istat.st_size-readInput;
182 fread(outBuf,toRead,1,src);
189 jsonWriter_->streamerCommon_.clearSerializeDataBuffer();
195 uint32_t adler32c = (adlerb << 16) | adlera;
196 if (adler32c != preamble_adler32) {
197 throw cms::Exception(
"EvFOutputModule") <<
"Checksum mismatch of ini file -: " << openIniFileName
198 <<
" expected:" << preamble_adler32 <<
" obtained:" << adler32c;
216 std::shared_ptr<EvFOutputEventWriter>
221 return std::make_shared<EvFOutputEventWriter>(openDatFilePath);
234 lumiWriter->incAccepted();
235 lumiWriter->doOutputEvent(*msg);
242 auto lumiWriter = luminosityBlockCache(iLB.
index());
246 jsonWriter_->fileAdler32_.value() = lumiWriter->get_adler32();
247 jsonWriter_->accepted_.value() = lumiWriter->getAccepted();
249 bool abortFlag =
false;
252 edm::LogInfo(
"EvFOutputModule") <<
"Abort flag has been set. Output is suppressed";
259 stat(openDatFilePath.string().c_str(), &istat);
262 jsonWriter_->filelist_ = openDatFilePath.filename().string();
265 remove(lumiWriter->getFilePath().c_str());
void addLegendItem(std::string const &name, std::string const &type, std::string const &operation)
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
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_