16 #include <sys/types.h>
26 #include <openssl/md5.h>
27 #include <boost/iostreams/device/mapped_file.hpp>
28 #include <boost/filesystem.hpp>
46 if (refsave ==
"skip")
50 else if (refsave ==
"all")
54 else if (refsave ==
"qtests")
61 <<
"Invalid 'referenceHandling' parameter '" << refsave
62 <<
"'. Expected 'skip', 'all' or 'qtests'.";
97 int irun = iLS.
id().
run();
110 store->markForDeletion(store->mtEnabled() ? irun : 0, ilumi);
129 unsigned int childIndex,
unsigned int numberOfChildren) {
131 unsigned int digits = 0;
132 while (numberOfChildren != 0) {
134 numberOfChildren /= 10;
141 char buffer[digits + 2];
142 snprintf(buffer, digits + 2,
"_F%0*d", digits, childIndex);
151 snprintf(buf, 256,
"%s_V%04d_%s_R%09ld_L%09ld%s", fp.
producer_.c_str(),
160 namespace fs = boost::filesystem;
164 return (path / file).string();
168 boost::property_tree::ptree
171 namespace bpt = boost::property_tree;
172 namespace bfs = boost::filesystem;
178 hostnameReturn = gethostname(host ,
sizeof(host));
179 if (hostnameReturn == -1)
181 <<
"Internal error, cannot get host name";
184 std::ostringstream oss_pid;
188 struct stat dataFileStat;
189 if (stat(dataFilePathName.c_str(), &dataFileStat) != 0)
191 <<
"Internal error, cannot get data file: "
197 bpt::ptree processedEvents, acceptedEvents, errorEvents, bitmask, fileList, fileSize,
inputFiles, fileAdler32, transferDestination;
202 errorEvents.put(
"", 0);
204 fileList.put(
"", dataFileName);
205 fileSize.put(
"", dataFileStat.st_size);
206 inputFiles.put(
"",
"");
207 fileAdler32.put(
"", -1);
208 transferDestination.put(
"", transferDestinationStr);
210 data.push_back(std::make_pair(
"", processedEvents));
211 data.push_back(std::make_pair(
"", acceptedEvents));
212 data.push_back(std::make_pair(
"", errorEvents));
213 data.push_back(std::make_pair(
"", bitmask));
214 data.push_back(std::make_pair(
"", fileList));
215 data.push_back(std::make_pair(
"", fileSize));
216 data.push_back(std::make_pair(
"", inputFiles));
217 data.push_back(std::make_pair(
"", fileAdler32));
218 data.push_back(std::make_pair(
"", transferDestination));
220 pt.add_child(
"data", data);
222 if (fms ==
nullptr) {
223 pt.put(
"definition",
"/fakeDefinition.jsn");
228 pt.put(
"definition", outJsonDefName.string());
232 sprintf(sourceInfo,
"%s_%d", host, pid);
233 pt.put(
"source", sourceInfo);
244 unsigned char md5[MD5_DIGEST_LENGTH];
246 boost::iostreams::mapped_file_source
fp(filename);
248 MD5((
unsigned char *)fp.data(), fp.size(), md5);
250 std::ostringstream
hash;
251 for (
int i = 0;
i < MD5_DIGEST_LENGTH; ++
i) {
252 hash << std::hex << std::setfill(
'0') << std::setw(2) << (int)(md5[
i]);
255 std::ostringstream
out;
256 out <<
"md5:" << hash.str() <<
" " << fp.size() <<
" " << final_filename;
266 std::map<std::string, std::string>
info;
267 info[
"Source"] =
"DQMStore";
268 info[
"FileClass"] =
"DQM";
282 ->setComment(
"File tag, DQM_V000_<TAG>*, usually a subsytem name.");
285 ->setComment(
"Base prefix for files, <BASE>_V000_**, either 'DQM' or 'Playback'.");
288 ->setComment(
"saveReference_, passed to the DQMStore");
291 ->setComment(
"saveReference_, passed to the DQMStore");
294 "Output path prefix.");
DQMFileSaverBase(const edm::ParameterSet &ps)
LuminosityBlockID id() const
T getUntrackedParameter(std::string const &, T const &) const
unsigned int getEventsProcessedForLumi(unsigned int lumi, bool *abortFlag=0)
void saveJobReport(const std::string &filename) const
ParameterDescriptionBase * addUntracked(U const &iLabel, T const &value)
std::mutex initial_fp_lock_
static const std::string fillOrigin(const std::string filename, const std::string final_filename)
static const std::string filename(FileParameters fp, bool useLumi=false)
virtual void endJob(void)
virtual void analyze(edm::StreamID, const edm::Event &e, const edm::EventSetup &) const
virtual void beginJob(void)
virtual void globalEndRun(const edm::Run &, const edm::EventSetup &) const
tuple path
else: Piece not in the list, fine.
virtual void postForkReacquireResources(unsigned int childIndex, unsigned int numberOfChildren)
virtual std::shared_ptr< NoCache > globalBeginLuminosityBlock(const edm::LuminosityBlock &, const edm::EventSetup &) const
void logFileAction(const std::string &msg, const std::string &fileName) const
virtual std::shared_ptr< NoCache > globalBeginRun(const edm::Run &, const edm::EventSetup &) const
DQMStore::SaveReferenceTag saveReference_
LuminosityBlockNumber_t luminosityBlock() const
virtual void saveLumi(FileParameters fp) const
FileParameters initial_fp_
char data[epos_bytes_allocation]
void reportAnalysisFile(std::string const &fileName, std::map< std::string, std::string > const &fileData)
virtual void saveRun(FileParameters fp) const
static boost::property_tree::ptree fillJson(int run, int lumi, const std::string &dataFilePathName, const std::string transferDestinationStr, evf::FastMonitoringService *fms)
static const int STATUS_OK
static void fillDescription(edm::ParameterSetDescription &d)
virtual void globalEndLuminosityBlock(const edm::LuminosityBlock &, const edm::EventSetup &) const