18 #include "TBufferFile.h"
20 #include <openssl/md5.h>
21 #include <boost/property_tree/json_parser.hpp>
22 #include <boost/filesystem.hpp>
23 #include <boost/format.hpp>
25 #include <google/protobuf/io/coded_stream.h>
26 #include <google/protobuf/io/gzip_stream.h>
27 #include <google/protobuf/io/zero_copy_stream_impl.h>
51 std::ofstream
file(initFileName);
58 namespace bpt = boost::property_tree;
73 boost::filesystem::create_directories(runDir);
75 jsonFilePathName = baseName +
".jsn";
76 openJsonFilePathName = jsonFilePathName +
".open";
78 histoFilePathName = baseName +
".pb";
79 openHistoFilePathName = histoFilePathName +
".open";
84 openHistoFilePathName =
93 this->
savePB(&*store, openHistoFilePathName,
fp.run_,
fp.lumi_);
96 ::rename(openHistoFilePathName.c_str(), histoFilePathName.c_str());
101 write_json(openJsonFilePathName,
pt);
102 ::rename(openJsonFilePathName.c_str(), jsonFilePathName.c_str());
115 namespace bpt = boost::property_tree;
116 namespace bfs = boost::filesystem;
122 hostnameReturn = gethostname(
host,
sizeof(
host));
123 if (hostnameReturn == -1)
124 throw cms::Exception(
"fillJson") <<
"Internal error, cannot get host name";
127 std::ostringstream oss_pid;
134 struct stat dataFileStat;
135 dataFileStat.st_size = 0;
137 if (
stat(dataFilePathName.c_str(), &dataFileStat) != 0)
138 throw cms::Exception(
"fillJson") <<
"Internal error, cannot get data file: " << dataFilePathName;
140 dataFileName =
bfs::path(dataFilePathName).filename().string();
144 bpt::ptree processedEvents, acceptedEvents, errorEvents, bitmask, fileList, fileSize,
inputFiles, fileAdler32,
145 transferDestination, mergeType, hltErrorEvents;
147 processedEvents.put(
"", nProcessed);
148 acceptedEvents.put(
"", nProcessed);
150 errorEvents.put(
"", 0);
152 fileList.put(
"", dataFileName);
153 fileSize.put(
"", dataFileStat.st_size);
155 fileAdler32.put(
"", -1);
156 transferDestination.put(
"", transferDestinationStr);
157 mergeType.put(
"", mergeTypeStr);
158 hltErrorEvents.put(
"", 0);
160 data.push_back(std::make_pair(
"", processedEvents));
161 data.push_back(std::make_pair(
"", acceptedEvents));
162 data.push_back(std::make_pair(
"", errorEvents));
163 data.push_back(std::make_pair(
"", bitmask));
164 data.push_back(std::make_pair(
"", fileList));
165 data.push_back(std::make_pair(
"", fileSize));
167 data.push_back(std::make_pair(
"", fileAdler32));
168 data.push_back(std::make_pair(
"", transferDestination));
169 data.push_back(std::make_pair(
"", mergeType));
170 data.push_back(std::make_pair(
"", hltErrorEvents));
172 pt.add_child(
"data",
data);
174 if (fms ==
nullptr) {
175 pt.put(
"definition",
"/fakeDefinition.jsn");
181 pt.put(
"definition", outJsonDefName.string());
185 sprintf(sourceInfo,
"%s_%d",
host, pid);
186 pt.put(
"source", sourceInfo);
193 desc.
setComment(
"Saves histograms from DQM store, HLT->pb workflow.");
195 desc.
addUntracked<
bool>(
"fakeFilterUnitMode",
false)->setComment(
"If set, EvFDaqDirector is emulated and not used.");
209 using google::protobuf::io::FileOutputStream;
210 using google::protobuf::io::GzipOutputStream;
211 using google::protobuf::io::StringOutputStream;
213 unsigned int nme = 0;
219 for (
auto const me : mes) {
220 TBufferFile
buffer(TBufferFile::kWrite);
222 TObjString
object(
me->tagString().c_str());
223 buffer.WriteObject(&
object);
225 buffer.WriteObject(
me->getRootObject());
228 histo.set_full_pathname(
me->getFullname());
231 if (
me->getLumiFlag())
233 if (
me->getEfficiencyFlag())
253 ::open(
filename.c_str(), O_WRONLY | O_CREAT | O_TRUNC, S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH);
254 FileOutputStream file_stream(filedescriptor);
256 options.format = GzipOutputStream::GZIP;
258 GzipOutputStream gzip_stream(&file_stream,
options);
259 dqmstore_message.SerializeToZeroCopyStream(&gzip_stream);
264 ::close(filedescriptor);
267 edm::LogInfo(
"DQMFileSaverPB") <<
"savePB: successfully wrote " << nme <<
" objects "
268 <<
"into DQM file '" <<
filename <<
"'\n";